mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-13 22:53:32 +03:00
a4dc5f8bee
fixes #3105, refs #3012 - Add additional closeAll() calls where users interact with data
60 lines
1.6 KiB
JavaScript
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;
|