mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #6535 from Ocelot-Social-Community/6500-refactor-filter-menu
refactor(webapp): refactor filter menu
This commit is contained in:
commit
776d7b984c
@ -4,7 +4,7 @@ import CategoriesFilter from './CategoriesFilter'
|
|||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
let wrapper, environmentAndNatureButton, democracyAndPoliticsButton
|
let wrapper, environmentAndNatureButton
|
||||||
|
|
||||||
describe('CategoriesFilter.vue', () => {
|
describe('CategoriesFilter.vue', () => {
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@ -63,12 +63,13 @@ describe('CategoriesFilter.vue', () => {
|
|||||||
expect(allCategoriesButton.attributes().class).toContain('--filled')
|
expect(allCategoriesButton.attributes().class).toContain('--filled')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('sets category button attribute `filled` when corresponding category is filtered', async () => {
|
// TODO move to FilterMenuComponent.spec.js?
|
||||||
getters['posts/filteredCategoryIds'] = jest.fn(() => ['cat9'])
|
// it('sets category button attribute `filled` when corresponding category is filtered', async () => {
|
||||||
wrapper = await Wrapper()
|
// getters['posts/filteredCategoryIds'] = jest.fn(() => ['cat9'])
|
||||||
democracyAndPoliticsButton = wrapper.find('.categories-filter .item-save-topics .base-button')
|
// wrapper = await Wrapper()
|
||||||
expect(democracyAndPoliticsButton.attributes().class).toContain('--filled')
|
// democracyAndPoliticsButton = wrapper.find('.categories-filter .item-save-topics .base-button')
|
||||||
})
|
// expect(democracyAndPoliticsButton.attributes().class).toContain('--filled')
|
||||||
|
// })
|
||||||
|
|
||||||
describe('click on an "catetories-buttons" button', () => {
|
describe('click on an "catetories-buttons" button', () => {
|
||||||
it('calls TOGGLE_CATEGORY when clicked', () => {
|
it('calls TOGGLE_CATEGORY when clicked', () => {
|
||||||
@ -88,13 +89,14 @@ describe('CategoriesFilter.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('save categories', () => {
|
// TODO move to FilterMenuComponent.spec.js?
|
||||||
it('calls the API', async () => {
|
// describe('save categories', () => {
|
||||||
wrapper = await Wrapper()
|
// it('calls the API', async () => {
|
||||||
const saveButton = wrapper.find('.categories-filter .item-save-topics .base-button')
|
// wrapper = await Wrapper()
|
||||||
saveButton.trigger('click')
|
// const saveButton = wrapper.find('.categories-filter .item-save-topics .base-button')
|
||||||
expect(apolloMutationMock).toBeCalled()
|
// saveButton.trigger('click')
|
||||||
})
|
// expect(apolloMutationMock).toBeCalled()
|
||||||
})
|
// })
|
||||||
|
// })
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,27 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<filter-menu-section :title="$t('filter-menu.categories')" class="categories-filter">
|
<filter-menu-section :title="$t('filter-menu.categories')" class="categories-filter">
|
||||||
<template #filter-topics>
|
<template #filter-list>
|
||||||
<li class="item item-all-topics">
|
<div class="item item-all-topics">
|
||||||
<labeled-button
|
<base-button
|
||||||
:filled="!filteredCategoryIds.length"
|
:filled="!filteredCategoryIds.length"
|
||||||
:label="$t('filter-menu.all')"
|
:label="$t('filter-menu.all')"
|
||||||
icon="check"
|
icon="check"
|
||||||
@click="setResetCategories"
|
@click="setResetCategories"
|
||||||
/>
|
size="small"
|
||||||
</li>
|
>
|
||||||
<li class="item item-save-topics">
|
{{ $t('filter-menu.all') }}
|
||||||
<labeled-button filled :label="$t('actions.save')" icon="save" @click="saveCategories" />
|
</base-button>
|
||||||
</li>
|
</div>
|
||||||
</template>
|
|
||||||
|
|
||||||
<template #filter-list>
|
|
||||||
<div class="category-filter-list">
|
<div class="category-filter-list">
|
||||||
<hr />
|
<!-- <ds-space margin="small" /> -->
|
||||||
<ds-space margin="small" />
|
|
||||||
<base-button
|
<base-button
|
||||||
v-for="category in categories"
|
v-for="category in categories"
|
||||||
:key="category.id"
|
:key="category.id"
|
||||||
@click="toggleCategory(category.id)"
|
@click="saveCategories(category.id)"
|
||||||
:filled="filteredCategoryIds.includes(category.id)"
|
:filled="filteredCategoryIds.includes(category.id)"
|
||||||
:icon="category.icon"
|
:icon="category.icon"
|
||||||
size="small"
|
size="small"
|
||||||
@ -40,15 +36,12 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import CategoryQuery from '~/graphql/CategoryQuery.js'
|
import CategoryQuery from '~/graphql/CategoryQuery.js'
|
||||||
import SaveCategories from '~/graphql/SaveCategories.js'
|
|
||||||
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
||||||
import LabeledButton from '~/components/_new/generic/LabeledButton/LabeledButton'
|
|
||||||
import SortCategories from '~/mixins/sortCategoriesMixin.js'
|
import SortCategories from '~/mixins/sortCategoriesMixin.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
FilterMenuSection,
|
FilterMenuSection,
|
||||||
LabeledButton,
|
|
||||||
},
|
},
|
||||||
mixins: [SortCategories],
|
mixins: [SortCategories],
|
||||||
data() {
|
data() {
|
||||||
@ -70,19 +63,9 @@ export default {
|
|||||||
this.resetCategories()
|
this.resetCategories()
|
||||||
this.$emit('showFilterMenu')
|
this.$emit('showFilterMenu')
|
||||||
},
|
},
|
||||||
saveCategories() {
|
saveCategories(categoryId) {
|
||||||
this.$apollo
|
this.toggleCategory(categoryId)
|
||||||
.mutate({
|
this.$emit('updateCategories', categoryId)
|
||||||
mutation: SaveCategories(),
|
|
||||||
variables: { activeCategories: this.filteredCategoryIds },
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
this.$emit('showFilterMenu')
|
|
||||||
this.$toast.success(this.$t('filter-menu.save.success'))
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
this.$toast.error(this.$t('filter-menu.save.error'))
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
@ -101,7 +84,7 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.category-filter-list {
|
.category-filter-list {
|
||||||
margin-left: $space-xx-large;
|
margin-left: $space-xx-small;
|
||||||
|
|
||||||
> .base-button {
|
> .base-button {
|
||||||
margin-right: $space-xx-small;
|
margin-right: $space-xx-small;
|
||||||
|
|||||||
@ -2,24 +2,30 @@
|
|||||||
<filter-menu-section class="order-by-filter" :title="sectionTitle" :divider="false">
|
<filter-menu-section class="order-by-filter" :title="sectionTitle" :divider="false">
|
||||||
<template #filter-list>
|
<template #filter-list>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<labeled-button
|
<base-button
|
||||||
icon="check"
|
icon="check"
|
||||||
:label="$t('filter-menu.ended.all.label')"
|
:label="$t('filter-menu.ended.all.label')"
|
||||||
:filled="!eventsEnded"
|
:filled="!eventsEnded"
|
||||||
:title="$t('filter-menu.ended.all.hint')"
|
:title="$t('filter-menu.ended.all.hint')"
|
||||||
@click="toggleEventsEnded"
|
@click="toggleEventsEnded"
|
||||||
data-test="all-button"
|
data-test="all-button"
|
||||||
/>
|
size="small"
|
||||||
|
>
|
||||||
|
{{ $t('filter-menu.ended.all.label') }}
|
||||||
|
</base-button>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<labeled-button
|
<base-button
|
||||||
icon="calendar"
|
icon="calendar"
|
||||||
:label="$t('filter-menu.ended.onlyEnded.label')"
|
:label="$t('filter-menu.ended.onlyEnded.label')"
|
||||||
:filled="eventsEnded"
|
:filled="eventsEnded"
|
||||||
:title="$t('filter-menu.ended.onlyEnded.hint')"
|
:title="$t('filter-menu.ended.onlyEnded.hint')"
|
||||||
@click="toggleEventsEnded"
|
@click="toggleEventsEnded"
|
||||||
data-test="not-ended-button"
|
data-test="not-ended-button"
|
||||||
/>
|
size="small"
|
||||||
|
>
|
||||||
|
{{ $t('filter-menu.ended.onlyEnded.label') }}
|
||||||
|
</base-button>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</filter-menu-section>
|
</filter-menu-section>
|
||||||
@ -28,13 +34,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
||||||
import LabeledButton from '~/components/_new/generic/LabeledButton/LabeledButton'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'EventsByFilter',
|
name: 'EventsByFilter',
|
||||||
components: {
|
components: {
|
||||||
FilterMenuSection,
|
FilterMenuSection,
|
||||||
LabeledButton,
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
|
|||||||
@ -1,9 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="filter-menu-options">
|
<div class="filter-menu-options">
|
||||||
<h2 class="title">{{ $t('filter-menu.filter-by') }}</h2>
|
<div class="filter-header">
|
||||||
<following-filter />
|
<h2 class="title">{{ $t('filter-menu.filter-by') }}</h2>
|
||||||
|
<div class="item-save-topics">
|
||||||
|
<labeled-button
|
||||||
|
filled
|
||||||
|
:label="$t('actions.saveCategories')"
|
||||||
|
icon="save"
|
||||||
|
@click="saveCategories"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<post-type-filter />
|
<post-type-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">
|
||||||
@ -24,6 +34,8 @@ import PostTypeFilter from './PostTypeFilter'
|
|||||||
import FollowingFilter from './FollowingFilter'
|
import FollowingFilter from './FollowingFilter'
|
||||||
import OrderByFilter from './OrderByFilter'
|
import OrderByFilter from './OrderByFilter'
|
||||||
import CategoriesFilter from './CategoriesFilter'
|
import CategoriesFilter from './CategoriesFilter'
|
||||||
|
import LabeledButton from '~/components/_new/generic/LabeledButton/LabeledButton'
|
||||||
|
import SaveCategories from '~/graphql/SaveCategories.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -32,24 +44,49 @@ export default {
|
|||||||
OrderByFilter,
|
OrderByFilter,
|
||||||
CategoriesFilter,
|
CategoriesFilter,
|
||||||
PostTypeFilter,
|
PostTypeFilter,
|
||||||
|
LabeledButton,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
categoriesActive: this.$env.CATEGORIES_ACTIVE,
|
categoriesActive: this.$env ? this.$env.CATEGORIES_ACTIVE : false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
filteredPostTypes: 'posts/filteredPostTypes',
|
filteredPostTypes: 'posts/filteredPostTypes',
|
||||||
|
filteredCategoryIds: 'posts/filteredCategoryIds',
|
||||||
}),
|
}),
|
||||||
eventSetInPostTypeFilter() {
|
eventSetInPostTypeFilter() {
|
||||||
return this.filteredPostTypes.includes('Event')
|
return this.filteredPostTypes ? this.filteredPostTypes.includes('Event') : null
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
saveCategories() {
|
||||||
|
this.$apollo
|
||||||
|
.mutate({
|
||||||
|
mutation: SaveCategories(),
|
||||||
|
variables: { activeCategories: this.filteredCategoryIds },
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.$emit('showFilterMenu')
|
||||||
|
this.$toast.success(this.$t('filter-menu.save.success'))
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
this.$toast.error(this.$t('filter-menu.save.error'))
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.filter-header {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
& .labeled-button {
|
||||||
|
margin-right: 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
.filter-menu-options {
|
.filter-menu-options {
|
||||||
max-width: $size-max-width-filter-menu;
|
max-width: $size-max-width-filter-menu;
|
||||||
padding: $space-small $space-x-small;
|
padding: $space-small $space-x-small;
|
||||||
|
|||||||
@ -61,18 +61,18 @@ export default {
|
|||||||
|
|
||||||
> .filter-list {
|
> .filter-list {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
padding-left: $space-base;
|
||||||
|
|
||||||
> .item {
|
> .item {
|
||||||
width: 30%;
|
// width: 30%;
|
||||||
padding: 0 $space-x-small;
|
padding: 0 $space-xx-small;
|
||||||
margin-bottom: $space-small;
|
margin-bottom: $space-small;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
@media only screen and (min-width: 800px) {
|
@media only screen and (min-width: 800px) {
|
||||||
width: 20%;
|
// width: 15%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,24 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<filter-menu-section :divider="false" class="following-filter">
|
<filter-menu-section
|
||||||
|
:title="$t('filter-menu.following-title')"
|
||||||
|
:divider="false"
|
||||||
|
class="following-filter"
|
||||||
|
>
|
||||||
<template #filter-follower>
|
<template #filter-follower>
|
||||||
<li class="item follower-item">
|
<div class="item item-all-follower">
|
||||||
<labeled-button
|
<base-button
|
||||||
icon="user-plus"
|
:filled="!filteredByUsersFollowed && !filteredByPostsInMyGroups"
|
||||||
:label="$t('filter-menu.following')"
|
:label="$t('filter-menu.all')"
|
||||||
:filled="filteredByUsersFollowed"
|
icon="check"
|
||||||
:title="$t('contribution.filterFollow')"
|
@click="setResetFollowers"
|
||||||
@click="toggleFilteredByFollowed(currentUser.id)"
|
size="small"
|
||||||
/>
|
>
|
||||||
</li>
|
{{ $t('filter-menu.all') }}
|
||||||
<li class="item posts-in-my-groups-item">
|
</base-button>
|
||||||
<labeled-button
|
</div>
|
||||||
icon="users"
|
<div class="follower-filter-list">
|
||||||
:label="$t('filter-menu.my-groups')"
|
<li class="item follower-item">
|
||||||
:filled="filteredByPostsInMyGroups"
|
<base-button
|
||||||
:title="$t('contribution.filterMyGroups')"
|
icon="user-plus"
|
||||||
@click="toggleFilteredByMyGroups()"
|
:label="$t('filter-menu.following')"
|
||||||
/>
|
:filled="filteredByUsersFollowed"
|
||||||
</li>
|
: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>
|
</template>
|
||||||
</filter-menu-section>
|
</filter-menu-section>
|
||||||
</template>
|
</template>
|
||||||
@ -26,13 +49,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
||||||
import LabeledButton from '~/components/_new/generic/LabeledButton/LabeledButton'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FollowingFilter',
|
name: 'FollowingFilter',
|
||||||
components: {
|
components: {
|
||||||
FilterMenuSection,
|
FilterMenuSection,
|
||||||
LabeledButton,
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
@ -43,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>
|
||||||
|
|||||||
@ -35,7 +35,7 @@ describe('OrderByFilter', () => {
|
|||||||
it('sets "newest-button" attribute `filled`', () => {
|
it('sets "newest-button" attribute `filled`', () => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="newest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="newest-button"]')
|
||||||
.classes('--filled'),
|
.classes('--filled'),
|
||||||
).toBe(true)
|
).toBe(true)
|
||||||
})
|
})
|
||||||
@ -43,7 +43,7 @@ describe('OrderByFilter', () => {
|
|||||||
it('don\'t sets "oldest-button" attribute `filled`', () => {
|
it('don\'t sets "oldest-button" attribute `filled`', () => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="oldest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="oldest-button"]')
|
||||||
.classes('--filled'),
|
.classes('--filled'),
|
||||||
).toBe(false)
|
).toBe(false)
|
||||||
})
|
})
|
||||||
@ -58,7 +58,7 @@ describe('OrderByFilter', () => {
|
|||||||
it('don\'t sets "newest-button" attribute `filled`', () => {
|
it('don\'t sets "newest-button" attribute `filled`', () => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="newest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="newest-button"]')
|
||||||
.classes('--filled'),
|
.classes('--filled'),
|
||||||
).toBe(false)
|
).toBe(false)
|
||||||
})
|
})
|
||||||
@ -66,7 +66,7 @@ describe('OrderByFilter', () => {
|
|||||||
it('sets "oldest-button" attribute `filled`', () => {
|
it('sets "oldest-button" attribute `filled`', () => {
|
||||||
expect(
|
expect(
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="oldest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="oldest-button"]')
|
||||||
.classes('--filled'),
|
.classes('--filled'),
|
||||||
).toBe(true)
|
).toBe(true)
|
||||||
})
|
})
|
||||||
@ -75,7 +75,7 @@ describe('OrderByFilter', () => {
|
|||||||
describe('click "newest-button"', () => {
|
describe('click "newest-button"', () => {
|
||||||
it('calls TOGGLE_ORDER with "createdAt_desc"', () => {
|
it('calls TOGGLE_ORDER with "createdAt_desc"', () => {
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="newest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="newest-button"]')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
expect(mutations['posts/TOGGLE_ORDER']).toHaveBeenCalledWith({}, 'createdAt_desc')
|
expect(mutations['posts/TOGGLE_ORDER']).toHaveBeenCalledWith({}, 'createdAt_desc')
|
||||||
})
|
})
|
||||||
@ -84,7 +84,7 @@ describe('OrderByFilter', () => {
|
|||||||
describe('click "oldest-button"', () => {
|
describe('click "oldest-button"', () => {
|
||||||
it('calls TOGGLE_ORDER with "createdAt_asc"', () => {
|
it('calls TOGGLE_ORDER with "createdAt_asc"', () => {
|
||||||
wrapper
|
wrapper
|
||||||
.find('.order-by-filter .filter-list [data-test="oldest-button"] .base-button')
|
.find('.order-by-filter .filter-list .base-button[data-test="oldest-button"]')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
expect(mutations['posts/TOGGLE_ORDER']).toHaveBeenCalledWith({}, 'createdAt_asc')
|
expect(mutations['posts/TOGGLE_ORDER']).toHaveBeenCalledWith({}, 'createdAt_asc')
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,24 +2,30 @@
|
|||||||
<filter-menu-section class="order-by-filter" :title="sectionTitle" :divider="false">
|
<filter-menu-section class="order-by-filter" :title="sectionTitle" :divider="false">
|
||||||
<template #filter-list>
|
<template #filter-list>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<labeled-button
|
<base-button
|
||||||
icon="sort-amount-asc"
|
icon="sort-amount-asc"
|
||||||
:label="buttonLabel('desc')"
|
:label="buttonLabel('desc')"
|
||||||
:filled="orderBy === orderedDesc"
|
:filled="orderBy === orderedDesc"
|
||||||
:title="buttonTitle('desc')"
|
:title="buttonTitle('desc')"
|
||||||
@click="toggleOrder(orderedDesc)"
|
@click="toggleOrder(orderedDesc)"
|
||||||
data-test="newest-button"
|
data-test="newest-button"
|
||||||
/>
|
size="small"
|
||||||
|
>
|
||||||
|
{{ buttonLabel('desc') }}
|
||||||
|
</base-button>
|
||||||
</li>
|
</li>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<labeled-button
|
<base-button
|
||||||
icon="sort-amount-desc"
|
icon="sort-amount-desc"
|
||||||
:label="buttonLabel('asc')"
|
:label="buttonLabel('asc')"
|
||||||
:filled="orderBy === orderedAsc"
|
:filled="orderBy === orderedAsc"
|
||||||
:title="buttonTitle('asc')"
|
:title="buttonTitle('asc')"
|
||||||
@click="toggleOrder(orderedAsc)"
|
@click="toggleOrder(orderedAsc)"
|
||||||
data-test="oldest-button"
|
data-test="oldest-button"
|
||||||
/>
|
size="small"
|
||||||
|
>
|
||||||
|
{{ buttonTitle('asc') }}
|
||||||
|
</base-button>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</filter-menu-section>
|
</filter-menu-section>
|
||||||
@ -28,13 +34,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations } from 'vuex'
|
import { mapGetters, mapMutations } from 'vuex'
|
||||||
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
import FilterMenuSection from '~/components/FilterMenu/FilterMenuSection'
|
||||||
import LabeledButton from '~/components/_new/generic/LabeledButton/LabeledButton'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'OrderByFilter',
|
name: 'OrderByFilter',
|
||||||
components: {
|
components: {
|
||||||
FilterMenuSection,
|
FilterMenuSection,
|
||||||
LabeledButton,
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
<filter-menu-section
|
<filter-menu-section
|
||||||
:title="$t('filter-menu.post-type')"
|
:title="$t('filter-menu.post-type')"
|
||||||
:divider="false"
|
:divider="false"
|
||||||
class="following-filter"
|
class="following-filter post-type-filter"
|
||||||
>
|
>
|
||||||
<template #filter-follower>
|
<template #filter-follower>
|
||||||
<li class="item all-item">
|
<li class="item all-item">
|
||||||
@ -12,7 +12,9 @@
|
|||||||
:filled="filteredPostTypes.length === 0"
|
:filled="filteredPostTypes.length === 0"
|
||||||
:title="$t('filter-menu.all')"
|
:title="$t('filter-menu.all')"
|
||||||
@click="togglePostType(null)"
|
@click="togglePostType(null)"
|
||||||
/>
|
>
|
||||||
|
{{ $t('filter-menu.all') }}
|
||||||
|
</labeled-button>
|
||||||
</li>
|
</li>
|
||||||
<li class="item article-item">
|
<li class="item article-item">
|
||||||
<labeled-button
|
<labeled-button
|
||||||
@ -59,3 +61,13 @@ export default {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.post-type-filter {
|
||||||
|
& .filter-list {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 10%);
|
||||||
|
padding-left: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"edit": "Bearbeiten",
|
"edit": "Bearbeiten",
|
||||||
"loading": "wird geladen",
|
"loading": "wird geladen",
|
||||||
"loadMore": "mehr laden",
|
"loadMore": "mehr laden",
|
||||||
"save": "Speichern"
|
"save": "Speichern",
|
||||||
|
"saveCategories": "Themen speichern"
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
"categories": {
|
"categories": {
|
||||||
@ -298,16 +299,16 @@
|
|||||||
"happy": "Glücklich",
|
"happy": "Glücklich",
|
||||||
"surprised": "Erstaunt"
|
"surprised": "Erstaunt"
|
||||||
},
|
},
|
||||||
"filterFollow": "Beiträge von Nutzern filtern, denen ich folge",
|
"filterFollow": "Nutzern, denen ich folge",
|
||||||
"filterMasonryGrid": {
|
"filterMasonryGrid": {
|
||||||
"myFriends": "Nutzer denen ich folge",
|
"myFriends": "Nutzer denen ich folge",
|
||||||
"myGroups": "Aus meinen Gruppen",
|
"myGroups": "Aus meinen Gruppen",
|
||||||
"myTopics": "Meine Themen",
|
"myTopics": "Meine Themen",
|
||||||
"noFilter": "Inhalt filtern",
|
"noFilter": "Inhalte filtern",
|
||||||
"onlyArticles": "Nur Beiträge",
|
"onlyArticles": "Beiträge",
|
||||||
"onlyEvents": "Nur Veranstaltungen"
|
"onlyEvents": "Veranstaltungen"
|
||||||
},
|
},
|
||||||
"filterMyGroups": "Beiträge in meinen Gruppen",
|
"filterMyGroups": "Meine Gruppen",
|
||||||
"inappropriatePicture": "Dieses Bild kann für einige Menschen unangemessen sein.",
|
"inappropriatePicture": "Dieses Bild kann für einige Menschen unangemessen sein.",
|
||||||
"languageSelectLabel": "Sprache Deines Beitrags",
|
"languageSelectLabel": "Sprache Deines Beitrags",
|
||||||
"languageSelectText": "Sprache wählen",
|
"languageSelectText": "Sprache wählen",
|
||||||
@ -418,21 +419,22 @@
|
|||||||
"emotions": "Emotionen",
|
"emotions": "Emotionen",
|
||||||
"ended": {
|
"ended": {
|
||||||
"all": {
|
"all": {
|
||||||
"hint": "Zeige alle, auch beendete",
|
"hint": "Zeige alle, auch zukünftige",
|
||||||
"label": "Alle"
|
"label": "Alle"
|
||||||
},
|
},
|
||||||
"onlyEnded": {
|
"onlyEnded": {
|
||||||
"hint": "Zeige nur noch nicht beendete",
|
"hint": "Zeige nur noch zukünftige",
|
||||||
"label": "Nicht beendete"
|
"label": "Zukünftige"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"event": "Veranstaltung",
|
"event": "Veranstaltung",
|
||||||
"eventsBy": "Veranstaltungen – zeige ...",
|
"eventsBy": "Veranstaltungen – zeige ...",
|
||||||
"eventsEnded": "Beendet",
|
"eventsEnded": "Beendet",
|
||||||
"filter-by": "Filtern nach ...",
|
"filter-by": "Filtern nach ...",
|
||||||
"following": "Nutzer denen ich folge",
|
"following": "Nutzer, denen ich folge",
|
||||||
|
"following-title": "Quellen",
|
||||||
"languages": "Sprachen",
|
"languages": "Sprachen",
|
||||||
"my-groups": "Meinen Gruppen",
|
"my-groups": "Meine Gruppen",
|
||||||
"order": {
|
"order": {
|
||||||
"last": {
|
"last": {
|
||||||
"hint": "Sortiere die Letzten nach vorn",
|
"hint": "Sortiere die Letzten nach vorn",
|
||||||
|
|||||||
@ -6,7 +6,8 @@
|
|||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"loading": "loading",
|
"loading": "loading",
|
||||||
"loadMore": "load more",
|
"loadMore": "load more",
|
||||||
"save": "Save"
|
"save": "Save",
|
||||||
|
"saveCategories": "Save topics"
|
||||||
},
|
},
|
||||||
"admin": {
|
"admin": {
|
||||||
"categories": {
|
"categories": {
|
||||||
@ -298,16 +299,16 @@
|
|||||||
"happy": "Happy",
|
"happy": "Happy",
|
||||||
"surprised": "Surprised"
|
"surprised": "Surprised"
|
||||||
},
|
},
|
||||||
"filterFollow": "Filter contributions from users I follow",
|
"filterFollow": "Users I follow",
|
||||||
"filterMasonryGrid": {
|
"filterMasonryGrid": {
|
||||||
"myFriends": "Users I follow",
|
"myFriends": "Users I follow",
|
||||||
"myGroups": "By my groups",
|
"myGroups": "By my groups",
|
||||||
"myTopics": "My topics",
|
"myTopics": "My topics",
|
||||||
"noFilter": "Filter content",
|
"noFilter": "Filter content",
|
||||||
"onlyArticles": "Only articles",
|
"onlyArticles": "Articles",
|
||||||
"onlyEvents": "Only events"
|
"onlyEvents": "Events"
|
||||||
},
|
},
|
||||||
"filterMyGroups": "Contributions in my groups",
|
"filterMyGroups": "My groups",
|
||||||
"inappropriatePicture": "This image may be inappropriate for some people.",
|
"inappropriatePicture": "This image may be inappropriate for some people.",
|
||||||
"languageSelectLabel": "Language of your contribution",
|
"languageSelectLabel": "Language of your contribution",
|
||||||
"languageSelectText": "Select Language",
|
"languageSelectText": "Select Language",
|
||||||
@ -431,6 +432,7 @@
|
|||||||
"eventsEnded": "Ended",
|
"eventsEnded": "Ended",
|
||||||
"filter-by": "Filter by ...",
|
"filter-by": "Filter by ...",
|
||||||
"following": "Users I follow",
|
"following": "Users I follow",
|
||||||
|
"following-title": "Sources",
|
||||||
"languages": "Languages",
|
"languages": "Languages",
|
||||||
"my-groups": "My groups",
|
"my-groups": "My groups",
|
||||||
"order": {
|
"order": {
|
||||||
|
|||||||
@ -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