2019-10-22 21:46:10 +08:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2020-07-22 23:25:58 +08:00
|
|
|
import EmberObject from "@ember/object";
|
2015-03-11 03:01:15 +08:00
|
|
|
|
2019-10-22 21:46:10 +08:00
|
|
|
export default DiscourseRoute.extend({
|
2020-07-22 23:25:58 +08:00
|
|
|
queryParams: {
|
|
|
|
filters: { refreshModel: true },
|
|
|
|
},
|
|
|
|
|
2021-02-17 02:48:39 +08:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-07-22 23:25:58 +08:00
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
2015-02-06 03:34:57 +08:00
|
|
|
// TODO: make this automatic using an `{{outlet}}`
|
2020-07-22 23:25:58 +08:00
|
|
|
renderTemplate() {
|
2016-11-10 03:47:58 +08:00
|
|
|
this.render("admin/templates/logs/staff-action-logs", {
|
|
|
|
into: "adminLogs",
|
|
|
|
});
|
2015-02-06 03:34:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2020-07-22 23:25:58 +08:00
|
|
|
onFiltersChange(filters) {
|
|
|
|
if (filters && Object.keys(filters) === 0) {
|
|
|
|
this.transitionTo("adminLogs.staffActionLogs");
|
|
|
|
} else {
|
|
|
|
this.transitionTo("adminLogs.staffActionLogs", {
|
|
|
|
queryParams: { filters },
|
|
|
|
});
|
|
|
|
}
|
2015-02-06 03:34:57 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|