diff --git a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 0650c290f..7ec639b9d 100644 --- a/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/dmp-frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -24,6 +24,8 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< @Input() configuration: SingleAutoCompleteConfiguration; // Selected Option Event @Output() optionSelected: EventEmitter = new EventEmitter(); + // Removed Option Event + @Output() optionRemoved: EventEmitter = new EventEmitter(); id = `single-autocomplete-${SingleAutoCompleteComponent.nextId++}`; stateChanges = new Subject(); @@ -231,6 +233,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl< chipRemove(): void { this._setValue(null); + this.optionRemoved.emit(); } autoCompleteDisplayFn() { 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 ce7f8b967..967fd3775 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,7 +36,7 @@ export class FunderFormModel { 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: 'existFunder', validators: [BackendErrorValidator(this.validationErrorModel, 'existFunder')] }); + baseContext.validation.push({ key: 'existFunder', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'existFunder')] }); 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 b36d0a087..5cedf1964 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 @@ -1,23 +1,24 @@
-
+

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

- + + {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}}

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

- - - {{formGroup.get('label').getError('backendError').message}} - + + + {{funderFormGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | 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 ab1433438..24bf86356 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 @@ -5,6 +5,7 @@ import { FunderService } from '../../../core/services/funder/funder.service'; import { RequestItem } from '../../../core/query/request-item'; import { FunderCriteria } from '../../../core/query/funder/funder-criteria'; import { FunderFormModel } from '../../dmp/editor/grant-tab/funder-form-model'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-quick-wizard-funder-editor-component', @@ -15,11 +16,13 @@ export class FunderEditorWizardComponent implements OnInit { isNew = false; funder: FunderFormModel; - @Input() formGroup: FormGroup; + @Input() funderFormGroup: FormGroup; + @Input() grantformGroup: FormGroup; funderAutoCompleteConfiguration: SingleAutoCompleteConfiguration; constructor( - private funderService: FunderService + private funderService: FunderService, + private language: TranslateService ) { } ngOnInit() { @@ -28,16 +31,17 @@ export class FunderEditorWizardComponent implements OnInit { filterFn: this.searchFunder.bind(this), initialItems: (extraData) => this.searchFunder(''), displayFn: (item) => item['label'], - titleFn: (item) => item['label'] + titleFn: (item) => item['label'], + subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; - if (!this.formGroup) { + if (!this.funderFormGroup) { this.funder = new FunderFormModel(); - this.formGroup = this.funder.buildForm(); + this.funderFormGroup = this.funder.buildForm(); } - this.formGroup.get('existFunder').enable(); - this.formGroup.get('label').disable(); + this.funderFormGroup.get('existFunder').enable(); + this.funderFormGroup.get('label').disable(); } searchFunder(query: string) { @@ -50,13 +54,32 @@ export class FunderEditorWizardComponent implements OnInit { create() { this.isNew = !this.isNew; if (this.isNew) { - this.formGroup.get('existFunder').disable(); - this.formGroup.get('existFunder').reset(); - this.formGroup.get('label').enable(); + this.funderFormGroup.get('existFunder').disable(); + this.funderFormGroup.get('existFunder').reset(); + this.funderFormGroup.get('label').enable(); } else { - this.formGroup.get('existFunder').enable(); - this.formGroup.get('label').disable(); - this.formGroup.get('label').reset(); + this.funderFormGroup.get('existFunder').enable(); + this.funderFormGroup.get('label').disable(); + this.funderFormGroup.get('label').reset(); + } + } + + onFunderSelected(event: any) { + this.grantformGroup.get('existGrant').enable(); + } + + onFunderRemoved(event: any) { + this.grantformGroup.get('existGrant').disable(); + this.grantformGroup.get('existGrant').reset(); + } + + controlModified(event: any) { + if (event) { + this.grantformGroup.get('existGrant').enable(); + } + else { + this.grantformGroup.get('existGrant').disable(); + this.grantformGroup.get('existGrant').reset(); } } 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 ddb3a4e8c..bd01567ed 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 @@ -12,6 +12,7 @@ + {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}} {{grantformGroup.get('grant').getError('backendError').message}} @@ -53,7 +54,7 @@
- +
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 cdfa6e73b..b2800990f 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 @@ -57,7 +57,7 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, initialItems: (extraData) => this.searchGrant(''), displayFn: (item) => item['label'], titleFn: (item) => item['label'], - subtitleFn: (item) => item ? item['source'] : null + subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; if (!this.grantformGroup) { @@ -65,7 +65,11 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, this.grantformGroup = this.grant.buildForm(); } - this.grantformGroup.get('existGrant').enable(); + if (this.funderFormGroup && this.funderFormGroup.get('funder')) { + this.grantformGroup.get('existGrant').enable(); + } else { + this.grantformGroup.get('existGrant').disable(); + } this.grantformGroup.get('label').disable(); this.grantformGroup.get('description').disable(); @@ -101,6 +105,10 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit, return this.grantformGroup.valid; } + isFunderFormInvalid() { + return !this.funderFormGroup.get('existFunder').value && !this.funderFormGroup.get('label').valid; + } + public touchAllFormFields(formControl: AbstractControl) { if (formControl instanceof FormControl) { formControl.markAsTouched(); diff --git a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html index b53fb7f43..208838c21 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html +++ b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.html @@ -9,6 +9,7 @@ + {{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}}
diff --git a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts index 73c5c22dc..bc81cbc21 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/project-editor/project-editor-wizard.component.ts @@ -5,6 +5,7 @@ import { ProjectService } from '../../../core/services/project/project.service'; import { RequestItem } from '../../../core/query/request-item'; import { ProjectCriteria } from '../../../core/query/project/project-criteria'; import { ProjectFormModel } from '../../dmp/editor/grant-tab/project-form-model'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'app-quick-wizard-project-editor-component', @@ -19,7 +20,8 @@ export class ProjectEditorWizardComponent implements OnInit { projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration; constructor( - private projectService: ProjectService + private projectService: ProjectService, + private language: TranslateService ) { } ngOnInit() { @@ -27,7 +29,8 @@ export class ProjectEditorWizardComponent implements OnInit { filterFn: this.searchProject.bind(this), initialItems: (extraData) => this.searchProject(''), displayFn: (item) => item['label'], - titleFn: (item) => item['label'] + titleFn: (item) => item['label'], + subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; if (!this.formGroup) { 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 62571c7b8..9b3bca847 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 @@ -11,14 +11,14 @@ {{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
- +
diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts index 0890149e8..2ef3ebbb6 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts @@ -133,7 +133,7 @@ export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent imp } public isFormValid() { - return this.formGroup.get('grant').valid; + return this.formGroup.get('grant').valid && this.formGroup.get('funder').valid; } public touchAllFormFields(formControl: AbstractControl) {