Do not change participant primary key

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-05-06 09:24:41 +02:00
parent 1539b2cf50
commit 611f9ff6a5
8 changed files with 29 additions and 20 deletions

View File

@@ -31,7 +31,7 @@ class Circle extends RelationalObject {
protected $object; protected $object;
public function __construct(\OCA\Circles\Model\Circle $circle) { public function __construct(\OCA\Circles\Model\Circle $circle) {
$primaryKey = IShare::TYPE_CIRCLE . ':' . $circle->getUniqueId(); $primaryKey = $circle->getUniqueId();
parent::__construct($primaryKey, $circle); parent::__construct($primaryKey, $circle);
} }
@@ -40,7 +40,8 @@ class Circle extends RelationalObject {
'uid' => $this->object->getUniqueId(), 'uid' => $this->object->getUniqueId(),
'displayname' => $this->object->getName(), 'displayname' => $this->object->getName(),
'typeString' => $this->object->getTypeString(), 'typeString' => $this->object->getTypeString(),
'circleOwner' => $this->object->getOwner() 'circleOwner' => $this->object->getOwner(),
'type' => 7
]; ];
} }
} }

View File

@@ -28,14 +28,15 @@ use OCP\Share\IShare;
class Group extends RelationalObject { class Group extends RelationalObject {
public function __construct(IGroup $group) { public function __construct(IGroup $group) {
$primaryKey = IShare::TYPE_GROUP . ':' . $group->getGID(); $primaryKey = $group->getGID();
parent::__construct($primaryKey, $group); parent::__construct($primaryKey, $group);
} }
public function getObjectSerialization() { public function getObjectSerialization() {
return [ return [
'uid' => $this->object->getGID(), 'uid' => $this->object->getGID(),
'displayname' => $this->object->getDisplayName() 'displayname' => $this->object->getDisplayName(),
'type' => 1
]; ];
} }
} }

View File

