FIX: Theme translations resetting on save (#22072)
Fixes an issue where saving a theme translation would reset unsaved changes made to other theme translations. Also cleans up unused `saveSettings` and `saveTranslations` actions. Co-authored-by: Jarek Radosz <jradosz@gmail.com>
This commit is contained in:
parent
19133af057
commit
fc11e77eff
|
@ -1,16 +1,23 @@
|
||||||
import SiteSettingComponent from "./site-setting";
|
import SiteSettingComponent from "./site-setting";
|
||||||
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import { url } from "discourse/lib/computed";
|
||||||
import { alias } from "@ember/object/computed";
|
import { alias } from "@ember/object/computed";
|
||||||
|
|
||||||
export default class ThemeTranslation extends SiteSettingComponent {
|
export default class ThemeTranslation extends SiteSettingComponent {
|
||||||
@alias("translation") setting;
|
@alias("translation") setting;
|
||||||
@alias("translation.key") settingName;
|
@alias("translation.key") settingName;
|
||||||
|
@url("model.id", "/admin/themes/%@") updateUrl;
|
||||||
|
|
||||||
type = "string";
|
type = "string";
|
||||||
|
|
||||||
_save() {
|
_save() {
|
||||||
return this.model.saveTranslation(
|
const translations = {
|
||||||
this.get("translation.key"),
|
[this.get("translation.key")]: this.get("buffered.value"),
|
||||||
this.get("buffered.value")
|
};
|
||||||
);
|
|
||||||
|
return ajax(this.updateUrl, {
|
||||||
|
type: "PUT",
|
||||||
|
data: { theme: translations },
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,16 +309,6 @@ class Theme extends RestModel {
|
||||||
.finally(() => this.set("changed", false))
|
.finally(() => this.set("changed", false))
|
||||||
.catch(popupAjaxError);
|
.catch(popupAjaxError);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveSettings(name, value) {
|
|
||||||
const settings = {};
|
|
||||||
settings[name] = value;
|
|
||||||
return this.save({ settings });
|
|
||||||
}
|
|
||||||
|
|
||||||
saveTranslation(name, value) {
|
|
||||||
return this.save({ translations: { [name]: value } });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Theme;
|
export default Theme;
|
||||||
|
|
Loading…
Reference in New Issue