Skip to content

Commit

Permalink
group completed filters to one property
Browse files Browse the repository at this point in the history
Signed-off-by: grnd-alt <[email protected]>
  • Loading branch information
grnd-alt committed Mar 13, 2024
1 parent 9a3521b commit c6728d3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 31 deletions.
39 changes: 12 additions & 27 deletions src/components/Controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,34 +141,34 @@
<h3>{{ t('deck', 'Filter by completed') }}</h3>
<div class="filter--item">
<input id="filter-option-both"
v-model="filter.completedOrOpen"
v-model="filter.completed"
type="radio"
class="radio"
:value="true"
value="both"
@change="setFilter"
@click="beforeSetFilter">
<label for="filter-option-both">{{ t('deck', 'both') }}</label>
<label for="filter-option-both">{{ t('deck', 'Open and completed') }}</label>
</div>
<div class="filter--item">
<input id="filter-option-open"
v-model="filter.open"
v-model="filter.completed"
type="radio"
class="radio"
:value="true"
value="open"
@change="setFilter"
@click="beforeSetFilter">
<label for="filter-option-open">{{ t('deck', 'open') }}</label>
<label for="filter-option-open">{{ t('deck', 'Open') }}</label>
</div>

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

<h3>{{ t('deck', 'Filter by due date') }}</h3>
Expand Down Expand Up @@ -325,7 +325,7 @@ export default {
filterVisible: false,
showArchived: false,
isAddStackVisible: false,
filter: { tags: [], users: [], due: '', unassigned: false, open: false, completed: false, completedOrOpen: true },
filter: { tags: [], users: [], due: '', unassigned: false, completed: 'both' },
showAddCardModal: false,
defaultPageTitle: false,
isNotifyPushEnabled: isNotifyPushEnabled(),
Expand All @@ -349,7 +349,7 @@ export default {
}
},
isFilterActive() {
return this.filter.tags.length !== 0 || this.filter.users.length !== 0 || this.filter.due !== '' || this.filter.open || this.filter.completed || !this.filter.completedOrOpen
return this.filter.tags.length !== 0 || this.filter.users.length !== 0 || this.filter.due !== '' || this.filter.completed !== 'both'
},
labelsSorted() {
return [...this.board.labels].sort((a, b) => (a.title < b.title) ? -1 : 1)
Expand Down Expand Up @@ -393,22 +393,8 @@ export default {
if (e.target.value === 'unassigned') {
this.filter.users = []
this.$store.dispatch('setFilter', { ...this.filter })
}
if (e.target.id === 'filter-option-open') {
this.filter.open = !this.filter.open
this.$store.dispatch('setFilter', { ...this.filter })
}
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.filter.completed = 'both'
this.$store.dispatch('setFilter', { ...this.filter })
}
this.$store.dispatch('setFilter', { ...this.filter })
Expand Down Expand Up @@ -453,7 +439,7 @@ export default {
}
},
clearFilter() {
const filterReset = { tags: [], users: [], due: '', open: false, completed: false, completedOrOpen: true }
const filterReset = { tags: [], users: [], due: '', completed: 'both' }
this.$store.dispatch('setFilter', { ...filterReset })
this.filter = filterReset
},
Expand Down Expand Up @@ -570,7 +556,6 @@ export default {
input + label {
display: block;
padding: 6px 0;
vertical-align: middle;
.avatardiv {
vertical-align: middle;
margin-bottom: 2px;
Expand Down
6 changes: 3 additions & 3 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, completed } = rootState.filter
const { tags, users, due, unassigned, completed } = rootState.filter

if (open && card.done !== null) { return false }
if (completed && card.done == null) { return false }
if (completed === 'open' && card.done !== null) { return false }
if (completed === '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 @@ -74,7 +74,7 @@ export default new Vuex.Store({
searchQuery: '',
activity: [],
activityLoadMore: true,
filter: { tags: [], users: [], due: '', open: false, completed: false, completedOrOpen: true },
filter: { tags: [], users: [], due: '', completed: 'both' },
shortcutLock: false,
},
getters: {
Expand Down

0 comments on commit c6728d3

Please sign in to comment.