1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-24 15:49:44 +02:00

Refactor user settings to use component

This commit is contained in:
zinyando 2016-07-27 17:26:20 +02:00
parent fadbb57188
commit ab94dabbd2
5 changed files with 96 additions and 46 deletions

View file

@ -1,11 +1,11 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
// by contacting <sales@documize.com>.
//
// https://documize.com
@ -17,30 +17,13 @@ export default Ember.Controller.extend(NotifierMixin, {
newUser: { firstname: "", lastname: "", email: "", active: true },
actions: {
add: function () {
if (is.empty(this.newUser.firstname)) {
$("#newUserFirstname").addClass("error").focus();
return;
}
if (is.empty(this.newUser.lastname)) {
$("#newUserLastname").addClass("error").focus();
return;
}
if (is.empty(this.newUser.email) || is.not.email(this.newUser.email)) {
$("#newUserEmail").addClass("error").focus();
return;
}
add(user) {
Ember.set(this, 'newUser', user);
$("#newUserFirstname").removeClass("error");
$("#newUserLastname").removeClass("error");
$("#newUserEmail").removeClass("error");
this.get('userService')
return this.get('userService')
.add(this.get('newUser'))
.then((user) => {
this.showNotification('Added');
this.set('newUser', { firstname: "", lastname: "", email: "", active: true });
$("#newUserFirstname").focus();
this.get('model').pushObject(user);
})
.catch(function (error) {
@ -76,4 +59,4 @@ export default Ember.Controller.extend(NotifierMixin, {
this.showNotification('Password changed');
}
}
});
});