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

Fix/batch fixes jan 18 2024 #2139

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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