Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/init-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,59 @@ const getAsyncImports = async () => {
}

const { default: Vue } = await import('vue')
const { createPinia, PiniaVuePlugin } = await import('pinia')
const { default: Vuex } = await import('vuex')
const { default: dashboard } = await import('./store/dashboard.js')

Vue.prototype.t = t
Vue.prototype.n = n
Vue.prototype.OC = OC
const pinia = createPinia()
Vue.use(PiniaVuePlugin)
Vue.use(Vuex)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are still injecting vuex here because some components in the dashboard require vuex state from not yet migrated stores. for example: https://github.com/nextcloud/deck/blob/main/src/components/cards/badges/DueDate.vue#L48


const store = new Vuex.Store({
modules: {
dashboard,
},
strict: debug,
})

_imports = {
store, Vue,
pinia, Vue, store,
}

return _imports
}

document.addEventListener('DOMContentLoaded', () => {
OCA.Dashboard.register('deck', async (el) => {
const { Vue, store } = await getAsyncImports()
const { Vue, pinia, store } = await getAsyncImports()
const { default: DashboardUpcoming } = await import('./views/DashboardUpcoming.vue')

const View = Vue.extend(DashboardUpcoming)
const vm = new View({
propsData: {},
pinia,
store,
}).$mount(el)
return vm
})

OCA.Dashboard.register('deckToday', async (el) => {
const { Vue, store } = await getAsyncImports()
const { Vue, pinia, store } = await getAsyncImports()
const { default: DashboardToday } = await import('./views/DashboardToday.vue')
const View = Vue.extend(DashboardToday)
const vm = new View({
propsData: {},
pinia,
store,
}).$mount(el)
return vm
})

OCA.Dashboard.register('deckTomorrow', async (el) => {
const { Vue, store } = await getAsyncImports()
const { Vue, pinia, store } = await getAsyncImports()
const { default: DashboardTomorrow } = await import('./views/DashboardTomorrow.vue')
const View = Vue.extend(DashboardTomorrow)
const vm = new View({
propsData: {},
pinia,
store,
}).$mount(el)
return vm
Expand Down
34 changes: 0 additions & 34 deletions src/store/dashboard.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/stores/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { defineStore } from 'pinia'
import { OverviewApi } from '../services/OverviewApi.js'

const apiClient = new OverviewApi()

export const useDashboardStore = defineStore('dashboard', {
state: () => ({
assignedCards: [],
}),
actions: {
async loadUpcoming() {
const upcommingCards = await apiClient.get('upcoming')
this.assignedCards = upcommingCards
},
},
})
14 changes: 8 additions & 6 deletions src/views/DashboardToday.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

<script>
import { NcDashboardWidget } from '@nextcloud/vue'
import { mapGetters } from 'vuex'
import Card from '../components/dashboard/Card.vue'
import { generateUrl } from '@nextcloud/router'
import { useDashboardStore } from '../stores/dashboard.js'
import { mapActions, mapState } from 'pinia'

export default {
name: 'DashboardToday',
Expand All @@ -36,11 +37,9 @@ export default {
}
},
computed: {
...mapGetters([
'assignedCardsDashboard',
]),
...mapState(useDashboardStore, ['assignedCards']),
cards() {
const list = [...this.assignedCardsDashboard.today || []]
const list = [...this.assignedCards.today || []]
list.sort((a, b) => {
return (new Date(a.duedate)).getTime() - (new Date(b.duedate)).getTime()
})
Expand All @@ -52,10 +51,13 @@ export default {
},
beforeMount() {
this.loading = true
this.$store.dispatch('loadUpcoming').then(() => {
this.loadUpcoming().then(() => {
this.loading = false
})
},
methods: {
...mapActions(useDashboardStore, ['loadUpcoming']),
},
}
</script>

Expand Down
14 changes: 8 additions & 6 deletions src/views/DashboardTomorrow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

<script>
import { NcDashboardWidget } from '@nextcloud/vue'
import { mapGetters } from 'vuex'
import Card from '../components/dashboard/Card.vue'
import { generateUrl } from '@nextcloud/router'
import { useDashboardStore } from '../stores/dashboard.js'
import { mapActions, mapState } from 'pinia'

export default {
name: 'DashboardTomorrow',
Expand All @@ -36,11 +37,9 @@ export default {
}
},
computed: {
...mapGetters([
'assignedCardsDashboard',
]),
...mapState(useDashboardStore, ['assignedCards']),
cards() {
const list = [...this.assignedCardsDashboard.tomorrow || []]
const list = [...this.assignedCards.tomorrow || []]
list.sort((a, b) => {
return (new Date(a.duedate)).getTime() - (new Date(b.duedate)).getTime()
})
Expand All @@ -52,10 +51,13 @@ export default {
},
beforeMount() {
this.loading = true
this.$store.dispatch('loadUpcoming').then(() => {
this.loadUpcoming().then(() => {
this.loading = false
})
},
methods: {
...mapActions(useDashboardStore, ['loadUpcoming']),
},
}
</script>

Expand Down
12 changes: 6 additions & 6 deletions src/views/DashboardUpcoming.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
<script>
import PlusIcon from 'vue-material-design-icons/Plus.vue'
import { NcButton, NcDashboardWidget, NcModal } from '@nextcloud/vue'
import { mapGetters } from 'vuex'
import Card from '../components/dashboard/Card.vue'
import { generateUrl } from '@nextcloud/router'
import CreateNewCardCustomPicker from './CreateNewCardCustomPicker.vue'
import { useDashboardStore } from '../stores/dashboard.js'
import { mapActions, mapState } from 'pinia'

export default {
name: 'DashboardUpcoming',
Expand All @@ -55,11 +56,9 @@ export default {
}
},
computed: {
...mapGetters([
'assignedCardsDashboard',
]),
...mapState(useDashboardStore, ['assignedCards']),
cards() {
const list = Object.values(this.assignedCardsDashboard).flat()
const list = Object.values(this.assignedCards).flat()
.filter((card) => {
return card.duedate !== null
})
Expand All @@ -74,11 +73,12 @@ export default {
},
beforeMount() {
this.loading = true
this.$store.dispatch('loadUpcoming').then(() => {
this.loadUpcoming().then(() => {
this.loading = false
})
},
methods: {
...mapActions(useDashboardStore, ['loadUpcoming']),
toggleAddCardModel() {
this.showAddCardModal = !this.showAddCardModal
},
Expand Down
Loading