implement BoardReferenceWidget and CommentReferenceWidget
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
This commit is contained in:
@@ -92,7 +92,7 @@ class Application extends App implements IBootstrap {
|
||||
$container = $this->getContainer();
|
||||
$eventDispatcher = $container->get(IEventDispatcher::class);
|
||||
$eventDispatcher->addListener(RenderReferenceEvent::class, function () {
|
||||
Util::addScript(self::APP_ID, self::APP_ID . '-card-reference');
|
||||
Util::addScript(self::APP_ID, self::APP_ID . '-reference');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ import { registerWidget } from '@nextcloud/vue-richtext'
|
||||
import { Tooltip } from '@nextcloud/vue'
|
||||
import Vue from 'vue'
|
||||
import CardReferenceWidget from './views/CardReferenceWidget.vue'
|
||||
import BoardReferenceWidget from './views/BoardReferenceWidget.vue'
|
||||
import CommentReferenceWidget from './views/CommentReferenceWidget.vue'
|
||||
|
||||
import { translate, translatePlural } from '@nextcloud/l10n'
|
||||
|
||||
@@ -48,3 +50,33 @@ registerWidget('deck-card', (el, { richObjectType, richObject, accessible }) =>
|
||||
},
|
||||
}).$mount(el)
|
||||
})
|
||||
|
||||
registerWidget('deck-board', (el, { richObjectType, richObject, accessible }) => {
|
||||
el.parentNode.style['max-width'] = '400px'
|
||||
el.parentNode.style['margin-left'] = '0'
|
||||
el.parentNode.style['margin-right'] = '0'
|
||||
|
||||
const Widget = Vue.extend(BoardReferenceWidget)
|
||||
new Widget({
|
||||
propsData: {
|
||||
richObjectType,
|
||||
richObject,
|
||||
accessible,
|
||||
},
|
||||
}).$mount(el)
|
||||
})
|
||||
|
||||
registerWidget('deck-comment', (el, { richObjectType, richObject, accessible }) => {
|
||||
el.parentNode.style['max-width'] = '400px'
|
||||
el.parentNode.style['margin-left'] = '0'
|
||||
el.parentNode.style['margin-right'] = '0'
|
||||
|
||||
const Widget = Vue.extend(CommentReferenceWidget)
|
||||
new Widget({
|
||||
propsData: {
|
||||
richObjectType,
|
||||
richObject,
|
||||
accessible,
|
||||
},
|
||||
}).$mount(el)
|
||||
})
|
||||
128
src/views/BoardReferenceWidget.vue
Normal file
128
src/views/BoardReferenceWidget.vue
Normal file
@@ -0,0 +1,128 @@
|
||||
<!--
|
||||
- @copyright Copyright (c) 2023 Julien Veyssier <julien-nc@posteo.net>
|
||||
-
|
||||
- @author 2023 Julien Veyssier <julien-nc@posteo.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/>.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="deck-board-reference">
|
||||
<div class="line">
|
||||
<DeckIcon :size="20" class="title-icon" />
|
||||
<strong>
|
||||
<a :href="boardLink"
|
||||
:title="boardTooltip"
|
||||
target="_blank"
|
||||
class="link">
|
||||
{{ board.title }}
|
||||
</a>
|
||||
</strong>
|
||||
</div>
|
||||
<div class="line">
|
||||
{{ t('deck', 'Owner') + ': ' }}
|
||||
<NcUserBubble :user="boardOwnerUserId"
|
||||
:display-name="boardOwnerDisplayName" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DeckIcon from '../components/icons/DeckIcon.vue'
|
||||
|
||||
import NcUserBubble from '@nextcloud/vue/dist/Components/NcUserBubble.js'
|
||||
|
||||
import moment from '@nextcloud/moment'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
||||
export default {
|
||||
name: 'BoardReferenceWidget',
|
||||
|
||||
components: {
|
||||
DeckIcon,
|
||||
NcUserBubble,
|
||||
},
|
||||
|
||||
props: {
|
||||
richObjectType: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
richObject: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
accessible: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
board() {
|
||||
return this.richObject.board
|
||||
},
|
||||
boardLink() {
|
||||
return generateUrl('/apps/deck/#/board/{boardId}', { boardId: this.board.id })
|
||||
},
|
||||
boardTooltip() {
|
||||
return t('deck', 'Deck board {name}\n* Last modified on {lastMod}', {
|
||||
name: this.board.title,
|
||||
lastMod: moment.unix(this.board.lastModified).format('LLL'),
|
||||
})
|
||||
},
|
||||
boardOwnerUserId() {
|
||||
return this.board.owner?.uid ?? '???'
|
||||
},
|
||||
boardOwnerDisplayName() {
|
||||
return this.board.owner?.displayname ?? this.boardOwnerUserId
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.deck-board-reference {
|
||||
width: 100%;
|
||||
// needed for the specific case of Text
|
||||
.editor__content & {
|
||||
width: calc(100% - 24px);
|
||||
}
|
||||
white-space: normal;
|
||||
padding: 12px;
|
||||
|
||||
.link {
|
||||
text-decoration: underline;
|
||||
color: var(--color-main-text) !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.title-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
- @copyright Copyright (c) 2022 2022 Julien Veyssier <eneiluj@posteo.net>
|
||||
- @copyright Copyright (c) 2022 Julien Veyssier <julien-nc@posteo.net>
|
||||
-
|
||||
- @author 2022 Julien Veyssier <eneiluj@posteo.net>
|
||||
- @author 2022 Julien Veyssier <julien-nc@posteo.net>
|
||||
-
|
||||
- @license GNU AGPL version 3 or any later version
|
||||
-
|
||||
|
||||
273
src/views/CommentReferenceWidget.vue
Normal file
273
src/views/CommentReferenceWidget.vue
Normal file
@@ -0,0 +1,273 @@
|
||||
<!--
|
||||
- @copyright Copyright (c) 2023 Julien Veyssier <julien-nc@posteo.net>
|
||||
-
|
||||
- @author 2023 Julien Veyssier <julien-nc@posteo.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/>.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="deck-comment-reference">
|
||||
<div class="line">
|
||||
<DeckIcon :size="20" class="title-icon" />
|
||||
<strong>
|
||||
<a :href="cardLink"
|
||||
:title="cardTooltip"
|
||||
target="_blank"
|
||||
class="link">
|
||||
{{ card.title }}
|
||||
</a>
|
||||
</strong>
|
||||
<div v-if="dueDate" class="spacer" />
|
||||
<span v-if="dueDate"
|
||||
v-tooltip.top="{ content: formattedDueDate }"
|
||||
class="due-date">
|
||||
<CalendarBlankIcon :size="20"
|
||||
class="icon" />
|
||||
{{ dueDate }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="line">
|
||||
<a v-tooltip.top="{ content: stackTooltip }"
|
||||
:href="boardLink"
|
||||
target="_blank"
|
||||
class="link">
|
||||
{{ t('deck', '{stack} in {board}', { stack: stack.title, board: board.title }) }}
|
||||
</a>
|
||||
</div>
|
||||
<div>
|
||||
<transition-group v-if="card.labels && card.labels.length"
|
||||
name="zoom"
|
||||
tag="ul"
|
||||
class="labels"
|
||||
@click.stop="openCard">
|
||||
<li v-for="label in labelsSorted" :key="label.id" :style="labelStyle(label)">
|
||||
<span>{{ label.title }}</span>
|
||||
</li>
|
||||
</transition-group>
|
||||
</div>
|
||||
<div class="line description-assignees">
|
||||
<TextIcon v-if="card.description" :size="20" class="icon" />
|
||||
<div v-if="card.description"
|
||||
:class="{
|
||||
'description': true,
|
||||
'short-description': shortDescription,
|
||||
}">
|
||||
<RichText v-tooltip.top="{ content: shortDescription ? t('deck', 'Click to expand description') : undefined }"
|
||||
:text="card.description"
|
||||
:use-markdown="true"
|
||||
@click.native="shortDescription = !shortDescription" />
|
||||
</div>
|
||||
<div v-if="card.assignedUsers .length > 0"
|
||||
class="spacer" />
|
||||
<AvatarList v-if="card.assignedUsers .length > 0"
|
||||
:users="card.assignedUsers"
|
||||
class="card-assignees" />
|
||||
</div>
|
||||
<div v-if="comment" class="line comment-wrapper">
|
||||
<CommentProcessingOutlineIcon :size="20" class="icon" />
|
||||
<div :class="{
|
||||
'comment': true,
|
||||
'short-comment': shortComment,
|
||||
}">
|
||||
<RichText v-tooltip.top="{ content: shortComment ? t('deck', 'Click to expand comment') : undefined }"
|
||||
:text="commentMessageText"
|
||||
:use-markdown="false"
|
||||
@click.native="shortComment = !shortComment" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CalendarBlankIcon from 'vue-material-design-icons/CalendarBlank.vue'
|
||||
import TextIcon from 'vue-material-design-icons/Text.vue'
|
||||
import CommentProcessingOutlineIcon from 'vue-material-design-icons/CommentProcessingOutline.vue'
|
||||
|
||||
import DeckIcon from '../components/icons/DeckIcon.vue'
|
||||
import AvatarList from '../components/cards/AvatarList.vue'
|
||||
import labelStyle from '../mixins/labelStyle.js'
|
||||
|
||||
import { RichText } from '@nextcloud/vue-richtext'
|
||||
import moment from '@nextcloud/moment'
|
||||
import { generateUrl } from '@nextcloud/router'
|
||||
|
||||
export default {
|
||||
name: 'CommentReferenceWidget',
|
||||
|
||||
components: {
|
||||
AvatarList,
|
||||
DeckIcon,
|
||||
CalendarBlankIcon,
|
||||
TextIcon,
|
||||
RichText,
|
||||
CommentProcessingOutlineIcon,
|
||||
},
|
||||
|
||||
mixins: [labelStyle],
|
||||
|
||||
props: {
|
||||
richObjectType: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
richObject: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
accessible: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
shortDescription: true,
|
||||
shortComment: true,
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
card() {
|
||||
return this.richObject.card
|
||||
},
|
||||
board() {
|
||||
return this.richObject.board
|
||||
},
|
||||
stack() {
|
||||
return this.richObject.stack
|
||||
},
|
||||
comment() {
|
||||
return this.richObject.comment
|
||||
},
|
||||
commentMessageText() {
|
||||
const e = document.createElement('div')
|
||||
e.innerHTML = this.comment.message
|
||||
return e.textContent
|
||||
},
|
||||
cardLink() {
|
||||
return generateUrl('/apps/deck/#/board/{boardId}/card/{cardId}', { boardId: this.board.id, cardId: this.card.id })
|
||||
},
|
||||
boardLink() {
|
||||
return generateUrl('/apps/deck/#/board/{boardId}', { boardId: this.board.id })
|
||||
},
|
||||
cardTooltip() {
|
||||
return t('deck', '* Created on {created}\n* Last modified on {lastMod}\n* {nbAttachments} attachments\n* {nbComments} comments', {
|
||||
created: moment.unix(this.card.createdAt).format('LLL'),
|
||||
lastMod: moment.unix(this.card.lastModified).format('LLL'),
|
||||
nbAttachments: this.card.attachments.length,
|
||||
nbComments: this.card.commentsCount,
|
||||
})
|
||||
},
|
||||
stackTooltip() {
|
||||
return t('deck', '{nbCards} cards', { nbCards: this.stack.cards.length })
|
||||
},
|
||||
dueDate() {
|
||||
return this.card.duedate
|
||||
? moment(this.card.duedate).fromNow()
|
||||
: null
|
||||
},
|
||||
formattedDueDate() {
|
||||
return this.card.duedate
|
||||
? t('deck', 'Due on {date}', { date: moment(this.card.duedate).format('LLL') })
|
||||
: null
|
||||
},
|
||||
labelsSorted() {
|
||||
return [...this.card.labels].sort((a, b) => (a.title < b.title) ? -1 : 1)
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* stylelint-disable-next-line no-invalid-position-at-import-rule */
|
||||
@import '../css/labels';
|
||||
|
||||
.deck-comment-reference {
|
||||
width: 100%;
|
||||
// needed for the specific case of Text
|
||||
.editor__content & {
|
||||
width: calc(100% - 24px);
|
||||
}
|
||||
white-space: normal;
|
||||
padding: 12px;
|
||||
|
||||
.link {
|
||||
text-decoration: underline;
|
||||
color: var(--color-main-text) !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
.icon {
|
||||
margin-right: 4px;
|
||||
}
|
||||
.title-icon {
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.due-date {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.labels {
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.comment-wrapper,
|
||||
.description-assignees {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: start;
|
||||
|
||||
.icon {
|
||||
align-self: start;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.comment,
|
||||
.description {
|
||||
margin-right: 8px;
|
||||
padding-top: 6px;
|
||||
max-height: 250px;
|
||||
overflow: scroll;
|
||||
&.short-comment,
|
||||
&.short-description {
|
||||
max-height: 25px;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.card-assignees {
|
||||
margin-top: 0;
|
||||
height: 36px;
|
||||
flex-grow: unset;
|
||||
}
|
||||
}
|
||||
|
||||
.spacer {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,7 +12,7 @@ webpackConfig.entry = {
|
||||
dashboard: path.join(__dirname, 'src', 'init-dashboard.js'),
|
||||
calendar: path.join(__dirname, 'src', 'init-calendar.js'),
|
||||
talk: path.join(__dirname, 'src', 'init-talk.js'),
|
||||
'card-reference': path.join(__dirname, 'src', 'init-card-reference.js'),
|
||||
reference: path.join(__dirname, 'src', 'init-reference.js'),
|
||||
}
|
||||
|
||||
webpackConfig.stats = {
|
||||
|
||||
Reference in New Issue
Block a user