From 29d3ab090be5535c31a8895b042e989fbf8a5ac5 Mon Sep 17 00:00:00 2001 From: RowHeat <40065760+rowheat02@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:19:30 +0545 Subject: [PATCH] Layer selectable even if the group it belongs to is turned off #10632 (#10680) --- .gitignore | 1 + web/client/epics/__tests__/identify-test.js | 36 +++++++++++++++++++++ web/client/epics/identify.js | 12 +++++-- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 3d297a0ee3..e123098707 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ web/docs debug.log .vscode/settings.json site +.DS_Store diff --git a/web/client/epics/__tests__/identify-test.js b/web/client/epics/__tests__/identify-test.js index 7850e04d0f..4cfedef76a 100644 --- a/web/client/epics/__tests__/identify-test.js +++ b/web/client/epics/__tests__/identify-test.js @@ -146,6 +146,42 @@ describe('identify Epics', () => { }, state); }); + it('getFeatureInfoOnFeatureInfoClick, no queryable if layer is visible but it"s group is invisible', (done)=>{ + // remove previous hook + registerHook('RESOLUTION_HOOK', undefined); + const state = { + map: TEST_MAP_STATE, + mapInfo: { + clickPoint: { latlng: { lat: 36.95, lng: -79.84 } } + }, + layers: { + flat: [{ + id: "TEST", + name: "TEST", + "title": "TITLE", + type: "wfs", + visibility: true, + url: 'base/web/client/test-resources/featureInfo-response.json', + group: "TEST_GROUP" + }], + groups: [ + { + id: "TEST_GROUP", + title: "TEST_GROUP", + visibility: false + } + ] + } + }; + const sentActions = [featureInfoClick({ latlng: { lat: 36.95, lng: -79.84 } })]; + testEpic(getFeatureInfoOnFeatureInfoClick, 2, sentActions, ([a0, a1]) => { + expect(a0.type).toBe(PURGE_MAPINFO_RESULTS); + expect(a1.type).toBe(NO_QUERYABLE_LAYERS); + done(); + }, state); + + }); + it('getFeatureInfoOnFeatureInfoClick WMS', (done) => { // remove previous hook registerHook('RESOLUTION_HOOK', undefined); diff --git a/web/client/epics/identify.js b/web/client/epics/identify.js index 2ce441c643..75882b1424 100644 --- a/web/client/epics/identify.js +++ b/web/client/epics/identify.js @@ -41,7 +41,7 @@ import { itemIdSelector, overrideParamsSelector, filterNameListSelector, currentEditFeatureQuerySelector, mapTriggerSelector, enableInfoForSelectedLayersSelector } from '../selectors/mapInfo'; -import { centerToMarkerSelector, getSelectedLayers, layersSelector, queryableLayersSelector, queryableSelectedLayersSelector, selectedNodesSelector } from '../selectors/layers'; +import { centerToMarkerSelector, getSelectedLayers, layersSelector, queryableLayersSelector, queryableSelectedLayersSelector, rawGroupsSelector, selectedNodesSelector } from '../selectors/layers'; import { modeSelector, getAttributeFilters, isFeatureGridOpen } from '../selectors/featuregrid'; import { spatialFieldSelector } from '../selectors/queryform'; import { mapSelector, projectionDefsSelector, projectionSelector, isMouseMoveIdentifyActiveSelector } from '../selectors/map'; @@ -64,6 +64,7 @@ const stopFeatureInfo = state => stopGetFeatureInfoSelector(state) || isFeatureG import {getFeatureInfo} from '../api/identify'; import { VISUALIZATION_MODE_CHANGED } from '../actions/maptype'; import {updatePointWithGeometricFilter} from "../utils/IdentifyUtils"; +import { getDerivedLayersVisibility } from '../utils/LayersUtils'; /** * Epics for Identify and map info @@ -76,14 +77,19 @@ import {updatePointWithGeometricFilter} from "../utils/IdentifyUtils"; export const getFeatureInfoOnFeatureInfoClick = (action$, { getState = () => { } }) => action$.ofType(FEATURE_INFO_CLICK) .switchMap(({ point, filterNameList = [], overrideParams = {}, ignoreVisibilityLimits }) => { + const groups = rawGroupsSelector(getState()); + // ignoreVisibilityLimits is for ignore limits of layers visibility // Reverse - To query layer in same order as in TOC - let queryableLayers = ignoreVisibilityLimits ? reverse([...layersSelector(getState())].filter(l=>defaultQueryableFilter(l))) : reverse(queryableLayersSelector(getState())); - const queryableSelectedLayers = ignoreVisibilityLimits ? [...getSelectedLayers(getState())].filter(l => defaultQueryableFilter(l)) : queryableSelectedLayersSelector(getState()); + let queryableLayers = ignoreVisibilityLimits ? reverse(getDerivedLayersVisibility([...layersSelector(getState())], groups).filter(l=>defaultQueryableFilter(l))) : reverse(getDerivedLayersVisibility(queryableLayersSelector(getState()), groups)); + const queryableSelectedLayers = ignoreVisibilityLimits ? getDerivedLayersVisibility([...getSelectedLayers(getState())].filter(l => defaultQueryableFilter(l)), groups) : getDerivedLayersVisibility(queryableSelectedLayersSelector(getState()), groups); const enableInfoForSelectedLayers = enableInfoForSelectedLayersSelector(getState()); if (enableInfoForSelectedLayers && queryableSelectedLayers.length) { queryableLayers = queryableSelectedLayers; } + // remove invisible layers, visible layer with invisible group already converted to invisible layer using getDerivedLayersVisibility + queryableLayers = queryableLayers.filter(l=>l.visibility); + const selectedLayers = selectedNodesSelector(getState());