mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Move all computed in file 'filterMenuMixin.js' to the store
This commit is contained in:
parent
9fee1b43c8
commit
52c474536f
@ -14,21 +14,13 @@ export default {
|
||||
...mapGetters({
|
||||
currentUser: 'auth/user',
|
||||
filteredPostTypes: 'posts/filteredPostTypes',
|
||||
noneSetInPostTypeFilter: 'posts/noneSetInPostTypeFilter',
|
||||
articleSetInPostTypeFilter: 'posts/articleSetInPostTypeFilter',
|
||||
eventSetInPostTypeFilter: 'posts/eventSetInPostTypeFilter',
|
||||
orderedByCreationDate: 'posts/orderedByCreationDate',
|
||||
eventsEnded: 'posts/eventsEnded',
|
||||
orderBy: 'posts/orderBy',
|
||||
}),
|
||||
noneSetInPostTypeFilter() {
|
||||
return !this.articleSetInPostTypeFilter && !this.eventSetInPostTypeFilter
|
||||
},
|
||||
articleSetInPostTypeFilter() {
|
||||
return this.filteredPostTypes.includes('Article')
|
||||
},
|
||||
eventSetInPostTypeFilter() {
|
||||
return this.filteredPostTypes.includes('Event')
|
||||
},
|
||||
orderedByCreationDate() {
|
||||
return this.noneSetInPostTypeFilter || this.articleSetInPostTypeFilter
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
|
||||
@ -7,6 +7,22 @@ import clone from 'lodash/clone'
|
||||
|
||||
const defaultFilter = {}
|
||||
|
||||
const filteredPostTypes = (state) => {
|
||||
return get(state.filter, 'postType_in') || []
|
||||
}
|
||||
const noneSetInPostTypeFilter = (state) => {
|
||||
return !articleSetInPostTypeFilter(state) && !eventSetInPostTypeFilter(state)
|
||||
}
|
||||
const articleSetInPostTypeFilter = (state) => {
|
||||
return filteredPostTypes(state).includes('Article')
|
||||
}
|
||||
const eventSetInPostTypeFilter = (state) => {
|
||||
return filteredPostTypes(state).includes('Event')
|
||||
}
|
||||
const orderedByCreationDate = (state) => {
|
||||
return noneSetInPostTypeFilter(state) || articleSetInPostTypeFilter(state)
|
||||
}
|
||||
|
||||
export const state = () => {
|
||||
return {
|
||||
filter: {
|
||||
@ -100,9 +116,7 @@ export const getters = {
|
||||
filteredCategoryIds(state) {
|
||||
return get(state.filter, 'categories_some.id_in') || []
|
||||
},
|
||||
filteredPostTypes(state) {
|
||||
return get(state.filter, 'postType_in') || []
|
||||
},
|
||||
filteredPostTypes,
|
||||
filteredLanguageCodes(state) {
|
||||
return get(state.filter, 'language_in') || []
|
||||
},
|
||||
@ -115,6 +129,10 @@ export const getters = {
|
||||
filteredByEmotions(state) {
|
||||
return get(state.filter, 'emotions_some.emotion_in') || []
|
||||
},
|
||||
noneSetInPostTypeFilter,
|
||||
articleSetInPostTypeFilter,
|
||||
eventSetInPostTypeFilter,
|
||||
orderedByCreationDate,
|
||||
eventsEnded(state) {
|
||||
return state.eventsEnded
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user