discourse/app/assets/javascripts/admin/addon/routes/admin-logs-staff-action-logs.js
Jarek Radosz 321b14d40c
DEV: Remove unused render() calls (#19224)
`Route#render` and `Route#renderTemplate` have been deprecated and are removed in Ember 4.x (see: https://deprecations.emberjs.com/v3.x#toc_route-render-template)

The templates of modified routes in this PR are already automatically inserted into `{{outlet}}`s.
2022-11-30 16:49:23 +01:00

49 lines
1.2 KiB
JavaScript

import DiscourseRoute from "discourse/routes/discourse";
import EmberObject from "@ember/object";
export default DiscourseRoute.extend({
queryParams: {
filters: { refreshModel: true },
},
beforeModel(transition) {
const params = transition.to.queryParams;
const controller = this.controllerFor("admin-logs-staff-action-logs");
if (controller.filters === null || params.force_refresh) {
controller.resetFilters();
}
},
deserializeQueryParam(value, urlKey, defaultValueType) {
if (urlKey === "filters") {
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
}
return this._super(value, urlKey, defaultValueType);
},
serializeQueryParam(value, urlKey, defaultValueType) {
if (urlKey === "filters") {
if (value && Object.keys(value).length > 0) {
return JSON.stringify(value);
} else {
return null;
}
}
return this._super(value, urlKey, defaultValueType);
},
actions: {
onFiltersChange(filters) {
if (filters && Object.keys(filters) === 0) {
this.transitionTo("adminLogs.staffActionLogs");
} else {
this.transitionTo("adminLogs.staffActionLogs", {
queryParams: { filters },
});
}
},
},
});