Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(showcase): add the ngx-form-errors to the showcase #1721

Merged

Conversation

christophercr
Copy link
Collaborator

ISSUES CLOSED: #1195

Supersedes: #1361

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: Incomplete PR #1361

What is the new behavior?

Took over the same changes from #1361 and made the necessary fixes based on the pending remarks:

  • update to latest version of ngx-form-errors
  • translations
  • replace grid layout by flex layout to make it compatible with IE
  • update example files to be in sync with the actual implementation

Does this PR introduce a breaking change?

[ ] Yes
[X] No

@christophercr christophercr changed the title feat(showcase): add the ngx form error to the showcase feat(showcase): add the ngx-form-errorr to the showcase Mar 16, 2020
@christophercr christophercr changed the title feat(showcase): add the ngx-form-errorr to the showcase feat(showcase): add the ngx-form-errors to the showcase Mar 16, 2020
@christophercr christophercr added this to the 10.0.1 milestone Mar 16, 2020
@coveralls
Copy link

coveralls commented Mar 16, 2020

Coverage Status

Coverage remained the same at 88.154% when pulling 4a98d3c on christophercr:feature/ngx-forms into bee0d72 on NationalBankBelgium:master.

@christophercr christophercr modified the milestones: 10.0.1, 10.1.0 Mar 19, 2020
Copy link
Member

@SuperITMan SuperITMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small changes for the translations.
Also a small issue in the demo page.

It's almost OK 😊

showcase/src/assets/translations/en.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/fr.json Show resolved Hide resolved
showcase/src/assets/translations/fr.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/fr.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/fr.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/en.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/en.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/fr.json Outdated Show resolved Hide resolved
showcase/src/assets/translations/fr.json Outdated Show resolved Hide resolved
type="password"
[placeholder]="'SHOWCASE.NGX_FORM_ERRORS.FIELDS.CONFIRM_PASSWORD' | translate"
formControlName="confirmPassword"
[errorStateMatcher]="parentErrorStateMatcher"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some tests locally and I have the feeling this line should not be there. Indeed, if I remove it, I don't have the following issue:
image

(password fields contain the same values and respect the rules)

Could you please explain why this "parentErrorStateMatcher" is necessary ? 😊

Another point, if the passwords are not equal, the "Submit" button is disabled but no error is displayed 😕

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was a bit lazy in the original implementation and I didn't check properly that it was working as expected.

The reason of the StateMatcher is to programmatically tell the mat-input when to toggle to the "error" state because we use a form group validator instead of a control validator, so we must tell the field when there is an error in the group. However our state matcher implementation is indeed buggy.

So I reworked this and the StateMatcher is not needed anymore 👍 I now use simple control validators and I even use the literal SHOWCASE.NGX_FORM_ERRORS.FORM.VALIDATION.CONFIRM_PASSWORD.ARE_EQUAL which was not used at all before 😉

Now it works like a charm 💪

@christophercr
Copy link
Collaborator Author

christophercr commented Mar 25, 2020

Updated the PR with the fixes for the translations and refactored the validation of the "confirmPassword" field.

Could you guys have a look?

@SuperITMan SuperITMan modified the milestones: 10.1.0, 10.2.0 Jul 24, 2020
@christophercr christophercr force-pushed the feature/ngx-forms branch 2 times, most recently from 3442e87 to 7e8e5b8 Compare August 23, 2020 12:17
@christophercr
Copy link
Collaborator Author

@SuperITMan I've rebased this PR and fixed all conflicts. It's ready to be merged 😉

Copy link
Contributor

@nicanac nicanac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

Copy link
Collaborator

@carlo-nomes carlo-nomes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of thoughts about the translations. 😜

"REQUIRED": "{{fieldName}} is verplicht",
"PASSWORD_REQUIRED": "{{fieldName}} moet worden gegeven",
"USER_NAME": {
"UNIQUE": "Dit gebruikersnaam is al in gebruik"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*Deze gebruikersnaam is al in gebruik

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think you are not using this translation.

"PASSWORD": {
"MAX_LENGTH": "Wachtwoord mag niet meer dan {{requiredLength}} tekens lang zijn",
"MIN_LENGTH": "Wachtwoord moet minimaal {{requiredLength}} tekens lang zijn",
"PATTERN": "Het wachtwoord moet minimaal één hoofdletter, één kleine letter en één cijfer bevatten"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the sentence structure similar here. Eg: "Wachtwoord moet minimaal één hoofdletter, één kleine letter en één cijfer bevatten"

"PASSWORD": {
"MAX_LENGTH": "Password cannot be more than {{requiredLength}} characters long",
"MIN_LENGTH": "Password must be at least {{requiredLength}} characters long",
"PATTERN": "The password must contain at least one uppercase, one lowercase, and one number"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the sentence structure similar here. Eg: "Password must contain at least one uppercase, one lowercase, and one number"

@SuperITMan SuperITMan modified the milestones: 10.2.0, 11.0.0 Mar 10, 2021
@christophercr
Copy link
Collaborator Author

Hey guys, fyi I'll continue with this PR in the next days so it can finally be merged 😉 (god! it's been open for a year now!!)

@christophercr christophercr force-pushed the feature/ngx-forms branch 3 times, most recently from a839e85 to b119bc4 Compare May 12, 2021 07:42
@sonarcloud
Copy link

sonarcloud bot commented May 12, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@christophercr
Copy link
Collaborator Author

Finally the day has come! PR rebased and updated with the latest remarks! 👍

Can you guys have a look?

@SuperITMan
Copy link
Member

LGTM! Thanks for your great job on this! 👍
Let's merge it, finally 🥳 🎉

@SuperITMan SuperITMan merged commit 0f05c34 into NationalBankBelgium:master May 16, 2021
@christophercr christophercr deleted the feature/ngx-forms branch September 8, 2021 07:03
@SuperITMan SuperITMan modified the milestones: 12.0.0, 12.0.0-beta.0 Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

showcase: ngx-form-errors - we should integrate the module and present it
5 participants