@@ -28,14 +28,15 @@ use OCP\Share\IShare;
class User extends RelationalObject { class User extends RelationalObject {
public function __construct(IUser $user) { public function __construct(IUser $user) {
$primaryKey = IShare::TYPE_USER . ':' . $user->getUID(); $primaryKey = $user->getUID();
parent::__construct($primaryKey, $user); parent::__construct($primaryKey, $user);
} }
public function getObjectSerialization() { public function getObjectSerialization() {
return [ return [
'uid' => $this->object->getUID(), 'uid' => $this->object->getUID(),
'displayname' => $this->object->getDisplayName() 'displayname' => $this->object->getDisplayName(),
'type' => 0
]; ];
} }

View File

@@ -24,12 +24,12 @@
<div class="board-wrapper"> <div class="board-wrapper">
<Controls :board="board" /> <Controls :board="board" />
<transition name="fade" mode="out-in"> <transition name="fade" mode="out-in">
<div v-if="loading" class="emptycontent" key="loading"> <div v-if="loading" key="loading" class="emptycontent">
<div class="icon icon-loading" /> <div class="icon icon-loading" />
<h2>{{ t('deck', 'Loading board') }}</h2> <h2>{{ t('deck', 'Loading board') }}</h2>
<p /> <p />
</div> </div>
<div v-else-if="board && !loading" class="board" key="board"> <div v-else-if="board && !loading" key="board" class="board">
<Container lock-axix="y" <Container lock-axix="y"
orientation="horizontal" orientation="horizontal"
:drag-handle-selector="dragHandleSelector" :drag-handle-selector="dragHandleSelector"
@@ -39,13 +39,12 @@
</Draggable> </Draggable>
</Container> </Container>
</div> </div>
<div v-else class="emptycontent" key="notfound"> <div v-else key="notfound" class="emptycontent">
<div class="icon icon-deck" /> <div class="icon icon-deck" />
<h2>{{ t('deck', 'Board not found') }}</h2> <h2>{{ t('deck', 'Board not found') }}</h2>
<p /> <p />
</div> </div>
</transition> </transition>
</div> </div>
</template> </template>

View File

@@ -7,8 +7,8 @@
:options="formatedSharees" :options="formatedSharees"
:user-select="true" :user-select="true"
label="displayName" label="displayName"
track-by="user" track-by="multiselectKey"
:internal-search="false" :internal-search="true"
@input="clickAddAcl" @input="clickAddAcl"
@search-change="asyncFind" /> @search-change="asyncFind" />
@@ -24,7 +24,7 @@
</span> </span>
</span> </span>
</li> </li>
<li v-for="acl in board.acl" :key="acl.participant.primaryKey"> <li v-for="acl in board.acl" :key="acl.id">
<Avatar v-if="acl.type===0" :user="acl.participant.uid" /> <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===1" class="avatardiv icon icon-group" />
<div v-if="acl.type===7" class="avatardiv icon icon-circles" /> <div v-if="acl.type===7" class="avatardiv icon icon-circles" />
@@ -101,11 +101,11 @@ export default {
}, },
formatedSharees() { formatedSharees() {
return this.unallocatedSharees.map(item => { return this.unallocatedSharees.map(item => {
const sharee = { const sharee = {
user: item.label, user: item.label,
displayName: item.label, displayName: item.label,
icon: 'icon-user', icon: 'icon-user',
multiselectKey: item.shareType + ':' + item.primaryKey,
} }
if (item.value.shareType === 1) { if (item.value.shareType === 1) {
@@ -124,7 +124,7 @@ export default {
unallocatedSharees() { unallocatedSharees() {
return this.sharees.filter((sharee) => { return this.sharees.filter((sharee) => {
const foundIndex = this.board.acl.findIndex((acl) => { const foundIndex = this.board.acl.findIndex((acl) => {
return acl.participant.uid === sharee.value.shareWith return acl.participant.uid === sharee.value.shareWith && acl.participant.type === sharee.value.shareType
}) })
if (foundIndex === -1) { if (foundIndex === -1) {
return true return true

View File

@@ -72,7 +72,7 @@
:auto-limit="false" :auto-limit="false"
:placeholder="t('deck', 'Assign a user to this card…')" :placeholder="t('deck', 'Assign a user to this card…')"
label="displayname" label="displayname"
track-by="primaryKey" track-by="multiselectKey"
@select="assignUserToCard" @select="assignUserToCard"
@remove="removeUserFromCard"> @remove="removeUserFromCard">
<template #tag="scope"> <template #tag="scope">
@@ -80,6 +80,7 @@
<Avatar :user="scope.option.uid" <Avatar :user="scope.option.uid"
:display-name="scope.option.displayname" :display-name="scope.option.displayname"
:size="24" :size="24"
:is-no-user="scope.option.isNoUser"
:disable-menu="true" /> :disable-menu="true" />
</div> </div>
</template> </template>
@@ -89,6 +90,7 @@
:key="option.primaryKey" :key="option.primaryKey"
:user="option.participant.uid" :user="option.participant.uid"
:display-name="option.participant.displayname" :display-name="option.participant.displayname"
:is-no-user="scope.option.isNoUser"
:size="32" /> :size="32" />
</div> </div>
</div> </div>
@@ -258,6 +260,7 @@ export default {
displayName: item.displayname, displayName: item.displayname,
icon: 'icon-user', icon: 'icon-user',
isNoUser: false, isNoUser: false,
multiselectKey: item.type + ':' + item.uid,
} }
if (item.type === 1) { if (item.type === 1) {
@@ -313,7 +316,11 @@ export default {
this.allLabels = this.currentCard.labels this.allLabels = this.currentCard.labels
if (this.currentCard.assignedUsers && this.currentCard.assignedUsers.length > 0) { if (this.currentCard.assignedUsers && this.currentCard.assignedUsers.length > 0) {
this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant) this.assignedUsers = this.currentCard.assignedUsers.map((item) => ({
...item.participant,
isNoUser: item.participant.type !== 0,
multiselectKey: item.participant.type + ':' + item.participant.primaryKey,
}))
} else { } else {
this.assignedUsers = [] this.assignedUsers = []
} }

View File

@@ -33,14 +33,14 @@
:disable-menu="true" :disable-menu="true"
:size="32" /> :size="32" />
<Avatar v-if="user.type === 1" <Avatar v-if="user.type === 1"
:user="user.participant.primaryKey" :user="user.participant.uid"
:display-name="user.participant.displayname" :display-name="user.participant.displayname"
:tooltip-message="user.participant.displayname + ' ' + t('deck', '(group)')" :tooltip-message="user.participant.displayname + ' ' + t('deck', '(group)')"
:is-no-user="true" :is-no-user="true"
:disable-="true" :disable-="true"
:size="32" /> :size="32" />
<Avatar v-if="user.type === 7" <Avatar v-if="user.type === 7"
:user="user.participant.primaryKey" :user="user.participant.uid"
:display-name="user.participant.displayname" :display-name="user.participant.displayname"
:tooltip-message="user.participant.displayname + ' ' + t('deck', '(circle)')" :tooltip-message="user.participant.displayname + ' ' + t('deck', '(circle)')"
:is-no-user="true" :is-no-user="true"

View File

@@ -181,7 +181,7 @@ export default new Vuex.Store({
state.boards = boards state.boards = boards
}, },
setSharees(state, shareesUsersAndGroups) { setSharees(state, shareesUsersAndGroups) {
state.sharees = shareesUsersAndGroups.exact.users Vue.set(state, 'sharees', shareesUsersAndGroups.exact.users)
state.sharees.push(...shareesUsersAndGroups.exact.groups) state.sharees.push(...shareesUsersAndGroups.exact.groups)
state.sharees.push(...shareesUsersAndGroups.exact.circles) state.sharees.push(...shareesUsersAndGroups.exact.circles)