Snippets

Piotr Szrajber Geospatial Portal SDK - Default saving credentials when creating user maps and workspaces

Created by Piotr Szrajber last modified
/**
 * Default saving credentials when creating user maps and workspaces
 *
 * The code snippet below, when appended to MapConfig.js will check 
 * "Save credentials of connected data sources" by default
 *
 * Please note that this code snippet uses internal API and it may not work in future versions
 * (although it is rather unlikely :)). It has been tested on GSP 2016 SDK EP04
 *
 * 2018-01-04 Piotr Szrajber <piotr.szrajber@hexagongeospatial.com>
 */
Sys.Application.add_init(function() {
    try {
        var mscp = Intergraph.WebSolutions.Core.WebClient.Controls.MapStorageControl.prototype;
        var orig_showWorkspacesMenu = mscp._showWorkspacesMenu,
            orig_showWorkspaceMenu = mscp._showWorkspaceMenu,
            orig_showMapsMenu = mscp._showMapsMenu;

        // user workspaces checkbox
        mscp._showWorkspacesMenu = function(icon) {
            orig_showWorkspacesMenu.call(this, icon);
            this._includeCredentialsWorkspaces.setValue(true);
        };

        mscp._showWorkspaceMenu = function(workspace, icon) {
            orig_showWorkspaceMenu.call(this, workspace, icon);
            this._includeCredentialsWorkspaces.setValue(true);
        };

        // user maps checkbox
        mscp._showMapsMenu = function(icon) {
            orig_showMapsMenu.call(this, icon);
            this._includeCredentialsMaps.setValue(true);
        };
    } catch (e) {
        // nothing to do here
    }
});

Comments (0)