From b76354d95d23562e832f0a3ffe3d36aa94430bbb Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Nov 2019 09:12:13 +0100 Subject: [PATCH 01/18] 2119-Fix consistent form input validation --- .../ContributionForm/ContributionForm.vue | 59 +++++++++++++++++-- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index eb849c71f..e27730584 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -21,7 +21,26 @@ name="title" autofocus /> - {{ form.title.length }}/{{ formSchema.title.max }} + + + {{ form.title.length }}/{{ formSchema.title.max }} + + + + {{ form.title.length }}/{{ formSchema.title.max }} + + + + {{ form.title.length }}/{{ formSchema.title.max }} + + + + - {{ form.contentLength }} + + {{ form.contentLength }} + + + + + + + @@ -113,7 +156,7 @@ export default { }, formSchema: { title: { required: true, min: 3, max: 100 }, - content: [{ required: true }], + content: { required: true, min: 3 }, }, id: null, loading: false, @@ -204,9 +247,7 @@ export default { this.manageContent(value) }, manageContent(content) { - // filter HTML out of content value - const str = content.replace(/<\/?[^>]+(>|$)/gm, '') - // Set counter length of text + let str = content.replace(/<\/?[^>]+(>|$)/gm, '') this.form.contentLength = str.length this.validatePost() }, @@ -288,4 +329,10 @@ export default { padding-right: 0; } } +.checkicon { + top: -18px; +} +.checkicon_cat { + top: -38px; +} From 32c5ea1d52bffa60995dd389587097a11fd334c6 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Nov 2019 09:23:00 +0100 Subject: [PATCH 02/18] fix category if fail, fix lint --- webapp/components/ContributionForm/ContributionForm.vue | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index e27730584..1ba254aac 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -40,7 +40,6 @@ - Date: Thu, 7 Nov 2019 11:39:07 +0100 Subject: [PATCH 03/18] fix css - checkbutton cursor: default --- webapp/components/ContributionForm/ContributionForm.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 1ba254aac..22b0f9ba3 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -329,6 +329,7 @@ export default { } } .checkicon { + cursor: default; top: -18px; } .checkicon_cat { From e4cbf9246bf3e6f8130bc28db108fdc26487bae2 Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Nov 2019 13:00:28 +0100 Subject: [PATCH 04/18] better style and dom --- .../ContributionForm/ContributionForm.vue | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 22b0f9ba3..f6ebf6bcc 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -24,7 +24,7 @@ {{ form.title.length }}/{{ formSchema.title.max }} - + {{ form.title.length }}/{{ formSchema.title.max }} - + @@ -48,14 +48,18 @@ @input="updateEditorContent" /> - {{ form.contentLength }} - - + size="base" + > + {{ form.contentLength }} + + + + {{ form.contentLength }} + + @@ -65,19 +69,14 @@ :existingCategoryIds="form.categoryIds" /> - - + + {{ form.categoryIds.length }} / 3 + + + + {{ form.categoryIds.length }} / 3 + + @@ -333,6 +332,6 @@ export default { top: -18px; } .checkicon_cat { - top: -38px; + top: -58px; } From 253032468f8a1913adb0896c86304e78dd1f5f2c Mon Sep 17 00:00:00 2001 From: roschaefer Date: Thu, 7 Nov 2019 14:17:22 +0100 Subject: [PATCH 05/18] Refactor: Re-use validation via error slot --- .../ContributionForm/ContributionForm.vue | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index f6ebf6bcc..4c55a89b3 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -22,22 +22,12 @@ autofocus /> - + {{ form.title.length }}/{{ formSchema.title.max }} - + {{ form.title.length }}/{{ formSchema.title.max }} - - - - {{ form.title.length }}/{{ formSchema.title.max }} - From c83a808825a7676edde2a5f34714297626035f2a Mon Sep 17 00:00:00 2001 From: roschaefer Date: Thu, 7 Nov 2019 14:22:05 +0100 Subject: [PATCH 06/18] Refactor content length validation with transform --- .../ContributionForm/ContributionForm.vue | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index 4c55a89b3..224390d7e 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -39,16 +39,15 @@ /> - {{ form.contentLength }} + {{ contentLength }} - - {{ form.contentLength }} - + + {{ contentLength }} @@ -135,7 +134,6 @@ export default { form: { title: '', content: '', - contentLength: 0, teaserImage: null, image: null, language: null, @@ -144,7 +142,13 @@ export default { }, formSchema: { title: { required: true, min: 3, max: 100 }, - content: { required: true, min: 3 }, + content: { + required: true, + min: 3, + transform: (content) => { + return this.$filters.removeHtml(content) + } + }, }, id: null, loading: false, @@ -168,11 +172,13 @@ export default { this.form.content = contribution.content this.form.image = contribution.image this.form.categoryIds = this.categoryIds(contribution.categories) - this.manageContent(this.form.content) }, }, }, computed: { + contentLength() { + return this.$filters.removeHtml(this.form.content).length + }, locale() { const locale = this.contribution && this.contribution.language @@ -230,14 +236,7 @@ export default { }) }, updateEditorContent(value) { - // TODO: Do smth????? what is happening this.$refs.contributionForm.update('content', value) - this.manageContent(value) - }, - manageContent(content) { - let str = content.replace(/<\/?[^>]+(>|$)/gm, '') - this.form.contentLength = str.length - this.validatePost() }, availableLocales() { orderBy(locales, 'name').map(locale => { @@ -259,10 +258,9 @@ export default { return categoryIds }, validatePost() { - const passesContentValidations = this.form.contentLength >= this.contentMin const passesCategoryValidations = this.form.categoryIds.length > 0 && this.form.categoryIds.length <= 3 - this.failsValidations = !(passesContentValidations && passesCategoryValidations) + this.failsValidations = !(passesCategoryValidations) }, }, apollo: { From dd03f4b7f09623fb9eb11cd7197b1192c221417b Mon Sep 17 00:00:00 2001 From: ogerly Date: Thu, 7 Nov 2019 15:40:58 +0100 Subject: [PATCH 07/18] Fix Add Language check for form submit --- .../ContributionForm/ContributionForm.vue | 39 +++++++++++++++---- webapp/locales/de.json | 3 +- webapp/locales/en.json | 3 +- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index f6ebf6bcc..236a1a722 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -24,7 +24,7 @@ {{ form.title.length }}/{{ formSchema.title.max }} - + {{ form.contentLength }} - + {{ form.contentLength }} @@ -71,7 +71,7 @@ {{ form.categoryIds.length }} / 3 - + > {{ form.categoryIds.length }} / 3 @@ -79,18 +79,28 @@ - - + + + + {{ form.language.label }} + + + + {{ $t('contribution.languageSelectLabel') }} + + +
= this.contentMin const passesCategoryValidations = this.form.categoryIds.length > 0 && this.form.categoryIds.length <= 3 - this.failsValidations = !(passesContentValidations && passesCategoryValidations) + const passedLanguageValidation = this.form.language !== null + + this.failsValidations = !( + passesContentValidations && + passesCategoryValidations && + passedLanguageValidation + ) }, }, apollo: { @@ -334,4 +356,7 @@ export default { .checkicon_cat { top: -58px; } +.colorRed { + color: red; +} diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 34cd948ed..eba0c7d26 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -579,7 +579,8 @@ "filterFollow": "Beiträge filtern von Usern denen ich folge", "filterALL": "Alle Beiträge anzeigen", "success": "Gespeichert!", - "languageSelectLabel": "Sprache", + "languageSelectLabel": "Sprache deines Beitrags", + "languageSelectText": "Sprache wählen", "categories": { "infoSelectedNoOfMaxCategories": "{chosen} von {max} Kategorien ausgewählt" }, diff --git a/webapp/locales/en.json b/webapp/locales/en.json index d3b4e8edc..e51eab534 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -580,7 +580,8 @@ "filterFollow": "Filter contributions from users I follow", "filterALL": "View all contributions", "success": "Saved!", - "languageSelectLabel": "Language", + "languageSelectLabel": "Language of your contribution", + "languageSelectText": "Select Language", "categories": { "infoSelectedNoOfMaxCategories": "{chosen} of {max} categories selected" }, From 62b393b0f00e07d2a4a16cff342546c69d4cb58b Mon Sep 17 00:00:00 2001 From: roschaefer Date: Thu, 7 Nov 2019 23:23:47 +0100 Subject: [PATCH 08/18] Refactoring of Categories Select component --- .../CategoriesSelect/CategoriesSelect.vue | 37 ++++------ .../ContributionForm/ContributionForm.vue | 67 ++++++------------- 2 files changed, 33 insertions(+), 71 deletions(-) diff --git a/webapp/components/CategoriesSelect/CategoriesSelect.vue b/webapp/components/CategoriesSelect/CategoriesSelect.vue index cbe46b890..9b54b3283 100644 --- a/webapp/components/CategoriesSelect/CategoriesSelect.vue +++ b/webapp/components/CategoriesSelect/CategoriesSelect.vue @@ -28,16 +28,23 @@ From edbb0c3d1f78afad94db2d12e88fc4e99edc630a Mon Sep 17 00:00:00 2001 From: roschaefer Date: Tue, 12 Nov 2019 17:37:16 +0100 Subject: [PATCH 12/18] Fix cypress tests --- cypress/integration/common/steps.js | 7 ++++++- cypress/integration/notifications/Mentions.feature | 1 + cypress/integration/post/WritePost.feature | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 493c54e38..ec63a81c8 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -245,6 +245,11 @@ Then("I select a category", () => { .click(); }); +When("I choose a language for the post", () => { + cy.get('.ds-flex-item > .ds-form-item .ds-select ') + .click().get('.ds-select-option').first().click() +}) + Then("the post shows up on the landing page at position {int}", index => { cy.openPage("landing"); const selector = `.post-card:nth-child(${index}) > .ds-card-content`; @@ -536,4 +541,4 @@ Then("I see only one post with the title {string}", title => { .find(".post-link") .should("have.length", 1); cy.get(".main-container").contains(".post-link", title); -}); \ No newline at end of file +}); diff --git a/cypress/integration/notifications/Mentions.feature b/cypress/integration/notifications/Mentions.feature index 7523e3d05..810b77433 100644 --- a/cypress/integration/notifications/Mentions.feature +++ b/cypress/integration/notifications/Mentions.feature @@ -20,6 +20,7 @@ Feature: Notification for a mention """ And mention "@matt-rider" in the text And I select a category + And I choose a language for the post And I click on "Save" When I log out And I log in with the following credentials: diff --git a/cypress/integration/post/WritePost.feature b/cypress/integration/post/WritePost.feature index 461766532..c5762536e 100644 --- a/cypress/integration/post/WritePost.feature +++ b/cypress/integration/post/WritePost.feature @@ -17,7 +17,8 @@ Feature: Create a post Human Connection is a free and open-source social network for active citizenship. """ - Then I select a category + And I select a category + And I choose a language for the post And I click on "Save" Then I get redirected to ".../my-first-post" And the post was saved successfully From c20a656405eef0b6896bc85a1a76937b27608f52 Mon Sep 17 00:00:00 2001 From: roschaefer Date: Fri, 15 Nov 2019 11:51:53 +0100 Subject: [PATCH 13/18] Follow @mattwr18 suggestions --- cypress/integration/common/steps.js | 8 ++++++-- cypress/integration/notifications/Mentions.feature | 2 +- cypress/integration/post/WritePost.feature | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index ec63a81c8..c51c863d1 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -5,9 +5,12 @@ import { } from "cypress-cucumber-preprocessor/steps"; import helpers from "../../support/helpers"; import { VERSION } from '../../constants/terms-and-conditions-version.js' +import locales from '../../../webapp/locales' +import orderBy from 'lodash/orderBy' /* global cy */ +const languages = orderBy(locales, 'name') let lastPost = {}; let loginCredentials = { @@ -245,9 +248,10 @@ Then("I select a category", () => { .click(); }); -When("I choose a language for the post", () => { +When("I choose {string} as the language for the post", (languageCode) => { cy.get('.ds-flex-item > .ds-form-item .ds-select ') - .click().get('.ds-select-option').first().click() + .click().get('.ds-select-option') + .eq(languages.findIndex(l => l.code === languageCode)).click() }) Then("the post shows up on the landing page at position {int}", index => { diff --git a/cypress/integration/notifications/Mentions.feature b/cypress/integration/notifications/Mentions.feature index 810b77433..ef2694abc 100644 --- a/cypress/integration/notifications/Mentions.feature +++ b/cypress/integration/notifications/Mentions.feature @@ -20,7 +20,7 @@ Feature: Notification for a mention """ And mention "@matt-rider" in the text And I select a category - And I choose a language for the post + And I choose "en" as the language for the post And I click on "Save" When I log out And I log in with the following credentials: diff --git a/cypress/integration/post/WritePost.feature b/cypress/integration/post/WritePost.feature index c5762536e..0d74606ad 100644 --- a/cypress/integration/post/WritePost.feature +++ b/cypress/integration/post/WritePost.feature @@ -18,7 +18,7 @@ Feature: Create a post for active citizenship. """ And I select a category - And I choose a language for the post + And I choose "en" as the language for the post And I click on "Save" Then I get redirected to ".../my-first-post" And the post was saved successfully From 04f07b90915e10bc2485daa30a222e6002b59a9a Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Mon, 18 Nov 2019 17:25:44 +0100 Subject: [PATCH 14/18] Fix lint --- webapp/components/Editor/Editor.story.js | 6 +++++- webapp/pages/admin/hashtags.vue | 4 +--- webapp/pages/admin/users.vue | 4 +--- webapp/plugins/vue-filters.js | 6 +++++- webapp/store/auth.test.js | 10 ++++++++-- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/webapp/components/Editor/Editor.story.js b/webapp/components/Editor/Editor.story.js index 7a69b347f..8efcf3f4c 100644 --- a/webapp/components/Editor/Editor.story.js +++ b/webapp/components/Editor/Editor.story.js @@ -27,7 +27,11 @@ const plugins = [ ] helpers.init({ plugins }) -const users = [{ id: 1, slug: 'peter' }, { id: 2, slug: 'sandra' }, { id: 3, slug: 'jane' }] +const users = [ + { id: 1, slug: 'peter' }, + { id: 2, slug: 'sandra' }, + { id: 3, slug: 'jane' }, +] storiesOf('Editor', module) .addDecorator(withA11y) diff --git a/webapp/pages/admin/hashtags.vue b/webapp/pages/admin/hashtags.vue index 76306873a..521d3110a 100644 --- a/webapp/pages/admin/hashtags.vue +++ b/webapp/pages/admin/hashtags.vue @@ -1,9 +1,7 @@