mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-02-20 17:52:46 +00:00
This commit is contained in:
parent
d290daed11
commit
1d5bbb58f9
@ -1,4 +1,4 @@
|
||||
<button mat-menu-item (click)="delete()">
|
||||
<button mat-menu-item (click)="confirmDelete()">
|
||||
<mat-icon>delete</mat-icon>
|
||||
<span>Delete</span>
|
||||
</button>
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MatBottomSheetModule } from '@angular/material/bottom-sheet';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
@ -24,7 +25,7 @@ describe('DeleteActionComponent', () => {
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [MatIconModule, MatMenuModule, NoopAnimationsModule],
|
||||
imports: [MatIconModule, MatMenuModule, NoopAnimationsModule, MatBottomSheetModule],
|
||||
providers: [
|
||||
{ provide: NodesDataSource, useClass: NodesDataSource },
|
||||
{ provide: DrawingsDataSource, useClass: DrawingsDataSource },
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { MatBottomSheet } from '@angular/material/bottom-sheet';
|
||||
import { ConfirmationBottomSheetComponent } from 'app/components/projects/confirmation-bottomsheet/confirmation-bottomsheet.component';
|
||||
import { DrawingsDataSource } from '../../../../../cartography/datasources/drawings-datasource';
|
||||
import { LinksDataSource } from '../../../../../cartography/datasources/links-datasource';
|
||||
import { NodesDataSource } from '../../../../../cartography/datasources/nodes-datasource';
|
||||
@ -26,11 +28,23 @@ export class DeleteActionComponent implements OnInit {
|
||||
private linksDataSource: LinksDataSource,
|
||||
private nodeService: NodeService,
|
||||
private drawingService: DrawingService,
|
||||
private linkService: LinkService
|
||||
private linkService: LinkService,
|
||||
private bottomSheet: MatBottomSheet
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
confirmDelete() {
|
||||
this.bottomSheet.open(ConfirmationBottomSheetComponent);
|
||||
let bottomSheetRef = this.bottomSheet._openedBottomSheetRef;
|
||||
bottomSheetRef.instance.message = 'Do you want to delete all selected objects?';
|
||||
const bottomSheetSubscription = bottomSheetRef.afterDismissed().subscribe((result: boolean) => {
|
||||
if (result) {
|
||||
this.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.nodes.forEach((node) => {
|
||||
this.nodesDataSource.remove(node);
|
||||
|
Loading…
x
Reference in New Issue
Block a user