From 64a0692cf3704abb570acc833337b55d12276b1a Mon Sep 17 00:00:00 2001 From: horatio Date: Sat, 19 Oct 2024 16:11:56 -0400 Subject: [PATCH] tried to make validations work, it was an incomplete success. --- .../projects/projects-new-information.hbs | 20 ++++--- .../submittable-projects-new-form.js | 52 ++++++++++++------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/client/app/components/packages/projects/projects-new-information.hbs b/client/app/components/packages/projects/projects-new-information.hbs index 04b1005f..13b10922 100644 --- a/client/app/components/packages/projects/projects-new-information.hbs +++ b/client/app/components/packages/projects/projects-new-information.hbs @@ -15,32 +15,38 @@ /> - + Borough - {{borough.label}} - + Applicant Type

Identify if you represent a public agency or are a private entity.

- - {{applicantType.label}} + @searchField='label' + data-test-id='projects-new-applicant-type' + @placeholder='select applicant type' as |dcpApplicantType| > + {{dcpApplicantType.label}}
diff --git a/client/app/validations/submittable-projects-new-form.js b/client/app/validations/submittable-projects-new-form.js index a532a024..81466ebb 100644 --- a/client/app/validations/submittable-projects-new-form.js +++ b/client/app/validations/submittable-projects-new-form.js @@ -9,109 +9,121 @@ export default { validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), ], primaryContactLastName: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), ], primaryContactEmail: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), validateFormat({ - type: 'email', + type: "email", // Set allowBlank=true so that the validation message // only appears after user first types something. // This field still indicates it is 'required' // through validatePresence allowBlank: true, - message: 'Must be a valid email address', + message: "Must be a valid email address", }), ], primaryContactPhone: [ validateLength({ min: 0, max: 10, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), ], applicantFirstName: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), ], applicantLastName: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), ], applicantEmail: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", }), validateFormat({ - type: 'email', + type: "email", // Set allowBlank=true so that the validation message // only appears after user first types something. // This field still indicates it is 'required' // through validatePresence allowBlank: true, - message: 'Must be a valid email address', + message: "Must be a valid email address", }), ], applicantPhone: [ validateLength({ min: 0, max: 10, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), ], projectName: [ validateLength({ min: 0, max: 50, - message: 'Text is too long (max {max} characters)', + message: "Text is too long (max {max} characters)", }), validatePresence({ presence: true, - message: 'This field is required', + message: "This field is required", + }), + ], + borough: [ + validatePresence({ + presence: true, + message: "Please select a Borough", + }), + ], + dcpApplicantType: [ + validatePresence({ + presence: true, + message: "Please select an Applicant Type", }), ], };