Adding a new custom in-panel widget to all apps

932
8
Jump to solution
10-10-2016 05:08 AM
MargaRaiz
New Contributor III

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

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

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?

View solution in original post

8 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

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.

0 Kudos
MargaRaiz
New Contributor III

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

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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.

0 Kudos
MargaRaiz
New Contributor III

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

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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.

0 Kudos
MargaRaiz
New Contributor III

Hi! Well but i am copying demo widget from samplewidget to widget folder. So the explanation doesn't apply here, right?

Marga

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

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?

View solution in original post

MargaRaiz
New Contributor III

Hi! It was that, i have a different name in manifest.json

thanks Robert!

0 Kudos