Skip to content

Commit

Permalink
Merge pull request #2139 from ORCID/fix/batch-fixes-jan-18-2024
Browse files Browse the repository at this point in the history
Fix/batch fixes jan 18 2024
  • Loading branch information
leomendoza123 authored Jan 18, 2024
2 parents bb4681c + 2e1b006 commit d64ff8f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
matInput
#firstInput
/>
<mat-error
*ngIf="form.hasError('maxlength', 'givenNames')"
i18n="@@topBar.keywordMaxLength"
>
Must be less than 100 characters
</mat-error>
<mat-error
*ngIf="form.hasError('required', 'givenNames')"
i18n="@@register.firstNamePassword"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class FormPersonalComponent
extends BaseForm
implements OnInit, AfterViewInit
{
nameMaxLength = 99

@Input() reactivation: ReactivationLocal
@ViewChild('firstInput') firstInput: ElementRef
labelInfoAboutName = $localize`:@@register.ariaLabelInfo:info about names`
Expand Down Expand Up @@ -97,7 +99,11 @@ export class FormPersonalComponent

this.form = new UntypedFormGroup({
givenNames: new UntypedFormControl('', {
validators: [Validators.required, OrcidValidators.illegalName],
validators: [
Validators.required,
OrcidValidators.illegalName,
Validators.maxLength(this.nameMaxLength),
],
asyncValidators: this._register.backendValueValidate('givenNames'),
}),
familyNames: new UntypedFormControl('', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class FormCurrentEmploymentComponent extends BaseForm implements OnInit {
startDateMonth: [''],
startDateYear: [''],
},
dateMonthYearValidator('startDate')
{ validator: dateMonthYearValidator('startDate') }
),
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ <h3 i18n="@@register.yourNames" class="orc-font-body margin-top-12">
/>
</mat-form-field>

<mat-error
*ngIf="form.hasError('maxlength', 'givenNames')"
i18n="@@topBar.keywordMaxLength"
>
Must be less than 100 characters
</mat-error>
<mat-error
*ngIf="givenNameFormTouched && form.hasError('required', 'givenNames')"
i18n="@@register.firstNameError"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class MyErrorStateMatcher implements ErrorStateMatcher {
})
export class FormPersonalComponent extends BaseForm implements OnInit {
matcher = new MyErrorStateMatcher()
maxNameLenght = 100
@Input() nextButtonWasClicked: boolean
@Input() reactivation: ReactivationLocal
@ViewChild(FormGroupDirective) formGroupDir: FormGroupDirective
Expand Down Expand Up @@ -158,7 +159,7 @@ export class FormPersonalComponent extends BaseForm implements OnInit {

this.form = new UntypedFormGroup({
givenNames: new UntypedFormControl('', {
validators: [Validators.required, OrcidValidators.illegalName],
validators: [Validators.required, OrcidValidators.illegalName, Validators.maxLength(this.maxNameLenght)],
asyncValidators: this._register.backendValueValidate('givenNames'),
}),
familyNames: new UntypedFormControl('', {
Expand Down
3 changes: 2 additions & 1 deletion src/app/shared/validators/date/date.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ export function dateValidator(dateType: string) {
}
}

export function dateMonthYearValidator(dateType: string) {
export function dateMonthYearValidator(dateType: string, formHasDay = true) {
return (c: AbstractControl): { [key: string]: any } | null => {
const year = c.get(dateType + 'Year').value
const month = c.get(dateType + 'Month').value


if (!year && !month) {
return null
}
Expand Down

0 comments on commit d64ff8f

Please sign in to comment.