mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-13 22:53:32 +03:00
0e9d4e6792
Refs #4001 - grunt-jscs@0.8.1 which provides ES6 support.
64 lines
1.6 KiB
JavaScript
64 lines
1.6 KiB
JavaScript
/*global alert */
|
|
|
|
var appStates,
|
|
SettingsAppController;
|
|
|
|
appStates = {
|
|
active: 'active',
|
|
working: 'working',
|
|
inactive: 'inactive'
|
|
};
|
|
|
|
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: Ember.computed('appState', function () {
|
|
return this.appState === appStates.active ? true : false;
|
|
}),
|
|
|
|
inactiveClass: Ember.computed('appState', function () {
|
|
return this.appState === appStates.inactive ? true : false;
|
|
}),
|
|
|
|
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;
|