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