mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
a1ed9adf92
Ember.ObjectController (and Ember.ArrayController) will be deprecated in Ember 1.11 (and removed from core in Ember 2.0). The reasoning is detailed in the Ember 2.0 RFC. This PR does the following: * Updates templates/controllers/views to explicitly reference model properties (instead of relying on proxying behavior). * Clearly delineate where certain properties are being set or retrieved from (for example it was not clear exactly where `scratch` and `titleScratch` were stored). * Remove usage of `Ember.ObjectController`. * Add JSCS rule to prevent future PR's from adding regressions.
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
var SettingsGeneralController = Ember.Controller.extend({
|
|
selectedTheme: null,
|
|
|
|
isDatedPermalinks: Ember.computed('model.permalinks', function (key, value) {
|
|
// setter
|
|
if (arguments.length > 1) {
|
|
this.set('model.permalinks', value ? '/:year/:month/:day/:slug/' : '/:slug/');
|
|
}
|
|
|
|
// getter
|
|
var slugForm = this.get('model.permalinks');
|
|
|
|
return slugForm !== '/:slug/';
|
|
}),
|
|
|
|
themes: Ember.computed(function () {
|
|
return this.get('model.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;
|
|
}, []);
|
|
}).readOnly(),
|
|
|
|
actions: {
|
|
save: function () {
|
|
var self = this;
|
|
|
|
return this.get('model').save().then(function (model) {
|
|
self.notifications.showSuccess('Settings successfully saved.');
|
|
|
|
return model;
|
|
}).catch(function (errors) {
|
|
self.notifications.showErrors(errors);
|
|
});
|
|
},
|
|
|
|
checkPostsPerPage: function () {
|
|
var postsPerPage = this.get('model.postsPerPage');
|
|
|
|
if (postsPerPage < 1 || postsPerPage > 1000 || isNaN(postsPerPage)) {
|
|
this.set('model.postsPerPage', 5);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SettingsGeneralController;
|