Use @nextcloud/vue-dashboard

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2020-08-24 14:01:42 +02:00
parent 0dfa241f48
commit d9e69d5246
3 changed files with 68 additions and 34 deletions

6
package-lock.json generated
View File

@@ -3852,9 +3852,9 @@
} }
}, },
"@nextcloud/vue-dashboard": { "@nextcloud/vue-dashboard": {
"version": "0.1.6", "version": "0.1.8",
"resolved": "https://registry.npmjs.org/@nextcloud/vue-dashboard/-/vue-dashboard-0.1.6.tgz", "resolved": "https://registry.npmjs.org/@nextcloud/vue-dashboard/-/vue-dashboard-0.1.8.tgz",
"integrity": "sha512-AgJMFYLuWWKi7U5TE+Zjta02OzS83nMgmgQZOjvP92VV/TwcxMnUo/3eJRaNrAnoRej4x1hjdroQC8PgDbZqzQ==", "integrity": "sha512-OGr1oK/WF9+bYHK8dE8Vjwh3IDNamN+9MSti1VO7zuUSm5A9EGCzAghR7zzCG4O43rAJEDcvnQwsYIiA6g4Yrw==",
"requires": { "requires": {
"@nextcloud/vue": "^2.3.0", "@nextcloud/vue": "^2.3.0",
"core-js": "^3.6.4", "core-js": "^3.6.4",

View File

@@ -40,7 +40,7 @@
"@nextcloud/moment": "^1.1.1", "@nextcloud/moment": "^1.1.1",
"@nextcloud/router": "^1.1.0", "@nextcloud/router": "^1.1.0",
"@nextcloud/vue": "^2.6.0", "@nextcloud/vue": "^2.6.0",
"@nextcloud/vue-dashboard": "^0.1.6", "@nextcloud/vue-dashboard": "^0.1.8",
"blueimp-md5": "^2.17.0", "blueimp-md5": "^2.17.0",
"dompurify": "^2.0.12", "dompurify": "^2.0.12",
"lodash": "^4.17.20", "lodash": "^4.17.20",

View File

@@ -21,27 +21,41 @@
--> -->
<template> <template>
<div> <DashboardWidget :items="cards"
<a v-for="card in assignedCardsDashboard" :show-more-url="showMoreUrl"
:key="card.id" :loading="loading"
:href="cardLink(card)" @hide="() => {}"
class="card"> @markDone="() => {}">
<div class="card--header"> <template v-slot:default="{ item }">
<DueDate class="right" :card="card" /> <a :key="item.id"
<span>{{ card.title }}</span> :href="cardLink(item)"
</div> target="_blank"
<ul v-if="card.labels && card.labels.length" class="card">
class="labels" <div class="card--header">
@click="openCard"> <DueDate class="right" :card="item" />
<li v-for="label in card.labels" :key="label.id" :style="labelStyle(label)"> <span class="title">{{ item.title }}</span>
<span>{{ label.title }}</span> </div>
</li> <ul v-if="item.labels && item.labels.length"
</ul> class="labels">
</a> <li v-for="label in item.labels" :key="label.id" :style="labelStyle(label)">
</div> <span>{{ label.title }}</span>
</li>
</ul>
</a>
</template>
<template v-slot:empty-content>
<EmptyContent
id="deck-widget-empty-content"
icon="icon-deck">
{{ t('deck', 'No upcoming cards') }}
</EmptyContent>
</template>
</DashboardWidget>
</template> </template>
<script> <script>
import { DashboardWidget } from '@nextcloud/vue-dashboard'
import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import labelStyle from './../mixins/labelStyle' import labelStyle from './../mixins/labelStyle'
import DueDate from '../components/cards/badges/DueDate' import DueDate from '../components/cards/badges/DueDate'
@@ -51,27 +65,44 @@ export default {
name: 'Dashboard', name: 'Dashboard',
components: { components: {
DueDate, DueDate,
EmptyContent,
DashboardWidget,
}, },
mixins: [ labelStyle ], mixins: [ labelStyle ],
data() {
return {
loading: false,
}
},
computed: { computed: {
...mapGetters([ ...mapGetters([
'withDueDashboard',
'assignedCardsDashboard', 'assignedCardsDashboard',
]), ]),
cards() { cards() {
return [ const list = [
...this.withDueDashboard,
...this.assignedCardsDashboard, ...this.assignedCardsDashboard,
] ].filter((card) => {
return card.duedate !== null
})
list.sort((a, b) => {
return (new Date(a.duedate)).getTime() - (new Date(b.duedate)).getTime()
})
return list
}, },
cardLink() { cardLink() {
return (card) => { return (card) => {
return generateUrl('/apps/deck') + `#/board/${card.boardId}/card/${card.id}` return generateUrl('/apps/deck') + `#/board/${card.boardId}/card/${card.id}`
} }
}, },
showMoreUrl() {
return this.cards.length > 7 ? generateUrl('/apps/deck') : null
},
}, },
beforeMount() { beforeMount() {
this.$store.dispatch('loadAssignDashboard') this.loading = true
this.$store.dispatch('loadAssignDashboard').then(() => {
this.loading = false
})
}, },
} }
</script> </script>
@@ -82,8 +113,8 @@ export default {
.card { .card {
display: block; display: block;
border-radius: var(--border-radius-large); border-radius: var(--border-radius-large);
margin-bottom: 8px; padding: 8px;
padding: 5px; height: 60px;
&:hover { &:hover {
background-color: var(--color-background-hover); background-color: var(--color-background-hover);
@@ -92,10 +123,11 @@ export default {
.card--header { .card--header {
overflow: hidden; overflow: hidden;
margin-bottom: 5px; .title {
span { overflow: hidden;
display: inline-block; text-overflow: ellipsis;
padding: 5px; white-space: nowrap;
display: block;
} }
} }
@@ -105,7 +137,9 @@ export default {
.duedate::v-deep { .duedate::v-deep {
.due { .due {
margin: 0; margin: 0 0 0 10px;
padding: 2px 4px;
font-size: 90%;
} }
} }