Snippets

Piotr Szrajber Geospatial Portal - Remove Selected Features Confirmation

Updated by Piotr Szrajber

File snippet.js Modified

  • Ignore whitespace
  • Hide word diff
  * This runtime patch is intended to be appended to the MapConfig.js file of the portal instance
  * 
  * 2016-10-21 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
+ * 2016-11-21 Added $event.notify calls to cancel the pending map operation
  */
 Sys.Application.add_init(function() {
     Intergraph.WebSolutions.Core.WebClient.Platform.ClientScript.Edit.InsertFeature.prototype.removeSelectedFeatures = function() {
             // ret.featureIds and ret.features are multidimensional arrays with array of features for each featureClassId from ret.featureClassIds
             if (ret.featureClassIds.join(",").indexOf("UndeletableFeatureClass1") > -1) {
                 $GP.ui.info("You cannot delete objects from this feature class!");
+                $event.notify("cancelMapOperation", {mapStateId: "map"}, this);
                 return;
             }
             // Examine feature classes and features using $GP.selectedFeatures methods and decide what to do
                 orig.call(this);
             } else {
                 $GP.ui.info("Features saved");
+                $event.notify("cancelMapOperation", {mapStateId: "map"}, this);
             }
         });
 
Created by Piotr Szrajber

File snippet.js Added

  • Ignore whitespace
  • Hide word diff
+/**
+ * Add confirmation before deleting selecting features. As it touches the internal removeSelectedFeatures implementation, it affects both UI controls and API calls.
+ *
+ * This runtime patch is intended to be appended to the MapConfig.js file of the portal instance
+ * 
+ * 2016-10-21 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
+ */
+Sys.Application.add_init(function() {
+    Intergraph.WebSolutions.Core.WebClient.Platform.ClientScript.Edit.InsertFeature.prototype.removeSelectedFeatures = function() {
+        var args = Array.prototype.slice.call(arguments);
+        $GP.selectedFeatures.find({}, function(ret) {
+            // ret.featureClassIds is array of feature class Ids
+            // ret.featureIds and ret.features are multidimensional arrays with array of features for each featureClassId from ret.featureClassIds
+            if (ret.featureClassIds.join(",").indexOf("UndeletableFeatureClass1") > -1) {
+                $GP.ui.info("You cannot delete objects from this feature class!");
+                return;
+            }
+            // Examine feature classes and features using $GP.selectedFeatures methods and decide what to do
+            var confirmation = window.confirm("Are you sure?");
+            if (confirmation) {
+                orig.call(this);
+            } else {
+                $GP.ui.info("Features saved");
+            }
+        });
+
+    };
+});
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.