Frontend: Fix assigning/removing users
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
committed by
Julius Härtl
parent
447cb80573
commit
f42e3eb857
@@ -139,21 +139,20 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
|
||||
CardService.update(element);
|
||||
StackService.updateCard(element);
|
||||
};
|
||||
|
||||
/**
|
||||
* Assigning users to cards
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Show ui-select field when clicking the add button
|
||||
*/
|
||||
$scope.showAssignUser = function() {
|
||||
$scope.status.showAssignUser = true;
|
||||
$timeout(function() {
|
||||
$("#assignUserSelect").find('a')[0].click();
|
||||
$("#assignUserSelect").find('a').click();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Hide ui-select when select list is closed
|
||||
*/
|
||||
$scope.assingUserOpenClose = function(isOpen) {
|
||||
if (!isOpen) {
|
||||
$scope.status.showAssignUser = false;
|
||||
@@ -161,12 +160,12 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
|
||||
};
|
||||
|
||||
$scope.addAssignedUser = function(item) {
|
||||
CardService.assignUser(CardService.getCurrent(), item.uid);
|
||||
$scope.status.showAssignUser = false;
|
||||
$('assignUserSelect').hide();
|
||||
console.log(a);
|
||||
};
|
||||
|
||||
$scope.removeAssignedUser = function() {
|
||||
|
||||
$scope.removeAssignedUser = function(item) {
|
||||
CardService.unassignUser(CardService.getCurrent(), item.participant.uid);
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user