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/users/edit/controller.js
Matthew Dillon f2f16e15a4 Edit user
2015-10-01 07:13:36 -07:00

32 lines
789 B
JavaScript

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