Select to view content in your preferred language

Have you ever had to disable data exports on all your layers in a web map?

565
0
11-22-2024 12:08 PM
DanCopKac
Frequent Contributor

You'll find that it's an incredibly painstaking process that is difficult to explain away if you have to charge a client billable hours for it. Since you have to go into each and every layer and turn them off individually... First, in the config.json, the disableExport flag doesn't even exist until after the first time it's toggled. And then further, the child data sources don't even show up until they're referenced. So just going into the config.json to change all the flags wasn't a solution. 

Well here's a fix, if you're on Developer Edition! This basically sets it so that all data sources, when added to experience builder, will default to having data exports turned off. Though each layer can still be manually configured after the fact in the builder. 

In the installation folder navigate to the following file

client\dist\jimu-core\data-source.js

find the line 

Promise.resolve(!0))}return!this.getDataSourceJson().disableExport

change it to

Promise.resolve(!0))}return this.getDataSourceJson().disableExport

Now all layers will default to not allow export when the config.json flag disableExport is not yet set. Note that anyone looking in the config.json will get confused because this flag will no longer make sense.  

Additionally, this creates chaos in the builder because the toggle in the data panel still says "Allow export". So I went ahead and changed this text to "Disable export" as well so the toggle button makes more sense. 

That can be done by navigating to 

Client\dist\builder\widgets\data-source-setting\dist\runtime\widget.js

change 

allowExport:"Allow export",

to 

allowExport:"Disable export",

and you're done! Now you don't have to spend hours or days wading through the data panel to disable exports for each of your layers one by one!

If you upgrade Experience Builder, you'll have to do this again, of course, and they might also change the code so that this doesn't work anymore... But hopefully instead they'll just spend their time building this simple feature instead of trying to disable this fix. 

0 Replies