assign to me feature
codacy fix codacy fix #2 revert translation files coding style : spaces to tabs Signed-off-by: Philippe Le Van <philippe.levan@kibatic.com>
This commit is contained in:
@@ -200,6 +200,27 @@ app.controller('BoardController', function ($rootScope, $scope, $stateParams, St
|
||||
CardService.archive(card);
|
||||
StackService.removeCard(card);
|
||||
};
|
||||
$scope.isCurrentUserAssigned = function (card) {
|
||||
if (! CardService.get(card.id).assignedUsers) {
|
||||
return false;
|
||||
}
|
||||
var userList = CardService.get(card.id).assignedUsers.filter(function (obj) {
|
||||
return obj.participant.uid === OC.getCurrentUser().uid;
|
||||
});
|
||||
return userList.length === 1;
|
||||
};
|
||||
$scope.cardAssignToMe = function (card) {
|
||||
CardService.assignUser(card, OC.getCurrentUser().uid)
|
||||
.then(
|
||||
function() {StackService.updateCard(card);}
|
||||
);
|
||||
$('.popovermenu').addClass('hidden');
|
||||
};
|
||||
$scope.cardUnassignFromMe = function (card) {
|
||||
CardService.unassignUser(card, OC.getCurrentUser().uid);
|
||||
StackService.updateCard(card);
|
||||
$('.popovermenu').addClass('hidden');
|
||||
};
|
||||
$scope.cardUnarchive = function (card) {
|
||||
CardService.unarchive(card);
|
||||
StackService.removeCard(card);
|
||||
|
||||
@@ -106,11 +106,11 @@ app.factory('CardService', function (ApiService, $http, $q) {
|
||||
CardService.prototype.assignUser = function (card, user) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
if (self.getCurrent().assignedUsers === null) {
|
||||
self.getCurrent().assignedUsers = [];
|
||||
if (self.get(card.id).assignedUsers === null) {
|
||||
self.get(card.id).assignedUsers = [];
|
||||
}
|
||||
$http.post(this.baseUrl + '/' + card.id + '/assign', {'userId': user}).then(function (response) {
|
||||
self.getCurrent().assignedUsers.push(response.data);
|
||||
self.get(card.id).assignedUsers.push(response.data);
|
||||
deferred.resolve(response.data);
|
||||
}, function (error) {
|
||||
deferred.reject('Error while update ' + self.endpoint);
|
||||
@@ -123,7 +123,7 @@ app.factory('CardService', function (ApiService, $http, $q) {
|
||||
var deferred = $q.defer();
|
||||
var self = this;
|
||||
$http.delete(this.baseUrl + '/' + card.id + '/assign/' + user, {}).then(function (response) {
|
||||
self.getCurrent().assignedUsers = self.getCurrent().assignedUsers.filter(function (obj) {
|
||||
self.get(card.id).assignedUsers = self.get(card.id).assignedUsers.filter(function (obj) {
|
||||
return obj.participant.uid !== user;
|
||||
});
|
||||
deferred.resolve(response.data);
|
||||
@@ -174,4 +174,4 @@ app.factory('CardService', function (ApiService, $http, $q) {
|
||||
|
||||
var service = new CardService($http, 'cards', $q);
|
||||
return service;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
</form>
|
||||
<button class="icon-delete button-inline stack-actions"
|
||||
ng-if="!s.status.editStack"
|
||||
ng-click="stackservice.delete(s.id)"></button>
|
||||
ng-click="stackservice.delete(s.id)"></button>
|
||||
</h3>
|
||||
<ul data-as-sortable="sortOptions" is-disabled="!boardservice.canEdit() || filter==='archive'" data-ng-model="s.cards" class="card-list" ng-class="{emptyStack: !s.cards.length}">
|
||||
<li class="card as-sortable-item"
|
||||
@@ -101,6 +101,18 @@
|
||||
<button class="button-inline card-options icon-more" ng-model="card"></button>
|
||||
<div class="popovermenu hidden">
|
||||
<ul>
|
||||
<li ng-if="!isCurrentUserAssigned(c)">
|
||||
<a class="menuitem action action-rename permanent"
|
||||
data-action="AssignToMe"
|
||||
ng-click="cardAssignToMe(c); $event.stopPropagation();"><span
|
||||
class="icon icon-user"></span><span><?php p($l->t('Assign to me')); ?></span></a>
|
||||
</li>
|
||||
<li ng-if="isCurrentUserAssigned(c)">
|
||||
<a class="menuitem action action-rename permanent"
|
||||
data-action="UnassignFromMe"
|
||||
ng-click="cardUnassignFromMe(c); $event.stopPropagation();"><span
|
||||
class="icon icon-user"></span><span><?php p($l->t('Unassign from me')); ?></span></a>
|
||||
</li>
|
||||
<li ng-if="params.filter!=='archive'">
|
||||
<a class="menuitem action action-rename permanent"
|
||||
data-action="Archive"
|
||||
|
||||
Reference in New Issue
Block a user