The name of the hashtag is now it's ID

`name` was just a redundant attribute
This commit is contained in:
roschaefer 2019-08-16 00:18:10 +02:00
parent bb4b3196a7
commit 51b734275a
12 changed files with 36 additions and 51 deletions

View File

@ -198,7 +198,6 @@ describe('Hashtags', () => {
Post(id: $id) {
tags {
id
name
}
}
}
@ -234,10 +233,7 @@ describe('Hashtags', () => {
})
it('both Hashtags are created with the "id" set to their "name"', async () => {
const expected = [
{ id: 'Democracy', name: 'Democracy' },
{ id: 'Liberty', name: 'Liberty' },
]
const expected = [{ id: 'Democracy' }, { id: 'Liberty' }]
await expect(
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
).resolves.toEqual(
@ -277,10 +273,7 @@ describe('Hashtags', () => {
},
})
const expected = [
{ id: 'Elections', name: 'Elections' },
{ id: 'Liberty', name: 'Liberty' },
]
const expected = [{ id: 'Elections' }, { id: 'Liberty' }]
await expect(
query({ query: postWithHastagsQuery, variables: postWithHastagsVariables }),
).resolves.toEqual(

View File

@ -1,6 +1,5 @@
type Tag {
id: ID!
name: String!
taggedPosts: [Post]! @relation(name: "TAGGED", direction: "IN")
taggedOrganizations: [Organization]! @relation(name: "TAGGED", direction: "IN")
taggedCount: Int! @cypher(statement: "MATCH (this)<-[:TAGGED]-(p) RETURN COUNT(DISTINCT p)")

View File

@ -5,9 +5,9 @@ export default function(params) {
return {
mutation: `
mutation($id: ID!, $name: String!) {
CreateTag(id: $id, name: $name) {
name
mutation($id: ID!) {
CreateTag(id: $id) {
id
}
}
`,

View File

@ -42,9 +42,9 @@ Given("we have a selection of tags and categories as well as posts", () => {
slug: "health-wellbeing",
icon: "medkit"
})
.create("Tag", { id: "t1", name: "Ecology" })
.create("Tag", { id: "t2", name: "Nature" })
.create("Tag", { id: "t3", name: "Democracy" });
.create("Tag", { id: "Ecology" })
.create("Tag", { id: "Nature" })
.create("Tag", { id: "Democracy" });
const someAuthor = {
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: "p1", to: "cat2" })
.relate("Post", "Categories", { from: "p2", to: "cat1" })
.relate("Post", "Tags", { from: "p0", to: "t1" })
.relate("Post", "Tags", { from: "p0", to: "t2" })
.relate("Post", "Tags", { from: "p0", to: "t3" })
.relate("Post", "Tags", { from: "p1", to: "t2" })
.relate("Post", "Tags", { from: "p1", to: "t3" })
.relate("Post", "Tags", { from: "p2", to: "t2" })
.relate("Post", "Tags", { from: "p2", to: "t3" })
.relate("Post", "Tags", { from: "p3", to: "t3" });
.relate("Post", "Tags", { from: "p0", to: "Ecology" })
.relate("Post", "Tags", { from: "p0", to: "Nature" })
.relate("Post", "Tags", { from: "p0", to: "Democracy" })
.relate("Post", "Tags", { from: "p1", to: "Nature" })
.relate("Post", "Tags", { from: "p1", to: "Democracy" })
.relate("Post", "Tags", { from: "p2", to: "Nature" })
.relate("Post", "Tags", { from: "p2", to: "Democracy" })
.relate("Post", "Tags", { from: "p3", to: "Democracy" });
});
Given("we have the following user accounts:", table => {

View File

@ -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 (t:Tag) ASSERT t.id 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 (u:User) ASSERT u.slug IS UNIQUE;

View File

@ -244,9 +244,8 @@ export default {
query() {
return gql`
{
Tag(orderBy: name_asc) {
Tag(orderBy: id_asc) {
id
name
}
}
`

View File

@ -12,15 +12,13 @@
@click="selectItem(item)"
>
<div v-if="isMention">@{{ item.slug }}</div>
<div v-if="isHashtag">#{{ item.name }}</div>
<div v-if="isHashtag">#{{ item.id }}</div>
</div>
<div v-if="isHashtag">
<!-- 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" @click="selectItem({ name: query })">
#{{ query }}
</div>
<div class="suggestion-list__item" @click="selectItem({ id: query })">#{{ query }}</div>
</div>
<!-- otherwise if sanitized query is empty advice the user to add a char -->
<div v-else-if="!query">
@ -40,9 +38,7 @@
<!-- if "query" is not empty -->
<div v-else>
<div class="suggestion-list__item is-empty">{{ $t('editor.hashtag.addHashtag') }}</div>
<div class="suggestion-list__item" @click="selectItem({ name: query })">
#{{ query }}
</div>
<div class="suggestion-list__item" @click="selectItem({ id: query })">#{{ query }}</div>
</div>
</div>
</div>
@ -455,7 +451,7 @@ export default {
// For hashtags handles pressing of space.
spaceHandler() {
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
@ -467,8 +463,8 @@ export default {
label: item.slug,
},
hashtag: {
id: item.name,
label: item.name,
id: item.id,
label: item.id,
},
}
this.insertMentionOrHashtag({

View File

@ -1,7 +1,7 @@
<template>
<ds-tag>
<ds-icon name="tag" />
{{ name }}
{{ id }}
</ds-tag>
</template>
@ -9,7 +9,7 @@
export default {
name: 'HcTag',
props: {
name: { type: String, required: true },
id: { type: String, required: true },
},
}
</script>

View File

@ -6,20 +6,20 @@ const localVue = createLocalVue()
localVue.use(Styleguide)
describe('Tag', () => {
let name
let id
let Wrapper = () => {
return shallowMount(Tag, {
localVue,
propsData: {
name,
id,
},
})
}
describe('given a String for Name', () => {
beforeEach(() => {
name = 'Liebe'
id = 'Liebe'
})
it('shows Name', () => {

View File

@ -34,7 +34,7 @@ export default i18n => {
}
}
tags {
name
id
}
commentsCount
comments(orderBy: createdAt_desc) {

View File

@ -1,12 +1,12 @@
<template>
<ds-card :header="$t('admin.tags.name')">
<ds-table :data="Tag" :fields="fields" condensed>
<template slot="id" slot-scope="scope">
<template slot="index" slot-scope="scope">
{{ scope.index + 1 }}.
</template>
<template slot="name" slot-scope="scope">
<template slot="id" slot-scope="scope">
<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>
</template>
</ds-table>
@ -25,8 +25,8 @@ export default {
computed: {
fields() {
return {
id: this.$t('admin.tags.number'),
name: this.$t('admin.tags.name'),
index: this.$t('admin.tags.number'),
id: this.$t('admin.tags.name'),
taggedCountUnique: {
label: this.$t('admin.tags.tagCountUnique'),
align: 'right',
@ -44,7 +44,6 @@ export default {
query {
Tag(first: 20, orderBy: taggedCountUnique_desc) {
id
name
taggedCount
taggedCountUnique
}

View File

@ -38,7 +38,7 @@
<!-- Tags -->
<div v-if="post.tags && post.tags.length" class="tags">
<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>
<ds-space margin-top="x-large">
<ds-flex :gutter="{ lg: 'small' }">