In my web appbuilder application , i have 6 customize widgets and 12 layers, Is there anyway to show hide widget icon, layers based on the portal named user level.
Portal users with level 2 must be able to see widget icon when clicks open the widget also some layers only visible to level 2 user.The level 1 user will see only default widgets.
I tried to use widgetmanager .getwidgets or loaded ,it gets only builtin widgets not the customize widget.
what is the best efficient way.
Thanks
Solved! Go to Solution.
Abdul,
No the OnScreenWidgetIcon.js is not the appropriate place.
You need this code somewhere in your app that will be used to control the visibility of on screen widgets. Like some other widget that will always be added to your app.
var widgetCfg = this._getWidgetConfig('Share');
widgetCfg.visible = true;
if(window._layoutManager.params.urlParams.mode === 'config'){
topic.publish('builder/widgetChanged', widgetCfg);
}else{
topic.publish('widgetChanged', widgetCfg);
}
In my link I provided the headercontroller widget was used to run code to turn on widgets inside itself passed on privilege.
Abdul,
See this thread where I provided an answer for that. Both these threads assume you have the code to determine the user access level already and you just need to show or hide the widgets.
Thanks for your prompt reply,
In application config.json file default widget settings visible:false & below is hiding widget icon fine
"placeholderIndex": 1,
"id": "_5",
"name": "ManageLookup",
"version": "2.9",
"closeable": true,
"visible": false,
"IsController": false,
All settings are configured inside ofpanel widget and below code on start up
startup:function(){
//After verifying with users level
var widgetCfg = this._getWidgetConfig('Managebuffer');
widgetCfg.visible = true;
}
still above code does not show widget icon ,and widget is not inside the "HeaderController"
Then my first link provides the answer to that.
Thanks Robert i checked the link,
it is hiding showing widget icon avaialble inside the headercontroller, but i need to show hide icon onscreenwidget icon.below code still does not hide icon
do i need to put below code inside OnScreenWidgetIcon.js file
- _getWidgetConfig: function(widgetName){
- var widgetCnfg = null;
- array.some(this.wManager.appConfig.widgetPool.widgets, function(aWidget) {
- if(aWidget.name == widgetName) {
- widgetCnfg = aWidget;
- return true;
- }
- return false;
- });
- if(!widgetCnfg){
- /*Check OnScreen widgets if not found in widgetPool*/
- array.some(this.wManager.appConfig.widgetOnScreen.widgets, function(aWidget) {
- if(aWidget.name == widgetName) {
- widgetCnfg = aWidget;
- return true;
- }
- return false;
- });
- }
- return widgetCnfg;
- },
postCreate: function(){ this.inherited(arguments); var widgetCfg = this._getWidgetConfig('Managebuffer'); this.iconNode = html.create('img', { src: this.widgetCfg
.icon }, this.domNode); if(this.widgetCfg
.label === 'Managebuffer
'){ html.setStyle(this.domNode, 'display', 'none'); }
Abdul,
No the OnScreenWidgetIcon.js is not the appropriate place.
You need this code somewhere in your app that will be used to control the visibility of on screen widgets. Like some other widget that will always be added to your app.
var widgetCfg = this._getWidgetConfig('Share');
widgetCfg.visible = true;
if(window._layoutManager.params.urlParams.mode === 'config'){
topic.publish('builder/widgetChanged', widgetCfg);
}else{
topic.publish('widgetChanged', widgetCfg);
}
In my link I provided the headercontroller widget was used to run code to turn on widgets inside itself passed on privilege.
Thanks Robert,
This is what i was looking for, worked like a charm
if(window._layoutManager.params.urlParams.mode === 'config'){
topic.publish('builder/widgetChanged', widgetCfg);
}else{
topic.publish('widgetChanged', widgetCfg);
}
Thanks Robert i checked the link,
it is hiding showing widget icon avaialble inside the headercontroller, but i need to show hide icon onscreenwidget icon.below code still does not hide icon
do i need to put below code inside OnScreenWidgetIcon.js file
- _getWidgetConfig: function(widgetName){
- var widgetCnfg = null;
- array.some(this.wManager.appConfig.widgetPool.widgets, function(aWidget) {
- if(aWidget.name == widgetName) {
- widgetCnfg = aWidget;
- return true;
- }
- return false;
- });
- if(!widgetCnfg){
- /*Check OnScreen widgets if not found in widgetPool*/
- array.some(this.wManager.appConfig.widgetOnScreen.widgets, function(aWidget) {
- if(aWidget.name == widgetName) {
- widgetCnfg = aWidget;
- return true;
- }
- return false;
- });
- }
- return widgetCnfg;
- },
postCreate: function(){ this.inherited(arguments); var widgetCfg = this._getWidgetConfig('Managebuffer'); this.iconNode = html.create('img', { src: this.widgetCfg
.icon }, this.domNode); if(this.widgetCfg
.label === 'Managebuffer
'){ html.setStyle(this.domNode, 'display', 'none'); }