diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java index c7f21914c..f2348d016 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java @@ -3,4 +3,14 @@ package eu.eudat.data.dao.criteria; import eu.eudat.data.entities.DMPProfile; public class DataManagementPlanBlueprintCriteria extends Criteria { + + private Integer status; + + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } + } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java index 671fc8b67..7033473c2 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java @@ -72,6 +72,13 @@ public class DMPProfileDaoImpl extends DatabaseAccess implements DMP QueryableList query = getDatabaseService().getQueryable(DMPProfile.class); if (criteria.getLike() != null && !criteria.getLike().isEmpty()) query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%")); + if (criteria.getStatus() != null) { + if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) { + query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue())); + } else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) { + query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue())); + } + } query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue()))); return query; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java index 29e823cb1..420ebe5a3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DmpRDAMapper.java @@ -87,7 +87,19 @@ public class DmpRDAMapper { rda.getCost().add(CostRDAMapper.toRDA((Map)costl)); }); } - UserInfo contact = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact"))); + UserInfo contactDb = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact"))); + UserInfo contact = new UserInfo(); + contact.setId(contactDb.getId()); + contact.setName(contactDb.getName()); + contact.setEmail(contactDb.getEmail()); + if(contact.getEmail() == null){ + for(UserDMP userDMP: dmp.getUsers()){ + if(userDMP.getDmp().getId() == dmp.getId() && userDMP.getUser().getEmail() != null){ + contact.setEmail(userDMP.getUser().getEmail()); + break; + } + } + } rda.setContact(ContactRDAMapper.toRDA(contact)); } diff --git a/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts b/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts index 8f9a77042..0d460ba89 100644 --- a/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts +++ b/dmp-frontend/src/app/core/query/dmp/dmp-blueprint-criteria.ts @@ -1,5 +1,5 @@ import { BaseCriteria } from "../base-criteria"; export class DmpBlueprintCriteria extends BaseCriteria { - + public status?: number; } \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts index 31d6950bb..ed3ee6d4c 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts @@ -402,8 +402,18 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie formSubmit(): void { this.formService.touchAllFormFields(this.formGroup); if (!this.isFormValid()) { return; } + let errorMessages = []; + if(!this.hasTitle()) { + errorMessages.push("Title should be set."); + } + if(!this.hasDescription()) { + errorMessages.push("Description should be set."); + } if(!this.hasDescriptionTemplates()) { - this.showValidationErrorsDialog(undefined, ["At least one section should have description templates."]); + errorMessages.push("At least one section should have description templates."); + } + if(errorMessages.length > 0) { + this.showValidationErrorsDialog(undefined, errorMessages); return; } this.onSubmit(); @@ -413,9 +423,19 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie return this.formGroup.valid; } + hasTitle(): boolean { + const dmpBlueprint: DmpBlueprint = this.formGroup.value; + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.TEXT)); + } + + hasDescription(): boolean { + const dmpBlueprint: DmpBlueprint = this.formGroup.value; + return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category === FieldCategory.SYSTEM && field.type === SystemFieldType.HTML_TEXT)); + } + hasDescriptionTemplates(): boolean { const dmpBlueprint: DmpBlueprint = this.formGroup.value; - return (dmpBlueprint.definition.sections.filter(s => s.hasTemplates == true).length > 0) ? true : false; + return dmpBlueprint.definition.sections.some(section => section.hasTemplates == true); } private showValidationErrorsDialog(projectOnly?: boolean, errmess?: string[]) { @@ -515,7 +535,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie confirmed =>{ if(confirmed){ this.formGroup.get('status').setValue(DmpProfileStatus.Deleted); - this.dmpProfileService.createDmp(this.formGroup.value) + this.dmpProfileService.createBlueprint(this.formGroup.value) .pipe(takeUntil(this._destroyed)) .subscribe( complete => this.onCallbackSuccess(), diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html index 7ddfbb9d0..bcbad4cfe 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.html @@ -143,15 +143,15 @@
- + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
+ [placeholder]="'DMP-EDITOR.PLACEHOLDER.DESCRIPTION'" [required]="field.required">
@@ -218,13 +218,13 @@
- +
- +
- +
@@ -274,11 +274,17 @@
- - - + + + + + + + + + +
diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts index 113de61a3..97df863da 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts @@ -55,6 +55,7 @@ import { Guid } from '@common/types/guid'; import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component'; import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model'; import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; +import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status'; interface Visible { value: boolean; @@ -305,6 +306,10 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im }; } + extraFieldsArray(): FormArray { + return this.formGroup.get('extraFields') as FormArray; + } + setIsUserOwner() { if (this.dmp) { const principal: Principal = this.authService.current(); @@ -450,7 +455,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im } previousStep() { - this.step = this.step !== 0 ? this.step - 1 : this.step; + this.step = this.step !== 1 ? this.step - 1 : this.step; this.resetScroll(); // if (this.step >= this.stepsBeforeDatasets) { // this.datasetId = this.datasets.at(this.step - this.stepsBeforeDatasets).get('id').value; @@ -813,7 +818,10 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im let extraField = new DmpExtraFieldEditorModel(); extraField.id = field.id; if (!isNullOrUndefined(this.dmp.extraFields)) { - extraField.value = this.dmp.extraFields.find(f => f.id === field.id).value; + let found = this.dmp.extraFields.find(f => f.id === field.id); + if(found !== undefined) { + extraField.value = found.value; + } } extraFields.push(extraField.buildForm()); } @@ -925,6 +933,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im let fields: Array = new Array(); var request = new DataTableRequest(0, 10, { fields: fields }); request.criteria = new DmpBlueprintCriteria(); + request.criteria.status = DmpProfileStatus.Finalized; return this.dmpProfileService.getPagedBlueprint(request).pipe(map(x => x.data)); } diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts index 74880b99f..3c1888121 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts @@ -128,7 +128,7 @@ export class DmpEditorModel { baseContext.validation.push({ key: 'groupId', validators: [BackendErrorValidator(this.validationErrorModel, 'groupId')] }); baseContext.validation.push({ key: 'version', validators: [BackendErrorValidator(this.validationErrorModel, 'version')] }); baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'status')] }); - baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); + baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); baseContext.validation.push({ key: 'grant', validators: [BackendErrorValidator(this.validationErrorModel, 'grant')] }); baseContext.validation.push({ key: 'project', validators: [BackendErrorValidator(this.validationErrorModel, 'project')] }); baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] }); diff --git a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.html b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.html index 2582589cc..723d4a39d 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.html @@ -16,7 +16,7 @@
- +
@@ -31,7 +31,7 @@ clear - + {{funderFormGroup.get('label').getError('backendError').message}} @@ -66,7 +66,7 @@
- +
@@ -81,14 +81,14 @@ clear - + {{grantformGroup.get('label').getError('backendError').message}} {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + {{projectFormGroup.get('description').getError('backendError').message}} @@ -122,14 +122,14 @@
- +
- + {{'DMP-EDITOR.FUNDING-INFO.IDENTIFIER-PROJECT-EXISTS' | translate}} check diff --git a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts index c9afb34ed..8559eda7f 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts @@ -28,6 +28,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { @Input() isClone: boolean = false; @Input() isNewVersion: boolean; + @Input() isRequired: boolean; @Input() type: number; @Input() formGroup: FormGroup; @@ -81,16 +82,24 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { this.initializeReferenceValidators(); - this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0); - this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0); - this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0); - this.setGrantValidators(); - this.setProjectValidators(); - this.setFunderValidators(); + if (this.grantformGroup != null) { + this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.get('label').value.length > 0); + this.setGrantValidators(); + } + if (this.projectFormGroup != null) { + this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0); + this.setProjectValidators(); + } + if (this.funderFormGroup != null) { + this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0); + this.setFunderValidators(); + } this.registerFormListeners(); if (this.isNew && !this.isClone) { - this.grantformGroup.reset(); - this.grantformGroup.disable(); + if (this.grantformGroup != null && this.funderFormGroup != null) { + this.grantformGroup.reset(); + this.grantformGroup.disable(); + } } this.formGroup.valueChanges.pipe(takeUntil(this._destroyed)) @@ -101,108 +110,114 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { initializeReferenceValidators() { //Validator for funder - this.funderFormGroup.get('reference').valueChanges.pipe( - takeUntil(this._destroyed), - filter(value =>!isNullOrUndefined(value)), - tap(_=>this.isFunderPending = true), - debounceTime(500), - switchMap(value=> { - const requestItem = new RequestItem(); - requestItem.criteria = new FunderCriteria(); - requestItem.criteria.exactReference = this._FUNDER_PREFIX +value; - return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); - }), - map(response=>{ - if(response && response.length){ - const internalFunders = (response as Array).filter(funder=> funder.key === this._KEY); + if (this.funderFormGroup != null) { + this.funderFormGroup.get('reference').valueChanges.pipe( + takeUntil(this._destroyed), + filter(value =>!isNullOrUndefined(value)), + tap(_=>this.isFunderPending = true), + debounceTime(500), + switchMap(value=> { + const requestItem = new RequestItem(); + requestItem.criteria = new FunderCriteria(); + requestItem.criteria.exactReference = this._FUNDER_PREFIX +value; + return this.funderService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); + }), + map(response=>{ + if(response && response.length){ + const internalFunders = (response as Array).filter(funder=> funder.key === this._KEY); - if(internalFunders && internalFunders.length){ - return {funderIdentifierExists:true}; + if(internalFunders && internalFunders.length){ + return {funderIdentifierExists:true}; + } + return null; } return null; + }) + ) + .subscribe(error=>{ + this.isFunderPending = false; + this.funderFormGroup.get('reference').setErrors(error); + if(!error && this.funderFormGroup.get('reference').validator){ + const validator = this.funderFormGroup.get('reference').validator({} as AbstractControl); + if(validator && validator.required && this.funderFormGroup.get('reference').touched && !this.funderFormGroup.get('reference').value){ + this.funderFormGroup.get('reference').setErrors({required : true}); + } } - return null; - }) - ) - .subscribe(error=>{ - this.isFunderPending = false; - this.funderFormGroup.get('reference').setErrors(error); - if(!error && this.funderFormGroup.get('reference').validator){ - const validator = this.funderFormGroup.get('reference').validator({} as AbstractControl); - if(validator && validator.required && this.funderFormGroup.get('reference').touched && !this.funderFormGroup.get('reference').value){ - this.funderFormGroup.get('reference').setErrors({required : true}); - } - } - }); + }); + } //Validator for grants - this.grantformGroup.get('reference').valueChanges.pipe( - takeUntil(this._destroyed), - filter(value =>!isNullOrUndefined(value)), - tap(_=> this.isGrantPending = true), - debounceTime(500), - switchMap(value=> { - const requestItem = new RequestItem(); - requestItem.criteria = new GrantCriteria(); - requestItem.criteria.exactReference = this._GRANT_PREFIX + value; - return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); - }), - map(response=>{ - if(response && response.length){ - const internalGrants = (response as Array).filter(grant=> grant.key === this._KEY); + if (this.grantformGroup != null) { + this.grantformGroup.get('reference').valueChanges.pipe( + takeUntil(this._destroyed), + filter(value =>!isNullOrUndefined(value)), + tap(_=> this.isGrantPending = true), + debounceTime(500), + switchMap(value=> { + const requestItem = new RequestItem(); + requestItem.criteria = new GrantCriteria(); + requestItem.criteria.exactReference = this._GRANT_PREFIX + value; + return this.grantService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); + }), + map(response=>{ + if(response && response.length){ + const internalGrants = (response as Array).filter(grant=> grant.key === this._KEY); - if(internalGrants && internalGrants.length){ - return {grantIdentifierExists:true}; + if(internalGrants && internalGrants.length){ + return {grantIdentifierExists:true}; + } + return null; } return null; + }) + ) + .subscribe(error=>{ + this.isGrantPending = false; + this.grantformGroup.get('reference').setErrors(error); + if(!error && this.grantformGroup.get('reference').validator){ + const validator = this.grantformGroup.get('reference').validator({} as AbstractControl); + if(validator && validator.required && this.grantformGroup.get('reference').touched && !this.grantformGroup.get('reference').value){ + this.grantformGroup.get('reference').setErrors({required : true}); + } } - return null; - }) - ) - .subscribe(error=>{ - this.isGrantPending = false; - this.grantformGroup.get('reference').setErrors(error); - if(!error && this.grantformGroup.get('reference').validator){ - const validator = this.grantformGroup.get('reference').validator({} as AbstractControl); - if(validator && validator.required && this.grantformGroup.get('reference').touched && !this.grantformGroup.get('reference').value){ - this.grantformGroup.get('reference').setErrors({required : true}); - } - } - }); + }); + } //validator for projects - this.projectFormGroup.get('reference').valueChanges.pipe( - takeUntil(this._destroyed), - filter(value =>!isNullOrUndefined(value)), - tap(_ => this.isProjectPending = true), - debounceTime(500), - switchMap(value=> { - const requestItem = new RequestItem(); - requestItem.criteria = new ProjectCriteria(); - requestItem.criteria.exactReference = this._PROJECT_PREFIX + value; - return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); - }), - map(response=>{ - if(response && response.length){ - const internalProjects = (response as Array).filter(project=> project.key === this._KEY); - if(internalProjects && internalProjects.length){ - return {projectIdentifierExists:true}; + if (this.projectFormGroup != null) { + this.projectFormGroup.get('reference').valueChanges.pipe( + takeUntil(this._destroyed), + filter(value =>!isNullOrUndefined(value)), + tap(_ => this.isProjectPending = true), + debounceTime(500), + switchMap(value=> { + const requestItem = new RequestItem(); + requestItem.criteria = new ProjectCriteria(); + requestItem.criteria.exactReference = this._PROJECT_PREFIX + value; + return this.projectService.getWithExternal(requestItem).pipe(takeUntil(this._destroyed)); + }), + map(response=>{ + if(response && response.length){ + const internalProjects = (response as Array).filter(project=> project.key === this._KEY); + if(internalProjects && internalProjects.length){ + return {projectIdentifierExists:true}; + } + return null; } return null; + }) + ) + .subscribe(error=>{ + this.isProjectPending = false; + this.projectFormGroup.get('reference').setErrors(error); + if(!error && this.projectFormGroup.get('reference').validator){ + const validator = this.projectFormGroup.get('reference').validator({} as AbstractControl); + if(validator && validator.required && this.projectFormGroup.get('reference').touched && !this.projectFormGroup.get('reference').value){ + this.projectFormGroup.get('reference').setErrors({required : true}); + } } - return null; - }) - ) - .subscribe(error=>{ - this.isProjectPending = false; - this.projectFormGroup.get('reference').setErrors(error); - if(!error && this.projectFormGroup.get('reference').validator){ - const validator = this.projectFormGroup.get('reference').validator({} as AbstractControl); - if(validator && validator.required && this.projectFormGroup.get('reference').touched && !this.projectFormGroup.get('reference').value){ - this.projectFormGroup.get('reference').setErrors({required : true}); - } - } - }); + }); + } } configureAutoCompletes(): void { @@ -283,7 +298,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { this.grantformGroup.get('description').enable(); this.grantformGroup.get('reference').enable(); - this.grantformGroup.get('reference').setValidators(Validators.required); + if(this.isRequired) + this.grantformGroup.get('reference').setValidators(Validators.required); this.grantformGroup.get('reference').updateValueAndValidity(); } else if (this.isClone && !this.isNewVersion) { this.grantformGroup.get('existGrant').enable(); @@ -326,7 +342,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { this.projectFormGroup.get('description').enable(); this.projectFormGroup.get('reference').enable() - this.projectFormGroup.get('reference').setValidators(Validators.required); + if(this.isRequired) + this.projectFormGroup.get('reference').setValidators(Validators.required); this.projectFormGroup.get('reference').updateValueAndValidity(); } else if (this.isClone && !this.isNewVersion) { this.projectFormGroup.get('existProject').enable(); @@ -368,7 +385,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { this.funderFormGroup.get('label').enable(); this.funderFormGroup.get('reference').enable(); - this.funderFormGroup.get('reference').setValidators(Validators.required); + if(this.isRequired) + this.funderFormGroup.get('reference').setValidators(Validators.required); this.funderFormGroup.get('reference').updateValueAndValidity(); } else if (this.isClone && !this.isNewVersion) { @@ -383,7 +401,8 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { } else { this.funderFormGroup.get('label').enable(); this.funderFormGroup.get('reference').enable(); - this.funderFormGroup.get('reference').setValidators(Validators.required); + if(this.isRequired) + this.funderFormGroup.get('reference').setValidators(Validators.required); this.funderFormGroup.get('reference').updateValueAndValidity(); } } else if (this.isFinalized || this.isNewVersion || !this.isUserOwner) { @@ -407,11 +426,13 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { } registerFormListeners() { - this.funderFormGroup.valueChanges - .pipe(takeUntil(this._destroyed)) - .subscribe(x => { - this.funderValueChanged(x); - }) + if (this.funderFormGroup != null) { + this.funderFormGroup.valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.funderValueChanged(x); + }) + } } funderValueChanged(funder: any) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/funder-form-model.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/funder-form-model.ts index a2e00cd8d..b06b1fb89 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/funder-form-model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/funder-form-model.ts @@ -36,9 +36,9 @@ export class FunderFormModel { createValidationContext(): ValidationContext { const baseContext: ValidationContext = new ValidationContext(); baseContext.validation.push({ key: 'id', validators: [] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); + baseContext.validation.push({ key: 'label', validators: [BackendErrorValidator(this.validationErrorModel, 'label')] }); baseContext.validation.push({ key: 'status', validators: [] }); - baseContext.validation.push({ key: 'existFunder', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'existFunder')] }); + baseContext.validation.push({ key: 'existFunder', validators: [BackendErrorValidator(this.validationErrorModel, 'existFunder')] }); baseContext.validation.push({ key: 'reference', validators: [BackendErrorValidator(this.validationErrorModel, 'reference')] }); return baseContext; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts index 9a922c6a7..aa2f38789 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts @@ -41,10 +41,10 @@ export class GrantTabModel { createValidationContext(): ValidationContext { const baseContext: ValidationContext = new ValidationContext(); baseContext.validation.push({ key: 'id', validators: [] }); - baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); + baseContext.validation.push({ key: 'label', validators: [BackendErrorValidator(this.validationErrorModel, 'label')] }); baseContext.validation.push({ key: 'status', validators: [] }); - baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); - baseContext.validation.push({ key: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] }); + baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] }); + baseContext.validation.push({ key: 'existGrant', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] }); baseContext.validation.push({ key: 'funderId', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'funderId')] }); baseContext.validation.push({ key: 'reference', validators: [BackendErrorValidator(this.validationErrorModel, 'reference')] }); return baseContext;