Skip to content

Commit

Permalink
batch-fixes-jan-18-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Mendoza Fernadez authored and Leonardo Mendoza Fernadez committed Jan 18, 2024
1 parent a23af9d commit 7d723dd
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 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 @@ -113,7 +113,8 @@ <h3 class="orc-font-body" i18n="@@register.thisLooksLikeAPersonalEmail">
*ngIf="selectedOrganizationFromDatabase && displayOrganizationHint"
>
{{ selectedOrganizationFromDatabase.value }},
{{ selectedOrganizationFromDatabase.city }}<ng-container *ngIf="selectedOrganizationFromDatabase.city"
{{ selectedOrganizationFromDatabase.city
}}<ng-container *ngIf="selectedOrganizationFromDatabase.city"
>,</ng-container
>
{{ selectedOrganizationFromDatabase.country }}
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
4 changes: 3 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,13 @@ 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

console.log(year, month)

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

0 comments on commit 7d723dd

Please sign in to comment.