From 51b734275a12c5c57d916ecceda7271b9b2a5df2 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 16 Aug 2019 00:18:10 +0200 Subject: [PATCH] The name of the hashtag is now it's ID `name` was just a redundant attribute --- .../handleContentData.spec.js | 11 ++-------- backend/src/schema/types/type/Tag.gql | 1 - backend/src/seed/factories/tags.js | 6 ++--- cypress/integration/common/steps.js | 22 +++++++++---------- neo4j/db_setup.sh | 1 - .../ContributionForm/ContributionForm.vue | 3 +-- webapp/components/Editor/Editor.vue | 18 ++++++--------- webapp/components/Tag/index.vue | 4 ++-- webapp/components/Tag/spec.js | 6 ++--- webapp/graphql/PostQuery.js | 2 +- webapp/pages/admin/tags.vue | 11 +++++----- webapp/pages/post/_id/_slug/index.vue | 2 +- 12 files changed, 36 insertions(+), 51 deletions(-) diff --git a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js index 40d8a2481..fb088e428 100644 --- a/backend/src/middleware/handleHtmlContent/handleContentData.spec.js +++ b/backend/src/middleware/handleHtmlContent/handleContentData.spec.js @@ -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( diff --git a/backend/src/schema/types/type/Tag.gql b/backend/src/schema/types/type/Tag.gql index 47021bf82..c9c36343a 100644 --- a/backend/src/schema/types/type/Tag.gql +++ b/backend/src/schema/types/type/Tag.gql @@ -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)") diff --git a/backend/src/seed/factories/tags.js b/backend/src/seed/factories/tags.js index 15ded1986..4a135e051 100644 --- a/backend/src/seed/factories/tags.js +++ b/backend/src/seed/factories/tags.js @@ -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 } } `, diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index e1eab98c1..4abade0fa 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -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 => { diff --git a/neo4j/db_setup.sh b/neo4j/db_setup.sh index d4c7b9af8..51276cf39 100755 --- a/neo4j/db_setup.sh +++ b/neo4j/db_setup.sh @@ -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; diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index dca23a882..9d1c92cc9 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -244,9 +244,8 @@ export default { query() { return gql` { - Tag(orderBy: name_asc) { + Tag(orderBy: id_asc) { id - name } } ` diff --git a/webapp/components/Editor/Editor.vue b/webapp/components/Editor/Editor.vue index 4a4880eeb..fce3889d2 100644 --- a/webapp/components/Editor/Editor.vue +++ b/webapp/components/Editor/Editor.vue @@ -12,15 +12,13 @@ @click="selectItem(item)" >
@{{ item.slug }}
-
#{{ item.name }}
+
#{{ item.id }}
-
+
{{ $t('editor.hashtag.addHashtag') }}
-
- #{{ query }} -
+
#{{ query }}
@@ -40,9 +38,7 @@
{{ $t('editor.hashtag.addHashtag') }}
-
- #{{ query }} -
+
#{{ query }}
@@ -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({ diff --git a/webapp/components/Tag/index.vue b/webapp/components/Tag/index.vue index 9337c02a6..1895d4fcf 100644 --- a/webapp/components/Tag/index.vue +++ b/webapp/components/Tag/index.vue @@ -1,7 +1,7 @@ @@ -9,7 +9,7 @@ export default { name: 'HcTag', props: { - name: { type: String, required: true }, + id: { type: String, required: true }, }, } diff --git a/webapp/components/Tag/spec.js b/webapp/components/Tag/spec.js index 6a82ce641..4824c65fc 100644 --- a/webapp/components/Tag/spec.js +++ b/webapp/components/Tag/spec.js @@ -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', () => { diff --git a/webapp/graphql/PostQuery.js b/webapp/graphql/PostQuery.js index 9d54a5d2b..f5da8dc56 100644 --- a/webapp/graphql/PostQuery.js +++ b/webapp/graphql/PostQuery.js @@ -34,7 +34,7 @@ export default i18n => { } } tags { - name + id } commentsCount comments(orderBy: createdAt_desc) { diff --git a/webapp/pages/admin/tags.vue b/webapp/pages/admin/tags.vue index c5a28dc11..9ede1d502 100644 --- a/webapp/pages/admin/tags.vue +++ b/webapp/pages/admin/tags.vue @@ -1,12 +1,12 @@