Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"assign to me" feature #544

Merged
merged 3 commits into from
Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions js/controller/BoardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,29 @@ 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);}
);
// TODO: remove this jquery call. Fix and use appPopoverMenuUtils instead
$('.popovermenu').addClass('hidden');
};
$scope.cardUnassignFromMe = function (card) {
CardService.unassignUser(card, OC.getCurrentUser().uid);
StackService.updateCard(card);
// TODO: remove this jquery call.Fix and use appPopoverMenuUtils instead
$('.popovermenu').addClass('hidden');
};
$scope.cardUnarchive = function (card) {
CardService.unarchive(card);
StackService.removeCard(card);
Expand Down
10 changes: 5 additions & 5 deletions js/service/CardService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -174,4 +174,4 @@ app.factory('CardService', function (ApiService, $http, $q) {

var service = new CardService($http, 'cards', $q);
return service;
});
});
14 changes: 13 additions & 1 deletion templates/part.board.mainView.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down