Add frontend for assigning groups to cards
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -86,7 +86,8 @@ class AssignmentService {
|
|||||||
NotificationHelper $notificationHelper,
|
NotificationHelper $notificationHelper,
|
||||||
ActivityManager $activityManager,
|
ActivityManager $activityManager,
|
||||||
ChangeHelper $changeHelper,
|
ChangeHelper $changeHelper,
|
||||||
IEventDispatcher $eventDispatcher
|
IEventDispatcher $eventDispatcher,
|
||||||
|
$userId
|
||||||
) {
|
) {
|
||||||
$this->permissionService = $permissionService;
|
$this->permissionService = $permissionService;
|
||||||
$this->cardMapper = $cardMapper;
|
$this->cardMapper = $cardMapper;
|
||||||
@@ -96,6 +97,7 @@ class AssignmentService {
|
|||||||
$this->changeHelper = $changeHelper;
|
$this->changeHelper = $changeHelper;
|
||||||
$this->activityManager = $activityManager;
|
$this->activityManager = $activityManager;
|
||||||
$this->eventDispatcher = $eventDispatcher;
|
$this->eventDispatcher = $eventDispatcher;
|
||||||
|
$this->currentUser = $userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +109,7 @@ class AssignmentService {
|
|||||||
* @throws MultipleObjectsReturnedException
|
* @throws MultipleObjectsReturnedException
|
||||||
* @throws DoesNotExistException
|
* @throws DoesNotExistException
|
||||||
*/
|
*/
|
||||||
public function assignUser($cardId, $userId, int $type = 0) {
|
public function assignUser($cardId, $userId, int $type = AssignedUsers::TYPE_USER) {
|
||||||
|
|
||||||
if (is_numeric($cardId) === false) {
|
if (is_numeric($cardId) === false) {
|
||||||
throw new BadRequestException('card id must be a number');
|
throw new BadRequestException('card id must be a number');
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { Avatar, Multiselect, Actions, ActionButton, ActionCheckbox } from '@nextcloud/vue'
|
import { Avatar, Multiselect, Actions, ActionButton, ActionCheckbox } from '@nextcloud/vue'
|
||||||
import { CollectionList } from 'nextcloud-vue-collections'
|
import { CollectionList } from 'nextcloud-vue-collections'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
import { getCurrentUser } from '@nextcloud/auth'
|
import { getCurrentUser } from '@nextcloud/auth'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -87,8 +87,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters([
|
...mapState([
|
||||||
'sharees',
|
'sharees',
|
||||||
|
]),
|
||||||
|
...mapGetters([
|
||||||
'canEdit',
|
'canEdit',
|
||||||
'canManage',
|
'canManage',
|
||||||
'canShare',
|
'canShare',
|
||||||
|
|||||||
@@ -64,20 +64,34 @@
|
|||||||
<span class="hidden-visually">{{ t('deck', 'Assign to users') }}</span>
|
<span class="hidden-visually">{{ t('deck', 'Assign to users') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-details">
|
<div class="section-details">
|
||||||
<Multiselect v-model="assignedUsers"
|
<!-- FIXME: model not wokring due to id -->
|
||||||
:disabled="!canEdit"
|
<Multiselect v-if="canEdit"
|
||||||
|
v-model="assignedUsers"
|
||||||
:multiple="true"
|
:multiple="true"
|
||||||
:options="assignableUsers"
|
:options="formatedAssignables"
|
||||||
|
:user-select="true"
|
||||||
|
: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="primaryKey"
|
||||||
@select="assignUserToCard"
|
@select="assignUserToCard"
|
||||||
@remove="removeUserFromCard">
|
@remove="removeUserFromCard">
|
||||||
<template #option="scope">
|
<template #tag="scope">
|
||||||
<Avatar :user="scope.option.primaryKey" />
|
<div class="avatarlist--inline">
|
||||||
<span class="avatarLabel">{{ scope.option.displayname }} </span>
|
<Avatar :user="scope.option.primaryKey"
|
||||||
|
:display-name="scope.option.displayname"
|
||||||
|
:size="24"
|
||||||
|
:disable-menu="true" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Multiselect>
|
</Multiselect>
|
||||||
|
<div v-else class="avatar-list--readonly">
|
||||||
|
<Avatar v-for="option in currentCard.assignedUsers"
|
||||||
|
:key="option.id"
|
||||||
|
:user="option.participant.primaryKey"
|
||||||
|
:display-name="option.participant.displayname"
|
||||||
|
:size="32" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -86,14 +100,11 @@
|
|||||||
<span class="hidden-visually">{{ t('deck', 'Due date') }}</span>
|
<span class="hidden-visually">{{ t('deck', 'Due date') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="section-details">
|
<div class="section-details">
|
||||||
<DatetimePicker v-model="copiedCard.duedate"
|
<DatetimePicker v-model="duedate"
|
||||||
:placeholder="t('deck', 'Set a due date')"
|
:placeholder="t('deck', 'Set a due date')"
|
||||||
type="datetime"
|
type="datetime"
|
||||||
lang="en"
|
:disabled="saving || !canEdit"
|
||||||
:disabled="!canEdit"
|
confirm />
|
||||||
format="YYYY-MM-DD HH:mm"
|
|
||||||
confirm
|
|
||||||
@change="setDue()" />
|
|
||||||
<Actions v-if="canEdit">
|
<Actions v-if="canEdit">
|
||||||
<ActionButton v-if="copiedCard.duedate" icon="icon-delete" @click="removeDue()">
|
<ActionButton v-if="copiedCard.duedate" icon="icon-delete" @click="removeDue()">
|
||||||
{{ t('deck', 'Remove due date') }}
|
{{ t('deck', 'Remove due date') }}
|
||||||
@@ -189,11 +200,12 @@ export default {
|
|||||||
copiedCard: null,
|
copiedCard: null,
|
||||||
allLabels: null,
|
allLabels: null,
|
||||||
desc: null,
|
desc: null,
|
||||||
|
saving: false,
|
||||||
mdeConfig: {
|
mdeConfig: {
|
||||||
autoDownloadFontAwesome: false,
|
autoDownloadFontAwesome: false,
|
||||||
spellChecker: false,
|
spellChecker: false,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
autosave: { enabled: true, uniqueId: 'unique' },
|
autosave: { enabled: false, uniqueId: 'unique' },
|
||||||
toolbar: false,
|
toolbar: false,
|
||||||
},
|
},
|
||||||
lastModifiedRelative: null,
|
lastModifiedRelative: null,
|
||||||
@@ -205,15 +217,49 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
currentBoard: state => state.currentBoard,
|
currentBoard: state => state.currentBoard,
|
||||||
assignableUsers: state => state.assignableUsers,
|
|
||||||
}),
|
}),
|
||||||
...mapGetters(['canEdit']),
|
...mapGetters(['canEdit', 'assignables']),
|
||||||
currentCard() {
|
currentCard() {
|
||||||
return this.$store.getters.cardById(this.id)
|
return this.$store.getters.cardById(this.id)
|
||||||
},
|
},
|
||||||
subtitle() {
|
subtitle() {
|
||||||
return t('deck', 'Modified') + ': ' + this.lastModifiedRelative + ' ' + t('deck', 'Created') + ': ' + this.lastCreatedRemative
|
return t('deck', 'Modified') + ': ' + this.lastModifiedRelative + ' ' + t('deck', 'Created') + ': ' + this.lastCreatedRemative
|
||||||
},
|
},
|
||||||
|
formatedAssignables() {
|
||||||
|
return this.assignables.map(item => {
|
||||||
|
const assignable = {
|
||||||
|
...item,
|
||||||
|
user: item.primaryKey,
|
||||||
|
displayName: item.displayname,
|
||||||
|
icon: 'icon-user',
|
||||||
|
isNoUser: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.type === 1) {
|
||||||
|
assignable.icon = 'icon-group'
|
||||||
|
assignable.isNoUser = true
|
||||||
|
}
|
||||||
|
if (item.type === 7) {
|
||||||
|
assignable.icon = 'icon-circles'
|
||||||
|
assignable.isNoUser = true
|
||||||
|
}
|
||||||
|
|
||||||
|
return assignable
|
||||||
|
})
|
||||||
|
},
|
||||||
|
duedate: {
|
||||||
|
get() {
|
||||||
|
return this.currentCard.duedate ? new Date(this.currentCard.duedate) : null
|
||||||
|
},
|
||||||
|
async set(val) {
|
||||||
|
this.saving = true
|
||||||
|
await this.$store.dispatch('updateCardDue', {
|
||||||
|
...this.copiedCard,
|
||||||
|
duedate: val ? (new Date(val)).toISOString() : null,
|
||||||
|
})
|
||||||
|
this.saving = false
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'currentCard': {
|
'currentCard': {
|
||||||
@@ -235,10 +281,6 @@ export default {
|
|||||||
this.updateRelativeTimestamps()
|
this.updateRelativeTimestamps()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'copiedCard.description': function() {
|
|
||||||
this.saveDesc()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
setInterval(this.updateRelativeTimestamps, 10000)
|
setInterval(this.updateRelativeTimestamps, 10000)
|
||||||
@@ -267,13 +309,23 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
assignUserToCard(user) {
|
assignUserToCard(user) {
|
||||||
this.copiedCard.newUserUid = user.uid
|
this.$store.dispatch('assignCardToUser', {
|
||||||
this.$store.dispatch('assignCardToUser', this.copiedCard)
|
card: this.copiedCard,
|
||||||
|
assignee: {
|
||||||
|
userId: user.uid,
|
||||||
|
type: user.type,
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
removeUserFromCard(user) {
|
removeUserFromCard(user) {
|
||||||
this.copiedCard.removeUserUid = user.uid
|
this.$store.dispatch('removeUserFromCard', {
|
||||||
this.$store.dispatch('removeUserFromCard', this.copiedCard)
|
card: this.copiedCard,
|
||||||
|
assignee: {
|
||||||
|
userId: user.uid,
|
||||||
|
type: user.type,
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
addLabelToCard(newLabel) {
|
addLabelToCard(newLabel) {
|
||||||
@@ -376,4 +428,28 @@ export default {
|
|||||||
padding: 6px
|
padding: 6px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-details::v-deep .multiselect__tags-wrap {
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-list--readonly .avatardiv {
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatarlist--inline {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 3px;
|
||||||
|
.avatarLabel {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.multiselect::v-deep .multiselect__tags-wrap {
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.multiselect.multiselect--active::v-deep .multiselect__tags-wrap {
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="comment--header">
|
<div class="comment--header">
|
||||||
<Avatar :user="card.owner.uid" />
|
<Avatar :user="currentUser.uid" />
|
||||||
<span class="has-tooltip username">
|
<span class="has-tooltip username">
|
||||||
{{ card.owner.displayname }}
|
{{ currentUser.displayName }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
newComment: '',
|
newComment: '',
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
|
currentUser: OC.getCurrentUser(),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|||||||
@@ -22,13 +22,31 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="avatars">
|
<div class="avatars">
|
||||||
<div class="avatar-list" @click.stop="popoverVisible=!popoverVisible">
|
<div class="avatar-list" @click.stop="togglePopover">
|
||||||
<div v-if="popover.length > 0" class="avatardiv icon-more" />
|
<div v-if="popover.length > 0">
|
||||||
<Avatar v-for="user in firstUsers"
|
<div class="avatardiv icon-more" />
|
||||||
:key="user.id"
|
</div>
|
||||||
:url="avatarUrl(user)"
|
<div v-for="user in firstUsers" :key="user.id">
|
||||||
:disable-tooltip="true"
|
<Avatar v-if="user.type === 0"
|
||||||
:size="32" />
|
:user="user.participant.uid"
|
||||||
|
:display-name="user.participant.displayname"
|
||||||
|
:disable-menu="true"
|
||||||
|
: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)')"
|
||||||
|
: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)')"
|
||||||
|
:is-no-user="true"
|
||||||
|
:disable-="true"
|
||||||
|
:size="32" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-show="popoverVisible" class="popovermenu menu-right">
|
<div v-show="popoverVisible" class="popovermenu menu-right">
|
||||||
@@ -69,8 +87,11 @@ export default {
|
|||||||
return this.users.slice(0, 3)
|
return this.users.slice(0, 3)
|
||||||
},
|
},
|
||||||
avatarUrl() {
|
avatarUrl() {
|
||||||
return (session) => {
|
return (assignable) => {
|
||||||
const user = session.participant.displayname
|
if (assignable.type === 1) {
|
||||||
|
return 'icon-group'
|
||||||
|
}
|
||||||
|
const user = assignable.participant.primaryKey
|
||||||
const size = 32
|
const size = 32
|
||||||
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}',
|
const avatarUrl = OC.generateUrl('/avatar/{user}/{size}',
|
||||||
{
|
{
|
||||||
@@ -81,7 +102,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
popover() {
|
popover() {
|
||||||
if (!this.users || this.users.length < 0) {
|
if (!this.users || this.users.length === 0) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
@@ -89,19 +110,25 @@ export default {
|
|||||||
return {
|
return {
|
||||||
href: '#',
|
href: '#',
|
||||||
icon: this.avatarUrl(session),
|
icon: this.avatarUrl(session),
|
||||||
text: session.participant.displayname,
|
text: session.participant.displayname + (session.type === 1 ? ' ' + t('deck', '(group)') : ''),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
togglePopover() {
|
||||||
|
if (this.popover.length > 0) {
|
||||||
|
this.popoverVisible = !this.popoverVisible
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.avatars {
|
.avatars {
|
||||||
margin: 0;
|
margin-top: 5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
/deep/ .popovermenu {
|
/deep/ .popovermenu {
|
||||||
@@ -118,14 +145,12 @@ export default {
|
|||||||
.avatar-list {
|
.avatar-list {
|
||||||
float: right;
|
float: right;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
|
padding-right: 8px;
|
||||||
flex-direction: row-reverse;
|
flex-direction: row-reverse;
|
||||||
.avatardiv,
|
.avatardiv,
|
||||||
/deep/ .avatardiv {
|
/deep/ .avatardiv {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
margin-right: -8px;
|
|
||||||
border: 2px solid var(--color-main-background);
|
|
||||||
background-color: var(--color-main-background) !important;
|
|
||||||
box-sizing: content-box !important;
|
box-sizing: content-box !important;
|
||||||
&.icon-more {
|
&.icon-more {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
@@ -134,6 +159,13 @@ export default {
|
|||||||
background-color: var(--color-background-dark) !important;
|
background-color: var(--color-background-dark) !important;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
& {
|
||||||
|
margin-right: -12px;
|
||||||
|
transition: margin-right 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&:hover div:nth-child(n+2) /deep/ .avatardiv {
|
||||||
|
margin-right: 1px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.popovermenu {
|
.popovermenu {
|
||||||
|
|||||||
@@ -97,19 +97,21 @@ export default {
|
|||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.badges {
|
.badges {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
padding: 12px 14px;
|
padding: 12px 14px;
|
||||||
margin-right: 10px;
|
padding-right: 4px;
|
||||||
|
margin-right: 5px;
|
||||||
background-position: left;
|
background-position: left;
|
||||||
background-size: 16px;
|
background-size: 16px;
|
||||||
span {
|
span {
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
}
|
}
|
||||||
&.icon-filetype-text {
|
&.icon-edit {
|
||||||
opacity: 1;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,6 +126,7 @@ export default {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
opacity: .5;
|
opacity: .5;
|
||||||
|
flex-shrink: 1;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
background-size: contain;
|
background-size: contain;
|
||||||
@@ -145,6 +148,9 @@ export default {
|
|||||||
|
|
||||||
span {
|
span {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -196,8 +196,13 @@ export default {
|
|||||||
},
|
},
|
||||||
assignCardToMe() {
|
assignCardToMe() {
|
||||||
this.copiedCard = Object.assign({}, this.card)
|
this.copiedCard = Object.assign({}, this.card)
|
||||||
this.copiedCard.newUserUid = this.card.owner.uid
|
this.$store.dispatch('assignCardToUser', {
|
||||||
this.$store.dispatch('assignCardToUser', this.copiedCard)
|
card: this.copiedCard,
|
||||||
|
assignee: {
|
||||||
|
userId: OC.getCurrentUser().uid,
|
||||||
|
type: 0,
|
||||||
|
},
|
||||||
|
})
|
||||||
},
|
},
|
||||||
async loadStacksFromBoard(board) {
|
async loadStacksFromBoard(board) {
|
||||||
try {
|
try {
|
||||||
@@ -234,6 +239,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
|
transition: box-shadow 0.1s ease-in-out;
|
||||||
box-shadow: 0 0 2px 0 var(--color-box-shadow);
|
box-shadow: 0 0 2px 0 var(--color-box-shadow);
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
font-size: 100%;
|
font-size: 100%;
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ export class CardApi {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
assignUser(card) {
|
assignUser(cardId, id, type) {
|
||||||
return axios.post(this.url(`/cards/${card.id}/assign`), { userId: card.newUserUid })
|
return axios.post(this.url(`/cards/${cardId}/assign`), { userId: id, type: type })
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
return Promise.resolve(response.data)
|
return Promise.resolve(response.data)
|
||||||
@@ -120,8 +120,8 @@ export class CardApi {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
removeUser(card) {
|
removeUser(cardId, id, type) {
|
||||||
return axios.delete(this.url(`/cards/${card.id}/assign/${card.removeUserUid}`))
|
return axios.put(this.url(`/cards/${cardId}/unassign`), { userId: id, type: type })
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
return Promise.resolve(response.data)
|
return Promise.resolve(response.data)
|
||||||
|
|||||||
@@ -198,12 +198,12 @@ export default {
|
|||||||
const updatedCard = await apiClient[call](card)
|
const updatedCard = await apiClient[call](card)
|
||||||
commit('deleteCard', updatedCard)
|
commit('deleteCard', updatedCard)
|
||||||
},
|
},
|
||||||
async assignCardToUser({ commit }, card) {
|
async assignCardToUser({ commit }, { card, assignee }) {
|
||||||
const user = await apiClient.assignUser(card)
|
const user = await apiClient.assignUser(card.id, assignee.userId, assignee.type)
|
||||||
commit('assignCardToUser', user)
|
commit('assignCardToUser', user)
|
||||||
},
|
},
|
||||||
async removeUserFromCard({ commit }, card) {
|
async removeUserFromCard({ commit }, { card, assignee }) {
|
||||||
const user = await apiClient.removeUser(card)
|
const user = await apiClient.removeUser(card.id, assignee.userId, assignee.type)
|
||||||
commit('removeUserFromCard', user)
|
commit('removeUserFromCard', user)
|
||||||
},
|
},
|
||||||
async addLabel({ commit }, data) {
|
async addLabel({ commit }, data) {
|
||||||
@@ -219,7 +219,7 @@ export default {
|
|||||||
commit('updateCardProperty', { property: 'description', card: updatedCard })
|
commit('updateCardProperty', { property: 'description', card: updatedCard })
|
||||||
},
|
},
|
||||||
async updateCardDue({ commit }, card) {
|
async updateCardDue({ commit }, card) {
|
||||||
const updatedCard = apiClient.updateCard(card)
|
const updatedCard = await apiClient.updateCard(card)
|
||||||
commit('updateCardProperty', { property: 'duedate', card: updatedCard })
|
commit('updateCardProperty', { property: 'duedate', card: updatedCard })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -78,8 +78,12 @@ export default new Vuex.Store({
|
|||||||
boards: state => {
|
boards: state => {
|
||||||
return state.boards
|
return state.boards
|
||||||
},
|
},
|
||||||
sharees: state => {
|
assignables: state => {
|
||||||
return state.sharees
|
return [
|
||||||
|
...state.assignableUsers.map((user) => ({ ...user, type: 0 })),
|
||||||
|
...state.currentBoard.acl.filter((acl) => acl.type === 1 && typeof acl.participant === 'object').map((group) => ({ ...group.participant, type: 1 })),
|
||||||
|
...state.currentBoard.acl.filter((acl) => acl.type === 7 && typeof acl.participant === 'object').map((circle) => ({ ...circle.participant, type: 7 })),
|
||||||
|
]
|
||||||
},
|
},
|
||||||
noneArchivedBoards: state => {
|
noneArchivedBoards: state => {
|
||||||
return state.boards.filter(board => {
|
return state.boards.filter(board => {
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ use OCA\Deck\Notification\NotificationHelper;
|
|||||||
use OCA\Deck\StatusException;
|
use OCA\Deck\StatusException;
|
||||||
use OCP\Activity\IEvent;
|
use OCP\Activity\IEvent;
|
||||||
use OCP\Comments\ICommentsManager;
|
use OCP\Comments\ICommentsManager;
|
||||||
|
use OCP\EventDispatcher\ABroadcastedEvent;
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
|
use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\IUser;
|
use OCP\IUser;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
@@ -91,7 +94,7 @@ class CardServiceTest extends TestCase {
|
|||||||
$this->activityManager = $this->createMock(ActivityManager::class);
|
$this->activityManager = $this->createMock(ActivityManager::class);
|
||||||
$this->commentsManager = $this->createMock(ICommentsManager::class);
|
$this->commentsManager = $this->createMock(ICommentsManager::class);
|
||||||
$this->userManager = $this->createMock(IUserManager::class);
|
$this->userManager = $this->createMock(IUserManager::class);
|
||||||
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
|
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
||||||
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
$this->changeHelper = $this->createMock(ChangeHelper::class);
|
||||||
$this->cardService = new CardService(
|
$this->cardService = new CardService(
|
||||||
$this->cardMapper,
|
$this->cardMapper,
|
||||||
@@ -318,102 +321,4 @@ class CardServiceTest extends TestCase {
|
|||||||
$this->cardService->removeLabel(123, 999);
|
$this->cardService->removeLabel(123, 999);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssignUser() {
|
|
||||||
$assignments = [];
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('find')
|
|
||||||
->with(123)
|
|
||||||
->willReturn($assignments);
|
|
||||||
$assignment = new AssignedUsers();
|
|
||||||
$assignment->setCardId(123);
|
|
||||||
$assignment->setParticipant('admin');
|
|
||||||
$this->cardMapper->expects($this->once())
|
|
||||||
->method('findBoardId')
|
|
||||||
->willReturn(1);
|
|
||||||
$this->permissionService->expects($this->once())
|
|
||||||
->method('findUsers')
|
|
||||||
->with(1)
|
|
||||||
->willReturn(['admin' => 'admin', 'user1' => 'user1']);
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('insert')
|
|
||||||
->with($assignment)
|
|
||||||
->willReturn($assignment);
|
|
||||||
$actual = $this->cardService->assignUser(123, 'admin');
|
|
||||||
$this->assertEquals($assignment, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAssignUserNoParticipant() {
|
|
||||||
$this->expectException(BadRequestException::class);
|
|
||||||
$this->expectExceptionMessage('The user is not part of the board');
|
|
||||||
$assignments = [];
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('find')
|
|
||||||
->with(123)
|
|
||||||
->willReturn($assignments);
|
|
||||||
$assignment = new AssignedUsers();
|
|
||||||
$assignment->setCardId(123);
|
|
||||||
$assignment->setParticipant('admin');
|
|
||||||
$this->cardMapper->expects($this->once())
|
|
||||||
->method('findBoardId')
|
|
||||||
->willReturn(1);
|
|
||||||
$this->permissionService->expects($this->once())
|
|
||||||
->method('findUsers')
|
|
||||||
->with(1)
|
|
||||||
->willReturn(['user2' => 'user2', 'user1' => 'user1']);
|
|
||||||
$actual = $this->cardService->assignUser(123, 'admin');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAssignUserExisting() {
|
|
||||||
$this->expectException(BadRequestException::class);
|
|
||||||
$this->expectExceptionMessage('The user is already assigned to the card');
|
|
||||||
$assignment = new AssignedUsers();
|
|
||||||
$assignment->setCardId(123);
|
|
||||||
$assignment->setParticipant('admin');
|
|
||||||
$assignments = [
|
|
||||||
$assignment
|
|
||||||
];
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('find')
|
|
||||||
->with(123)
|
|
||||||
->willReturn($assignments);
|
|
||||||
$actual = $this->cardService->assignUser(123, 'admin');
|
|
||||||
$this->assertFalse($actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUnassignUserExisting() {
|
|
||||||
$assignment = new AssignedUsers();
|
|
||||||
$assignment->setCardId(123);
|
|
||||||
$assignment->setParticipant('admin');
|
|
||||||
$assignments = [
|
|
||||||
$assignment
|
|
||||||
];
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('find')
|
|
||||||
->with(123)
|
|
||||||
->willReturn($assignments);
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('delete')
|
|
||||||
->with($assignment)
|
|
||||||
->willReturn($assignment);
|
|
||||||
$actual = $this->cardService->unassignUser(123, 'admin');
|
|
||||||
$this->assertEquals($assignment, $actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUnassignUserNotExisting() {
|
|
||||||
$this->expectException(NotFoundException::class);
|
|
||||||
$assignment = new AssignedUsers();
|
|
||||||
$assignment->setCardId(123);
|
|
||||||
$assignment->setParticipant('admin');
|
|
||||||
$assignments = [
|
|
||||||
$assignment
|
|
||||||
];
|
|
||||||
$this->assignedUsersMapper->expects($this->once())
|
|
||||||
->method('find')
|
|
||||||
->with(123)
|
|
||||||
->willReturn($assignments);
|
|
||||||
$this->expectException(NotFoundException::class);
|
|
||||||
$actual = $this->cardService->unassignUser(123, 'user');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace OCA\Deck\Controller;
|
namespace OCA\Deck\Controller;
|
||||||
|
|
||||||
|
use OCA\Deck\Service\AssignmentService;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
@@ -37,12 +38,14 @@ class CardApiControllerTest extends \Test\TestCase {
|
|||||||
private $userId = 'admin';
|
private $userId = 'admin';
|
||||||
private $cardExample;
|
private $cardExample;
|
||||||
private $stackExample;
|
private $stackExample;
|
||||||
|
private $assignmentService;
|
||||||
|
|
||||||
public function setUp(): void {
|
public function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->request = $this->createMock(IRequest::class);
|
$this->request = $this->createMock(IRequest::class);
|
||||||
$this->cardService = $this->createMock(CardService::class);
|
$this->cardService = $this->createMock(CardService::class);
|
||||||
|
$this->assignmentService = $this->createMock(AssignmentService::class);
|
||||||
|
|
||||||
$this->cardExample['id'] = 1;
|
$this->cardExample['id'] = 1;
|
||||||
$this->stackExample['id'] = 1;
|
$this->stackExample['id'] = 1;
|
||||||
@@ -51,6 +54,7 @@ class CardApiControllerTest extends \Test\TestCase {
|
|||||||
$appName = 'deck',
|
$appName = 'deck',
|
||||||
$this->request,
|
$this->request,
|
||||||
$this->cardService,
|
$this->cardService,
|
||||||
|
$this->assignmentService,
|
||||||
$this->userId
|
$this->userId
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user