2019-11-09 03:13:35 +08:00
|
|
|
import EmberObject from "@ember/object";
|
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";
|
2018-03-05 08:04:23 +08:00
|
|
|
import Setting from "admin/mixins/setting-object";
|
|
|
|
|
2024-03-11 08:42:12 +08:00
|
|
|
export default class ThemeSettings extends EmberObject.extend(Setting) {
|
|
|
|
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
|
|
|
}
|