This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/pods/protected/characteristics/edit/controller.js
2015-09-08 10:37:48 -07:00

30 lines
857 B
JavaScript

import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let characteristic = this.get('model');
if (characteristic.get('hasDirtyAttributes')) {
characteristic.save().then((characteristic) => {
this.transitionToRoute('protected.characteristics.show', characteristic);
}, (err) => {
this.get('flashMessages').error(err.responseJSON.error);
});
} else {
characteristic.deleteRecord();
this.transitionToRoute('protected.characteristics.show', characteristic);
}
},
cancel: function() {
let characteristic = this.get('model');
characteristic.get('errors').clear();
characteristic.rollbackAttributes();
this.transitionToRoute('protected.characteristics.show', characteristic);
},
},
});