2019-11-09 03:13:35 +08:00
|
|
|
import EmberObject from "@ember/object";
|
2025-01-06 12:02:46 +08:00
|
|
|
import { alias } from "@ember/object/computed";
|
2024-03-11 08:42:12 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
2024-03-26 14:02:05 +08:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2025-01-06 12:02:46 +08:00
|
|
|
import SettingObjectHelper from "admin/lib/setting-object-helper";
|
|
|
|
|
|
|
|
export default class ThemeSettings extends EmberObject {
|
|
|
|
settingObjectHelper = new SettingObjectHelper(this);
|
|
|
|
|
|
|
|
@alias("settingObjectHelper.overridden") overridden;
|
|
|
|
@alias("settingObjectHelper.computedValueProperty") computedValueProperty;
|
|
|
|
@alias("settingObjectHelper.computedNameProperty") computedNameProperty;
|
|
|
|
@alias("settingObjectHelper.validValues") validValues;
|
|
|
|
@alias("settingObjectHelper.allowsNone") allowsNone;
|
|
|
|
@alias("settingObjectHelper.anyValue") anyValue;
|
2018-03-05 08:04:23 +08:00
|
|
|
|
2024-03-11 08:42:12 +08:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2024-03-26 14:02:05 +08:00
|
|
|
|
|
|
|
loadMetadata(themeId) {
|
|
|
|
return ajax(
|
|
|
|
`/admin/themes/${themeId}/objects_setting_metadata/${this.setting}.json`
|
|
|
|
)
|
|
|
|
.then((result) => this.set("metadata", result))
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
}
|
2024-03-11 08:42:12 +08:00
|
|
|
}
|