WIP: assign users

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2017-09-15 14:12:43 +02:00
committed by Julius Härtl
parent 4fa37f0548
commit 4cf746dd6f
8 changed files with 204 additions and 14 deletions

View File

@@ -316,6 +316,44 @@
</index>
</declaration>
</table>
<table>
<name>*dbprefix*deck_assigned_users</name>
<declaration>
<field>
<name>id</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<autoincrement>1</autoincrement>
<length>4</length>
</field>
<field>
<name>participant</name>
<type>text</type>
<notnull>true</notnull>
<length>64</length>
</field>
<field>
<name>card_id</name>
<type>integer</type>
<default>0</default>
<notnull>true</notnull>
<length>4</length>
</field>
<index>
<name>deck_assigned_users_idx_p</name>
<field>
<name>participant</name>
</field>
</index>
<index>
<name>deck_assigned_users_idx_c</name>
<field>
<name>card_id</name>
</field>
</index>
</declaration>
</table>
<table>
<name>*dbprefix*deck_board_acl</name>
<declaration>

View File

@@ -16,7 +16,7 @@
💥 This is still alpha software: it may not be stable enough for production!
</description>
<version>0.3.0-dev1</version>
<version>0.3.0-dev2</version>
<licence>agpl</licence>
<author>Julius Härtl</author>
<namespace>Deck</namespace>

View File

@@ -601,14 +601,27 @@ input.input-inline {
h4 {
border-bottom: 1px solid $color-lightgrey;
padding: 15px 0px 5px 0px;
margin: 0 0 10px 0;
font-size: 15px;
display: flex;
flex-direction: row;
height: 30px;
div:first-child {
flex-grow: 1;
padding: 15px 0 5px 0;
display: inline-block;
> div {
display: inline-flex;
align-content: center;
justify-content: space-between;
}
}
.section-header {
border-bottom: 1px solid $color-lightgrey;
display: flex;
flex-direction: row;
padding: 15px 0 5px 0;
margin: 10px 0 10px 0;
h4 {
margin: 0;
border: none;
margin: 15px 0 5px 0;
}
}

41
lib/Db/AssignedUsers.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
/**
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Deck\Db;
use JsonSerializable;
class AssignedUsers extends RelationalEntity implements JsonSerializable {
public $id;
protected $participant;
protected $cardId;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('card_id', 'integer');
$this->addResolvable('participant');
}
}

View File

@@ -0,0 +1,76 @@
<?php
/**
* @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
*
* @author Julius Härtl <jus@bitgrid.net>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\Entity;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUserManager;
class AssignedUsersMapper extends DeckMapper implements IPermissionMapper {
private $cardMapper;
private $userManager;
public function __construct(IDBConnection $db, CardMapper $cardMapper, IUserManager $userManager) {
parent::__construct($db, 'deck_assigned_users', '\OCA\Deck\Db\AssignedUsers');
$this->cardMapper = $cardMapper;
$this->userManager = $userManager;
}
public function find($cardId) {
$sql = 'SELECT * FROM `*PREFIX*deck_assigned_users` ' .
'WHERE `card_id` = ?';
$users = $this->findEntities($sql, [$cardId]);
foreach ($users as &$user) {
$this->mapParticipant($user);
}
return $users;
}
public function isOwner($userId, $cardId) {
return $this->cardMapper->isOwner($userId, $cardId);
}
public function findBoardId($cardId) {
return $this->cardMapper->findBoardId($cardId);
}
public function mapParticipant(AssignedUsers &$assignment) {
$userManager = $this->userManager;
$assignment->resolveRelation('participant', function() use (&$userManager, &$assignment) {
$user = $userManager->get($assignment->getParticipant());
if($user !== null) {
return new User($user);
}
return null;
});
}
}

View File

@@ -56,6 +56,7 @@ class Card extends RelationalEntity {
$this->addType('archived', 'boolean');
$this->addType('notified', 'boolean');
$this->addRelation('labels');
$this->addRelation('participants');
$this->addResolvable('owner');
}

View File

@@ -24,6 +24,7 @@
namespace OCA\Deck\Db;
use OCP\AppFramework\Db\Entity;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IUserManager;
use OCP\Notification\IManager;
@@ -103,6 +104,7 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
$card = $this->findEntity($sql, [$id]);
$labels = $this->labelMapper->findAssignedLabelsForCard($card->id);
$card->setLabels($labels);
$this->mapOwner($card);
return $card;
}

View File

@@ -47,17 +47,35 @@
</ui-select-choices>
</ui-select>
</div>
<h4>
<?php p($l->t('Due date')); ?>
</h4>
<div class="section-header">
<h4><?php p($l->t('Assign users')); ?></h4>
<button class="button icon-add"></button>
</div>
<ui-select ng-model="status.addSharee" theme="select2" style="width:100%;" title="Choose a user to assign" placeholder="Assign users ..." on-select="aclAdd(status.addSharee)" search-enabled="true">
<ui-select-match placeholder="<?php p($l->t('Assign this card to a user')); ?>">
<span><i class="icon icon-{{$item.type}}"></i> {{ $item.participant.displayname }}</span>
</ui-select-match>
<ui-select-choices refresh="searchForUser($select.search)" refresh-delay="0" repeat="sharee in boardservice.sharees">
<span><i class="icon icon-{{sharee.type}}"></i> {{ sharee.participant.displayname }}</span>
</ui-select-choices>
<ui-select-no-choice>
<?php p($l->t('No matching user or group found.')); ?>
</ui-select-no-choice>
</ui-select>
<div class="avatardiv" avatar ng-attr-displayname="{{ boardservice.getCurrent().owner.uid }}" ng-if="boardservice.id"></div>
<div class="section-header">
<h4>
<?php p($l->t('Due date')); ?>
</h4>
</div>
<div class="duedate">
<input class="datepicker-input medium focus" type="text" placeholder="<?php p($l->t('Click to set')); ?>" value="{{ cardservice.getCurrent().duedate | parseDate }}" datepicker="due" ng-disabled="(boardservice.isArchived() || card.archived)" />
<input class="timepicker-input medium focus" type="text" placeholder="00:00" ng-disabled="!cardservice.getCurrent().duedate || (boardservice.isArchived() || card.archived)" value="{{ cardservice.getCurrent().duedate | parseTime }}" timepicker="due" />
<button class="icon icon-delete button-inline" title="<?php p($l->t('Remove due date')); ?>" ng-if="cardservice.getCurrent().duedate" ng-click="resetDuedate()"></button>
</div>
<div id="card-description">
<div class="section-header">
<h4>
<div>
<?php p($l->t('Description')); ?>
@@ -65,8 +83,9 @@
</div>
<span class="save-indicator saved"><?php p($l->t('Saved')); ?></span>
<span class="save-indicator unsaved"><?php p($l->t('Unsaved changes')); ?></span>
</h4>
</div>
<div id="card-description">
<textarea elastic ng-if="status.cardEditDescription"
placeholder="<?php p($l->t('Add a card description…')); ?>"
ng-blur="cardUpdate(cardservice.getCurrent())"