From e10179d04276431ca5656b6937e64dd4dbc96f7a Mon Sep 17 00:00:00 2001 From: dtziotzios Date: Tue, 29 Jan 2019 09:56:46 +0200 Subject: [PATCH] Fixed the dmp delete function --- .../dataset-wizard.component.ts | 67 +++++++++---------- 1 file changed, 33 insertions(+), 34 deletions(-) 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 2f9771b16..643a2f837 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 @@ -25,6 +25,7 @@ import { IBreadCrumbComponent } from '../../misc/breadcrumb/definition/IBreadCru import { DatasetDescriptionFormEditorModel } from '../../misc/dataset-description-form/dataset-description-form.model'; import { DatasetWizardEditorModel } from './dataset-wizard-editor.model'; import { SnackBarNotificationLevel, UiNotificationService } from '../../../core/services/notification/ui-notification-service'; +import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component'; @Component({ selector: 'app-dataset-wizard-component', @@ -194,11 +195,11 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, Aft .pipe(takeUntil(this._destroyed)) .subscribe(x => { if (x) { this.loadDatasetProfiles(); } - else{ - this.availableProfiles=[]; + else { + this.availableProfiles = []; this.formGroup.get('profile').reset(); } - + }); } } @@ -263,17 +264,17 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, Aft this.datasetWizardService.createDataset(this.formGroup.value) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { - this.datasetWizardService.getSingle(complete.id) - .pipe(takeUntil(this._destroyed)) - .subscribe( - result => { - this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); - } - ); - this.onCallbackSuccess(); - }, - error => this.onCallbackError(error) + complete => { + this.datasetWizardService.getSingle(complete.id) + .pipe(takeUntil(this._destroyed)) + .subscribe( + result => { + this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(result); + } + ); + this.onCallbackSuccess(); + }, + error => this.onCallbackError(error) ); } @@ -389,25 +390,23 @@ export class DatasetWizardComponent extends BaseComponent implements OnInit, Aft } openConfirm(dmpLabel, id): void { - // this._dialogService.openConfirm({ - // message: 'Are you sure you want to delete the "' + dmpLabel + '"', - // disableClose: true || false, - // viewContainerRef: this._viewContainerRef, - // title: 'Confirm', - // cancelButton: 'No', - // acceptButton: 'Yes' - // }).afterClosed() - // .pipe(takeUntil(this._destroyed)) - // .subscribe((accept: boolean) => { - // if (accept) { - // this.datasetWizardService.delete(id) - // .pipe(takeUntil(this._destroyed)) - // .subscribe(() => { - // this.router.navigate(['/datasets']); - // }); - // } else { - // // DO SOMETHING ELSE - // } - // }); + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '300px', + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL') + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + this.datasetWizardService.delete(id) + .pipe(takeUntil(this._destroyed)) + .subscribe( + complete => { this.onCallbackSuccess() }, + error => this.onCallbackError(error) + ); + } + }); } }