Remove existing shares from ui-select field

This commit is contained in:
Julius Haertl
2016-10-14 23:55:08 +02:00
parent 382b4175a6
commit c37f9384c3
6 changed files with 92 additions and 14 deletions

View File

@@ -126,7 +126,14 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
BoardService.searchUsers();
BoardService.searchUsers('%25');
$scope.searchForUser = function(search) {
if(search=="") {
search = "%25";
}
BoardService.searchUsers(search);
}
$scope.newStack = { 'boardId': $scope.id};
$scope.newCard = {};

View File

@@ -223,7 +223,14 @@ app.controller('BoardController', ["$rootScope", "$scope", "$stateParams", "Stat
BoardService.searchUsers();
BoardService.searchUsers('%25');
$scope.searchForUser = function(search) {
if(search=="") {
search = "%25";
}
BoardService.searchUsers(search);
}
$scope.newStack = { 'boardId': $scope.id};
$scope.newCard = {};
@@ -859,13 +866,26 @@ app.factory('BoardService', ["ApiService", "$http", "$q", function(ApiService, $
};
BoardService.prototype = angular.copy(ApiService.prototype);
BoardService.prototype.searchUsers = function() {
var url = OC.generateUrl('/apps/deck/share/search/%');
BoardService.prototype.searchUsers = function(search) {
var url = OC.generateUrl('/apps/deck/share/search/'+search);
var deferred = $q.defer();
var self = this;
this.sharees = [];
$http.get(url).then(function (response) {
self.sharees = response.data;
self.sharees = [];
// filter out everyone who is already in the share list
angular.forEach(response.data, function(item) {
var exists = false;
angular.forEach(self.getCurrent().acl, function(acl) {
if (acl.participant === item.participant) {
exists = true;
}
});
if(!exists) {
self.sharees.push(item);
}
});
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error while update ' + self.endpoint);

View File

@@ -26,13 +26,26 @@ app.factory('BoardService', function(ApiService, $http, $q){
};
BoardService.prototype = angular.copy(ApiService.prototype);
BoardService.prototype.searchUsers = function() {
var url = OC.generateUrl('/apps/deck/share/search/%');
BoardService.prototype.searchUsers = function(search) {
var url = OC.generateUrl('/apps/deck/share/search/'+search);
var deferred = $q.defer();
var self = this;
this.sharees = [];
$http.get(url).then(function (response) {
self.sharees = response.data;
self.sharees = [];
// filter out everyone who is already in the share list
angular.forEach(response.data, function(item) {
var exists = false;
angular.forEach(self.getCurrent().acl, function(acl) {
if (acl.participant === item.participant) {
exists = true;
}
});
if(!exists) {
self.sharees.push(item);
}
});
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error while update ' + self.endpoint);