From d8562554055efb551c4206c046a5b7ac2fd686a2 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Wed, 7 Oct 2020 12:42:10 +0300 Subject: [PATCH] Fixes bug: after discard grant was not set to previous value --- .../src/app/ui/dmp/editor/dmp-editor.component.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index b9bbba867..7901b7ad4 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -51,6 +51,7 @@ import { CloneDialogComponent } from '../clone/clone-dialog/clone-dialog.compone import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; import { DatasetService } from '@app/core/services/dataset/dataset.service'; import { DmpToDatasetDialogComponent } from '../dmp-to-dataset/dmp-to-dataset-dialog.component'; +import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model'; @Component({ selector: 'app-dmp-editor-component', @@ -826,7 +827,19 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.isDiscarded = true; this.hasChanges = false; if (!this.isNew) { + let grantControl; + if(this.formGroup.get('grant').get('existGrant')) { + grantControl = new GrantTabModel(); + grantControl.fromModel(this.formGroup.get('grant').get('existGrant').value); + } else { + grantControl = new GrantEditorModel(); + grantControl.fromModel(this.formGroup.get('grant').value); + } + grantControl.buildForm() + this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); + + this.formGroup.get('grant').get('existGrant').setValue(grantControl.existGrant); } else { this.formGroup.reset(); this.formGroup.get('extraProperties').get('visible').setValue(false);