Skip to content

Commit

Permalink
add filter option to show both completed and open
Browse files Browse the repository at this point in the history
refactor element-ids to filter-option-

Signed-off-by: grnd-alt <[email protected]>
  • Loading branch information
grnd-alt committed Jan 31, 2024
1 parent dba9562 commit 39ed175
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
46 changes: 33 additions & 13 deletions src/components/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,37 @@
<label :for="user.uid"><NcAvatar :user="user.uid" :size="24" :disable-menu="true" /> {{ user.displayname }}</label>
</div>

<h3>{{ t('deck', 'Filter by done') }}</h3>
<h3>{{ t('deck', 'Filter by completed') }}</h3>
<div class="filter--item">
<input id="open"
<input id="filter-option-both"
v-model="filter.completedOrOpen"
type="radio"
class="radio"
:value="true"
@change="setFilter"
@click="beforeSetFilter">
<label for="filter-option-both">{{ t('deck', 'both') }}</label>
</div>
<div class="filter--item">
<input id="filter-option-open"
v-model="filter.open"
type="radio"
class="radio"
:value="true"
@change="setFilter"
@click="beforeSetFilter">
<label for="open">{{ t('deck', 'open') }}</label>
<label for="filter-option-open">{{ t('deck', 'open') }}</label>
</div>

<div class="filter--item">
<input id="done"
v-model="filter.done"
<input id="filter-option-completed"
v-model="filter.completed"
type="radio"
class="radio"
:value="true"
@change="setFilter"
@click="beforeSetFilter">
<label for="done">{{ t('deck', 'done') }}</label>
<label for="filter-option-completed">{{ t('deck', 'completed') }}</label>
</div>

<h3>{{ t('deck', 'Filter by due date') }}</h3>
Expand Down Expand Up @@ -315,7 +325,7 @@ export default {
filterVisible: false,
showArchived: false,
isAddStackVisible: false,
filter: { tags: [], users: [], due: '', unassigned: false, open: false, done: false },
filter: { tags: [], users: [], due: '', unassigned: false, open: false, completed: false, completedOrOpen: true },
showAddCardModal: false,
defaultPageTitle: false,
isNotifyPushEnabled: isNotifyPushEnabled(),
Expand All @@ -338,7 +348,7 @@ export default {
}
},
isFilterActive() {
return this.filter.tags.length !== 0 || this.filter.users.length !== 0 || this.filter.due !== '' || this.filter.open || this.filter.done
return this.filter.tags.length !== 0 || this.filter.users.length !== 0 || this.filter.due !== '' || this.filter.open || this.filter.completed || !this.filter.completedOrOpen
},
labelsSorted() {
return [...this.board.labels].sort((a, b) => (a.title < b.title) ? -1 : 1)
Expand Down Expand Up @@ -381,16 +391,26 @@ export default {
}
if (e.target.value === 'unassigned') {
this.filter.users = []
this.$store.dispatch('setFilter', { ...this.filter })
}
if (e.target.id === 'open') {
if (e.target.id === 'filter-option-open') {
this.filter.open = !this.filter.open
this.$store.dispatch('setFilter', { ...this.filter })
}
if (e.target.id === 'done') {
this.filter.done = !this.filter.done
if (e.target.id === 'filter-option-completed') {
this.filter.completed = !this.filter.completed
this.$store.dispatch('setFilter', { ...this.filter })
}
if (e.target.id !== 'filter-option-both') {
this.filter.completedOrOpen = !(this.filter.open || this.filter.completed)
this.$store.dispatch('setFilter', { ...this.filter })
} else {
this.filter.completedOrOpen = true
this.filter.open = false
this.filter.completed = false
this.$store.dispatch('setFilter', { ...this.filter })
}
this.$store.dispatch('setFilter', { ...this.filter })
},
setFilter() {
if (this.filter.users.length > 0) {
Expand Down Expand Up @@ -432,7 +452,7 @@ export default {
}
},
clearFilter() {
const filterReset = { tags: [], users: [], due: '', open: false, done: false }
const filterReset = { tags: [], users: [], due: '', open: false, completed: false, completedOrOpen: true }
this.$store.dispatch('setFilter', { ...filterReset })
this.filter = filterReset
},
Expand Down
4 changes: 2 additions & 2 deletions src/store/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ export default {
getters: {
cardsByStack: (state, getters, rootState) => (id) => {
return state.cards.filter((card) => {
const { tags, users, due, unassigned, open, done } = rootState.filter
const { tags, users, due, unassigned, open, completed } = rootState.filter

if (open && card.done !== null) { return false }
if (done && card.done == null) { return false }
if (completed && card.done == null) { return false }
let allTagsMatch = true
let allUsersMatch = true

Expand Down
2 changes: 1 addition & 1 deletion src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default new Vuex.Store({
searchQuery: '',
activity: [],
activityLoadMore: true,
filter: { tags: [], users: [], due: '', open: false, done: false },
filter: { tags: [], users: [], due: '', open: false, completed: false, completedOrOpen: true },
shortcutLock: false,
},
getters: {
Expand Down

0 comments on commit 39ed175

Please sign in to comment.