discourse/app/assets/javascripts/admin/models/site-setting.js.es6

32 lines
909 B
Plaintext
Raw Normal View History

2016-07-01 01:55:44 +08:00
import { ajax } from 'discourse/lib/ajax';
import Setting from 'admin/mixins/setting-object';
2015-03-03 01:12:19 +08:00
const SiteSetting = Discourse.Model.extend(Setting, {});
2015-03-03 01:12:19 +08:00
SiteSetting.reopenClass({
findAll() {
2016-07-01 01:55:44 +08:00
return ajax("/admin/site_settings").then(function (settings) {
2015-03-03 01:12:19 +08:00
// Group the results by category
const categories = {};
settings.site_settings.forEach(function(s) {
if (!categories[s.category]) {
categories[s.category] = [];
}
categories[s.category].pushObject(SiteSetting.create(s));
2015-03-03 01:12:19 +08:00
});
return Object.keys(categories).map(function(n) {
return {nameKey: n, name: I18n.t('admin.site_settings.categories.' + n), siteSettings: categories[n]};
});
});
},
update(key, value) {
const data = {};
data[key] = value;
return ajax(`/admin/site_settings/${key}`, { type: 'PUT', data });
2015-03-03 01:12:19 +08:00
}
});
export default SiteSetting;