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,37 +6,45 @@ import showModal from "discourse/lib/show-modal";
import AboutRoute from "discourse/routes/about";
export default Component.extend(BufferedContent, SettingComponent, {
updateExistingUsers: null,
_save() {
const defaultCategoriesSettings = [
"default_categories_watching",
"default_categories_tracking",
"default_categories_muted",
"default_categories_watching_first_post"
];
const setting = this.buffered;
const key = setting.get("setting");
const value = setting.get("value");
return SiteSetting.update(setting.get("setting"), setting.get("value"), {
updateExistingUsers: this.updateExistingUsers
});
},
if (defaultCategoriesSettings.includes(key)) {
AboutRoute.create()
.model()
.then(result => {
const controller = showModal("site-setting-default-categories", {
model: {
count: result.stats.user_count,
key: key.replace(/_/g, " ")
},
admin: true
});
actions: {
update() {
const defaultCategoriesSettings = [
"default_categories_watching",
"default_categories_tracking",
"default_categories_muted",
"default_categories_watching_first_post"
];
const key = this.buffered.get("setting");
controller.set("onClose", () => {
return SiteSetting.update(key, value, {
updateExistingUsers: controller.updateExistingUsers
if (defaultCategoriesSettings.includes(key)) {
AboutRoute.create()
.model()
.then(result => {
const controller = showModal("site-setting-default-categories", {
model: {
count: result.stats.user_count,
key: key.replace(/_/g, " ")
},
admin: true
});
controller.set("onClose", () => {
this.updateExistingUsers = controller.updateExistingUsers;
this.send("save");
});
});
});
} else {
return SiteSetting.update(key, value);
} else {
this.send("save");
}
}
}
});

View File

@ -6,7 +6,7 @@
</div>
{{#if dirty}}
<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"}}
</div>
{{else if setting.overridden}}