Frontend: Fix assigning/removing users

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-10-01 16:05:43 +02:00
committed by Julius Härtl
parent 447cb80573
commit f42e3eb857
4 changed files with 53 additions and 19 deletions

View File

@@ -98,7 +98,8 @@ app.factory('CardService', function(ApiService, $http, $q){
CardService.prototype.assignUser = function (card, user) {
var deferred = $q.defer();
var self = this;
$http.post(this.baseUrl + '/' + card.id + '/assign', {'user': user}).then(function (response) {
$http.post(this.baseUrl + '/' + card.id + '/assign', {'userId': user}).then(function (response) {
self.getCurrent().assignedUsers.push(response.data);
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error while update ' + self.endpoint);
@@ -110,7 +111,10 @@ app.factory('CardService', function(ApiService, $http, $q){
CardService.prototype.unassignUser = function (card, user) {
var deferred = $q.defer();
var self = this;
$http.delete(this.baseUrl + '/' + card.id + '/assign', {'user': user}).then(function (response) {
$http.delete(this.baseUrl + '/' + card.id + '/assign/' + user, {}).then(function (response) {
self.getCurrent().assignedUsers = self.getCurrent().assignedUsers.filter(function( obj ) {
return obj.participant.uid !== user;
});
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error while update ' + self.endpoint);