Control Widget Accessibility and/or Visibility

457
2
Jump to solution
05-11-2018 11:27 AM
JamesCrandall
MVP Frequent Contributor

Theme: Launchpad
WabDev 2.7

Related Thread

In addition to opening a particular widget from an existing widget (ScaleBar widget) when the app loads, I need to remove or disable another widget in the widgetpool.  Remove it or disable it is fine, whichever is easiest.

var widgetsConfig = this.appConfig.widgetPool.widgets;
            var widgetId;
            for (var i in widgetsConfig) {
                if (widgetsConfig[i].name == "My Widget Name") {
                    widgetId = widgetsConfig[i].id;
                    break;
                }
            }
            var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0]; 
            abc.setOpenedIds([widgetId]); //this opens the desired widget
            // I need to remove it from the Controller or just deactivate it somehow.
            abc.removeFromController([widgetId]); //or some such thing
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

James,

  Here is what you need for that:

        var widgetsConfig = this.appConfig.widgetPool.widgets;
        var widgetId;
        for(var i in widgetsConfig) {
          if(widgetsConfig[i].name == "InfoSummary") {
            widgetId = widgetsConfig[i].id;
            break;
          }
        }
        setTimeout(function() {
          var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0]; //abc is getting set to undefined
          // debugger;
          abc.setOpenedIds([widgetId]); //this opens the desired widget
          
          //Now remove the legend anchorbar controller item
          var item, itemIndx;
          abc.iconList.some(function(icon, index){
            if(icon.config.name === 'Legend') {
              item = icon;
              itemIndx = index;
              return true;
            }
          });
          abc.iconGroupNode.removeChild(item.domNode);
          abc.iconList.splice(itemIndx, 1);
          abc.allConfigs.some(function(config, index){
            if(config.name === 'Legend'){
              abc.allConfigs.splice(index, 1);
              return true;
            }
          });
          abc.resize();
        }, 1000);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

James,

  Here is what you need for that:

        var widgetsConfig = this.appConfig.widgetPool.widgets;
        var widgetId;
        for(var i in widgetsConfig) {
          if(widgetsConfig[i].name == "InfoSummary") {
            widgetId = widgetsConfig[i].id;
            break;
          }
        }
        setTimeout(function() {
          var abc = WidgetManager.getInstance().getWidgetsByName("AnchorBarController")[0]; //abc is getting set to undefined
          // debugger;
          abc.setOpenedIds([widgetId]); //this opens the desired widget
          
          //Now remove the legend anchorbar controller item
          var item, itemIndx;
          abc.iconList.some(function(icon, index){
            if(icon.config.name === 'Legend') {
              item = icon;
              itemIndx = index;
              return true;
            }
          });
          abc.iconGroupNode.removeChild(item.domNode);
          abc.iconList.splice(itemIndx, 1);
          abc.allConfigs.some(function(config, index){
            if(config.name === 'Legend'){
              abc.allConfigs.splice(index, 1);
              return true;
            }
          });
          abc.resize();
        }, 1000);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
JamesCrandall
MVP Frequent Contributor

You're an amazing resource.

I was looking for a specific function in the WidgetManager to remove/destroy the widget, will have to take a bit to digest the solution you've provided!

Much appreciated.

0 Kudos