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 f8e3644f5..133e7a461 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
@@ -55,7 +55,7 @@
1.5 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
-
+
{{profile.label}}
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html
index d713b8079..f8e97ed04 100644
--- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html
+++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html
@@ -76,8 +76,8 @@
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 119dea19c..46897ec16 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
@@ -41,12 +41,7 @@ import { isNullOrUndefined } from 'util';
import { AuthService } from '@app/core/services/auth/auth.service';
import { environment } from 'environments/environment';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
-
-
-enum SaveType {
- close = 0,
- addNew = 1
-}
+import { SaveType } from '@app/core/common/enum/save-type';
@Component({
selector: 'app-dataset-wizard-component',
@@ -59,6 +54,9 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
viewOnly = false;
editMode = false;
publicMode = false;
+ hasChanges = false;
+ isDiscarded = false;
+ formGroupRawValue: any;
DatasetStatus = DatasetStatus;
dmpAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
@@ -156,6 +154,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
]
}]);
this.formGroup = this.datasetWizardModel.buildForm();
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) {
this.formGroup.disable();
@@ -198,6 +197,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
setTimeout(() => {
this.datasetWizardModel.dmp = data;
this.formGroup = this.datasetWizardModel.buildForm();
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
this.formGroup.get('dmp').disable();
@@ -241,6 +241,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
setTimeout(() => {
this.datasetWizardModel.dmp = data;
this.formGroup.get('dmp').setValue(this.datasetWizardModel.dmp);
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.loadDatasetProfiles();
this.breadCrumbs = observableOf([
@@ -294,6 +295,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
if (data) {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.formGroup = this.datasetWizardModel.buildForm();
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
this.formGroup.disable();
this.viewOnly = true;
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
@@ -310,6 +312,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
+
this.needsUpdate();
this.breadCrumbs = observableOf([
{
@@ -342,6 +346,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
} else {
this.datasetWizardModel = new DatasetWizardEditorModel();
this.formGroup = this.datasetWizardModel.buildForm();
+ this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue()));
+
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === DatasetStatus.Finalized) {
this.formGroup.disable();
@@ -359,6 +365,7 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
!this.isNew ? this.maxStep = 1 : this.maxStep = 0;
+
// this.route.params
// .pipe(takeUntil(this._destroyed))
// .subscribe((params: Params) => {
@@ -376,7 +383,8 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
this.formGroup.get('profile').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
- this.datasetProfileValueChanged(x.id);
+ console.log(x)
+ if (x) { this.datasetProfileValueChanged(x.id); }
});
}
@@ -424,6 +432,12 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
}
+ public formChanged() {
+ if (!this.isDiscarded) {
+ this.hasChanges = true;
+ }
+ }
+
public cancel(): void {
if (!isNullOrUndefined(this.lock)) {
this.lockService.unlockTarget(this.datasetWizardModel.id).pipe(takeUntil(this._destroyed)).subscribe(
@@ -814,11 +828,23 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, IBr
}
isDirty() {
-
+ return this.formGroup.dirty && this.hasChanges; // do we need this.formGroup.dirty
}
discardChanges() {
-
+ 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();
+ }
+ });
+ } else {
+ this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue)));
+ }
+ this.isDiscarded = false;
}
addDataset(dmpId: string) {