FIX: default user preferenced categories are not updating in admin site setting UI.

This commit is contained in:
Vinoth Kannan 2019-10-31 05:45:57 +05:30
parent 13cca3eaa0
commit 7a264217f2
2 changed files with 34 additions and 26 deletions

View File

@ -6,16 +6,24 @@ import showModal from "discourse/lib/show-modal";
import AboutRoute from "discourse/routes/about"; import AboutRoute from "discourse/routes/about";
export default Component.extend(BufferedContent, SettingComponent, { export default Component.extend(BufferedContent, SettingComponent, {
updateExistingUsers: null,
_save() { _save() {
const setting = this.buffered;
return SiteSetting.update(setting.get("setting"), setting.get("value"), {
updateExistingUsers: this.updateExistingUsers
});
},
actions: {
update() {
const defaultCategoriesSettings = [ const defaultCategoriesSettings = [
"default_categories_watching", "default_categories_watching",
"default_categories_tracking", "default_categories_tracking",
"default_categories_muted", "default_categories_muted",
"default_categories_watching_first_post" "default_categories_watching_first_post"
]; ];
const setting = this.buffered; const key = this.buffered.get("setting");
const key = setting.get("setting");
const value = setting.get("value");
if (defaultCategoriesSettings.includes(key)) { if (defaultCategoriesSettings.includes(key)) {
AboutRoute.create() AboutRoute.create()
@ -30,13 +38,13 @@ export default Component.extend(BufferedContent, SettingComponent, {
}); });
controller.set("onClose", () => { controller.set("onClose", () => {
return SiteSetting.update(key, value, { this.updateExistingUsers = controller.updateExistingUsers;
updateExistingUsers: controller.updateExistingUsers this.send("save");
});
}); });
}); });
} else { } else {
return SiteSetting.update(key, value); this.send("save");
}
} }
} }
}); });

View File

@ -6,7 +6,7 @@
</div> </div>
{{#if dirty}} {{#if dirty}}
<div class='setting-controls'> <div class='setting-controls'>
{{d-button class="ok" action=(action "save") icon="check"}} {{d-button class="ok" action=(action "update") icon="check"}}
{{d-button class="cancel" action=(action "cancel") icon="times"}} {{d-button class="cancel" action=(action "cancel") icon="times"}}
</div> </div>
{{else if setting.overridden}} {{else if setting.overridden}}