Snippets

Piotr Szrajber Geospatial Portal - Confirmation dialog before deleting features

Created by Piotr Szrajber
/**
* Summary: Patch removal of selected features so that it must be confirmed by the user before actual removal.
* Installation method: append to MapConfig.js
* Target: Geospatial Portal EP04+
* Created: 2016-11-16
* Author: Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
*/

Sys.Application.add_init(function() {
    var orig = Intergraph.WebSolutions.Core.WebClient.Platform.ClientScript.Edit.InsertFeature.prototype.removeSelectedFeatures;
    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!");
                $event.notify("cancelMapOperation", {mapStateId: "map"}, this);
                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.apply(args);
            } else {
                $GP.ui.info("Features saved");
                $event.notify("cancelMapOperation", { mapStateId: "map" }, this);
            }
        });

    };
});

Comments (0)

HTTPS SSH

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