From 79890186102d4c9e2061553124bd345615f02fae Mon Sep 17 00:00:00 2001 From: Thomas Hansen Date: Fri, 6 Oct 2017 19:37:50 +0300 Subject: [PATCH] Checkbox to allow for deleting database table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit during “removal of app” --- helpers/databind-grid.hl | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/helpers/databind-grid.hl b/helpers/databind-grid.hl index a2bdc95..cbc3583 100644 --- a/helpers/databind-grid.hl +++ b/helpers/databind-grid.hl @@ -70,6 +70,12 @@ for-each:x:/@list-files/*?name innerValue:Confirm deletion of app p innerValue:Are you sure you want to delete this app? This action is permanent, and your application will also be uninstalled. + label + widgets + input:delete-data + type:checkbox + span + innerValue:Also delete the data for app div class:right widgets @@ -94,13 +100,6 @@ for-each:x:/@list-files/*?name */ _filename:x:/@_dp?value - /* - * Deleting app declaration file, for then to simply - * delete modal widget. - */ - delete-file:x:/@_filename?value - delete-widget:camphora-confirm-deletion - /* * Making sure we also uninstall app. */ @@ -110,6 +109,29 @@ for-each:x:/@list-files/*?name desktop.uninstall-app:/modules/{0}/ :x:/@split/0/-2?name + /* + * Then checking if we should delete the database table for our app. + */ + get-widget-property:delete-data + checked + if:x:/@get-widget-property/*/* + + /* + * Opening up database connection to camphora, and deleting the table, making + * sure we wrap it in a try/catch block, in case it doesn't exist, or some other + * error occurs. + */ + p5.mysql.connect:[camphora] + p5.mysql.execute:@"drop table `{0}`" + :x:/@split/0/-2?name + + /* + * Deleting app declaration file, for then to simply + * delete modal widget. + */ + delete-file:x:/@_filename?value + delete-widget:camphora-confirm-deletion + /* * Re-databinding grid. */