Fix primary key usage with different types
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -24,13 +24,15 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class Circle extends RelationalObject {
|
||||
|
||||
/** @var \OCA\Circles\Model\Circle */
|
||||
protected $object;
|
||||
|
||||
public function __construct(\OCA\Circles\Model\Circle $circle) {
|
||||
$primaryKey = $circle->getUniqueId();
|
||||
$primaryKey = IShare::TYPE_CIRCLE . ':' . $circle->getUniqueId();
|
||||
parent::__construct($primaryKey, $circle);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\IGroup;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class Group extends RelationalObject {
|
||||
|
||||
public function __construct(IGroup $group) {
|
||||
$primaryKey = $group->getGID();
|
||||
$primaryKey = IShare::TYPE_GROUP . ':' . $group->getGID();
|
||||
parent::__construct($primaryKey, $group);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,12 @@
|
||||
namespace OCA\Deck\Db;
|
||||
|
||||
use OCP\IUser;
|
||||
use OCP\Share\IShare;
|
||||
|
||||
class User extends RelationalObject {
|
||||
|
||||
public function __construct(IUser $user) {
|
||||
$primaryKey = $user->getUID();
|
||||
$primaryKey = IShare::TYPE_USER . ':' . $user->getUID();
|
||||
parent::__construct($primaryKey, $user);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ class AssignmentService {
|
||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_EDIT);
|
||||
$assignments = $this->assignedUsersMapper->find($cardId);
|
||||
foreach ($assignments as $assignment) {
|
||||
if ($assignment->getParticipant() === $userId) {
|
||||
if ($assignment->getParticipant() === $userId && $assignment->getType() === $type) {
|
||||
throw new BadRequestException('The user is already assigned to the card');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</span>
|
||||
</span>
|
||||
</li>
|
||||
<li v-for="acl in board.acl" :key="acl.participant.uid">
|
||||
<li v-for="acl in board.acl" :key="acl.participant.primaryKey">
|
||||
<Avatar v-if="acl.type===0" :user="acl.participant.uid" />
|
||||
<div v-if="acl.type===1" class="avatardiv icon icon-group" />
|
||||
<div v-if="acl.type===7" class="avatardiv icon icon-circles" />
|
||||
@@ -33,10 +33,10 @@
|
||||
<span v-if="acl.type===7">{{ t('deck', '(Circle)') }}</span>
|
||||
</span>
|
||||
|
||||
<ActionCheckbox v-if="!isCurrentUser(acl.participant.uid) && (canManage || (canEdit && canShare))" :checked="acl.permissionEdit" @change="clickEditAcl(acl)">
|
||||
<ActionCheckbox v-if="!(isCurrentUser(acl.participant.uid) && acl.type === 0) && (canManage || (canEdit && canShare))" :checked="acl.permissionEdit" @change="clickEditAcl(acl)">
|
||||
{{ t('deck', 'Can edit') }}
|
||||
</ActionCheckbox>
|
||||
<Actions v-if="!isCurrentUser(acl.participant.uid)" :force-menu="true">
|
||||
<Actions v-if="!(isCurrentUser(acl.participant.uid) && acl.type === 0)" :force-menu="true">
|
||||
<ActionCheckbox v-if="canManage || canShare" :checked="acl.permissionShare" @change="clickShareAcl(acl)">
|
||||
{{ t('deck', 'Can share') }}
|
||||
</ActionCheckbox>
|
||||
|
||||
@@ -61,10 +61,9 @@
|
||||
|
||||
<div class="section-wrapper">
|
||||
<div v-tooltip="t('deck', 'Assign to users')" class="section-label icon-group">
|
||||
<span class="hidden-visually">{{ t('deck', 'Assign to users') }}</span>
|
||||
<span class="hidden-visually">{{ t('deck', 'Assign to users/groups/circles') }}</span>
|
||||
</div>
|
||||
<div class="section-details">
|
||||
<!-- FIXME: model not wokring due to id -->
|
||||
<Multiselect v-if="canEdit"
|
||||
v-model="assignedUsers"
|
||||
:multiple="true"
|
||||
@@ -78,7 +77,7 @@
|
||||
@remove="removeUserFromCard">
|
||||
<template #tag="scope">
|
||||
<div class="avatarlist--inline">
|
||||
<Avatar :user="scope.option.primaryKey"
|
||||
<Avatar :user="scope.option.uid"
|
||||
:display-name="scope.option.displayname"
|
||||
:size="24"
|
||||
:disable-menu="true" />
|
||||
@@ -87,8 +86,8 @@
|
||||
</Multiselect>
|
||||
<div v-else class="avatar-list--readonly">
|
||||
<Avatar v-for="option in currentCard.assignedUsers"
|
||||
:key="option.id"
|
||||
:user="option.participant.primaryKey"
|
||||
:key="option.primaryKey"
|
||||
:user="option.participant.uid"
|
||||
:display-name="option.participant.displayname"
|
||||
:size="32" />
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<At ref="at"
|
||||
v-model="commentText"
|
||||
:members="members"
|
||||
name-key="primaryKey"
|
||||
name-key="uid"
|
||||
:tab-select="true">
|
||||
<template v-slot:item="s">
|
||||
<Avatar class="atwho-li--avatar" :user="s.item.uid" :size="24" />
|
||||
@@ -34,9 +34,9 @@
|
||||
</template>
|
||||
<template v-slot:embeddedItem="scope">
|
||||
<span>
|
||||
<UserBubble v-if="scope.current.primaryKey"
|
||||
:data-mention-id="scope.current.primaryKey"
|
||||
:user="scope.current.primaryKey"
|
||||
<UserBubble v-if="scope.current.uid"
|
||||
:data-mention-id="scope.current.uid"
|
||||
:user="scope.current.uid"
|
||||
:display-name="scope.current.displayname" />
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@@ -34,15 +34,15 @@
|
||||
:size="32" />
|
||||
<Avatar v-if="user.type === 1"
|
||||
:user="user.participant.primaryKey"
|
||||
:display-name="user.participant.primaryKey"
|
||||
:tooltip-message="user.participant.primaryKey + ' ' + t('deck', '(group)')"
|
||||
:display-name="user.participant.displayname"
|
||||
:tooltip-message="user.participant.displayname + ' ' + t('deck', '(group)')"
|
||||
:is-no-user="true"
|
||||
:disable-="true"
|
||||
:size="32" />
|
||||
<Avatar v-if="user.type === 7"
|
||||
:user="user.participant.primaryKey"
|
||||
:display-name="user.participant.primaryKey"
|
||||
:tooltip-message="user.participant.primaryKey + ' ' + t('deck', '(circle)')"
|
||||
:display-name="user.participant.displayname"
|
||||
:tooltip-message="user.participant.displayname + ' ' + t('deck', '(circle)')"
|
||||
:is-no-user="true"
|
||||
:disable-="true"
|
||||
:size="32" />
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
if (assignable.type === 1) {
|
||||
return 'icon-group'
|
||||
}
|
||||
const user = assignable.participant.primaryKey
|
||||
const user = assignable.participant.uid
|
||||
const size = 32
|
||||
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}',
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ class GroupTest extends \Test\TestCase {
|
||||
$expected = [
|
||||
'uid' => 'mygroup',
|
||||
'displayname' => 'My Group',
|
||||
'primaryKey' => 'mygroup'
|
||||
'primaryKey' => '1:mygroup'
|
||||
];
|
||||
|
||||
$actual = $groupRelationalObject->jsonSerialize();
|
||||
|
||||
@@ -57,7 +57,7 @@ class UserTest extends \Test\TestCase {
|
||||
$expected = [
|
||||
'uid' => 'myuser',
|
||||
'displayname' => 'myuser displayname',
|
||||
'primaryKey' => 'myuser'
|
||||
'primaryKey' => '0:myuser'
|
||||
];
|
||||
$this->assertEquals($expected, $userRelationalObject->jsonSerialize());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user