Skip to content

Commit 076995f

Browse files
committed
fix: remove extra component for NcAction entries
Signed-off-by: grnd-alt <github@belakkaf.net>
1 parent cad24c7 commit 076995f

10 files changed

Lines changed: 312 additions & 242 deletions

File tree

src/App.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NcAppContent, NcContent, NcModal } from '@nextcloud/vue'
77
import CardMoveDialog from './CardMoveDialog.vue'
88
import AppNavigation from './components/navigation/AppNavigation.vue'
99
import KeyboardShortcuts from './components/KeyboardShortcuts.vue'
10-
import {BoardApi} from './services/BoardApi.js'
10+
import { BoardApi } from './services/BoardApi.js'
1111
1212
const boardApi = new BoardApi()
1313
@@ -21,16 +21,16 @@ export default {
2121
CardMoveDialog,
2222
NcModal,
2323
},
24-
computed: {
25-
cardDetailsInModal() {
26-
return this.$store.getters.config('cardDetailsInModal')
27-
},
28-
},
2924
provide() {
3025
return {
3126
boardApi,
3227
}
3328
},
29+
computed: {
30+
cardDetailsInModal() {
31+
return this.$store.getters.config('cardDetailsInModal')
32+
},
33+
},
3434
3535
methods: {
3636
hideModal() {

src/components/card/CardSidebar.vue

Lines changed: 132 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55

6+
<!-- eslint-disable vue/no-v-model-argument -->
67
<template>
78
<NcAppSidebar v-if="currentBoard && currentCard"
89
ref="cardSidebar"
10+
v-model:name-editable="isEditingTitle"
911
:active="tabId"
1012
:name="displayTitle"
1113
:subname="subtitle"
1214
:subtitle="subtitleTooltip"
13-
:name-editable.sync="isEditingTitle"
14-
@update:name="(value) => titleEditing = value"
15+
@update:name="value => titleEditing = value"
1516
@dismiss-editing="titleEditing = currentCard.title"
1617
@submit-name="handleSubmitTitle"
1718
@opened="focusHeader"
@@ -24,35 +25,69 @@
2425
{{ t('deck', 'Open in bigger view') }}
2526
</NcActionButton>
2627

27-
<CardMenuEntries :card="currentCard" :hide-details-entry="true" />
28+
<NcActionButton v-if="canEdit && !isCurrentUserAssigned"
29+
icon="icon-user"
30+
:close-after-click="true"
31+
@click="assignCardToMe()">
32+
{{ t('deck', 'Assign to me') }}
33+
</NcActionButton>
34+
<NcActionButton v-if="canEdit && isCurrentUserAssigned"
35+
icon="icon-user"
36+
:close-after-click="true"
37+
@click="unassignCardFromMe()">
38+
{{ t('deck', 'Unassign myself') }}
39+
</NcActionButton>
40+
<NcActionButton v-if="canEdit"
41+
icon="icon-checkmark"
42+
:close-after-click="true"
43+
@click="changeCardDoneStatus()">
44+
{{ currentCard.done ? t('deck', 'Mark as not done') : t('deck', 'Mark as done') }}
45+
</NcActionButton>
46+
<NcActionButton v-if="canEdit"
47+
icon="icon-external"
48+
:close-after-click="true"
49+
@click="openCardMoveDialog">
50+
{{ t('deck', 'Move/copy card') }}
51+
</NcActionButton>
52+
<NcActionButton v-for="action in cardActions"
53+
:key="action.label"
54+
:close-after-click="true"
55+
:icon="action.icon"
56+
@click="action.callback(cardRichObject)">
57+
{{ action.label }}
58+
</NcActionButton>
59+
<NcActionButton v-if="canEditBoard" :close-after-click="true" @click="archiveUnarchiveCard()">
60+
<template #icon>
61+
<ArchiveIcon :size="20" decorative />
62+
</template>
63+
{{ currentCard.archived ? t('deck', 'Unarchive card') : t('deck', 'Archive card') }}
64+
</NcActionButton>
65+
<NcActionButton v-if="canEdit"
66+
icon="icon-delete"
67+
:close-after-click="true"
68+
@click="deleteCard()">
69+
{{ t('deck', 'Delete card') }}
70+
</NcActionButton>
2871
</template>
2972
<template #description>
30-
<NcReferenceList v-if="currentCard.referenceData"
31-
:text="currentCard.title"
32-
:interactive="false" />
73+
<NcReferenceList v-if="currentCard.referenceData" :text="currentCard.title" :interactive="false" />
3374
</template>
3475

35-
<NcAppSidebarTab id="details"
36-
:order="0"
37-
:name="t('deck', 'Details')">
76+
<NcAppSidebarTab id="details" :order="0" :name="t('deck', 'Details')">
3877
<CardSidebarTabDetails :card="currentCard" />
3978
<template #icon>
4079
<HomeIcon :size="20" />
4180
</template>
4281
</NcAppSidebarTab>
4382

44-
<NcAppSidebarTab id="attachments"
45-
:order="1"
46-
:name="t('deck', 'Attachments')">
83+
<NcAppSidebarTab id="attachments" :order="1" :name="t('deck', 'Attachments')">
4784
<template #icon>
4885
<AttachmentIcon :size="20" />
4986
</template>
5087
<CardSidebarTabAttachments :card="currentCard" />
5188
</NcAppSidebarTab>
5289

53-
<NcAppSidebarTab id="comments"
54-
:order="2"
55-
:name="t('deck', 'Comments')">
90+
<NcAppSidebarTab id="comments" :order="2" :name="t('deck', 'Comments')">
5691
<template #icon>
5792
<CommentIcon :size="20" />
5893
</template>
@@ -86,9 +121,15 @@ import HomeIcon from 'vue-material-design-icons/Home.vue'
86121
import CommentIcon from 'vue-material-design-icons/Comment.vue'
87122
import ActivityIcon from 'vue-material-design-icons/LightningBolt.vue'
88123
89-
import { showError } from '@nextcloud/dialogs'
124+
import { showError, showUndo } from '@nextcloud/dialogs'
90125
import { getLocale } from '@nextcloud/l10n'
91-
import CardMenuEntries from '../cards/CardMenuEntries.vue'
126+
import { emit } from '@nextcloud/event-bus'
127+
128+
import ArchiveIcon from 'vue-material-design-icons/Archive.vue'
129+
import { getCurrentUser } from '@nextcloud/auth'
130+
import { generateUrl } from '@nextcloud/router'
131+
132+
import '@nextcloud/dialogs/style.css'
92133
93134
const capabilities = getCapabilities()
94135
@@ -107,7 +148,7 @@ export default {
107148
AttachmentIcon,
108149
CommentIcon,
109150
HomeIcon,
110-
CardMenuEntries,
151+
ArchiveIcon,
111152
},
112153
mixins: [relativeDate],
113154
props: {
@@ -138,8 +179,17 @@ export default {
138179
...mapState({
139180
isFullApp: (state) => state.isFullApp,
140181
currentBoard: (state) => state.currentBoard,
182+
showArchived: (state) => state.showArchived,
141183
}),
142-
...mapGetters(['canEdit', 'assignables', 'cardActions', 'stackById']),
184+
...mapGetters([
185+
'canEdit',
186+
'assignables',
187+
'cardActions',
188+
'stackById',
189+
'isArchived',
190+
'boards',
191+
'boardById',
192+
]),
143193
currentCard() {
144194
return this.$store.getters.cardById(this.id)
145195
},
@@ -166,6 +216,31 @@ export default {
166216
return reference ? reference.openGraphObject.name : this.currentCard.title
167217
},
168218
},
219+
canEdit() {
220+
return !this.currentCard.archived
221+
},
222+
canEditBoard() {
223+
if (this.currentBoard) {
224+
return this.$store.getters.canEdit
225+
}
226+
const board = this.$store.getters.boards.find((item) => item.id === this.currentCard.boardId)
227+
return !!board?.permissions?.PERMISSION_EDIT
228+
},
229+
isCurrentUserAssigned() {
230+
return this.currentCard.assignedUsers.find((item) => item.type === 0 && item.participant.uid === getCurrentUser()?.uid)
231+
},
232+
boardId() {
233+
return this.card?.boardId ? this.currentCard.boardId : Number(this.$route.params.id)
234+
},
235+
cardRichObject() {
236+
return {
237+
id: '' + this.currentCard.id,
238+
name: this.currentCard.title,
239+
boardname: this.boardById(this.boardId)?.title,
240+
stackname: this.stackById(this.currentCard.stackId)?.title,
241+
link: window.location.protocol + '//' + window.location.host + generateUrl('/apps/deck/') + `card/${this.currentCard.id}`,
242+
}
243+
},
169244
},
170245
watch: {
171246
currentCard() {
@@ -210,12 +285,46 @@ export default {
210285
formatDate(timestamp) {
211286
return moment.unix(timestamp).locale(this.locale).format('LLLL')
212287
},
288+
deleteCard() {
289+
this.$store.dispatch('deleteCard', this.currentCard)
290+
const undoCard = { ...this.currentCard, deletedAt: 0 }
291+
showUndo(t('deck', 'Card deleted'), () => this.$store.dispatch('cardUndoDelete', undoCard))
292+
if (this.$router.currentRoute.name === 'card') {
293+
this.$router.push({ name: 'board' })
294+
}
295+
},
296+
changeCardDoneStatus() {
297+
this.$store.dispatch('changeCardDoneStatus', { ...this.currentCard, done: !this.currentCard.done })
298+
},
299+
archiveUnarchiveCard() {
300+
this.$store.dispatch('archiveUnarchiveCard', { ...this.currentCard, archived: !this.currentCard.archived })
301+
},
302+
assignCardToMe() {
303+
this.$store.dispatch('assignCardToUser', {
304+
card: this.currentCard,
305+
assignee: {
306+
userId: getCurrentUser()?.uid,
307+
type: 0,
308+
},
309+
})
310+
},
311+
unassignCardFromMe() {
312+
this.$store.dispatch('removeUserFromCard', {
313+
card: this.currentCard,
314+
assignee: {
315+
userId: getCurrentUser()?.uid,
316+
type: 0,
317+
},
318+
})
319+
},
320+
openCardMoveDialog() {
321+
emit('deck:card:show-move-dialog', this.currentCard)
322+
},
213323
},
214324
}
215325
</script>
216326
217327
<style lang="scss">
218-
219328
section.app-sidebar__tab--active {
220329
min-height: auto;
221330
display: flex;
@@ -267,6 +376,7 @@ section.app-sidebar__tab--active {
267376
z-index: 100;
268377
background-color: var(--color-main-background);
269378
}
379+
270380
.app-sidebar-tabs__nav {
271381
position: sticky;
272382
top: 87px;
@@ -279,10 +389,10 @@ section.app-sidebar__tab--active {
279389
overflow: initial;
280390
}
281391
282-
#emptycontent, .emptycontent {
392+
#emptycontent,
393+
.emptycontent {
283394
margin-top: 88px;
284395
}
285396
}
286397
}
287-
288398
</style>

0 commit comments

Comments
 (0)