serach cards

Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
Jakob Röhrl
2020-01-30 11:54:53 +01:00
parent b0e3520969
commit 032573bd69
3 changed files with 26 additions and 2 deletions

View File

@@ -44,6 +44,8 @@ Vue.mixin({
}, },
}) })
Vue.prototype.$OC = OC
Vue.directive('tooltip', Tooltip) Vue.directive('tooltip', Tooltip)
Vue.directive('click-outside', ClickOutside) Vue.directive('click-outside', ClickOutside)
@@ -58,5 +60,16 @@ new Vue({
el: '#content', el: '#content',
router, router,
store, store,
mounted: function() {
this.$OC.Search = new OCA.Search(this.filter, this.cleanSearch)
},
methods: {
filter(query) {
this.$store.commit('setSearchQuery', query)
},
cleanSearch() {
this.$store.commit('setSearchQuery', '')
},
},
render: h => h(App), render: h => h(App),
}) })

View File

@@ -30,8 +30,12 @@ export default {
cards: [], cards: [],
}, },
getters: { getters: {
cardsByStack: state => (id) => { cardsByStack: (state, getters) => (id) => {
return state.cards.filter((card) => card.stackId === id).sort((a, b) => a.order - b.order) return state.cards.filter(
(card) => card.stackId === id
&& (card.title.includes(getters.getSearchQuery) || card.description.includes(getters.getSearchQuery))
)
.sort((a, b) => a.order - b.order)
}, },
cardById: state => (id) => { cardById: state => (id) => {
return state.cards.find((card) => card.id === id) return state.cards.find((card) => card.id === id)

View File

@@ -61,8 +61,12 @@ export default new Vuex.Store({
boardFilter: BOARD_FILTERS.ALL, boardFilter: BOARD_FILTERS.ALL,
activity: [], activity: [],
activityLoadMore: true, activityLoadMore: true,
searchQuery: '',
}, },
getters: { getters: {
getSearchQuery: state => {
return state.searchQuery
},
boards: state => { boards: state => {
return state.boards return state.boards
}, },
@@ -107,6 +111,9 @@ export default new Vuex.Store({
}, },
}, },
mutations: { mutations: {
setSearchQuery(state, searchQuery) {
state.searchQuery = searchQuery
},
toggleShowArchived(state) { toggleShowArchived(state) {
state.showArchived = !state.showArchived state.showArchived = !state.showArchived
}, },