refactor components for store changes

This commit is contained in:
Moriz Wahl 2023-06-02 16:55:52 +02:00
parent ba80f14d8c
commit 73f62212f8
5 changed files with 25 additions and 26 deletions

View File

@ -7,7 +7,7 @@
:label="$t('filter-menu.ended.all.label')"
:filled="!eventsEnded"
:title="$t('filter-menu.ended.all.hint')"
@click="toggleEventsEnded(false)"
@click="toggleEventsEnded"
data-test="all-button"
/>
</li>
@ -17,7 +17,7 @@
:label="$t('filter-menu.ended.onlyEnded.label')"
:filled="!!eventsEnded"
:title="$t('filter-menu.ended.onlyEnded.hint')"
@click="toggleEventsEnded(true)"
@click="toggleEventsEnded"
data-test="not-ended-button"
/>
</li>

View File

@ -40,8 +40,11 @@ export default {
},
computed: {
...mapGetters({
eventSetInPostTypeFilter: 'posts/eventSetInPostTypeFilter',
filteredPostTypes: 'posts/filteredPostTypes',
}),
eventSetInPostTypeFilter() {
return this.filteredPostTypes.includes('Event')
},
},
}
</script>

View File

@ -38,9 +38,12 @@ export default {
},
computed: {
...mapGetters({
orderedByCreationDate: 'posts/orderedByCreationDate',
filteredPostTypes: 'posts/filteredPostTypes',
orderBy: 'posts/orderBy',
}),
orderedByCreationDate() {
return !this.filteredPostTypes.includes('Event')
},
orderedAsc() {
return this.orderedByCreationDate ? 'createdAt_asc' : 'eventStart_desc'
},

View File

@ -9,27 +9,27 @@
<labeled-button
icon="check"
:label="$t('filter-menu.all')"
:filled="noneSetInPostTypeFilter"
:filled="filteredPostTypes === []"
:title="$t('filter-menu.all')"
@click="toggleSetUnsetPostTypeFilter('All')"
@click="togglePostType(null)"
/>
</li>
<li class="item article-item">
<labeled-button
icon="book"
:label="$t('filter-menu.article')"
:filled="articleSetInPostTypeFilter"
:filled="filteredPostTypes.includes('Article')"
:title="$t('filter-menu.article')"
@click="toggleSetUnsetPostTypeFilter('Article')"
@click="togglePostType('Article')"
/>
</li>
<li class="item event-item">
<labeled-button
icon="calendar"
:label="$t('filter-menu.event')"
:filled="eventSetInPostTypeFilter"
:filled="filteredPostTypes.includes('Event')"
:title="$t('filter-menu.event')"
@click="toggleSetUnsetPostTypeFilter('Event')"
@click="togglePostType('Event')"
/>
</li>
</template>
@ -49,14 +49,12 @@ export default {
},
computed: {
...mapGetters({
noneSetInPostTypeFilter: 'posts/noneSetInPostTypeFilter',
articleSetInPostTypeFilter: 'posts/articleSetInPostTypeFilter',
eventSetInPostTypeFilter: 'posts/eventSetInPostTypeFilter',
filteredPostTypes: 'posts/filteredPostTypes',
}),
},
methods: {
...mapMutations({
toggleSetUnsetPostTypeFilter: 'posts/TOGGLE_SET_UNSET_POST_TYPE_FILTER',
togglePostType: 'posts/TOGGLE_POST_TYPE',
}),
},
}

View File

@ -25,8 +25,7 @@
<base-button
class="my-filter-button"
v-if="
!articleSetInPostTypeFilter &&
!eventSetInPostTypeFilter &&
!postsFilter['postType_in'] &&
!postsFilter['categories_some'] &&
!postsFilter['author'] &&
!postsFilter['postsInMyGroups']
@ -41,19 +40,19 @@
</base-button>
<header-button
v-if="articleSetInPostTypeFilter"
v-if="filteredPostTypes.includes('Article')"
:title="$t('contribution.filterMasonryGrid.onlyArticles')"
:clickButton="openFilterMenu"
:titleRemove="$t('filter-menu.deleteFilter')"
:clickRemove="toggleUnsetAllPostTypeFilters"
:clickRemove="togglePostType(null)"
/>
<header-button
v-if="eventSetInPostTypeFilter"
v-if="filteredPostTypes.includes('Event')"
:title="$t('contribution.filterMasonryGrid.onlyEvents')"
:clickButton="openFilterMenu"
:titleRemove="$t('filter-menu.deleteFilter')"
:clickRemove="toggleUnsetAllPostTypeFilters"
:clickRemove="togglePostType(null)"
/>
<header-button
@ -190,9 +189,7 @@ export default {
computed: {
...mapGetters({
postsFilter: 'posts/filter',
articleSetInPostTypeFilter: 'posts/articleSetInPostTypeFilter',
eventSetInPostTypeFilter: 'posts/eventSetInPostTypeFilter',
eventsEnded: 'posts/eventsEnded',
filteredPostTypes: 'posts/filteredPostTypes',
orderBy: 'posts/orderBy',
}),
filterButtonIcon() {
@ -203,7 +200,6 @@ export default {
filter = {
...filter,
tags_some: this.hashtag ? { id: this.hashtag } : undefined,
eventStart_gte: this.eventsEnded,
}
return filter
},
@ -225,8 +221,7 @@ export default {
},
methods: {
...mapMutations({
toggleUnsetAllPostTypeFilters: 'posts/TOGGLE_UNSET_ALL_POST_TYPES_FILTERS',
toggleSetUnsetPostTypeFilter: 'posts/TOGGLE_SET_UNSET_POST_TYPE_FILTER',
togglePostType: 'posts/TOGGLE_TYPE',
resetByFollowed: 'posts/TOGGLE_FILTER_BY_FOLLOWED',
resetByGroups: 'posts/TOGGLE_FILTER_BY_MY_GROUPS',
resetCategories: 'posts/RESET_CATEGORIES',