2014-12-30 05:11:24 +03:00
|
|
|
var SettingsGeneralController = Ember.Controller.extend({
|
|
|
|
selectedTheme: null,
|
|
|
|
|
|
|
|
isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) {
|
2014-03-21 06:55:32 +04:00
|
|
|
// setter
|
|
|
|
if (arguments.length > 1) {
|
2014-12-30 05:11:24 +03:00
|
|
|
this.set('model.permalinks', value ? '/:year/:month/:day/:slug/' : '/:slug/');
|
2014-03-21 06:55:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// getter
|
2014-12-30 05:11:24 +03:00
|
|
|
var slugForm = this.get('model.permalinks');
|
2014-03-21 06:55:32 +04:00
|
|
|
|
|
|
|
return slugForm !== '/:slug/';
|
2014-07-30 05:57:19 +04:00
|
|
|
}),
|
2014-03-21 06:55:32 +04:00
|
|
|
|
2014-07-30 05:57:19 +04:00
|
|
|
themes: Ember.computed(function () {
|
2014-12-30 05:11:24 +03:00
|
|
|
return this.get('model.availableThemes').reduce(function (themes, t) {
|
2014-06-20 06:29:49 +04:00
|
|
|
var theme = {};
|
|
|
|
|
|
|
|
theme.name = t.name;
|
|
|
|
theme.label = t.package ? t.package.name + ' - ' + t.package.version : t.name;
|
|
|
|
theme.package = t.package;
|
|
|
|
theme.active = !!t.active;
|
|
|
|
|
|
|
|
themes.push(theme);
|
|
|
|
|
|
|
|
return themes;
|
|
|
|
}, []);
|
2014-07-30 05:57:19 +04:00
|
|
|
}).readOnly(),
|
2014-06-20 06:29:49 +04:00
|
|
|
|
2014-03-21 06:55:32 +04:00
|
|
|
actions: {
|
2014-06-18 00:20:54 +04:00
|
|
|
save: function () {
|
2014-06-20 06:29:49 +04:00
|
|
|
var self = this;
|
2014-03-21 06:55:32 +04:00
|
|
|
|
2014-06-20 06:29:49 +04:00
|
|
|
return this.get('model').save().then(function (model) {
|
|
|
|
self.notifications.showSuccess('Settings successfully saved.');
|
2014-06-24 10:33:24 +04:00
|
|
|
|
2014-06-20 06:29:49 +04:00
|
|
|
return model;
|
2014-06-24 10:33:24 +04:00
|
|
|
}).catch(function (errors) {
|
|
|
|
self.notifications.showErrors(errors);
|
|
|
|
});
|
2014-03-21 06:55:32 +04:00
|
|
|
},
|
2014-08-19 02:56:28 +04:00
|
|
|
|
|
|
|
checkPostsPerPage: function () {
|
2014-12-30 05:11:24 +03:00
|
|
|
var postsPerPage = this.get('model.postsPerPage');
|
|
|
|
|
|
|
|
if (postsPerPage < 1 || postsPerPage > 1000 || isNaN(postsPerPage)) {
|
|
|
|
this.set('model.postsPerPage', 5);
|
2014-08-19 02:56:28 +04:00
|
|
|
}
|
|
|
|
}
|
2014-03-21 06:55:32 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-20 06:29:49 +04:00
|
|
|
export default SettingsGeneralController;
|