Update user list when acl is changed

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-02-04 12:35:23 +01:00
parent 220adf708f
commit 9bb474638d

View File

@@ -141,7 +141,11 @@ app.factory('BoardService', function (ApiService, $http, $q) {
board.acl = {};
}
board.acl[response.data.id] = response.data;
self._updateUsers();
if (response.data.type === OC.Share.SHARE_TYPE_USER) {
self._updateUsers();
} else {
self.fetchOne(response.data.boardId);
}
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error creating ACL ' + _acl);
@@ -156,7 +160,11 @@ app.factory('BoardService', function (ApiService, $http, $q) {
var self = this;
$http.delete(this.baseUrl + '/' + acl.boardId + '/acl/' + acl.id).then(function (response) {
delete board.acl[response.data.id];
self._updateUsers();
if (response.data.type === OC.Share.SHARE_TYPE_USER) {
self._updateUsers();
} else {
self.fetchOne(response.data.boardId);
}
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error deleting ACL ' + acl.id);
@@ -172,7 +180,11 @@ app.factory('BoardService', function (ApiService, $http, $q) {
var _acl = acl;
$http.put(this.baseUrl + '/' + acl.boardId + '/acl', _acl).then(function (response) {
board.acl[_acl.id] = response.data;
self._updateUsers();
if (response.data.type === OC.Share.SHARE_TYPE_USER) {
self._updateUsers();
} else {
self.fetchOne(response.data.boardId);
}
deferred.resolve(response.data);
}, function (error) {
deferred.reject('Error updating ACL ' + _acl);
@@ -185,20 +197,21 @@ app.factory('BoardService', function (ApiService, $http, $q) {
if (!this.getCurrent() || !this.getCurrent().acl) {
return [];
}
var result = [this.getCurrent().owner];
angular.forEach(this.getCurrent().acl, function(value, key) {
if (value.type === OC.Share.SHARE_TYPE_USER) {
result.push(value.participant);
}
});
this.getCurrent()._users = result;
this.getCurrent().users = result;
};
BoardService.prototype.getUsers = function () {
if (this.getCurrent() && !this.getCurrent()._users) {
if (this.getCurrent() && !this.getCurrent().users) {
this._updateUsers();
}
return this.getCurrent()._users;
return this.getCurrent().users;
};
BoardService.prototype.canRead = function () {