mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
[feature] have all button for source filter option
This commit is contained in:
parent
c6a1c1a8c8
commit
cbf93628a5
@ -13,7 +13,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<post-type-filter />
|
<post-type-filter />
|
||||||
<following-filter />
|
<following-filter @showFilterMenu="$emit('showFilterMenu')" />
|
||||||
<categories-filter v-if="categoriesActive" @showFilterMenu="$emit('showFilterMenu')" />
|
<categories-filter v-if="categoriesActive" @showFilterMenu="$emit('showFilterMenu')" />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="eventSetInPostTypeFilter" class="filter-menu-options">
|
<div v-if="eventSetInPostTypeFilter" class="filter-menu-options">
|
||||||
|
|||||||
@ -10,6 +10,7 @@ describe('FollowingFilter', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
'posts/TOGGLE_FILTER_BY_FOLLOWED': jest.fn(),
|
'posts/TOGGLE_FILTER_BY_FOLLOWED': jest.fn(),
|
||||||
'posts/TOGGLE_FILTER_BY_MY_GROUPS': jest.fn(),
|
'posts/TOGGLE_FILTER_BY_MY_GROUPS': jest.fn(),
|
||||||
|
'posts/RESET_FOLLOWERS_FILTER': jest.fn(),
|
||||||
}
|
}
|
||||||
const getters = {
|
const getters = {
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
@ -65,5 +66,15 @@ describe('FollowingFilter', () => {
|
|||||||
expect(mutations['posts/TOGGLE_FILTER_BY_MY_GROUPS']).toHaveBeenCalled()
|
expect(mutations['posts/TOGGLE_FILTER_BY_MY_GROUPS']).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
describe('clears follower filter', () => {
|
||||||
|
it('when all button is clicked', async () => {
|
||||||
|
wrapper = await Wrapper()
|
||||||
|
const clearFollowerButton = wrapper.find(
|
||||||
|
'.following-filter .item-all-follower .base-button',
|
||||||
|
)
|
||||||
|
clearFollowerButton.trigger('click')
|
||||||
|
expect(mutations['posts/RESET_FOLLOWERS_FILTER']).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -5,6 +5,18 @@
|
|||||||
class="following-filter"
|
class="following-filter"
|
||||||
>
|
>
|
||||||
<template #filter-follower>
|
<template #filter-follower>
|
||||||
|
<div class="item item-all-follower">
|
||||||
|
<base-button
|
||||||
|
:filled="!filteredByUsersFollowed && !filteredByPostsInMyGroups"
|
||||||
|
:label="$t('filter-menu.all')"
|
||||||
|
icon="check"
|
||||||
|
@click="setResetFollowers"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
{{ $t('filter-menu.all') }}
|
||||||
|
</base-button>
|
||||||
|
</div>
|
||||||
|
<div class="follower-filter-list">
|
||||||
<li class="item follower-item">
|
<li class="item follower-item">
|
||||||
<base-button
|
<base-button
|
||||||
icon="user-plus"
|
icon="user-plus"
|
||||||
@ -29,6 +41,7 @@
|
|||||||
{{ $t('contribution.filterMyGroups') }}
|
{{ $t('contribution.filterMyGroups') }}
|
||||||
</base-button>
|
</base-button>
|
||||||
</li>
|
</li>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</filter-menu-section>
|
</filter-menu-section>
|
||||||
</template>
|
</template>
|
||||||
@ -51,9 +64,26 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapMutations({
|
...mapMutations({
|
||||||
|
resetFollowers: 'posts/RESET_FOLLOWERS_FILTER',
|
||||||
toggleFilteredByFollowed: 'posts/TOGGLE_FILTER_BY_FOLLOWED',
|
toggleFilteredByFollowed: 'posts/TOGGLE_FILTER_BY_FOLLOWED',
|
||||||
toggleFilteredByMyGroups: 'posts/TOGGLE_FILTER_BY_MY_GROUPS',
|
toggleFilteredByMyGroups: 'posts/TOGGLE_FILTER_BY_MY_GROUPS',
|
||||||
}),
|
}),
|
||||||
|
setResetFollowers() {
|
||||||
|
this.resetFollowers()
|
||||||
|
this.$emit('showFilterMenu')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.follower-filter-list {
|
||||||
|
display: flex;
|
||||||
|
margin-left: $space-xx-small;
|
||||||
|
|
||||||
|
& .base-button {
|
||||||
|
margin-right: $space-xx-small;
|
||||||
|
margin-bottom: $space-xx-small;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -47,6 +47,16 @@ export const mutations = {
|
|||||||
delete filter.categories_some
|
delete filter.categories_some
|
||||||
state.filter = filter
|
state.filter = filter
|
||||||
},
|
},
|
||||||
|
RESET_FOLLOWERS_FILTER(state) {
|
||||||
|
const filter = clone(state.filter)
|
||||||
|
if (get(filter, 'postsInMyGroups')) {
|
||||||
|
delete filter.postsInMyGroups
|
||||||
|
}
|
||||||
|
if (get(filter, 'author.followedBy_some.id')) {
|
||||||
|
delete filter.author
|
||||||
|
}
|
||||||
|
state.filter = filter
|
||||||
|
},
|
||||||
RESET_EMOTIONS(state) {
|
RESET_EMOTIONS(state) {
|
||||||
const filter = clone(state.filter)
|
const filter = clone(state.filter)
|
||||||
delete filter.emotions_some
|
delete filter.emotions_some
|
||||||
|
|||||||
@ -146,6 +146,25 @@ describe('mutations', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('RESET_FOLLOWERS_FILTER', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
testMutation = () => {
|
||||||
|
mutations.RESET_FOLLOWERS_FILTER(state)
|
||||||
|
return getters.filter(state)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('resets the categories filter', () => {
|
||||||
|
state = {
|
||||||
|
filter: {
|
||||||
|
author: { followedBy_some: { id: 4711 } },
|
||||||
|
postsInMyGroups: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
expect(testMutation()).toEqual({})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('TOGGLE_LANGUAGE', () => {
|
describe('TOGGLE_LANGUAGE', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
testMutation = (languageCode) => {
|
testMutation = (languageCode) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user