Discard on dataset editor

This commit is contained in:
apapachristou 2020-09-21 18:05:53 +03:00
parent 3d323615e4
commit b75d7606cf
3 changed files with 35 additions and 11 deletions

View File

@ -50,7 +50,7 @@
</div>
</div>
<!-- External Fields -->
<app-dataset-external-references-editor-component (formChanged)="onFormChanged($event)" [formGroup]="formGroup" [viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
<app-dataset-external-references-editor-component [formGroup]="formGroup" [viewOnly]="viewOnly"></app-dataset-external-references-editor-component>
<!-- Template Field -->
<div class="heading">1.5 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*</div>
<div class="profile-form">

View File

@ -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<any> = 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);
}
}

View File

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