2023-03-15 21:17:51 +08:00
|
|
|
import EmberObject, { action } from "@ember/object";
|
2024-03-07 01:05:11 +08:00
|
|
|
import { service } from "@ember/service";
|
2023-10-11 02:38:59 +08:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2015-03-11 03:01:15 +08:00
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
export default class AdminLogsStaffActionLogsRoute extends DiscourseRoute {
|
2023-07-19 03:52:55 +08:00
|
|
|
@service router;
|
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
queryParams = {
|
2020-07-22 23:25:58 +08:00
|
|
|
filters: { refreshModel: true },
|
2023-03-15 21:17:51 +08:00
|
|
|
};
|
2020-07-22 23:25:58 +08:00
|
|
|
|
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();
|
|
|
|
}
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2021-02-17 02:48:39 +08:00
|
|
|
|
2020-07-22 23:25:58 +08:00
|
|
|
deserializeQueryParam(value, urlKey, defaultValueType) {
|
2023-07-19 18:40:48 +08:00
|
|
|
if (urlKey === "filters" && value) {
|
2020-07-22 23:25:58 +08:00
|
|
|
return EmberObject.create(JSON.parse(decodeURIComponent(value)));
|
|
|
|
}
|
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
return super.deserializeQueryParam(value, urlKey, defaultValueType);
|
|
|
|
}
|
2020-07-22 23:25:58 +08: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 21:17:51 +08:00
|
|
|
return super.serializeQueryParam(value, urlKey, defaultValueType);
|
|
|
|
}
|
2020-07-22 23:25:58 +08:00
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
@action
|
|
|
|
onFiltersChange(filters) {
|
2023-07-19 03:52:55 +08:00
|
|
|
this.router.transitionTo("adminLogs.staffActionLogs", {
|
2023-03-16 20:27:27 +08:00
|
|
|
queryParams: { filters },
|
|
|
|
});
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
|
|
|
}
|