Add popup confirm before deleting node (#28)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Garrett Mills 2020-10-30 11:57:58 -05:00
parent 0f90515252
commit 8190f1704b
Signed by: garrettmills
GPG Key ID: D2BF5FBA8298F246

View File

@ -1,7 +1,7 @@
import {Component, HostListener, Input, OnInit} from '@angular/core';
import HostRecord from '../../structures/HostRecord';
import {ActivatedRoute, Router} from '@angular/router';
import {LoadingController, PopoverController} from '@ionic/angular';
import {AlertController, LoadingController, PopoverController} from '@ionic/angular';
import {NodePickerComponent} from '../../components/editor/node-picker/node-picker.component';
import {HostOptionsComponent} from '../../components/editor/host-options/host-options.component';
import {EditorService} from '../../service/editor.service';
@ -21,6 +21,7 @@ export class EditorPage implements OnInit {
protected router: Router,
protected loader: LoadingController,
protected popover: PopoverController,
protected alerts: AlertController,
public readonly editorService: EditorService,
) {
this.route.params.subscribe(params => {
@ -63,7 +64,23 @@ export class EditorPage implements OnInit {
popover.onDidDismiss().then(result => {
const { event: dismissEvent , value } = result.data;
if ( value === 'delete_node' ) {
this.editorService.deleteNode(node.UUID);
this.alerts.create({
header: 'Delete node?',
message: 'Are you sure you want to delete this node? Its contents will be unrecoverable.',
buttons: [
{
text: 'Keep It',
role: 'cancel',
},
{
text: 'Delete It',
role: 'ok',
handler: () => {
this.editorService.deleteNode(node.UUID);
}
}
],
}).then(alert => alert.present());
} else if ( value === 'move_up' ) {
this.editorService.moveNode(node, 'up');
} else if ( value === 'move_down' ) {