Ghost/ghost/admin/controllers/settings/app.js
Fabian Becker a4dc5f8bee Close notifications on user action properly.
fixes #3105, refs #3012
- Add additional closeAll() calls where users interact with data
2014-06-25 16:56:09 +00:00

60 lines
1.6 KiB
JavaScript

/*global alert */
var AppStates = {
active: 'active',
working: 'working',
inactive: 'inactive'
};
var SettingsAppController = Ember.ObjectController.extend({
appState: AppStates.active,
buttonText: '',
setAppState: function () {
this.set('appState', this.get('active') ? AppStates.active : AppStates.inactive);
}.on('init'),
buttonTextSetter: function () {
switch (this.get('appState')) {
case AppStates.active:
this.set('buttonText', 'Deactivate');
break;
case AppStates.inactive:
this.set('buttonText', 'Activate');
break;
case AppStates.working:
this.set('buttonText', 'Working');
break;
}
}.observes('appState').on('init'),
activeClass: function () {
return this.appState === AppStates.active ? true : false;
}.property('appState'),
inactiveClass: function () {
return this.appState === AppStates.inactive ? true : false;
}.property('appState'),
actions: {
toggleApp: function (app) {
var self = this;
this.set('appState', AppStates.working);
app.set('active', !app.get('active'));
app.save().then(function () {
self.setAppState();
})
.then(function () {
alert('@TODO: Success');
})
.catch(function () {
alert('@TODO: Failure');
});
}
}
});
export default SettingsAppController;