mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
partially working, index page does not update when route is changed
This commit is contained in:
parent
16ad565ec8
commit
014be6e7f8
@ -43,6 +43,16 @@ export default {
|
|||||||
`
|
`
|
||||||
const myQuery = queryString(query)
|
const myQuery = queryString(query)
|
||||||
|
|
||||||
|
const tagCypher = `
|
||||||
|
CALL db.index.fulltext.queryNodes('tag_fulltext_search', $query)
|
||||||
|
YIELD node as resource, score
|
||||||
|
MATCH (resource)
|
||||||
|
WHERE score >= 0.5
|
||||||
|
AND NOT (resource.deleted = true OR resource.disabled = true)
|
||||||
|
RETURN resource {.*, __typename: labels(resource)[0]}
|
||||||
|
LIMIT $limit
|
||||||
|
`
|
||||||
|
|
||||||
const session = context.driver.session()
|
const session = context.driver.session()
|
||||||
const searchResultPromise = session.readTransaction(async transaction => {
|
const searchResultPromise = session.readTransaction(async transaction => {
|
||||||
const postTransactionResponse = transaction.run(postCypher, {
|
const postTransactionResponse = transaction.run(postCypher, {
|
||||||
@ -55,14 +65,25 @@ export default {
|
|||||||
limit,
|
limit,
|
||||||
thisUserId,
|
thisUserId,
|
||||||
})
|
})
|
||||||
return Promise.all([postTransactionResponse, userTransactionResponse])
|
const tagTransactionResponse = transaction.run(tagCypher, {
|
||||||
|
query: myQuery,
|
||||||
|
limit,
|
||||||
|
})
|
||||||
|
return Promise.all([
|
||||||
|
postTransactionResponse,
|
||||||
|
userTransactionResponse,
|
||||||
|
tagTransactionResponse,
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [postResults, userResults] = await searchResultPromise
|
const [postResults, userResults, tagResults] = await searchResultPromise
|
||||||
log(postResults)
|
log(postResults)
|
||||||
log(userResults)
|
log(userResults)
|
||||||
return [...postResults.records, ...userResults.records].map(r => r.get('resource'))
|
log(tagResults)
|
||||||
|
return [...postResults.records, ...userResults.records, ...tagResults.records].map(r =>
|
||||||
|
r.get('resource'),
|
||||||
|
)
|
||||||
} finally {
|
} finally {
|
||||||
session.close()
|
session.close()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
union SearchResult = Post | User
|
union SearchResult = Post | User | Tag
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
findResources(query: String!, limit: Int = 5): [SearchResult]!
|
findResources(query: String!, limit: Int = 5): [SearchResult]!
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-tag>
|
<ds-tag class="hc-hashtag">
|
||||||
<nuxt-link :to="hashtagUrl">#{{ id }}</nuxt-link>
|
<nuxt-link :to="hashtagUrl">#{{ id }}</nuxt-link>
|
||||||
</ds-tag>
|
</ds-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -6,18 +6,18 @@
|
|||||||
</ds-flex>
|
</ds-flex>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: 'SearchTag',
|
name: 'SearchTag',
|
||||||
props: {
|
props: {
|
||||||
option: { type: Object, required: true },
|
option: { type: Object, required: true },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.search-tag {
|
.search-tag {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
.search-tag-label {
|
.search-tag-label {
|
||||||
color: $text-color-primary;
|
color: $text-color-primary;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -35,6 +35,12 @@
|
|||||||
>
|
>
|
||||||
<search-post :option="option" />
|
<search-post :option="option" />
|
||||||
</p>
|
</p>
|
||||||
|
<p
|
||||||
|
v-if="option.__typename === 'Tag'"
|
||||||
|
:class="{ 'option-with-heading': isFirstOfType(option) }"
|
||||||
|
>
|
||||||
|
<hc-hashtag :id="option.id" />
|
||||||
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</ds-select>
|
</ds-select>
|
||||||
<base-button v-if="isActive" icon="close" circle ghost size="small" @click="clear" />
|
<base-button v-if="isActive" icon="close" circle ghost size="small" @click="clear" />
|
||||||
@ -45,6 +51,7 @@
|
|||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
import SearchHeading from '~/components/generic/SearchHeading/SearchHeading.vue'
|
import SearchHeading from '~/components/generic/SearchHeading/SearchHeading.vue'
|
||||||
import SearchPost from '~/components/generic/SearchPost/SearchPost.vue'
|
import SearchPost from '~/components/generic/SearchPost/SearchPost.vue'
|
||||||
|
import HcHashtag from '~/components/Hashtag/Hashtag.vue'
|
||||||
import UserTeaser from '~/components/UserTeaser/UserTeaser.vue'
|
import UserTeaser from '~/components/UserTeaser/UserTeaser.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -52,6 +59,7 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
SearchHeading,
|
SearchHeading,
|
||||||
SearchPost,
|
SearchPost,
|
||||||
|
HcHashtag,
|
||||||
UserTeaser,
|
UserTeaser,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -77,6 +85,16 @@ export default {
|
|||||||
return !isEmpty(this.previousSearchTerm)
|
return !isEmpty(this.previousSearchTerm)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
$route(to, from) {
|
||||||
|
console.log('to', to)
|
||||||
|
console.log('from', from)
|
||||||
|
// console.log(this.finalFilters)
|
||||||
|
if (to.query.hashtag) {
|
||||||
|
this.hashtag = to.query.hashtag
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
isFirstOfType(option) {
|
isFirstOfType(option) {
|
||||||
return (
|
return (
|
||||||
@ -138,12 +156,20 @@ export default {
|
|||||||
isPost(item) {
|
isPost(item) {
|
||||||
return item.__typename === 'Post'
|
return item.__typename === 'Post'
|
||||||
},
|
},
|
||||||
|
isTag(item) {
|
||||||
|
return item.__typename === 'Tag'
|
||||||
|
},
|
||||||
goToResource(item) {
|
goToResource(item) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$router.push({
|
if (!this.isTag(item)) {
|
||||||
name: this.isPost(item) ? 'post-id-slug' : 'profile-id-slug',
|
this.$router.push({
|
||||||
params: { id: item.id, slug: item.slug },
|
name: this.isPost(item) ? 'post-id-slug' : 'profile-id-slug',
|
||||||
})
|
params: { id: item.id, slug: item.slug },
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('HIT¡')
|
||||||
|
this.$router.push('?hashtag=' + item.id)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@ -19,6 +19,9 @@ export const findResourcesQuery = gql`
|
|||||||
... on User {
|
... on User {
|
||||||
...user
|
...user
|
||||||
}
|
}
|
||||||
|
... on Tag {
|
||||||
|
id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -558,6 +558,35 @@
|
|||||||
"message": "Bist Du sicher, dass Du den Kommentar von „<b>{name}</b>“ melden möchtest?",
|
"message": "Bist Du sicher, dass Du den Kommentar von „<b>{name}</b>“ melden möchtest?",
|
||||||
"title": "Kommentar melden",
|
"title": "Kommentar melden",
|
||||||
"type": "Kommentar"
|
"type": "Kommentar"
|
||||||
|
"content": {
|
||||||
|
"unavailable-placeholder": "… dieser Kommentar ist nicht mehr verfügbar"
|
||||||
|
},
|
||||||
|
"menu": {
|
||||||
|
"edit": "Kommentar bearbeiten",
|
||||||
|
"delete": "Kommentar löschen"
|
||||||
|
},
|
||||||
|
"show": {
|
||||||
|
"more": "mehr anzeigen",
|
||||||
|
"less": "weniger anzeigen"
|
||||||
|
},
|
||||||
|
"edited": "bearbeitet"
|
||||||
|
},
|
||||||
|
"followButton": {
|
||||||
|
"follow": "Folgen",
|
||||||
|
"following": "Folge Ich"
|
||||||
|
},
|
||||||
|
"shoutButton": {
|
||||||
|
"shouted": "empfohlen"
|
||||||
|
},
|
||||||
|
"search": {
|
||||||
|
"placeholder": "Suchen",
|
||||||
|
"hint": "Wonach suchst Du?",
|
||||||
|
"failed": "Nichts gefunden",
|
||||||
|
"heading": {
|
||||||
|
"Post": "Beiträge",
|
||||||
|
"User": "Benutzer",
|
||||||
|
"Tag": "Hashtags"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"contribution": {
|
"contribution": {
|
||||||
"error": "Du hast den Beitrag bereits gemeldet!",
|
"error": "Du hast den Beitrag bereits gemeldet!",
|
||||||
|
|||||||
@ -549,6 +549,16 @@
|
|||||||
"message": "Do you really want to release the user \"<b>{name}</b>\"?",
|
"message": "Do you really want to release the user \"<b>{name}</b>\"?",
|
||||||
"title": "Release User",
|
"title": "Release User",
|
||||||
"type": "User"
|
"type": "User"
|
||||||
|
"empty": "Sorry, you don't have any notifications at the moment."
|
||||||
|
},
|
||||||
|
"search": {
|
||||||
|
"placeholder": "Search",
|
||||||
|
"hint": "What are you searching for?",
|
||||||
|
"failed": "Nothing found",
|
||||||
|
"heading": {
|
||||||
|
"Post": "Posts",
|
||||||
|
"User": "Users",
|
||||||
|
"Tag": "Hashtags"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"report": {
|
"report": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user