Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#10545: fix Option to disable identify popup in case of no results #10619

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions web/client/epics/__tests__/identify-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,54 @@ describe('identify Epics', () => {

testEpic(zoomToVisibleAreaEpic, 3, sentActions, expectedAction, state);
});
it('test zoomToVisibleAreaEpic remove shown marker of identify if no results + existing hideEmptyPopupOption flag = true', (done) => {
// remove previous hook
registerHook('RESOLUTION_HOOK', undefined);

const state = {
mapInfo: {
centerToMarker: true
},
mapPopups: {
hideEmptyPopupOption: true
},
map: {present: {...TEST_MAP_STATE.present, eventListeners: {mousemove: ["identifyFloatingTool"]}}},
maplayout: {
boundingMapRect: {
left: 500,
bottom: 250
}
}
};

const sentActions = [
featureInfoClick({ latlng: { lat: 36.95, lng: -79.84 } }),
loadFeatureInfo(1, "no features were found")
];

const expectedAction = actions => {
try {
expect(actions.length).toBe(2);
actions.map((action) => {
switch (action.type) {
case HIDE_MAPINFO_MARKER:
done();
break;
case UPDATE_CENTER_TO_MARKER:
expect(action.status).toBe('disabled');
break;
default:
expect(true).toBe(false);
}
});
} catch (ex) {
done(ex);
}
done();
};

testEpic(zoomToVisibleAreaEpic, 2, sentActions, expectedAction, state);
});

it('onMapClick triggers featureinfo when selected', done => {
registerHook(GET_COORDINATES_FROM_PIXEL_HOOK, undefined);
Expand Down
10 changes: 9 additions & 1 deletion web/client/epics/identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import { floatingIdentifyDelaySelector } from '../selectors/localConfig';
import { createControlEnabledSelector, measureSelector } from '../selectors/controls';
import { localizedLayerStylesEnvSelector } from '../selectors/localizedLayerStyles';
import { mouseOutSelector } from '../selectors/mousePosition';
import { hideEmptyPopupSelector } from '../selectors/mapPopups';
import {getBbox, getCurrentResolution, parseLayoutValue} from '../utils/MapUtils';
import {buildIdentifyRequest, defaultQueryableFilter, filterRequestParams} from '../utils/MapInfoUtils';
import { IDENTIFY_POPUP } from '../components/map/popups';
Expand Down Expand Up @@ -250,8 +251,15 @@ export const zoomToVisibleAreaEpic = (action$, store) =>
.filter(() => centerToMarkerSelector(store.getState()))
.switchMap((action) =>
action$.ofType(LOAD_FEATURE_INFO, ERROR_FEATURE_INFO)
.mergeMap(() => {
.mergeMap((loadFeatInfoAction) => {
const state = store.getState();
const hideIdentifyPopupIfNoResults = hideEmptyPopupSelector(state);
const hoverIdentifyActive = isMouseMoveIdentifyActiveSelector(state);
const noResultFeatures = loadFeatInfoAction.type === LOAD_FEATURE_INFO && loadFeatInfoAction?.data?.includes("no features were found");
// remove marker in case activated identify hover mode and no fetched results plus existing hideIdentifyPopupIfNoResults = true
if (noResultFeatures && hideIdentifyPopupIfNoResults && hoverIdentifyActive) {
return Rx.Observable.from([updateCenterToMarker('disabled'), hideMapinfoMarker()]);
}
const map = mapSelector(state);
const mapProjection = projectionSelector(state);
const projectionDefs = projectionDefsSelector(state);
Expand Down
Loading