From b75d7606cf871d53e579b503fb84fef3862c39cb Mon Sep 17 00:00:00 2001 From: apapachristou Date: Mon, 21 Sep 2020 18:05:53 +0300 Subject: [PATCH] Discard on dataset editor --- .../dataset-editor.component.html | 2 +- .../dataset-editor.component.ts | 10 ++---- .../dataset-wizard.component.ts | 34 +++++++++++++++++-- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html index 133e7a461..643805a0d 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.html @@ -50,7 +50,7 @@ - +
1.5 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts index 1b8577b8d..e9b8d18e5 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-editor/dataset-editor.component.ts @@ -6,6 +6,7 @@ import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service' import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; import { TranslateService } from '@ngx-translate/core'; import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; +import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'app-dataset-editor-component', @@ -14,10 +15,10 @@ import { DatasetProfileModel } from '@app/core/model/dataset/dataset-profile'; }) export class DatasetEditorComponent extends BaseComponent { - @Input() formGroup: FormGroup = null; + @Input() formGroup: FormGroup; + // @Input() formGroup: FormGroup = null; @Input() availableProfiles: DatasetProfileModel[]; @Input() dmpId: string; - @Output() formChanged: EventEmitter = new EventEmitter(); showUri: boolean = false; dmpText: string; viewOnly = false; @@ -69,9 +70,4 @@ export class DatasetEditorComponent extends BaseComponent { public compareWith(object1: any, object2: any) { return object1 && object2 && object1.id === object2.id; } - - - onFormChanged(event) { - this.formChanged.emit(event); - } } diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts index 46897ec16..7865b44ac 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.ts @@ -383,9 +383,38 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.formGroup.get('profile').valueChanges .pipe(takeUntil(this._destroyed)) .subscribe(x => { - console.log(x) - if (x) { this.datasetProfileValueChanged(x.id); } + if (x) { + this.datasetProfileValueChanged(x.id); + this.formChanged(); + } }); + this.formGroup.get('label').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + this.formGroup.get('description').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + this.formGroup.get('uri').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + this.formGroup.get('tags').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + if (this.formGroup.get('datasetProfileDefinition')) { + this.formGroup.get('datasetProfileDefinition').valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(x => { + this.formChanged(); + }); + } } dmpValueChanged(dmp: DmpListingModel) { @@ -835,7 +864,6 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr this.isDiscarded = true; this.hasChanges = false; if (this.isNew) { - console.log(this.formGroup); Object.keys(this.formGroup['controls']).forEach((key: string) => { if (key !== 'dmp') { this.formGroup.get(key).reset();