discourse/app/assets/javascripts/admin/addon/models/theme-settings.js
Ted Johansson 7e77b24202
DEV: Preserve unsaved site settings (#32100)
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.
2025-04-03 16:10:30 +08:00

27 lines
711 B
JavaScript
Vendored

import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import SiteSetting from "admin/models/site-setting";
export default class ThemeSettings extends SiteSetting {
updateSetting(themeId, newValue) {
if (this.objects_schema) {
newValue = JSON.stringify(newValue);
}
return ajax(`/admin/themes/${themeId}/setting`, {
type: "PUT",
data: {
name: this.setting,
value: newValue,
},
});
}
loadMetadata(themeId) {
return ajax(
`/admin/themes/${themeId}/objects_setting_metadata/${this.setting}.json`
)
.then((result) => this.set("metadata", result))
.catch(popupAjaxError);
}
}