From e8c694114246c0f09c298176946b349aabc2e001 Mon Sep 17 00:00:00 2001 From: mattwr18 Date: Tue, 15 Oct 2019 20:23:47 +0200 Subject: [PATCH] Follow @roschaefer's `PR` review suggestions - disable button if form.reasonCategory is falsy - extract valuesReasonCategoryOptions to global constant - extract reasonCategoryOptions to created lifecycle hook to keep data() clean and use map - extract formSchema to components/utils and test - remove validator from formSchema and validate based on "Deep Rules" https://github.com/yiminghe/async-validator#deep-rules - Use v-model to update reasonCategory and reasonDescription - default to error message in English from backend - Update template slot to use new syntax --- .../validation/validationMiddleware.js | 5 +- webapp/components/Modal/ReportModal.vue | 76 +++++++------------ webapp/components/utils/ReportModal.js | 25 ++++++ webapp/components/utils/ReportModal.spec.js | 36 +++++++++ webapp/constants/modals.js | 11 +++ webapp/locales/de.json | 3 +- webapp/locales/en.json | 3 +- webapp/pages/moderation/index.vue | 2 +- 8 files changed, 104 insertions(+), 57 deletions(-) create mode 100644 webapp/components/utils/ReportModal.js create mode 100644 webapp/components/utils/ReportModal.spec.js create mode 100644 webapp/constants/modals.js diff --git a/backend/src/middleware/validation/validationMiddleware.js b/backend/src/middleware/validation/validationMiddleware.js index ff3992ead..1dbd36b72 100644 --- a/backend/src/middleware/validation/validationMiddleware.js +++ b/backend/src/middleware/validation/validationMiddleware.js @@ -78,10 +78,7 @@ const validateReport = async (resolve, root, args, context, info) => { } }) - if (existingReportedResource) - throw new Error( - `You have already reported the ${existingReportedResource.label}, please only report the same ${existingReportedResource.label} once`, - ) + if (existingReportedResource) throw new Error(`${existingReportedResource.label}`) return resolve(root, args, context, info) } diff --git a/webapp/components/Modal/ReportModal.vue b/webapp/components/Modal/ReportModal.vue index c33515a37..9b155e8b6 100644 --- a/webapp/components/Modal/ReportModal.vue +++ b/webapp/components/Modal/ReportModal.vue @@ -8,9 +8,8 @@

- - -