mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
sort categories on group profile
This commit is contained in:
parent
ab9b14d756
commit
e2ac3ba846
@ -74,7 +74,7 @@ export default {
|
|||||||
return CategoryQuery()
|
return CategoryQuery()
|
||||||
},
|
},
|
||||||
result({ data: { Category } }) {
|
result({ data: { Category } }) {
|
||||||
this.categories = this.sortCategories(Category, this.$t)
|
this.categories = this.sortCategories(Category)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -86,7 +86,7 @@ export default {
|
|||||||
},
|
},
|
||||||
update({ Category }) {
|
update({ Category }) {
|
||||||
if (!Category) return []
|
if (!Category) return []
|
||||||
this.categories = this.sortCategories(Category, this.$t)
|
this.categories = this.sortCategories(Category)
|
||||||
},
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
sortCategories(categories, locales) {
|
sortCategories(categories) {
|
||||||
const miscSlug = 'miscellaneous'
|
const miscSlug = 'miscellaneous'
|
||||||
const misc = categories.find((cat) => cat.slug === miscSlug)
|
const misc = categories.find((cat) => cat.slug === miscSlug)
|
||||||
const sortedCategories = categories
|
const sortedCategories = categories
|
||||||
.filter((cat) => cat.slug !== miscSlug)
|
.filter((cat) => cat.slug !== miscSlug)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
if (
|
if (
|
||||||
locales(`contribution.category.name.${a.slug}`) <
|
this.$t(`contribution.category.name.${a.slug}`) <
|
||||||
locales(`contribution.category.name.${b.slug}`)
|
this.$t(`contribution.category.name.${b.slug}`)
|
||||||
)
|
)
|
||||||
return -1
|
return -1
|
||||||
if (
|
if (
|
||||||
locales(`contribution.category.name.${a.slug}`) >
|
this.$t(`contribution.category.name.${a.slug}`) >
|
||||||
locales(`contribution.category.name.${b.slug}`)
|
this.$t(`contribution.category.name.${b.slug}`)
|
||||||
)
|
)
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@ -161,7 +161,9 @@
|
|||||||
<ds-space margin="xx-small" />
|
<ds-space margin="xx-small" />
|
||||||
<div class="categories">
|
<div class="categories">
|
||||||
<div
|
<div
|
||||||
v-for="(category, index) in group.categories"
|
v-for="(category, index) in sortCategories(
|
||||||
|
group && group.categories ? group.categories : [],
|
||||||
|
)"
|
||||||
:key="category.id"
|
:key="category.id"
|
||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
@ -326,6 +328,7 @@ import MasonryGridItem from '~/components/MasonryGrid/MasonryGridItem.vue'
|
|||||||
import PostTeaser from '~/components/PostTeaser/PostTeaser.vue'
|
import PostTeaser from '~/components/PostTeaser/PostTeaser.vue'
|
||||||
import ProfileAvatar from '~/components/_new/generic/ProfileAvatar/ProfileAvatar'
|
import ProfileAvatar from '~/components/_new/generic/ProfileAvatar/ProfileAvatar'
|
||||||
import ProfileList from '~/components/features/ProfileList/ProfileList'
|
import ProfileList from '~/components/features/ProfileList/ProfileList'
|
||||||
|
import SortCategories from '~/mixins/sortCategoriesMixin.js'
|
||||||
// import SocialMedia from '~/components/SocialMedia/SocialMedia'
|
// import SocialMedia from '~/components/SocialMedia/SocialMedia'
|
||||||
// import TabNavigation from '~/components/_new/generic/TabNavigation/TabNavigation'
|
// import TabNavigation from '~/components/_new/generic/TabNavigation/TabNavigation'
|
||||||
|
|
||||||
@ -356,7 +359,7 @@ export default {
|
|||||||
// SocialMedia,
|
// SocialMedia,
|
||||||
// TabNavigation,
|
// TabNavigation,
|
||||||
},
|
},
|
||||||
mixins: [postListActions],
|
mixins: [postListActions, SortCategories],
|
||||||
transition: {
|
transition: {
|
||||||
name: 'slide-up',
|
name: 'slide-up',
|
||||||
mode: 'out-in',
|
mode: 'out-in',
|
||||||
|
|||||||
@ -61,7 +61,7 @@
|
|||||||
<ds-space margin="xx-large" />
|
<ds-space margin="xx-large" />
|
||||||
<ds-space margin="xx-small" />
|
<ds-space margin="xx-small" />
|
||||||
<hc-category
|
<hc-category
|
||||||
v-for="category in sortCategories(post.categories, $t)"
|
v-for="category in sortCategories(post.categories)"
|
||||||
:key="category.id"
|
:key="category.id"
|
||||||
:icon="category.icon"
|
:icon="category.icon"
|
||||||
:name="$t(`contribution.category.name.${category.slug}`)"
|
:name="$t(`contribution.category.name.${category.slug}`)"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user