Skip to content

Commit

Permalink
fix: Only display email already associated inline error if the user…
Browse files Browse the repository at this point in the history
… clicks on `next` button
  • Loading branch information
DanielPalafox committed Dec 8, 2023
1 parent b37a461 commit db8039f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
<ng-container
*ngIf="recognizedError[errorCode] === 0 && !disableInlineAlreadyExistError"
*ngIf="recognizedError[errorCode] === 0"
>
<ng-container i18n="@@register.emailAlreadyExists"
>This email already exists in our system. Would you like to</ng-container
>
<ng-container *ngIf="!registrationTogglz">
<ng-container i18n="@@register.emailAlreadyExists"
>This email already exists in our system. Would you like to</ng-container
>

<a (click)="navigateToSignin(value)" i18n="@@register.signinLowerCase"
>sign in</a
><ng-container i18n="@@shared.questionMark">?</ng-container>
</ng-container>

<a (click)="navigateToSignin(value)" i18n="@@register.signinLowerCase"
>sign in</a
><ng-container i18n="@@shared.questionMark">?</ng-container>
<ng-container *ngIf="registrationTogglz && nextButtonWasClicked">
<ng-container i18n="@@register.emailIsAlreadyAssociated"
>This email is already associated with an existing ORCID record. Please use a different email address.</ng-container
>
</ng-container>
</ng-container>

<ng-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ErrorHandlerService } from 'src/app/core/error-handler/error-handler.se
import { SignInService } from 'src/app/core/sign-in/sign-in.service'
import { ERROR_REPORT } from 'src/app/errors'
import { WINDOW } from 'src/app/cdk/window'
import { TogglzService } from '../../../core/togglz/togglz.service'

// When the error text is not listed on the RegisterBackendErrors enum
// the error message will be displayed as it comes from the backend
Expand All @@ -29,7 +30,8 @@ enum RegisterBackendErrors {
export class BackendErrorComponent implements OnInit {
recognizedError = RegisterBackendErrors
_errorCode: string
@Input() disableInlineAlreadyExistError = false
@Input() nextButtonWasClicked = false
registrationTogglz = false

@Input()
set errorCode(errorCode: string) {
Expand All @@ -50,9 +52,14 @@ export class BackendErrorComponent implements OnInit {
private _snackbar: SnackbarService,
private _signIn: SignInService,
private _errorHandler: ErrorHandlerService,
@Inject(WINDOW) private window: Window
private _togglz: TogglzService,
@Inject(WINDOW) private window: Window
) {}
ngOnInit() {
this._togglz
.getStateOf('REGISTRATION_2_0')
.pipe(take(1))
.subscribe((value) => (this.registrationTogglz = value))
if (!(this.errorCode in RegisterBackendErrors)) {
this.unrecognizedError = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,10 @@ <h3 i18n="@@register.yourEmailAddresses" class="orc-font-body margin-top-12">
<ng-container formGroupName="emails">
<div class="input-container">
<mat-label
class="orc-font-small-print"
class="orc-font-small-print"
id="email-input-input-label"
[ngClass]="{
error: emailFormTouched && emails.controls.email.errors
error: emailError
}"
id="email-input-label"
i18n="@@register.primaryEmail"
Expand All @@ -102,7 +101,10 @@ <h3 i18n="@@register.yourEmailAddresses" class="orc-font-body margin-top-12">
<mat-form-field
appearance="outline"
[hideRequiredMarker]="true"
[ngClass]="{ 'valid-password-input': emailsAreValid }"
[ngClass]="{
'valid-password-input': emailsAreValid,
'disable-error': !emailError
}"
>
<mat-icon *ngIf="emailsAreValid" matSuffix>done</mat-icon>

Expand Down Expand Up @@ -143,7 +145,7 @@ <h3 i18n="@@register.yourEmailAddresses" class="orc-font-body margin-top-12">
*ngFor="let error of this.emails.getError('backendError', 'email')"
>
<app-backend-error
[disableInlineAlreadyExistError]="true"
[nextButtonWasClicked]="nextButtonWasClicked"
[errorCode]="error"
[value]="emails.get('email').value"
></app-backend-error>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,15 @@ export class FormPersonalComponent extends BaseForm implements OnInit {
return validStatus
}

get emailError(): boolean {
if (this.emailFormTouched && this.emails.controls.email.errors) {
const backendError = this.emails.controls.email.errors?.backendError
return !(backendError && backendError[0] === 'orcid.frontend.verify.duplicate_email' && !this.nextButtonWasClicked);
}
return false
}


private announce(announcement: string) {
if (environment.debugger) {
console.debug('📢' + announcement)
Expand Down
10 changes: 10 additions & 0 deletions src/app/register2/components/register2.scss-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@
);
}
}

.disable-error {
.mat-form-field-outline {
color: rgba(0, 0, 0, 0.12) !important;
}
.mat-input-element {
color: black !important;
}
}

}
}

Expand Down
1 change: 1 addition & 0 deletions src/locale/properties/register/register.en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,4 @@ register.emailAreNotValid=Your emails do not match
register.Email=Email
register.VisibilityParties=Trusted parties
register.emailPlaceholder=The email address you use most
register.emailIsAlreadyAssociated=This email is already associated with an existing ORCID record. Please use a different email address.
1 change: 1 addition & 0 deletions src/locale/properties/register/register.lr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ register.emailAreNotValid=LR
register.confirmYourPassword=LR
register.VisibilityParties=LR
register.emailPlaceholder=LR
register.emailIsAlreadyAssociated=LR
1 change: 1 addition & 0 deletions src/locale/properties/register/register.rl.properties
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ register.emailAreNotValid=RL
register.confirmYourPassword=RL
register.VisibilityParties=RL
register.emailPlaceholder=RL
register.emailIsAlreadyAssociated=RL
1 change: 1 addition & 0 deletions src/locale/properties/register/register.xx.properties
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,4 @@ register.emailAreNotValid=X
register.confirmYourPassword=X
register.VisibilityParties=X
register.emailPlaceholder=X
register.emailIsAlreadyAssociated=X

0 comments on commit db8039f

Please sign in to comment.