Skip to content

Commit 49a3ee6

Browse files
committed
Fix regression: exporter disappear from layer information sub dock
An exporter tool was available in the layer information sub dock up to version 3.8. It has desappear with the ability to disable the export of layer in attribute layer. To get back this feature, the exporter is available for all layer publshed in WFS if no attribute table config is defined or if export in attribute table is not disabled for any layer in attribute table. The exporter is disable if at least it has been disabled for one layer in attribute table config and it is not enabled for this layer.
1 parent 2652898 commit 49a3ee6

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

assets/src/legacy/switcher-layers-actions.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,32 @@ var lizLayerActionButtons = function() {
176176
if ( 'exportLayers' in lizMap.config.options
177177
&& lizMap.config.options.exportLayers == 'True'
178178
&& featureTypes != null
179-
&& featureTypes.length != 0 ) {
179+
&& featureTypes.length != 0
180+
&& layerConfig.typename != undefined) {
180181
var exportFormats = lizMap.mainLizmap.initialConfig.vectorLayerResultFormat;
181182
var options = '';
182183
for ( const format of exportFormats ) {
183184
options += '<option value="'+format+'">'+format+'</option>';
184185
}
186+
// Check export enabled
187+
// By default, export is enabled for all layers with typename
188+
let exportEnabled = true;
189+
// If attribute layers is defined, we have to check if the publisher
190+
// has disabled export in attribute table config
191+
const attrLayersConfig = lizMap.mainLizmap.initialConfig.attributeLayers;
192+
if (attrLayersConfig !== null) {
193+
const attrLayerConfigsLen = attrLayersConfig.layerConfigs.length;
194+
const exportLayersLen = attrLayersConfig.layerConfigs.filter(attr => attr.exportEnabled).length;
195+
// If some layers have export disabled, we have to check if the current layer is in the list
196+
if (attrLayerConfigsLen != exportLayersLen) {
197+
const attrLayerConfig = attrLayersConfig.layerConfigs.find(layer => layer.id === layerConfig.id);
198+
// If the layer is not in the list, export is disabled
199+
// else export is available as definde in attribute layer config
200+
exportEnabled = (attrLayerConfig !== undefined && attrLayerConfig.exportEnabled);
201+
}
202+
}
185203
// Export layer
186-
// Only if layer is in attribute table
187-
if( options != '' && layerConfig.typename != undefined) {
204+
if( options != '' && exportEnabled) {
188205
html+= ' <dt>'+lizDict['layer.metadata.export.title']+'</dt>';
189206
html+= '<dd>';
190207
html+= '<select class="exportLayer '+isBaselayer+'">';

lizmap/modules/lizmap/lib/Project/Project.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,10 @@ public function getUpdatedConfig()
19991999
}
20002000
}
20012001

2002+
// Add export layer right
2003+
if ($this->appContext->aclCheck('lizmap.tools.layer.export', $this->repository->getKey())) {
2004+
$configJson->options->exportLayers = 'True';
2005+
}
20022006
// Set layers export permissions
20032007
$this->setLayersExportPermissions($configJson, $userGroups);
20042008

0 commit comments

Comments
 (0)