0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-13 22:41:32 -05:00
ghost/core/client/controllers/settings/general.js
Matt Enlow b04dfd52c1 Cleanup Misc Ember Code
No issue

Misc Places
- Removed expired, irrelevant, and fixed todos

FloatingHeaderPartial
- Fixed "Written" vs "Published" text logic

SettingsGeneralController
- Removed single quotes from property names

EditorBaseController, MarkerManagerMixin
- Aligned var declarations

PostItemView
- Commented out unfunctional code for feature request #2398
- Switched `isPage`, `isFeatured` to be computed properties in `Po
- use `toggleProperty` in `PostController.action.toggleFeatured`
2014-06-17 14:59:15 -06:00

58 lines
No EOL
1.8 KiB
JavaScript

var elementLookup = {
title: '#blog-title',
description: '#blog-description',
email: '#email-address',
postsPerPage: '#postsPerPage'
};
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'),
actions: {
save: function () {
// Validate and save settings
var model = this.get('model'),
// @TODO: Don't know how to scope this to this controllers view because this.view is null
errs = model.validate();
if (errs.length > 0) {
// Set the actual element from this view based on the error
errs.forEach(function (err) {
// @TODO: Probably should still be scoped to this controllers root element.
err.el = $(elementLookup[err.el]);
});
// Let the applicationRoute handle validation errors
this.send('handleErrors', errs);
} else {
model.save().then(function () {
// @TODO: Notification of success
window.alert('Saved data!');
}, function () {
// @TODO: Notification of error
window.alert('Error saving data');
});
}
},
uploadLogo: function () {
// @TODO: Integrate with Modal component
},
uploadCover: function () {
// @TODO: Integrate with Modal component
}
}
});
export default SettingsGeneralController;