Implements board filters
This commit is contained in:
@@ -22,13 +22,24 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="deck-main">
|
<div class="deck-main">
|
||||||
Main
|
Boards
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'Main'
|
name: 'Main',
|
||||||
|
props: {
|
||||||
|
navFilter: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
navFilter: function(value) {
|
||||||
|
this.$store.commit('nav/setFilter', value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -23,8 +23,9 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Router from 'vue-router'
|
import Router from 'vue-router'
|
||||||
import { generateUrl } from 'nextcloud-server/dist/router'
|
import { generateUrl } from 'nextcloud-server/dist/router'
|
||||||
|
import { BOARD_FILTERS } from './store/modules/nav'
|
||||||
|
|
||||||
const Main = () => import('./components/Main')
|
const Boards = () => import('./components/Boards')
|
||||||
|
|
||||||
Vue.use(Router)
|
Vue.use(Router)
|
||||||
|
|
||||||
@@ -35,17 +36,31 @@ export default new Router({
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'main',
|
name: 'main',
|
||||||
component: Main
|
component: Boards
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/boards',
|
path: '/boards',
|
||||||
name: 'boards',
|
name: 'boards',
|
||||||
component: Main
|
component: Boards,
|
||||||
|
props: {
|
||||||
|
navFilter: BOARD_FILTERS.ALL
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/boards/archived',
|
path: '/boards/archived',
|
||||||
name: 'boards.archived',
|
name: 'boards.archived',
|
||||||
component: Main
|
component: Boards,
|
||||||
|
props: {
|
||||||
|
navFilter: BOARD_FILTERS.ARCHIVED
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/boards/shared',
|
||||||
|
name: 'boards.shared',
|
||||||
|
component: Boards,
|
||||||
|
props: {
|
||||||
|
navFilter: BOARD_FILTERS.SHARED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// eslint
|
||||||
|
|
||||||
import { translate as t } from 'nextcloud-server/dist/l10n'
|
import { translate as t } from 'nextcloud-server/dist/l10n'
|
||||||
import axios from 'nextcloud-axios'
|
import axios from 'nextcloud-axios'
|
||||||
|
|
||||||
@@ -112,16 +114,31 @@ const addButton = {
|
|||||||
const state = {
|
const state = {
|
||||||
hidden: false,
|
hidden: false,
|
||||||
boards: [],
|
boards: [],
|
||||||
loading: false
|
loading: false,
|
||||||
|
filter: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
export const BOARD_FILTERS = {
|
||||||
|
ALL: '',
|
||||||
|
ARCHIVED: 'archived',
|
||||||
|
SHARED: 'shared'
|
||||||
}
|
}
|
||||||
|
|
||||||
// getters
|
// getters
|
||||||
const getters = {
|
const getters = {
|
||||||
menu: state => {
|
menu: 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 {
|
return {
|
||||||
loading: state.loading,
|
loading: state.loading,
|
||||||
items: defaultCategories
|
items: defaultCategories
|
||||||
.concat(state.boards.map(mapBoardToItem))
|
.concat(boards.map(mapBoardToItem))
|
||||||
.concat([addButton])
|
.concat([addButton])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +164,9 @@ const mutations = {
|
|||||||
},
|
},
|
||||||
setBoards(state, boards) {
|
setBoards(state, boards) {
|
||||||
state.boards = boards
|
state.boards = boards
|
||||||
|
},
|
||||||
|
setFilter(state, filter) {
|
||||||
|
state.filter = filter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user