2014-03-20 21:55:32 -05:00
|
|
|
var SettingsGeneralController = Ember.ObjectController.extend({
|
|
|
|
isDatedPermalinks: function (key, value) {
|
|
|
|
// setter
|
|
|
|
if (arguments.length > 1) {
|
|
|
|
this.set('permalinks', value ? '/:year/:month/:day/:slug/' : '/:slug/');
|
|
|
|
}
|
|
|
|
|
|
|
|
// getter
|
|
|
|
var slugForm = this.get('permalinks');
|
|
|
|
|
|
|
|
return slugForm !== '/:slug/';
|
|
|
|
}.property('permalinks'),
|
|
|
|
|
2014-06-19 21:29:49 -05:00
|
|
|
themes: function () {
|
|
|
|
return this.get('availableThemes').reduce(function (themes, t) {
|
|
|
|
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-09 17:11:04 -05:00
|
|
|
}.property().readOnly(),
|
2014-06-19 21:29:49 -05:00
|
|
|
|
2014-03-20 21:55:32 -05:00
|
|
|
actions: {
|
2014-06-17 15:20:54 -05:00
|
|
|
save: function () {
|
2014-06-19 21:29:49 -05:00
|
|
|
var self = this;
|
2014-03-20 21:55:32 -05:00
|
|
|
|
2014-06-19 21:29:49 -05:00
|
|
|
return this.get('model').save().then(function (model) {
|
|
|
|
self.notifications.showSuccess('Settings successfully saved.');
|
2014-06-24 01:33:24 -05:00
|
|
|
|
2014-06-19 21:29:49 -05:00
|
|
|
return model;
|
2014-06-24 01:33:24 -05:00
|
|
|
}).catch(function (errors) {
|
|
|
|
self.notifications.showErrors(errors);
|
|
|
|
});
|
2014-03-20 21:55:32 -05:00
|
|
|
},
|
2014-08-18 17:56:28 -05:00
|
|
|
|
|
|
|
checkPostsPerPage: function () {
|
|
|
|
if (this.get('postsPerPage') < 1 || this.get('postsPerPage') > 1000 || isNaN(this.get('postsPerPage'))) {
|
|
|
|
this.set('postsPerPage', 5);
|
|
|
|
}
|
|
|
|
}
|
2014-03-20 21:55:32 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-19 21:29:49 -05:00
|
|
|
export default SettingsGeneralController;
|