Confirmation message dmp delete

This commit is contained in:
annampak 2018-02-05 12:34:25 +02:00
parent 49fe557fdc
commit 2fb06c63d0
3 changed files with 26 additions and 4 deletions

View File

@ -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: [

View File

@ -88,7 +88,7 @@
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button>
<!-- <button *ngIf="!isNew" mat-raised-button color="primary" (click)="invite()" type="button">{{'DMP-EDITOR.ACTIONS.INVITE' | translate}}</button> -->
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
<button *ngIf="!isNew" mat-raised-button color="primary" type="button" (click)="openConfirm(formGroup.get('label').value)">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
</div>
</mat-card-content>

View File

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