2019-10-22 09:46:10 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2023-03-15 09:17:51 -04:00
|
|
|
import EmberObject, { action } from "@ember/object";
|
2015-03-10 15:01:15 -04:00
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
export default class AdminLogsStaffActionLogsRoute extends DiscourseRoute {
|
|
|
|
queryParams = {
|
2020-07-22 11:25:58 -04:00
|
|
|
filters: { refreshModel: true },
|
2023-03-15 09:17:51 -04:00
|
|
|
};
|
2020-07-22 11:25:58 -04:00
|
|
|
|
2021-02-16 13:48:39 -05: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();
|
|
|
|
}
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
2021-02-16 13:48:39 -05:00
|
|
|
|
2020-07-22 11:25:58 -04:00
|
|
|
deserializeQueryParam(value, urlKey, defaultValueType) {
|
|
|
|
if (urlKey === "filters") {
|
|
|
|
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
|
|
|
|
}
|
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
return super.deserializeQueryParam(value, urlKey, defaultValueType);
|
|
|
|
}
|
2020-07-22 11:25:58 -04:00
|
|
|
|
|
|
|
serializeQueryParam(value, urlKey, defaultValueType) {
|
|
|
|
if (urlKey === "filters") {
|
|
|
|
if (value && Object.keys(value).length > 0) {
|
|
|
|
return JSON.stringify(value);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
return super.serializeQueryParam(value, urlKey, defaultValueType);
|
|
|
|
}
|
2020-07-22 11:25:58 -04:00
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
@action
|
|
|
|
onFiltersChange(filters) {
|
2023-03-16 08:27:27 -04:00
|
|
|
this.transitionTo("adminLogs.staffActionLogs", {
|
|
|
|
queryParams: { filters },
|
|
|
|
});
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
|
|
|
}
|