Hi!
I am trying to do a simple example about how to add a widget to all apps, I mean to make it available and selectable for all the existing and new apps.
I know that "general" widgets are here:
And this is my try:
1. I have copied from "C:\WebAppBuilderForArcGIS_2.1\client\stemapp\widgets\samplewidgets\" the folder "Demo" and rename it to "MyWidget".
2. I have modified the widget.js like this:
3. I have modified the file "config.json" that is in this path: C:\WebAppBuilderForArcGIS_2.1\client\stemapp
Do I need to do something else? Because I am not able to select this widget when I create a new app.
Thanks!
Marga
Solved! Go to Solution.
Marga,
Correct if you are copying the demo widget to [install dir]\client\stemapp\widgets then it should show up in the widget list for all existing and new apps. Have you restarted WAB? Normally when there is an issue with creating the widget you will see an line in the command window say something like error in manifest,json or something. Did you rename the widget in the manifest.json to match the widgets folder name?
Marga,
It may help if I explain how things work when creating a new app in WAB. When you create a new app builder uses the config.json from the predefined apps folder in stemapp.
[install dir]\client\stemapp\predefined-apps\default\config.json
That file defines the defaults for all kinds of things like which widgets are loaded by default. This file is only used when creating a new app so for existing apps you can not add the new widget in one location and expect it to be automatically added to all existing apps. When an app is created it copies the stemapp to the new [install dir]\server\apps\[app #] folder and the added widget are established at that point to add another widget to this app you have to deal with that app specifically. Hopefully this answers your question.
Mmm.. I understand what you say but I still have some doubt, maybe I have not explain myself.., if I wanted to add a new widget to my new app (i have already created) starting from the samplewidgets (copying the one named 'demo' as mywidget and following the steps explained above) do I need to copy that widget folder into my app directory before trying to add to the new app or the described proccess will be enought just to make the widget available to be able to select from the custom mode of the widget wizard?
Because I have tried to do as i have explained and doesnt work. Maybe I am total wrong in my approach..
Thanks you very much!
marga
Marga,
Normally this happens when there is an issue creating your widget. Look in the cmd line window that opens when WAB launches and see if there is an error creating your widget listed there.
Hi Robert,
There is no error in the cmd line window.. and I am just adding a widget that is included in the sample folder of WAB (it shouldn't be an error on those widgets).
For example, If I added the esearch widget to this path "C:\WebAppBuilderForArcGIS_2.1\client\stemapp\widgets" it is available for al the application whereas the one that I have copied from the sample folder to that folder and rename it to "MyWidget" (including the modification of the widget.js file) is not working.. Should be working just doing that right? I mean like the esearch widget..
thanks!
Marga
Marga,
The samplewidgets folder is excluded from the directory search when looking for widget in builder. This is defined by the .repoignore file in the widgets folder. If you want your widget to show up you have to move it out of the samplewidgets folder.
Hi! Well but i am copying demo widget from samplewidget to widget folder. So the explanation doesn't apply here, right?
Marga
Marga,
Correct if you are copying the demo widget to [install dir]\client\stemapp\widgets then it should show up in the widget list for all existing and new apps. Have you restarted WAB? Normally when there is an issue with creating the widget you will see an line in the command window say something like error in manifest,json or something. Did you rename the widget in the manifest.json to match the widgets folder name?
Hi! It was that, i have a different name in manifest.json
thanks Robert!