From bf37cc2ed8607e86cddfd29dd7aa5a7e079d783f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 5 Apr 2023 20:56:31 +0200 Subject: [PATCH] fix: Move dashboard fetching to dedicated store module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/init-dashboard.js | 5 +++-- src/store/dashboard.js | 51 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/store/dashboard.js diff --git a/src/init-dashboard.js b/src/init-dashboard.js index 3d36981f3..18be0c35b 100644 --- a/src/init-dashboard.js +++ b/src/init-dashboard.js @@ -33,7 +33,8 @@ document.addEventListener('DOMContentLoaded', () => { OCA.Dashboard.register('deck', async (el) => { const { default: Vue } = await import('vue') const { default: Vuex } = await import('vuex') - const { default: overview } = await import('./store/overview.js') + const { default: dashboard } = await import('./store/dashboard.js') + const { default: Dashboard } = await import('./views/Dashboard.vue') Vue.prototype.t = t Vue.prototype.n = n @@ -42,7 +43,7 @@ document.addEventListener('DOMContentLoaded', () => { const store = new Vuex.Store({ modules: { - overview, + dashboard, }, strict: debug, }) diff --git a/src/store/dashboard.js b/src/store/dashboard.js new file mode 100644 index 000000000..1b173b5ff --- /dev/null +++ b/src/store/dashboard.js @@ -0,0 +1,51 @@ +/* + * @copyright Copyright (c) 2020 Jakob Röhrl + * + * @author Jakob Röhrl + * + * @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 . + * + */ + +import Vue from 'vue' +import Vuex from 'vuex' +import { OverviewApi } from '../services/OverviewApi.js' + +Vue.use(Vuex) + +const apiClient = new OverviewApi() + +export default { + state: { + assignedCards: [], + }, + getters: { + assignedCardsDashboard: state => { + return Object.values(state.assignedCards).flat() + }, + }, + mutations: { + setAssignedCards(state, assignedCards) { + state.assignedCards = assignedCards + }, + }, + actions: { + async loadUpcoming({ commit }) { + const upcommingCards = await apiClient.get('upcoming') + commit('setAssignedCards', upcommingCards) + }, + }, +}