Fixes bug: after discard grant was not set to previous value

This commit is contained in:
apapachristou 2020-10-07 12:42:10 +03:00
parent 166f0f7c37
commit d856255405
1 changed files with 13 additions and 0 deletions

View File

@ -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);