Ticket 8389: Fix undo finalazation appears even finalized wasn't successful. Also fix issue where the buttons are remaining disabled when user press No in the dialog of finalization. On undo finalization do a save in order to be sync with the backend.

This commit is contained in:
Konstantinos Triantafyllou 2023-02-23 15:51:46 +02:00
parent 4c7dee3ece
commit 180e02c829
2 changed files with 41 additions and 15 deletions

View File

@ -63,12 +63,15 @@
<button [disabled]="saving" *ngIf="!lockStatus && !viewOnly" mat-raised-button
class="dataset-save-btn mr-2" type="button">
<span class="d-flex flex-row row">
<span (click)="save()" class="col">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</span>
<span (click)="!saving?save():null" class="col">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</span>
<mat-divider [vertical]="true"></mat-divider>
<span class="align-items-center justify-content-center col-4 d-flex"
<span *ngIf="!saving" class="align-items-center justify-content-center col-4 d-flex"
(click)="$event.stopPropagation();" [matMenuTriggerFor]="menu">
<mat-icon >expand_more</mat-icon>
</span>
<span *ngIf="saving" class="align-items-center justify-content-center col-4 d-flex">
<mat-icon >expand_more</mat-icon>
</span>
</span>
</button>
<mat-menu #menu="matMenu">

View File

@ -659,7 +659,7 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
// }
submit(saveType?: SaveType) {
submit(saveType?: SaveType, onSuccess: Function = null, onError: Function = null) {
this.scrollTop = document.getElementById('dataset-editor-form').scrollTop;
this.tocScrollTop = document.getElementById('stepper-options').scrollTop;
this.datasetWizardService.createDataset(this.formGroup.getRawValue())
@ -669,8 +669,16 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
this.hasChanges = false;
this.datasetIsOnceSaved = true;
this.onCallbackSuccess(data, saveType);
if(onSuccess) {
onSuccess();
}
},
error => this.onCallbackError(error));
error => {
if(onError) {
onError();
}
this.onCallbackError(error)
});
}
@ -840,16 +848,27 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
.pipe(
filter(x => x),
takeUntil(this._destroyed)
).subscribe(_ => {
this.viewOnly = false;
this.datasetWizardModel.status = DatasetStatus.Draft;
setTimeout(x => {
this.formGroup = null;
});
setTimeout(x => {
this.formGroup = this.datasetWizardModel.buildForm();
this.registerFormListeners();
});
).subscribe(result => {
if (result) {
// if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue(DatasetStatus.Draft);
this.submit(SaveType.finalize, () => {
this.viewOnly = false;
this.datasetWizardModel.status = DatasetStatus.Draft;
setTimeout(x => {
this.formGroup = null;
});
setTimeout(x => {
this.formGroup = this.datasetWizardModel.buildForm();
this.registerFormListeners();
});
}, () => {
this.formGroup.get('status').setValue(DatasetStatus.Finalized);
this.viewOnly = true;
});
} else {
this.saving = false;
}
});
@ -885,7 +904,11 @@ export class DatasetWizardComponent extends CheckDeactivateBaseComponent impleme
if (result) {
// if (!this.isFormValid()) { return; }
this.formGroup.get('status').setValue(DatasetStatus.Finalized);
this.submit(SaveType.finalize);
this.submit(SaveType.finalize, null, () => {
this.formGroup.get('status').setValue(DatasetStatus.Draft);
});
} else {
this.saving = false;
}
});
}