Ghost/ghost/admin/controllers/settings/app.js
Robert Jackson d8da21520f Remove ObjectController proxying behavior.
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.
2015-01-01 21:51:20 -05:00

64 lines
1.6 KiB
JavaScript

/*global alert */
var appStates,
SettingsAppController;
appStates = {
active: 'active',
working: 'working',
inactive: 'inactive'
};
SettingsAppController = Ember.Controller.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;