diff --git a/src/App.vue b/src/App.vue
index 179e92354..0694f9056 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -62,7 +62,7 @@ export default {
})
},
created: function() {
- this.$store.dispatch('nav/loadBoards')
+ this.$store.dispatch('boards/loadBoards')
}
}
diff --git a/src/components/Boards.vue b/src/components/Boards.vue
index 0816702be..c31cebc48 100644
--- a/src/components/Boards.vue
+++ b/src/components/Boards.vue
@@ -28,7 +28,7 @@
Members
-
+
@@ -49,13 +49,13 @@ export default {
}
},
computed: {
- ...mapGetters('nav', [
- 'boards'
+ ...mapGetters('boards', [
+ 'filteredBoards'
])
},
watch: {
navFilter: function(value) {
- this.$store.commit('nav/setFilter', value)
+ this.$store.commit('boards/setFilter', value)
}
}
}
diff --git a/src/router.js b/src/router.js
index c43223aa7..eda0f751b 100644
--- a/src/router.js
+++ b/src/router.js
@@ -23,7 +23,7 @@
import Vue from 'vue'
import Router from 'vue-router'
import { generateUrl } from 'nextcloud-server/dist/router'
-import { BOARD_FILTERS } from './store/modules/nav'
+import { BOARD_FILTERS } from './store/modules/boards'
import Boards from './components/Boards'
import Board from './components/Board'
diff --git a/src/store/main.js b/src/store/main.js
index aa619c5db..35bbe8914 100644
--- a/src/store/main.js
+++ b/src/store/main.js
@@ -22,6 +22,7 @@
import Vue from 'vue'
import Vuex from 'vuex'
+import boards from './modules/boards'
import nav from './modules/nav'
import sidebar from './modules/sidebar'
@@ -31,6 +32,7 @@ const debug = process.env.NODE_ENV !== 'production'
export default new Vuex.Store({
modules: {
+ boards,
nav,
sidebar
},
diff --git a/src/store/modules/boards.js b/src/store/modules/boards.js
new file mode 100644
index 000000000..52673008d
--- /dev/null
+++ b/src/store/modules/boards.js
@@ -0,0 +1,128 @@
+/*
+ * @copyright Copyright (c) 2018 Michael Weimann
+ *
+ * @author Michael Weimann
+ *
+ * @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 axios from 'nextcloud-axios'
+
+const boardActions = [
+ {
+ action: () => {
+ },
+ icon: 'icon-edit',
+ text: t('deck', 'Edit board')
+ },
+ {
+ action: () => {
+ },
+ icon: 'icon-archive',
+ text: t('deck', 'Archive board')
+ },
+ {
+ action: () => {
+ },
+ icon: 'icon-delete',
+ text: t('deck', 'Delete board')
+ },
+ {
+ action: () => {
+ },
+ icon: 'icon-settings',
+ text: t('deck', 'Board details')
+ }
+]
+
+export const BOARD_FILTERS = {
+ ALL: '',
+ ARCHIVED: 'archived',
+ SHARED: 'shared'
+}
+
+/**
+ * Maps an API board to a menu item.
+ * @param board
+ * @returns {{id: *, classes: Array, bullet: string, text: *, router: {name: string, params: {id: *}}, utils: {actions: *[]}}}
+ */
+export const mapBoardToItem = board => {
+ return {
+ id: board.id,
+ classes: [],
+ bullet: `#${board.color}`,
+ text: board.title,
+ owner: board.owner,
+ router: {
+ name: 'board',
+ params: { id: board.id }
+ },
+ utils: {
+ actions: boardActions
+ }
+ }
+}
+
+const state = {
+ boards: [],
+ loading: false,
+ filter: ''
+}
+
+const getters = {
+ filteredBoards: state => {
+ // filters the boards depending on the active filter
+ const boards = state.boards.filter(board => {
+ return state.filter === BOARD_FILTERS.ALL
+ || (state.filter === BOARD_FILTERS.ARCHIVED && board.archived === true)
+ || (state.filter === BOARD_FILTERS.SHARED && board.shared === 1)
+ })
+ return boards.map(mapBoardToItem)
+ }
+}
+
+const actions = {
+ toggle({ commit }) {
+ commit('toggle')
+ },
+ loadBoards({ commit }) {
+ axios.get('/apps/deck/boards')
+ .then((response) => {
+ commit('setBoards', response.data)
+ })
+ }
+}
+
+const mutations = {
+ toggle(state) {
+ state.hidden = !state.hidden
+ },
+ setBoards(state, boards) {
+ state.boards = boards
+ },
+ setFilter(state, filter) {
+ state.filter = filter
+ }
+}
+
+export default {
+ namespaced: true,
+ state,
+ getters,
+ actions,
+ mutations
+}
diff --git a/src/store/modules/nav.js b/src/store/modules/nav.js
index 503a51734..dc54155f2 100644
--- a/src/store/modules/nav.js
+++ b/src/store/modules/nav.js
@@ -1,5 +1,5 @@
/*
- * @copyright Copyright (c) 2018 Julius Härtl
+ * @copyright Copyright (c) 2018 Michael Weimann
*
* @author Michael Weimann
*
@@ -20,32 +20,8 @@
*
*/
-// eslint
-
import { translate as t } from 'nextcloud-server/dist/l10n'
-import axios from 'nextcloud-axios'
-
-/**
- * Maps an API board to a menu item.
- * @param board
- * @returns {{id: *, classes: Array, bullet: string, text: *, router: {name: string, params: {id: *}}, utils: {actions: *[]}}}
- */
-const mapBoardToItem = board => {
- return {
- id: board.id,
- classes: [],
- bullet: `#${board.color}`,
- text: board.title,
- owner: board.owner,
- router: {
- name: 'board',
- params: { id: board.id }
- },
- utils: {
- actions: boardActions
- }
- }
-}
+import { mapBoardToItem } from './boards'
let defaultCategories = [
{
@@ -77,33 +53,6 @@ let defaultCategories = [
}
]
-const boardActions = [
- {
- action: () => {
- },
- icon: 'icon-edit',
- text: t('deck', 'Edit board')
- },
- {
- action: () => {
- },
- icon: 'icon-archive',
- text: t('deck', 'Archive board')
- },
- {
- action: () => {
- },
- icon: 'icon-delete',
- text: t('deck', 'Delete board')
- },
- {
- action: () => {
- },
- icon: 'icon-settings',
- text: t('deck', 'Board details')
- }
-]
-
const addButton = {
icon: 'icon-add',
text: t('deck', 'Create new board'),
@@ -111,53 +60,25 @@ const addButton = {
}
}
-// initial state
const state = {
hidden: false,
- boards: [],
- loading: false,
- filter: ''
+ loading: false
}
-export const BOARD_FILTERS = {
- ALL: '',
- ARCHIVED: 'archived',
- SHARED: 'shared'
-}
-
-// getters
const getters = {
- menu: state => {
-
+ menu: (state, getters, rootState) => {
return {
loading: state.loading,
items: defaultCategories
- .concat(state.boards.map(mapBoardToItem))
+ .concat(rootState.boards.boards.map(mapBoardToItem))
.concat([addButton])
}
- },
- boards: state => {
- // filters the boards depending on the active filter
- const boards = state.boards.filter(board => {
- return state.filter === BOARD_FILTERS.ALL
- || (state.filter === BOARD_FILTERS.ARCHIVED && board.archived === true)
- || (state.filter === BOARD_FILTERS.SHARED && board.shared === 1)
- })
-
- return boards.map(mapBoardToItem)
}
}
-// actions
const actions = {
toggle({ commit }) {
commit('toggle')
- },
- loadBoards({ commit }) {
- axios.get('/apps/deck/boards')
- .then((response) => {
- commit('setBoards', response.data)
- })
}
}
@@ -165,12 +86,6 @@ const actions = {
const mutations = {
toggle(state) {
state.hidden = !state.hidden
- },
- setBoards(state, boards) {
- state.boards = boards
- },
- setFilter(state, filter) {
- state.filter = filter
}
}
diff --git a/src/store/modules/sidebar.js b/src/store/modules/sidebar.js
index f282c3359..9817fd894 100644
--- a/src/store/modules/sidebar.js
+++ b/src/store/modules/sidebar.js
@@ -1,5 +1,5 @@
/*
- * @copyright Copyright (c) 2018 Julius Härtl
+ * @copyright Copyright (c) 2018 Michael Weimann
*
* @author Michael Weimann
*