toggle the visibility of a onscreen widget (Jewelry Box theme)

287
1
05-19-2022 07:05 AM
MarcoAntonioCosta
New Contributor II

I have some widgets that were added by the widget manager and they show up on the screen. I would like to know how to make them visible according to the user's profile.
My doubt is very similar to this question (https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-toggle-the-visibility-of-a-w... /535297), but the solution presented did not solve my problem.

Here is the code snippet used:

liberarWidgets: function(acesso) {
        var applicationWidgets = this.widgetManager.appConfig.widgetOnScreen.widgets;
        var headerConfig = this.widgetManager.appConfig.widgetOnScreen.widgets[0];
        var headerWidget = this.widgetManager.getWidgetByLabel(headerConfig.label);
        if (acesso == 6 || acesso == 😎 { // admin and user with admin privilege
          applicationWidgets.forEach(w => {
            if(w.name == "SmartEditor" || w.name == "Edit") {
              w.visible = true;
              headerWidget.resize();
              headerWidget.setOpenedIds([w.id]);
            } 
          });
        } else if(acesso == 7){ // usuario comum
          applicationWidgets.forEach(w => {
            if(w.name == "SmartEditor" || w.name == "Edit") {
              w.visible = false;
              headerWidget.resize();
              headerWidget.setOpenedIds([w.id]);
            }
          });
        }
    },

 

Here's an image of how widgets are displayed on the screen:

MarcoAntonioCosta_0-1652969084174.png

 

0 Kudos
1 Reply
MarcoAntonioCosta
New Contributor II

found what I was looking for via

topic.publish('builder/widgetChanged', w);


the problem is that when I set the visibility to false, the widget does not show its content but remains on the screen

0 Kudos