mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-25 16:42:28 +08:00
This builds onto #32013 in two major ways: - Unsaved changes are now persisted when you browse categories inside "All site settings". - If you're about to navigate away (and lose edits) you will be prompted if you want to save or discard changes. (This applies to individual category site setting pages as well.
51 lines
1.2 KiB
JavaScript
Vendored
51 lines
1.2 KiB
JavaScript
Vendored
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
|
import SiteSetting from "admin/models/site-setting";
|
|
|
|
export default class AdminSiteSettingsRoute extends DiscourseRoute {
|
|
@service siteSettingChangeTracker;
|
|
|
|
queryParams = {
|
|
filter: { replace: true },
|
|
};
|
|
|
|
model() {
|
|
return SiteSetting.findAll();
|
|
}
|
|
|
|
afterModel(siteSettings) {
|
|
const controller = this.controllerFor("adminSiteSettings");
|
|
|
|
if (!controller.get("visibleSiteSettings")) {
|
|
controller.set("visibleSiteSettings", siteSettings);
|
|
}
|
|
}
|
|
|
|
@action
|
|
async willTransition(transition) {
|
|
if (
|
|
this.siteSettingChangeTracker.hasUnsavedChanges &&
|
|
transition.from.name !== transition.to.name
|
|
) {
|
|
transition.abort();
|
|
|
|
await this.siteSettingChangeTracker.confirmTransition();
|
|
|
|
transition.retry();
|
|
}
|
|
}
|
|
|
|
@action
|
|
refreshAll() {
|
|
SiteSetting.findAll().then((settings) => {
|
|
this.controllerFor("adminSiteSettings").set("model", settings);
|
|
});
|
|
}
|
|
|
|
resetController(controller, isExiting) {
|
|
if (isExiting) {
|
|
controller.set("filter", "");
|
|
}
|
|
}
|
|
}
|