Skip to content

Commit

Permalink
Card: Show assigned users on board
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Oct 3, 2017
1 parent 812357e commit 7c4d62f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
21 changes: 17 additions & 4 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,28 @@ input.input-inline {
padding: 5px;
}

.card-assigned-users {
display: flex;
justify-content: flex-end;
flex-grow: 1;
.assigned-user {
margin-right: 5px;
z-index: 4;
}
.avatardiv, .avatardiv img {
width: 26px !important;
height: 26px !important;
}
}

.card-controls {
padding: 10px;
background: $color-lightgrey;
display: flex;
position: relative;

.card-options {
opacity: 0.3;
position: absolute;
right: 10px;
top: 8px;
justify-content: flex-end;
}

&:hover .card-options {
Expand All @@ -374,6 +385,8 @@ input.input-inline {
button {
padding: 0px;
margin-right: 0px;
margin-top: 5px;
margin-left: 5px;
}
}

Expand Down
8 changes: 6 additions & 2 deletions js/controller/CardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,16 @@ app.controller('CardController', function ($scope, $rootScope, $routeParams, $lo
};

$scope.addAssignedUser = function(item) {
CardService.assignUser(CardService.getCurrent(), item.uid);
CardService.assignUser(CardService.getCurrent(), item.uid).then(function (data) {
StackService.updateCard(CardService.getCurrent());
});
$scope.status.showAssignUser = false;
};

$scope.removeAssignedUser = function(item) {
CardService.unassignUser(CardService.getCurrent(), item.participant.uid);
CardService.unassignUser(CardService.getCurrent(), item.participant.uid).then(function (data) {
StackService.updateCard(CardService.getCurrent());
});
};

});
2 changes: 2 additions & 0 deletions js/service/CardService.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ 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 = [];
$http.post(this.baseUrl + '/' + card.id + '/assign', {'userId': user}).then(function (response) {
self.getCurrent().assignedUsers.push(response.data);
deferred.resolve(response.data);
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/StackController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
class StackController extends Controller {
private $userId;
private $stackService;
public function __construct($appName, IRequest $request, StackService $cardService, $userId) {
public function __construct($appName, IRequest $request, StackService $stackService, $userId) {
parent::__construct($appName, $request);
$this->userId = $userId;
$this->stackService = $cardService;
$this->stackService = $stackService;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions lib/Service/StackService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\LabelMapper;

use OCA\Deck\Db\AssignedUsersMapper;

use OCA\Deck\Db\Stack;

Expand All @@ -42,12 +42,13 @@ class StackService {
private $permissionService;
private $boardService;

public function __construct(StackMapper $stackMapper, CardMapper $cardMapper, LabelMapper $labelMapper, PermissionService $permissionService, BoardService $boardService) {
public function __construct(StackMapper $stackMapper, CardMapper $cardMapper, LabelMapper $labelMapper, PermissionService $permissionService, BoardService $boardService, AssignedUsersMapper $assignedUsersMapper) {
$this->stackMapper = $stackMapper;
$this->cardMapper = $cardMapper;
$this->labelMapper = $labelMapper;
$this->permissionService = $permissionService;
$this->boardService = $boardService;
$this->assignedUsersMapper = $assignedUsersMapper;
}

public function findAll($boardId) {
Expand All @@ -57,6 +58,8 @@ public function findAll($boardId) {
foreach ($stacks as $stackIndex => $stack) {
$cards = $this->cardMapper->findAll($stack->id);
foreach ($cards as $cardIndex => $card) {
$assignedUsers = $this->assignedUsersMapper->find($card->getId());
$card->setAssignedUsers($assignedUsers);
if (array_key_exists($card->id, $labels)) {
$cards[$cardIndex]->setLabels($labels[$card->id]);
}
Expand Down
5 changes: 5 additions & 0 deletions templates/part.board.mainView.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
<i class="icon icon-badge"></i>
<span data-timestamp="{{ c.duedate | dateToTimestamp }}" class="live-relative-timestamp">{{ c.duedate | relativeDateFilterString }}</span>
</span>
<div class="card-assigned-users">
<div class="assigned-user" ng-repeat="user in c.assignedUsers | limitTo: 3">
<div class="avatardiv" avatar ng-attr-displayname="{{ user.participant.uid }}"></div>
</div>
</div>
<div class="app-popover-menu-utils" ng-if="!boardservice.isArchived()">
<button class="button-inline card-options icon-more" ng-model="card"></button>
<div class="popovermenu hidden">
Expand Down

0 comments on commit 7c4d62f

Please sign in to comment.