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