mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
sorting result in users and posts
This commit is contained in:
parent
bba5a09ba9
commit
1bf57cbf58
@ -100,6 +100,7 @@ export default {
|
|||||||
}, this.delay)
|
}, this.delay)
|
||||||
},
|
},
|
||||||
onEnter(event) {
|
onEnter(event) {
|
||||||
|
|
||||||
if (this.$router.history.current.path === '/search/search-results') {
|
if (this.$router.history.current.path === '/search/search-results') {
|
||||||
this.$store.commit('search/SET_VALUE', {
|
this.$store.commit('search/SET_VALUE', {
|
||||||
searchValue: this.unprocessedSearchInput,
|
searchValue: this.unprocessedSearchInput,
|
||||||
@ -111,10 +112,12 @@ export default {
|
|||||||
})
|
})
|
||||||
this.clear()
|
this.clear()
|
||||||
} else {
|
} else {
|
||||||
|
if (this.options.length === 0 ) return
|
||||||
this.$router.replace({
|
this.$router.replace({
|
||||||
path: '/search/search-results',
|
path: '/search/search-results',
|
||||||
query: { item: this.unprocessedSearchInput },
|
query: { item: this.unprocessedSearchInput },
|
||||||
})
|
})
|
||||||
|
this.clear()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDelete(event) {
|
onDelete(event) {
|
||||||
|
|||||||
@ -6,8 +6,8 @@ export const findResourcesQuery = gql`
|
|||||||
${postFragment}
|
${postFragment}
|
||||||
${tagsCategoriesAndPinnedFragment}
|
${tagsCategoriesAndPinnedFragment}
|
||||||
|
|
||||||
query($query: String!) {
|
query($query: String!, $limit: Int = 5) {
|
||||||
findResources(query: $query, limit: 5) {
|
findResources(query: $query, limit: $limit) {
|
||||||
__typename
|
__typename
|
||||||
... on Post {
|
... on Post {
|
||||||
...post
|
...post
|
||||||
|
|||||||
@ -1,14 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-container>
|
<ds-container>
|
||||||
<div>
|
<base-button
|
||||||
<ds-flex>
|
class="crop-cancel"
|
||||||
<ds-flex-item>
|
icon="close"
|
||||||
<ds-tag color="primary" size="x-large" round>{{ searchResults.length }}</ds-tag>
|
size="small"
|
||||||
|
circle
|
||||||
|
danger
|
||||||
|
filled
|
||||||
|
rigth
|
||||||
|
@click="closeSearch"
|
||||||
|
/>
|
||||||
|
<ds-section>
|
||||||
|
|
||||||
|
<ds-heading> <ds-tag color="primary" size="x-large" round>{{ searchResults.length }}</ds-tag>
|
||||||
Results for:
|
Results for:
|
||||||
<b>{{ value }}</b>
|
<b>{{ value }}</b></ds-heading>
|
||||||
</ds-flex-item>
|
<ds-text> <ds-button
|
||||||
<ds-flex-item width="2">
|
|
||||||
<ds-button
|
|
||||||
@click="postOnly = !postOnly"
|
@click="postOnly = !postOnly"
|
||||||
:secondary="postOnly"
|
:secondary="postOnly"
|
||||||
size="x-large"
|
size="x-large"
|
||||||
@ -25,31 +32,18 @@
|
|||||||
>
|
>
|
||||||
<ds-tag color="primary" size="x-large" round>{{ users.length }}</ds-tag>
|
<ds-tag color="primary" size="x-large" round>{{ users.length }}</ds-tag>
|
||||||
User
|
User
|
||||||
</ds-button>
|
</ds-button></ds-text>
|
||||||
<ds-button @click="closeSearch" size="x-large" icon="close" right>close</ds-button>
|
</ds-section>
|
||||||
</ds-flex-item>
|
|
||||||
</ds-flex>
|
|
||||||
</div>
|
|
||||||
<ds-space />
|
<ds-space />
|
||||||
|
|
||||||
<ds-space v-if="searchResults.length === 0">no Result</ds-space>
|
|
||||||
|
|
||||||
<!--
|
|
||||||
<ds-space v-for="(posts) in posts" :key="posts.key" class="Post searchresults">
|
|
||||||
<div v-show="postOnly">
|
|
||||||
|
|
||||||
{{ posts }}
|
|
||||||
</div>
|
|
||||||
</ds-space>
|
|
||||||
-->
|
|
||||||
<div>
|
|
||||||
<ds-space />
|
<ds-space />
|
||||||
|
<ds-section>
|
||||||
|
|
||||||
|
|
||||||
<ds-text size="x-large" v-show="userOnly">Menschen</ds-text>
|
<ds-text size="x-large" v-show="userOnly">Menschen</ds-text>
|
||||||
<ds-grid gap="x-small" v-show="userOnly">
|
<ds-space v-if="users.length === 0">no Result</ds-space>
|
||||||
|
<ds-grid v-else gap="x-small" v-show="userOnly">
|
||||||
<ds-grid-item v-for="users in users" :key="users.key" class="User searchresults">
|
<ds-grid-item v-for="users in users" :key="users.key" class="User searchresults">
|
||||||
<div>
|
|
||||||
<ds-placeholder>
|
<ds-placeholder>
|
||||||
<ds-avatar size="large" :title="users.name" :image="users.avatar" />
|
<ds-avatar size="large" :title="users.name" :image="users.avatar" />
|
||||||
{{ users.name }}
|
{{ users.name }}
|
||||||
@ -58,17 +52,22 @@
|
|||||||
<ds-chip>Kommentare</ds-chip>
|
<ds-chip>Kommentare</ds-chip>
|
||||||
</div>
|
</div>
|
||||||
</ds-placeholder>
|
</ds-placeholder>
|
||||||
</div>
|
|
||||||
</ds-grid-item>
|
</ds-grid-item>
|
||||||
</ds-grid>
|
</ds-grid>
|
||||||
|
</ds-section>
|
||||||
|
|
||||||
<ds-space />
|
<ds-space />
|
||||||
<ds-space />
|
<ds-space />
|
||||||
|
|
||||||
|
<ds-section>
|
||||||
|
|
||||||
<ds-text size="x-large" v-show="postOnly">Beiträge</ds-text>
|
<ds-text size="x-large" v-show="postOnly">Beiträge</ds-text>
|
||||||
<ds-list ordered v-show="postOnly">
|
<ds-space v-if="posts.length === 0">no Result</ds-space>
|
||||||
|
<ds-list v-else ordered v-show="postOnly">
|
||||||
<ds-list-item v-for="posts in posts" :key="posts.key" class="Post searchresults">
|
<ds-list-item v-for="posts in posts" :key="posts.key" class="Post searchresults">
|
||||||
<div>
|
<div>
|
||||||
<b>{{ posts.title }}</b>
|
<b>{{ posts.title }}</b>
|
||||||
|
|
||||||
<div v-html="posts.content"></div>
|
<div v-html="posts.content"></div>
|
||||||
<div>
|
<div>
|
||||||
<ds-text size="small">
|
<ds-text size="small">
|
||||||
@ -87,7 +86,6 @@
|
|||||||
:icon="category.icon"
|
:icon="category.icon"
|
||||||
:name="$t(`contribution.category.name.${category.slug}`)"
|
:name="$t(`contribution.category.name.${category.slug}`)"
|
||||||
/>
|
/>
|
||||||
<!-- Post language -->
|
|
||||||
<ds-tag v-if="posts.language" class="category-tag language">
|
<ds-tag v-if="posts.language" class="category-tag language">
|
||||||
<base-icon name="globe" />
|
<base-icon name="globe" />
|
||||||
{{ posts.language.toUpperCase() }}
|
{{ posts.language.toUpperCase() }}
|
||||||
@ -97,8 +95,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</ds-list-item>
|
</ds-list-item>
|
||||||
</ds-list>
|
</ds-list>
|
||||||
</div>
|
|
||||||
|
|
||||||
|
</ds-section>
|
||||||
|
|
||||||
</ds-container>
|
</ds-container>
|
||||||
</template>
|
</template>
|
||||||
@ -124,37 +122,36 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: true,
|
loading: true,
|
||||||
value: '',
|
value: '',
|
||||||
|
|
||||||
pending: false,
|
pending: false,
|
||||||
searchResults: [],
|
searchResults: [],
|
||||||
users: [],
|
|
||||||
posts: [],
|
|
||||||
userOnly: true,
|
userOnly: true,
|
||||||
postOnly: true,
|
postOnly: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
searchValue: 'search/searchValue',
|
searchValue: 'search/searchValue',
|
||||||
orderOptions: 'posts/orderOptions',
|
orderOptions: 'posts/orderOptions',
|
||||||
sortingIcon: 'posts/orderIcon',
|
sortingIcon: 'posts/orderIcon',
|
||||||
}),
|
}),
|
||||||
sortingOptions() {
|
posts() {
|
||||||
return this.orderOptions(this)
|
return this.searchResults.filter(result => result.__typename === 'Post')
|
||||||
|
},
|
||||||
|
users() {
|
||||||
|
return this.searchResults.filter(result => result.__typename === 'User')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
if (this.$route.query.item){
|
||||||
this.value = this.$route.query.item
|
this.value = this.$route.query.item
|
||||||
this.query(this.value)
|
this.query(this.value)
|
||||||
|
} else {
|
||||||
|
this.$router.replace('/')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
searchValue: function(val) {
|
searchValue(value) {
|
||||||
this.users = []
|
this.query(value)
|
||||||
this.posts = []
|
|
||||||
this.value = val
|
|
||||||
this.query(this.value)
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -167,18 +164,12 @@ export default {
|
|||||||
query: findResourcesQuery,
|
query: findResourcesQuery,
|
||||||
variables: {
|
variables: {
|
||||||
query: value,
|
query: value,
|
||||||
|
limit: 37,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
for (var i = 0; i < findResources.length; i++) {
|
|
||||||
if (findResources[i].__typename === 'User') {
|
|
||||||
this.users.push(findResources[i])
|
|
||||||
}
|
|
||||||
if (findResources[i].__typename === 'Post') {
|
|
||||||
this.posts.push(findResources[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('users', this.users)
|
// console.log('users', this.users)
|
||||||
// console.log('posts', this.posts)
|
// console.log('posts', this.posts)
|
||||||
|
console.log("findResources",findResources)
|
||||||
this.searchResults = findResources
|
this.searchResults = findResources
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.searchResults = []
|
this.searchResults = []
|
||||||
@ -193,4 +184,3 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss"></style>
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user