fix: Move dashboard fetching to dedicated store module
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -33,7 +33,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
OCA.Dashboard.register('deck', async (el) => {
|
OCA.Dashboard.register('deck', async (el) => {
|
||||||
const { default: Vue } = await import('vue')
|
const { default: Vue } = await import('vue')
|
||||||
const { default: Vuex } = await import('vuex')
|
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')
|
const { default: Dashboard } = await import('./views/Dashboard.vue')
|
||||||
Vue.prototype.t = t
|
Vue.prototype.t = t
|
||||||
Vue.prototype.n = n
|
Vue.prototype.n = n
|
||||||
@@ -42,7 +43,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
modules: {
|
modules: {
|
||||||
overview,
|
dashboard,
|
||||||
},
|
},
|
||||||
strict: debug,
|
strict: debug,
|
||||||
})
|
})
|
||||||
|
|||||||
51
src/store/dashboard.js
Normal file
51
src/store/dashboard.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* @copyright Copyright (c) 2020 Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @author Jakob Röhrl <jakob.roehrl@web.de>
|
||||||
|
*
|
||||||
|
* @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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
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)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user