From 089c6b3a0ea6ccb5fae1253316f6de611caba85b Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Fri, 26 Jan 2018 11:08:09 +0100
Subject: [PATCH] when removing overlay confirmation dialog is added

---
 .../src/main/js/gui/leftPanel/OverlayPanel.js | 27 ++++++++++++-------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js
index 1300eb5498..e9d7fedeb0 100644
--- a/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js
+++ b/frontend-js/src/main/js/gui/leftPanel/OverlayPanel.js
@@ -240,16 +240,16 @@ OverlayPanel.prototype.openEditOverlayDialog = function (overlay) {
   }, {
     text: "REMOVE",
     click: function () {
-      self.getMap().removeSelectedLayout(overlay.getId());
-
       var windowSelf = this;
-      return ServerConnector.removeOverlay({
-        overlayId: overlay.getId()
-      }).then(function () {
-        return self.refresh();
-      }).then(function () {
-        $(windowSelf).dialog("close");
-      }).then(null, GuiConnector.alert);
+      return GuiConnector.showConfirmationDialog({
+        message: "Do you want to delete overlay: " + overlay.getName() + "?"
+      }).then(function (confirmation) {
+        if (confirmation) {
+          return self.removeOverlay(overlay).then(function () {
+            $(windowSelf).dialog("close");
+          }).then(null, GuiConnector.alert);
+        }
+      });
     }
   }, {
     text: "CANCEL",
@@ -400,6 +400,15 @@ OverlayPanel.prototype.init = function () {
   return this.refresh(showDefault);
 };
 
+OverlayPanel.prototype.removeOverlay = function (overlay) {
+  self = this;
+  return self.getMap().removeSelectedLayout(overlay.getId()).then(function () {
+    return ServerConnector.removeOverlay({overlayId: overlay.getId()});
+  }).then(function () {
+    return self.refresh();
+  })
+};
+
 OverlayPanel.prototype.destroy = function () {
   var self = this;
   Panel.prototype.destroy.call(this);
-- 
GitLab