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 1ec6166dd..f89ca6cce 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 @@ -40,7 +40,7 @@ export class GrantTabModel { baseContext.validation.push({ key: 'id', validators: [] }); baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); baseContext.validation.push({ key: 'status', validators: [] }); - 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: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] }); baseContext.validation.push({ key: 'funderId', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'funderId')] }); return baseContext; diff --git a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html index 5cedf1964..b4606ff50 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html +++ b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.html @@ -6,7 +6,7 @@

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-FUNDER' | translate}}

- + {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} diff --git a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts index 24bf86356..45334e50a 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/funder-editor/funder-editor-wizard.component.ts @@ -16,6 +16,7 @@ export class FunderEditorWizardComponent implements OnInit { isNew = false; funder: FunderFormModel; + funderLabelCleared = true; @Input() funderFormGroup: FormGroup; @Input() grantformGroup: FormGroup; funderAutoCompleteConfiguration: SingleAutoCompleteConfiguration; @@ -64,22 +65,40 @@ export class FunderEditorWizardComponent implements OnInit { } } - onFunderSelected(event: any) { - this.grantformGroup.get('existGrant').enable(); + onFunderSelected() { + if (this.grantformGroup.get('existGrant').disabled) { + this.grantformGroup.get('existGrant').enable(); + this.grantformGroup.get('label').disable(); + this.grantformGroup.get('description').disable(); + } else { + this.grantformGroup.get('existGrant').disable(); + this.grantformGroup.get('label').enable(); + this.grantformGroup.get('description').enable(); + } } - onFunderRemoved(event: any) { - this.grantformGroup.get('existGrant').disable(); - this.grantformGroup.get('existGrant').reset(); + onFunderRemoved() { + if (this.grantformGroup.get('existGrant').enabled) { + this.grantformGroup.get('existGrant').disable(); + this.grantformGroup.get('existGrant').reset(); + this.grantformGroup.get('label').enable(); + this.grantformGroup.get('description').enable(); + } else { + this.grantformGroup.get('existGrant').enable(); + this.grantformGroup.get('label').disable(); + this.grantformGroup.get('label').reset(); + this.grantformGroup.get('description').disable(); + this.grantformGroup.get('description').reset(); + } } controlModified(event: any) { - if (event) { - this.grantformGroup.get('existGrant').enable(); - } - else { - this.grantformGroup.get('existGrant').disable(); - this.grantformGroup.get('existGrant').reset(); + if (event && this.funderLabelCleared) { + this.funderLabelCleared = false; + this.onFunderSelected(); + } else if (!event) { + this.funderLabelCleared = true; + this.onFunderRemoved(); } } diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html index bd01567ed..2b4d9e1b0 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html +++ b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.html @@ -10,7 +10,7 @@

{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-GRANT' | translate}}

- + {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} @@ -53,9 +53,8 @@
- - +
diff --git a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts index b2800990f..47f1c730a 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/grant-editor/grant-editor-wizard.component.ts @@ -1,5 +1,5 @@ -import {of as observableOf, Observable } from 'rxjs'; +import { of as observableOf, Observable } from 'rxjs'; import { Component, Input, OnInit } from '@angular/core'; import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms'; import { MatSnackBar } from '@angular/material/snack-bar'; @@ -34,7 +34,6 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, constructor( public snackBar: MatSnackBar, - private route: ActivatedRoute, public router: Router, public language: TranslateService, private grantService: GrantService @@ -67,11 +66,11 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, if (this.funderFormGroup && this.funderFormGroup.get('funder')) { this.grantformGroup.get('existGrant').enable(); + this.grantformGroup.get('label').disable(); + this.grantformGroup.get('description').disable(); } else { this.grantformGroup.get('existGrant').disable(); } - this.grantformGroup.get('label').disable(); - this.grantformGroup.get('description').disable(); // this.route.params // .pipe(takeUntil(this._destroyed)) @@ -180,4 +179,9 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, this.grantformGroup.get('description').reset(); } } + + onGrantSelected() { + this.grantformGroup.get('label').disable(); + this.grantformGroup.get('description').disable(); + } } diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html index 2cac94611..8b3a7c7c9 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html +++ b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.html @@ -10,9 +10,7 @@ {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}} -
- -
+
@@ -27,7 +25,7 @@
- +