Created
June 13, 2017 07:18
-
-
Save NotGrm/14554d044e95be3141982bac4d62f45c to your computer and use it in GitHub Desktop.
EmberJS action to add multiple user to a department. Not Working
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addMembers() { | |
const { department, selected } = this.getProperties('department', 'selected'); | |
Ember.RSVP.all( | |
selected.map((user) => { | |
if(!Ember.isNone(user.get('department'))) { | |
user.get('department').then((old) => { | |
old.get('members').removeObject(user); | |
old.save(); | |
}); | |
} | |
department.get('members').pushObject(user); | |
return user.save(); | |
}) | |
).then(() => { | |
department.save() | |
this.set('selected', []); | |
}) | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment