mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
The name of the hashtag is now it's ID
`name` was just a redundant attribute
This commit is contained in:
parent
bb4b3196a7
commit
51b734275a
@ -198,7 +198,6 @@ describe('Hashtags', () => {
|
|||||||
Post(id: $id) {
|
Post(id: $id) {
|
||||||
tags {
|
tags {
|
||||||
id
|
id
|
||||||
name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,10 +233,7 @@ describe('Hashtags', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('both Hashtags are created with the "id" set to their "name"', async () => {
|
it('both Hashtags are created with the "id" set to their "name"', async () => {
|
||||||
const expected = [
|
const expected = [{ id: 'Democracy' }, { id: 'Liberty' }]
|
||||||
{ id: 'Democracy', name: 'Democracy' },
|
|
||||||
{ id: 'Liberty', name: 'Liberty' },
|
|
||||||
]
|
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
|
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
@ -277,10 +273,7 @@ describe('Hashtags', () => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const expected = [
|
const expected = [{ id: 'Elections' }, { id: 'Liberty' }]
|
||||||
{ id: 'Elections', name: 'Elections' },
|
|
||||||
{ id: 'Liberty', name: 'Liberty' },
|
|
||||||
]
|
|
||||||
await expect(
|
await expect(
|
||||||
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
|
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
|
||||||
).resolves.toEqual(
|
).resolves.toEqual(
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
type Tag {
|
type Tag {
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String!
|
|
||||||
taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN")
|
taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN")
|
||||||
taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN")
|
taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN")
|
||||||
taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p) RETURN COUNT(DISTINCT p)")
|
taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p) RETURN COUNT(DISTINCT p)")
|
||||||
|
|||||||
@ -5,9 +5,9 @@ export default function(params) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
mutation: `
|
mutation: `
|
||||||
mutation($id: ID!, $name: String!) {
|
mutation($id: ID!) {
|
||||||
CreateTag(id: $id, name: $name) {
|
CreateTag(id: $id) {
|
||||||
name
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|||||||
@ -42,9 +42,9 @@ Given("we have a selection of tags and categories as well as posts", () => {
|
|||||||
slug: "health-wellbeing",
|
slug: "health-wellbeing",
|
||||||
icon: "medkit"
|
icon: "medkit"
|
||||||
})
|
})
|
||||||
.create("Tag", { id: "t1", name: "Ecology" })
|
.create("Tag", { id: "Ecology" })
|
||||||
.create("Tag", { id: "t2", name: "Nature" })
|
.create("Tag", { id: "Nature" })
|
||||||
.create("Tag", { id: "t3", name: "Democracy" });
|
.create("Tag", { id: "Democracy" });
|
||||||
|
|
||||||
const someAuthor = {
|
const someAuthor = {
|
||||||
id: "authorId",
|
id: "authorId",
|
||||||
@ -71,14 +71,14 @@ Given("we have a selection of tags and categories as well as posts", () => {
|
|||||||
.relate("Post", "Categories", { from: "p0", to: "cat1" })
|
.relate("Post", "Categories", { from: "p0", to: "cat1" })
|
||||||
.relate("Post", "Categories", { from: "p1", to: "cat2" })
|
.relate("Post", "Categories", { from: "p1", to: "cat2" })
|
||||||
.relate("Post", "Categories", { from: "p2", to: "cat1" })
|
.relate("Post", "Categories", { from: "p2", to: "cat1" })
|
||||||
.relate("Post", "Tags", { from: "p0", to: "t1" })
|
.relate("Post", "Tags", { from: "p0", to: "Ecology" })
|
||||||
.relate("Post", "Tags", { from: "p0", to: "t2" })
|
.relate("Post", "Tags", { from: "p0", to: "Nature" })
|
||||||
.relate("Post", "Tags", { from: "p0", to: "t3" })
|
.relate("Post", "Tags", { from: "p0", to: "Democracy" })
|
||||||
.relate("Post", "Tags", { from: "p1", to: "t2" })
|
.relate("Post", "Tags", { from: "p1", to: "Nature" })
|
||||||
.relate("Post", "Tags", { from: "p1", to: "t3" })
|
.relate("Post", "Tags", { from: "p1", to: "Democracy" })
|
||||||
.relate("Post", "Tags", { from: "p2", to: "t2" })
|
.relate("Post", "Tags", { from: "p2", to: "Nature" })
|
||||||
.relate("Post", "Tags", { from: "p2", to: "t3" })
|
.relate("Post", "Tags", { from: "p2", to: "Democracy" })
|
||||||
.relate("Post", "Tags", { from: "p3", to: "t3" });
|
.relate("Post", "Tags", { from: "p3", to: "Democracy" });
|
||||||
});
|
});
|
||||||
|
|
||||||
Given("we have the following user accounts:", table => {
|
Given("we have the following user accounts:", table => {
|
||||||
|
|||||||
@ -29,7 +29,6 @@ CREATE CONSTRAINT ON (u:User) ASSERT u.id IS UNIQUE;
|
|||||||
CREATE CONSTRAINT ON (o:Organization) ASSERT o.id IS UNIQUE;
|
CREATE CONSTRAINT ON (o:Organization) ASSERT o.id IS UNIQUE;
|
||||||
CREATE CONSTRAINT ON (t:Tag) ASSERT t.id IS UNIQUE;
|
CREATE CONSTRAINT ON (t:Tag) ASSERT t.id IS UNIQUE;
|
||||||
|
|
||||||
|
|
||||||
CREATE CONSTRAINT ON (p:Post) ASSERT p.slug IS UNIQUE;
|
CREATE CONSTRAINT ON (p:Post) ASSERT p.slug IS UNIQUE;
|
||||||
CREATE CONSTRAINT ON (c:Category) ASSERT c.slug IS UNIQUE;
|
CREATE CONSTRAINT ON (c:Category) ASSERT c.slug IS UNIQUE;
|
||||||
CREATE CONSTRAINT ON (u:User) ASSERT u.slug IS UNIQUE;
|
CREATE CONSTRAINT ON (u:User) ASSERT u.slug IS UNIQUE;
|
||||||
|
|||||||
@ -244,9 +244,8 @@ export default {
|
|||||||
query() {
|
query() {
|
||||||
return gql`
|
return gql`
|
||||||
{
|
{
|
||||||
Tag(orderBy: name_asc) {
|
Tag(orderBy: id_asc) {
|
||||||
id
|
id
|
||||||
name
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|||||||
@ -12,15 +12,13 @@
|
|||||||
@click="selectItem(item)"
|
@click="selectItem(item)"
|
||||||
>
|
>
|
||||||
<div v-if="isMention">@{{ item.slug }}</div>
|
<div v-if="isMention">@{{ item.slug }}</div>
|
||||||
<div v-if="isHashtag">#{{ item.name }}</div>
|
<div v-if="isHashtag">#{{ item.id }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isHashtag">
|
<div v-if="isHashtag">
|
||||||
<!-- if query is not empty and is find fully in the suggestions array ... -->
|
<!-- if query is not empty and is find fully in the suggestions array ... -->
|
||||||
<div v-if="query && !filteredItems.find(el => el.name === query)">
|
<div v-if="query && !filteredItems.find(el => el.id === query)">
|
||||||
<div class="suggestion-list__item is-empty">{{ $t('editor.hashtag.addHashtag') }}</div>
|
<div class="suggestion-list__item is-empty">{{ $t('editor.hashtag.addHashtag') }}</div>
|
||||||
<div class="suggestion-list__item" @click="selectItem({ name: query })">
|
<div class="suggestion-list__item" @click="selectItem({ id: query })">#{{ query }}</div>
|
||||||
#{{ query }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- otherwise if sanitized query is empty advice the user to add a char -->
|
<!-- otherwise if sanitized query is empty advice the user to add a char -->
|
||||||
<div v-else-if="!query">
|
<div v-else-if="!query">
|
||||||
@ -40,9 +38,7 @@
|
|||||||
<!-- if "query" is not empty -->
|
<!-- if "query" is not empty -->
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<div class="suggestion-list__item is-empty">{{ $t('editor.hashtag.addHashtag') }}</div>
|
<div class="suggestion-list__item is-empty">{{ $t('editor.hashtag.addHashtag') }}</div>
|
||||||
<div class="suggestion-list__item" @click="selectItem({ name: query })">
|
<div class="suggestion-list__item" @click="selectItem({ id: query })">#{{ query }}</div>
|
||||||
#{{ query }}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -455,7 +451,7 @@ export default {
|
|||||||
// For hashtags handles pressing of space.
|
// For hashtags handles pressing of space.
|
||||||
spaceHandler() {
|
spaceHandler() {
|
||||||
if (this.suggestionType === this.hashtagSuggestionType && this.query !== '') {
|
if (this.suggestionType === this.hashtagSuggestionType && this.query !== '') {
|
||||||
this.selectItem({ name: this.query })
|
this.selectItem({ id: this.query })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// we have to replace our suggestion text with a mention
|
// we have to replace our suggestion text with a mention
|
||||||
@ -467,8 +463,8 @@ export default {
|
|||||||
label: item.slug,
|
label: item.slug,
|
||||||
},
|
},
|
||||||
hashtag: {
|
hashtag: {
|
||||||
id: item.name,
|
id: item.id,
|
||||||
label: item.name,
|
label: item.id,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
this.insertMentionOrHashtag({
|
this.insertMentionOrHashtag({
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-tag>
|
<ds-tag>
|
||||||
<ds-icon name="tag" />
|
<ds-icon name="tag" />
|
||||||
{{ name }}
|
{{ id }}
|
||||||
</ds-tag>
|
</ds-tag>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
export default {
|
export default {
|
||||||
name: 'HcTag',
|
name: 'HcTag',
|
||||||
props: {
|
props: {
|
||||||
name: { type: String, required: true },
|
id: { type: String, required: true },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -6,20 +6,20 @@ const localVue = createLocalVue()
|
|||||||
localVue.use(Styleguide)
|
localVue.use(Styleguide)
|
||||||
|
|
||||||
describe('Tag', () => {
|
describe('Tag', () => {
|
||||||
let name
|
let id
|
||||||
|
|
||||||
let Wrapper = () => {
|
let Wrapper = () => {
|
||||||
return shallowMount(Tag, {
|
return shallowMount(Tag, {
|
||||||
localVue,
|
localVue,
|
||||||
propsData: {
|
propsData: {
|
||||||
name,
|
id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('given a String for Name', () => {
|
describe('given a String for Name', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
name = 'Liebe'
|
id = 'Liebe'
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows Name', () => {
|
it('shows Name', () => {
|
||||||
|
|||||||
@ -34,7 +34,7 @@ export default i18n => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tags {
|
tags {
|
||||||
name
|
id
|
||||||
}
|
}
|
||||||
commentsCount
|
commentsCount
|
||||||
comments(orderBy: createdAt_desc) {
|
comments(orderBy: createdAt_desc) {
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-card :header="$t('admin.tags.name')">
|
<ds-card :header="$t('admin.tags.name')">
|
||||||
<ds-table :data="Tag" :fields="fields" condensed>
|
<ds-table :data="Tag" :fields="fields" condensed>
|
||||||
<template slot="id" slot-scope="scope">
|
<template slot="index" slot-scope="scope">
|
||||||
{{ scope.index + 1 }}.
|
{{ scope.index + 1 }}.
|
||||||
</template>
|
</template>
|
||||||
<template slot="name" slot-scope="scope">
|
<template slot="id" slot-scope="scope">
|
||||||
<nuxt-link :to="{ path: '/', query: { hashtag: scope.row.id } }">
|
<nuxt-link :to="{ path: '/', query: { hashtag: scope.row.id } }">
|
||||||
<b>#{{ scope.row.name | truncate(20) }}</b>
|
<b>#{{ scope.row.id | truncate(20) }}</b>
|
||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</template>
|
</template>
|
||||||
</ds-table>
|
</ds-table>
|
||||||
@ -25,8 +25,8 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
fields() {
|
fields() {
|
||||||
return {
|
return {
|
||||||
id: this.$t('admin.tags.number'),
|
index: this.$t('admin.tags.number'),
|
||||||
name: this.$t('admin.tags.name'),
|
id: this.$t('admin.tags.name'),
|
||||||
taggedCountUnique: {
|
taggedCountUnique: {
|
||||||
label: this.$t('admin.tags.tagCountUnique'),
|
label: this.$t('admin.tags.tagCountUnique'),
|
||||||
align: 'right',
|
align: 'right',
|
||||||
@ -44,7 +44,6 @@ export default {
|
|||||||
query {
|
query {
|
||||||
Tag(first: 20, orderBy: taggedCountUnique_desc) {
|
Tag(first: 20, orderBy: taggedCountUnique_desc) {
|
||||||
id
|
id
|
||||||
name
|
|
||||||
taggedCount
|
taggedCount
|
||||||
taggedCountUnique
|
taggedCountUnique
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
<!-- Tags -->
|
<!-- Tags -->
|
||||||
<div v-if="post.tags && post.tags.length" class="tags">
|
<div v-if="post.tags && post.tags.length" class="tags">
|
||||||
<ds-space margin="xx-small" />
|
<ds-space margin="xx-small" />
|
||||||
<hc-tag v-for="tag in post.tags" :key="tag.id" :name="tag.name" />
|
<hc-tag v-for="tag in post.tags" :key="tag.id" :id="tag.id" />
|
||||||
</div>
|
</div>
|
||||||
<ds-space margin-top="x-large">
|
<ds-space margin-top="x-large">
|
||||||
<ds-flex :gutter="{ lg: 'small' }">
|
<ds-flex :gutter="{ lg: 'small' }">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user