2019-10-22 09:46:10 -04:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2020-07-22 11:25:58 -04:00
|
|
|
import EmberObject from "@ember/object";
|
2015-03-10 15:01:15 -04:00
|
|
|
import showModal from "discourse/lib/show-modal";
|
|
|
|
|
2019-10-22 09:46:10 -04:00
|
|
|
export default DiscourseRoute.extend({
|
2020-07-22 11:25:58 -04:00
|
|
|
queryParams: {
|
|
|
|
filters: { refreshModel: true },
|
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
|
|
|
},
|
|
|
|
|
|
|
|
activate() {
|
|
|
|
const controller = this.controllerFor("admin-logs-staff-action-logs");
|
|
|
|
if (controller.filters === null) {
|
|
|
|
controller.resetFilters();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-02-05 14:34:57 -05:00
|
|
|
// TODO: make this automatic using an `{{outlet}}`
|
2020-07-22 11:25:58 -04:00
|
|
|
renderTemplate() {
|
2016-11-09 14:47:58 -05:00
|
|
|
this.render("admin/templates/logs/staff-action-logs", {
|
|
|
|
into: "adminLogs",
|
|
|
|
});
|
2015-02-05 14:34:57 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2015-04-09 18:33:37 -04:00
|
|
|
showDetailsModal(model) {
|
2016-11-16 16:38:27 -05:00
|
|
|
showModal("admin-staff-action-log-details", { model, admin: true });
|
2015-02-05 14:34:57 -05:00
|
|
|
this.controllerFor("modal").set("modalClass", "log-details-modal");
|
|
|
|
},
|
|
|
|
|
2015-04-09 18:33:37 -04:00
|
|
|
showCustomDetailsModal(model) {
|
2017-04-12 10:52:52 -04:00
|
|
|
let modal = showModal("admin-theme-change", { model, admin: true });
|
|
|
|
this.controllerFor("modal").set("modalClass", "history-modal");
|
|
|
|
modal.loadDiff();
|
2020-07-22 11:25:58 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
onFiltersChange(filters) {
|
|
|
|
if (filters && Object.keys(filters) === 0) {
|
|
|
|
this.transitionTo("adminLogs.staffActionLogs");
|
|
|
|
} else {
|
|
|
|
this.transitionTo("adminLogs.staffActionLogs", {
|
|
|
|
queryParams: { filters },
|
|
|
|
});
|
|
|
|
}
|
2015-02-05 14:34:57 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|