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:
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