2018-06-15 17:03:24 +02:00
|
|
|
import BufferedContent from "discourse/mixins/buffered-content";
|
|
|
|
import SiteSetting from "admin/models/site-setting";
|
|
|
|
import SettingComponent from "admin/mixins/setting-component";
|
2019-10-15 18:41:27 +05:30
|
|
|
import showModal from "discourse/lib/show-modal";
|
|
|
|
import AboutRoute from "discourse/routes/about";
|
2015-03-02 12:12:19 -05:00
|
|
|
|
2018-03-05 03:04:23 +03:00
|
|
|
export default Ember.Component.extend(BufferedContent, SettingComponent, {
|
2019-10-15 18:41:27 +05:30
|
|
|
_save(callback) {
|
|
|
|
const defaultCategoriesSettings = [
|
|
|
|
"default_categories_watching",
|
|
|
|
"default_categories_tracking",
|
|
|
|
"default_categories_muted",
|
|
|
|
"default_categories_watching_first_post"
|
|
|
|
];
|
2019-05-27 10:15:39 +02:00
|
|
|
const setting = this.buffered;
|
2019-10-15 18:41:27 +05:30
|
|
|
const key = setting.get("setting");
|
|
|
|
const value = setting.get("value");
|
|
|
|
|
|
|
|
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
|
|
|
|
});
|
|
|
|
|
2019-10-17 22:05:44 +05:30
|
|
|
controller.set("onClose", () => {
|
|
|
|
callback(
|
|
|
|
SiteSetting.update(key, value, {
|
|
|
|
updateExistingUsers: controller.updateExistingUsers
|
|
|
|
})
|
|
|
|
);
|
2019-10-15 18:41:27 +05:30
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
2019-10-17 22:05:44 +05:30
|
|
|
callback(SiteSetting.update(key, value));
|
2019-10-15 18:41:27 +05:30
|
|
|
}
|
2015-03-02 12:12:19 -05:00
|
|
|
}
|
|
|
|
});
|