Add missing status reset on cleared inputs and optimize and adapt name validation logic#46
Open
SJHWU wants to merge 3 commits intoEndereco:masterfrom
Open
Add missing status reset on cleared inputs and optimize and adapt name validation logic#46SJHWU wants to merge 3 commits intoEndereco:masterfrom
SJHWU wants to merge 3 commits intoEndereco:masterfrom
Conversation
On clearing the title,phone, firstName or lastName field, the validation status was not reset . This could result in empty fields showing a validation status. This commit adds status reset, when the value in the respective input fields is changed to an empty string. Title-, phone- and name fields now behave consistently with the email- and addressfields. Ref: DEV-343/bugs 1 and 6
There was no salutation field with three options (m,f,x) in the example form use-cases/example. The configuration for correcTranspositionedNames could not be set in the example form itself, To enable and simplify thorough testing, this commit adds a third salutation option (salutation x) to both salutation dropdowns, and integrates the configuration for correctTranspositionedNames directly into the example form.
The name validation logic in NameCheckExtension.js had a few issues; DEV-343/2: When the first request returned "name_not_found", for example when there was a typo in the name, on the second request with API answer "name_needs_correction" the field status for firstName and lastName was not set. The reason was, that firstNameStatus and lastNameStatus where only set on the request with index 1. This commit replaces the request index in the respective if-clause with a persistent boolean flag nameCorrected. This ensures, that firstNameStatus and lastNameStatus will be set on the first request that returns "name_needs_correction" and, as it was before, on every request that returns "name_correct". DEV-343/3: On requests with response "salutation x", the salutation field status was set to "salutation_correct". This resulted in salutation fields with value "Bitte wählen" or "keine Angabe" showing green validation colors. With this commit, after requests that return "salutation x" , the salutation field is set to an empty status. DEV-343/4: Until now, the salutation field was automatically set for an unlimited number of requests. This prevented users from selecting a neutral option (salutation x), which is no longer in line with modern standards as it forces a gender disclosure. In this commit, the code block that automatically sets the salutation field is moved inside the clause controlled by the new nameCorrected flag. This ensures, that the salutation will only be automatically set on time max. DEV-343/5: On requests with empty firstName or empty lastName, for example "Herr Müller" or "Herr Florian", the API returns "name_correct" and the status of both input fields is set to "correct". This resulted in an empty input field, showing green validation colors. This commit introduces a ternary operator, that ensures, that only the status of not-empty firstName or lastName fields will be set to "correct".
a1a5ebc to
7fd4cf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add status reset on cleared input in Phone, Title and Name Extensions
On clearing the title,phone, firstName or lastName field, the validation status was
not reset . This could result in empty fields showing a validation status.
This commit adds status reset, when the value in the respective input fields
is changed to an empty string. Title-, phone- and name fields now behave consistently
with the email- and addressfields.
Ref: DEV-343/bugs 1 and 6
Optimize and adapt name validation logic
The name validation logic in NameCheckExtension.js had a few issues;
DEV-343/2: When the first request returned "name_not_found", for example
when there was a typo in the name, on the second request with API answer
"name_needs_correction" the field status for firstName and lastName was not
set. The reason was, that firstNameStatus and lastNameStatus where only
set on the request with index 1.
This commit replaces the request index in the respective if-clause with a persistent
boolean flag nameCorrected. This ensures, that firstNameStatus and lastNameStatus
will be set on the first request that returns "name_needs_correction" and, as it
was before, on every request that returns "name_correct".
DEV-343/3: On requests with response "salutation x", the salutation field status
was set to "salutation_correct". This resulted in salutation fields with value
"Bitte wählen" or "keine Angabe" showing green validation colors.
With this commit, after requests that return "salutation x" , the salutation field
is set to an empty status.
DEV-343/4: Until now, the salutation field was automatically set for an unlimited
number of requests. This prevented users from selecting a neutral option (salutation x),
which is no longer in line with modern standards as it forces a gender disclosure.
In this commit, the code block that automatically sets the salutation field is moved
inside the clause controlled by the new nameCorrected flag. This ensures, that the
salutation will only be automatically set on time max.
DEV-343/5: On requests with empty firstName or empty lastName, for example
"Herr Müller" or "Herr Florian", the API returns "name_correct" and the status
of both input fields is set to "correct". This resulted in an empty input field, showing
green validation colors.
This commit introduces a ternary operator, that ensures, that only the status of
not-empty firstName or lastName fields will be set to "correct".