From b09dce7e7c269e27b3c44672fc11b54c99b811b7 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Mon, 6 May 2024 17:17:17 +0200 Subject: [PATCH 1/6] Show EU funding name instead of organization name. --- .../ds-dynamic-sponsor-autocomplete.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-autocomplete/ds-dynamic-sponsor-autocomplete.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-autocomplete/ds-dynamic-sponsor-autocomplete.component.ts index c718595c0c8..3c5b462a69c 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-autocomplete/ds-dynamic-sponsor-autocomplete.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-autocomplete/ds-dynamic-sponsor-autocomplete.component.ts @@ -70,7 +70,7 @@ export class DsDynamicSponsorAutocompleteComponent extends DsDynamicAutocomplete if (suggestion instanceof ExternalSourceEntry) { // suggestion from the openAIRE fundingProjectCode = this.getProjectCodeFromId(suggestion?.id); - fundingName = suggestion.metadata?.['project.funder.name']?.[0]?.value; + fundingName = suggestion.metadata?.['dc.title']?.[0]?.value; } else if (suggestion instanceof VocabularyEntry) { // the value is in the format: `;;;;` const fundingFields = suggestion.value?.split(SEPARATOR); From 964d22d15ef94d85fa904ce63583a3a638c3b886 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Tue, 7 May 2024 14:26:19 +0200 Subject: [PATCH 2/6] Show required character in the submission complex input field `*` however the whole complex input field is not required. --- src/app/shared/form/builder/parsers/complex-field-parser.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/shared/form/builder/parsers/complex-field-parser.ts b/src/app/shared/form/builder/parsers/complex-field-parser.ts index 2eead2a63da..81034069981 100644 --- a/src/app/shared/form/builder/parsers/complex-field-parser.ts +++ b/src/app/shared/form/builder/parsers/complex-field-parser.ts @@ -124,9 +124,7 @@ export class ComplexFieldParser extends FieldParser { inputConfig.readOnly = true; } - if (this.configData.mandatory) { - inputConfig.required = hasValue(complexDefinitionInput.required) && complexDefinitionInput.required === 'true'; - } + inputConfig.required = hasValue(complexDefinitionInput.required) && complexDefinitionInput.required === 'true'; // max length - 200 chars this.addValidatorToComplexInput(inputConfig, complexDefinitionInput); From 456463dfc4a661d3521542dff2e60312ca94e2a3 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Tue, 14 May 2024 12:47:11 +0200 Subject: [PATCH 3/6] Refactored adding of error messages into complex input field. --- src/app/shared/form/form.component.ts | 21 ++------------------- src/app/shared/form/form.service.ts | 4 ++-- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/app/shared/form/form.component.ts b/src/app/shared/form/form.component.ts index c49b816ed02..bb312ac0431 100644 --- a/src/app/shared/form/form.component.ts +++ b/src/app/shared/form/form.component.ts @@ -191,25 +191,8 @@ export class FormComponent implements OnDestroy, OnInit { } if (field) { - const model: DynamicFormControlModel = this.formBuilderService.findById(fieldId, formModel); - - // Check if field has nested input fields - if (field instanceof UntypedFormGroup && isNotEmpty(field?.controls)) { - // For input field which consist of more input fields e.g. DynamicComplexModel - // add error for every input field - Object.keys(field.controls).forEach((nestedInputName, nestedInputIndex) => { - const nestedInputField = (model as DynamicFormGroupModel).group?.[nestedInputIndex]; - const nestedInputFieldInForm = formGroup.get(this.formBuilderService.getPath(nestedInputField)); - // Do not add errors for non-mandatory inputs - if (nestedInputField instanceof DsDynamicInputModel && !nestedInputField.required) { - return; - } - this.formService.addErrorToField(nestedInputFieldInForm, nestedInputField, error.message); - }); - } else { - // Add error to the input field - this.formService.addErrorToField(field, model, error.message); - } + const model: DynamicFormControlModel = this.formBuilderService.findById(fieldId, formModel); + this.formService.addErrorToField(field, model, error.message); this.changeDetectorRef.detectChanges(); } }); diff --git a/src/app/shared/form/form.service.ts b/src/app/shared/form/form.service.ts index bf316daaed3..6b6df5420e2 100644 --- a/src/app/shared/form/form.service.ts +++ b/src/app/shared/form/form.service.ts @@ -162,7 +162,7 @@ export class FormService { } // if the field in question is a concat group, pass down the error to its fields - if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) { + if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && (this.formBuilderService.isConcatGroup(model) || this.formBuilderService.isComplexGroup(model))) { model.group.forEach((subModel) => { const subField = field.controls[subModel.id]; @@ -183,7 +183,7 @@ export class FormService { } // if the field in question is a concat group, clear the error from its fields - if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) { + if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && (this.formBuilderService.isConcatGroup(model) || this.formBuilderService.isComplexGroup(model))) { model.group.forEach((subModel) => { const subField = field.controls[subModel.id]; From 755cf0ede86606596a7c3c40157f350b63a006a2 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Tue, 14 May 2024 12:48:13 +0200 Subject: [PATCH 4/6] Mark nested input field from the complex input field as required, however the complex input field is not required. --- src/app/shared/form/builder/parsers/complex-field-parser.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/shared/form/builder/parsers/complex-field-parser.ts b/src/app/shared/form/builder/parsers/complex-field-parser.ts index 81034069981..e84552b26d4 100644 --- a/src/app/shared/form/builder/parsers/complex-field-parser.ts +++ b/src/app/shared/form/builder/parsers/complex-field-parser.ts @@ -153,6 +153,12 @@ export class ComplexFieldParser extends FieldParser { // for non-EU funds hide EU identifier read only input field inputModel.hidden = complexDefinitionInput.name === OPENAIRE_INPUT_NAME; + + // Show error messages in the input field. It is ignored in the `initForm` because a whole input group is not + // required. It should be marked as required in the complex group for every input field. + if (inputConfig.required) { + this.markAsRequired(inputModel); + } concatGroup.group.push(inputModel); }); From e4e7c25aa6d9fcca5458611f62117c646f127848 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Tue, 14 May 2024 13:07:20 +0200 Subject: [PATCH 5/6] Removed unused import --- src/app/shared/form/form.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/shared/form/form.component.ts b/src/app/shared/form/form.component.ts index bb312ac0431..951d651d5f0 100644 --- a/src/app/shared/form/form.component.ts +++ b/src/app/shared/form/form.component.ts @@ -18,7 +18,6 @@ import { hasValue, isNotEmpty, isNotNull, isNull } from '../empty.util'; import { FormService } from './form.service'; import { FormEntry, FormError } from './form.reducer'; import { FormFieldMetadataValueObject } from './builder/models/form-field-metadata-value.model'; -import {DsDynamicInputModel} from './builder/ds-dynamic-form-ui/models/ds-dynamic-input.model'; /** * The default form component. From 57740695121d2fc95d3191fb747272bd4d59bea5 Mon Sep 17 00:00:00 2001 From: milanmajchrak Date: Wed, 15 May 2024 14:23:07 +0200 Subject: [PATCH 6/6] Removed complex input field when the value is `N/A` --- ...dynamic-sponsor-scrollable-dropdown.component.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts index 9221c920f27..fece3308784 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/sponsor-scrollable-dropdown/dynamic-sponsor-scrollable-dropdown.component.ts @@ -9,6 +9,7 @@ import { VocabularyService } from '../../../../../../core/submission/vocabularie import { FormFieldMetadataValueObject } from '../../../models/form-field-metadata-value.model'; import { DsDynamicScrollableDropdownComponent } from '../scrollable-dropdown/dynamic-scrollable-dropdown.component'; import { + DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN, DynamicScrollableDropdownModel } from '../scrollable-dropdown/dynamic-scrollable-dropdown.model'; import { @@ -19,6 +20,7 @@ import { DynamicComplexModel, EU_IDENTIFIER_INDEX } from '../ds-dynamic-complex. import { DsDynamicInputModel } from '../ds-dynamic-input.model'; import { DYNAMIC_FORM_CONTROL_TYPE_AUTOCOMPLETE } from '../autocomplete/ds-dynamic-autocomplete.model'; import isEqual from 'lodash/isEqual'; +import { TranslateService } from '@ngx-translate/core'; const DYNAMIC_INPUT_TYPE = 'INPUT'; @@ -47,7 +49,8 @@ export class DsDynamicSponsorScrollableDropdownComponent extends DsDynamicScroll constructor(protected vocabularyService: VocabularyService, protected cdr: ChangeDetectorRef, protected layoutService: DynamicFormLayoutService, - protected validationService: DynamicFormValidationService + protected validationService: DynamicFormValidationService, + protected translateService: TranslateService ) { super(vocabularyService, cdr, layoutService, validationService); } @@ -107,6 +110,9 @@ export class DsDynamicSponsorScrollableDropdownComponent extends DsDynamicScroll case DYNAMIC_INPUT_TYPE: (input as DsDynamicInputModel).value = ''; break; + case DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN: + (input as DynamicScrollableDropdownModel).value = ''; + break; default: break; } @@ -135,6 +141,11 @@ export class DsDynamicSponsorScrollableDropdownComponent extends DsDynamicScroll return true; } + // if the funding type is `N/A` -> clean inputs + if (isEqual(fundingTypeValue, this.translateService.instant('autocomplete.suggestion.sponsor.empty'))) { + return true; + } + return false; } }