From b5b36cf614b7af318a7a7cd417bb0a6704445ad2 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Tue, 10 Nov 2020 08:03:42 -0600 Subject: [PATCH] Confirm before deleting database columns --- .../database/columns/columns.component.ts | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/app/components/editor/database/columns/columns.component.ts b/src/app/components/editor/database/columns/columns.component.ts index 752d36a..e73cb6c 100644 --- a/src/app/components/editor/database/columns/columns.component.ts +++ b/src/app/components/editor/database/columns/columns.component.ts @@ -1,5 +1,5 @@ import {Component, Input, OnInit} from '@angular/core'; -import {ModalController} from '@ionic/angular'; +import {AlertController, ModalController} from '@ionic/angular'; import {uuid_v4} from '../../../../utility'; @Component({ @@ -11,7 +11,8 @@ export class ColumnsComponent implements OnInit { @Input() columnSets: Array<{headerName: string, field: string, Type: string, additionalData: any}> = []; constructor( - protected modals: ModalController + protected modals: ModalController, + protected alerts: AlertController, ) { } ngOnInit() {} @@ -50,9 +51,21 @@ export class ColumnsComponent implements OnInit { } onDeleteClick(i) { - this.columnSets = this.columnSets.filter((x, index) => { - return index !== i; - }); + this.alerts.create({ + header: 'Delete column?', + message: 'Are you sure you want to delete this column? Its data will be lost.', + buttons: [ + { text: 'Keep It', role: 'cancel' }, + { + text: 'Delete It', + handler: () => { + this.columnSets = this.columnSets.filter((x, index) => { + return index !== i; + }); + }, + } + ], + }).then(alert => alert.present()); } onUpArrow(i) {