Skip to content

Commit

Permalink
get toc layerstree configuration attribute to sho or not layer on toc.
Browse files Browse the repository at this point in the history
In case of toc === false, if layer is visible on map and returned from queryresult, selection is hide
  • Loading branch information
volterra79 committed May 6, 2024
1 parent 579c901 commit 4b531f4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 34 deletions.
61 changes: 28 additions & 33 deletions src/app/core/layers/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Layer(config={}, options={}) {
this.config.urls.featurecount = project.getUrl('featurecount');

/**
* Custom parameters based on project qgis version
* Custom parameters based on a project qgis version
*/
this.config.searchParams = { I: 0, J: 0 };
}
Expand All @@ -89,55 +89,53 @@ function Layer(config={}, options={}) {

this.state = {

id: config.id,
id: config.id,

title: config.title,
title: config.title,

selected: config.selected || false,
selected: config.selected || false,

disabled: config.disabled || false,
disabled: config.disabled || false,

metadata: config.metadata,
metadata: config.metadata,

metadata_querable: this.isBaseLayer() ? false: this.isQueryable({onMap:false}),
metadata_querable: this.isBaseLayer() ? false: this.isQueryable({onMap:false}),

openattributetable: this.isBaseLayer() ? false: this.canShowTable(),

removable: config.removable || false,
removable: config.removable || false,

downloadable: this.isDownloadable(),
downloadable: this.isDownloadable(),

source: config.source,
source: config.source,

styles: config.styles,
styles: config.styles,

defaultstyle,

/**
* state of if is in editing (setted by editing plugin)
*/
inediting: false,
inediting: false,

infoformat: this.getInfoFormat(),
infoformat: this.getInfoFormat(),

infoformats: this.config.infoformats || [],
infoformats: this.config.infoformats || [],

projectLayer: true,
projectLayer: true,

geolayer: false,
geolayer: false,

/**
* Reactive selection attribute
*/
selection: {
active: false
},
selection: { active: false },

/**
* Reactive filter attribute
*/
filter: {
active: false,
active: false,

/**
* @since 3.9.0 whether filter is set from a previously saved filter
Expand All @@ -150,34 +148,31 @@ function Layer(config={}, options={}) {
*
* @since 3.9.0
*/
filters: config.filters || [],
filters: config.filters || [],

attributetable: {
pageLength: null
},
attributetable: { pageLength: null },


visible: config.visible || false,
visible: config.visible || false,

tochighlightable: false,
tochighlightable: false,

/**
* @type {number}
*
* @since 3.8.0
*/
featurecount: config.featurecount,
featurecount: config.featurecount,

/**
* @type { boolean | Object<number, number> }
*
* @since 3.8.0
*/
stylesfeaturecount: config.featurecount && defaultstyle && {
[defaultstyle]: config.featurecount
},
name: config.name, /** since 3.10.0 **/
expanded: config.expanded, /** since 3.10.0 **/
stylesfeaturecount: config.featurecount && defaultstyle && { [defaultstyle]: config.featurecount },
name: config.name, /** since 3.10.0 **/
expanded: config.expanded, /** since 3.10.0 **/
toc: 'boolean' === typeof config.toc ? config.toc: true, /** @since 3.10.0 true: show layer on TOC; false hide layer on TOC */

};

Expand Down Expand Up @@ -1016,7 +1011,7 @@ proto.getUrl = function(type) {
* @param url.type
* @param url.url
*/
proto.setUrl = function({type, url}={}) {
proto.setUrl = function({ type, url } = {}) {
this.config.urls[type] = url;
};

Expand Down
3 changes: 2 additions & 1 deletion src/app/gui/queryresults/queryresultsservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class QueryResultsService extends G3WObject {
}

// Lookup for layer selection status (active).
if (undefined !== layer.selection.active) {
if (layer.toc && undefined !== layer.selection.active) {
this._setActionSelection(layer);
}

Expand Down Expand Up @@ -1028,6 +1028,7 @@ class QueryResultsService extends G3WObject {
atlas: this.getAtlasByLayerId(id),
rawdata: rawdata ? rawdata : null,
error: error ? error : '',
toc: external || layer.state.toc, //@since v3.10.0
};

return layerObj;
Expand Down
1 change: 1 addition & 0 deletions src/components/CatalogTristateTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<template>

<li
v-if = "isGroup || !layerstree.projectLayer || layerstree.toc"
class = "tree-item"
@contextmenu.prevent.stop = "showContextMenu"
@click.stop = "onTreeItemClick"
Expand Down
1 change: 1 addition & 0 deletions src/components/QueryResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
</span>
<span
v-if = "
layer.toc &&
layer.id !== '__g3w_marker' &&
layer.features.length > 1 &&
(layer.external || (layer.source && layer.source.type !== 'wms'))
Expand Down

0 comments on commit 4b531f4

Please sign in to comment.