From 2fb06c63d0f1bbf034ce40221aba3e56a88eed7e Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 5 Feb 2018 12:34:25 +0200 Subject: [PATCH] Confirmation message dmp delete --- dmp-frontend/src/app/dmps/dmps.module.ts | 3 ++- .../app/dmps/editor/dmp-editor.component.html | 2 +- .../app/dmps/editor/dmp-editor.component.ts | 25 +++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/dmps/dmps.module.ts b/dmp-frontend/src/app/dmps/dmps.module.ts index e6f3385a8..4ae220f53 100644 --- a/dmp-frontend/src/app/dmps/dmps.module.ts +++ b/dmp-frontend/src/app/dmps/dmps.module.ts @@ -9,7 +9,7 @@ import { DataManagementPlanRoutes } from './dmps.routes'; import { HttpClient, HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; - +import { CovalentDialogsModule } from '@covalent/core'; import { SharedModule } from '../shared/shared.module' import { NgModule } from '@angular/core'; @@ -30,6 +30,7 @@ import { AddResearchersComponent } from '@app/add-researchers/add-researchers.co deps: [HttpClient] } }), + CovalentDialogsModule ], declarations: [ diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html index aa650f1c6..b2af3ecb7 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html @@ -88,7 +88,7 @@ - + diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts index a27c74f0a..f095ae735 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts @@ -21,7 +21,8 @@ import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria"; import { ProjectService } from "../../services/project/project.service"; import { DmpUsersModel } from "@app/models/dmpUsers/DmpUsersModel"; import { AddResearchersComponent } from "@app/add-researchers/add-researchers.component"; - +import { ViewContainerRef } from '@angular/core'; +import { TdDialogService } from '@covalent/core'; @Component({ @@ -58,7 +59,9 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { public router: Router, public language: TranslateService, private _service: DataManagementPlanService, - public dialog: MatDialog + public dialog: MatDialog, + private _dialogService: TdDialogService, + private _viewContainerRef: ViewContainerRef ) { } @@ -222,4 +225,22 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { }); } + openConfirm(dmpLabel): void { + this._dialogService.openConfirm({ + message: 'Are you sure you want to delete the "' + dmpLabel +'"', + disableClose: true || false, // defaults to false + viewContainerRef: this._viewContainerRef, //OPTIONAL + title: 'Confirm', //OPTIONAL, hides if not provided + cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL' + acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT' + // width: '500px', //OPTIONAL, defaults to 400px + }).afterClosed().subscribe((accept: boolean) => { + if (accept) { + // DO SOMETHING + } else { + // DO SOMETHING ELSE + } + }); + } + } \ No newline at end of file