mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +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>
|
||||
<post-type-filter />
|
||||
<following-filter />
|
||||
<following-filter @showFilterMenu="$emit('showFilterMenu')" />
|
||||
<categories-filter v-if="categoriesActive" @showFilterMenu="$emit('showFilterMenu')" />
|
||||
</div>
|
||||
<div v-if="eventSetInPostTypeFilter" class="filter-menu-options">
|
||||
|
||||
@ -10,6 +10,7 @@ describe('FollowingFilter', () => {
|
||||
const mutations = {
|
||||
'posts/TOGGLE_FILTER_BY_FOLLOWED': jest.fn(),
|
||||
'posts/TOGGLE_FILTER_BY_MY_GROUPS': jest.fn(),
|
||||
'posts/RESET_FOLLOWERS_FILTER': jest.fn(),
|
||||
}
|
||||
const getters = {
|
||||
'auth/user': () => {
|
||||
@ -65,5 +66,15 @@ describe('FollowingFilter', () => {
|
||||
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,30 +5,43 @@
|
||||
class="following-filter"
|
||||
>
|
||||
<template #filter-follower>
|
||||
<li class="item follower-item">
|
||||
<div class="item item-all-follower">
|
||||
<base-button
|
||||
icon="user-plus"
|
||||
:label="$t('filter-menu.following')"
|
||||
:filled="filteredByUsersFollowed"
|
||||
:title="$t('contribution.filterFollow')"
|
||||
@click="toggleFilteredByFollowed(currentUser.id)"
|
||||
:filled="!filteredByUsersFollowed && !filteredByPostsInMyGroups"
|
||||
:label="$t('filter-menu.all')"
|
||||
icon="check"
|
||||
@click="setResetFollowers"
|
||||
size="small"
|
||||
>
|
||||
{{ $t('contribution.filterFollow') }}
|
||||
{{ $t('filter-menu.all') }}
|
||||
</base-button>
|
||||
</li>
|
||||
<li class="item posts-in-my-groups-item">
|
||||
<base-button
|
||||
icon="users"
|
||||
:label="$t('filter-menu.my-groups')"
|
||||
:filled="filteredByPostsInMyGroups"
|
||||
:title="$t('contribution.filterMyGroups')"
|
||||
@click="toggleFilteredByMyGroups()"
|
||||
size="small"
|
||||
>
|
||||
{{ $t('contribution.filterMyGroups') }}
|
||||
</base-button>
|
||||
</li>
|
||||
</div>
|
||||
<div class="follower-filter-list">
|
||||
<li class="item follower-item">
|
||||
<base-button
|
||||
icon="user-plus"
|
||||
:label="$t('filter-menu.following')"
|
||||
:filled="filteredByUsersFollowed"
|
||||
:title="$t('contribution.filterFollow')"
|
||||
@click="toggleFilteredByFollowed(currentUser.id)"
|
||||
size="small"
|
||||
>
|
||||
{{ $t('contribution.filterFollow') }}
|
||||
</base-button>
|
||||
</li>
|
||||
<li class="item posts-in-my-groups-item">
|
||||
<base-button
|
||||
icon="users"
|
||||
:label="$t('filter-menu.my-groups')"
|
||||
:filled="filteredByPostsInMyGroups"
|
||||
:title="$t('contribution.filterMyGroups')"
|
||||
@click="toggleFilteredByMyGroups()"
|
||||
size="small"
|
||||
>
|
||||
{{ $t('contribution.filterMyGroups') }}
|
||||
</base-button>
|
||||
</li>
|
||||
</div>
|
||||
</template>
|
||||
</filter-menu-section>
|
||||
</template>
|
||||
@ -51,9 +64,26 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
resetFollowers: 'posts/RESET_FOLLOWERS_FILTER',
|
||||
toggleFilteredByFollowed: 'posts/TOGGLE_FILTER_BY_FOLLOWED',
|
||||
toggleFilteredByMyGroups: 'posts/TOGGLE_FILTER_BY_MY_GROUPS',
|
||||
}),
|
||||
setResetFollowers() {
|
||||
this.resetFollowers()
|
||||
this.$emit('showFilterMenu')
|
||||
},
|
||||
},
|
||||
}
|
||||
</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
|
||||
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) {
|
||||
const filter = clone(state.filter)
|
||||
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', () => {
|
||||
beforeEach(() => {
|
||||
testMutation = (languageCode) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user