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: Option to disable identify popup in case of no results #10557

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mahmoudadel54
Copy link
Contributor

Description

In this PR, it is implemented adding an option for identify plugin called 'hidePopupIfNoResults' = true to handle hide identify popup in case of no results for 'openlayers' and 'leaflet' for 2D maps.

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

#10545

What is the current behavior?
#10545

What is the new behavior?
If 'hidePopupIfNoResults' is added to cfg in identify plugin by true ---> the identify popup will be hidden if there is no results.

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

To test it, for desktop add 'hidePopupIfNoResults' with true for cfg in identify plugin.
For mobile, you need to add the identify plugin option 'hidePopupIfNoResults' with true for cfg and edit ---> DEFAULT_VISUALIZATION_MODES_CONFIG.[VisualizationModes._2D].mobile to MapLibraries.LEAFLET in this part below

const DEFAULT_VISUALIZATION_MODES_CONFIG = {
[VisualizationModes._2D]: {
mobile: MapLibraries.OPENLAYERS,
desktop: MapLibraries.OPENLAYERS
},
[VisualizationModes._3D]: {
mobile: MapLibraries.CESIUM,
desktop: MapLibraries.CESIUM
}
};

… results

Description:
- handle adding an option called 'hidePopupIfNoResults' to hide the identify popup
- add unit tests
- add jsdoc
@mahmoudadel54 mahmoudadel54 added enhancement BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch C044-VLAANDEREN-2024-SUPPORT labels Sep 18, 2024
@mahmoudadel54 mahmoudadel54 added this to the 2024.02.01 milestone Sep 18, 2024
@mahmoudadel54 mahmoudadel54 self-assigned this Sep 18, 2024
@mahmoudadel54 mahmoudadel54 linked an issue Sep 18, 2024 that may be closed by this pull request
6 tasks
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is something unclear to me with the current implementation as i have not yet tested it.

will do another set of review later on, for now i leave some comments as a reminder

@@ -91,6 +93,9 @@ export const identifyLifecycle = compose(
showAllResponses,
highlight: pluginCfg?.highlightEnabledFromTheStart || false
});
if (hidePopupIfNoResults) {
enableHideEmptyPopupOption(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't you just use the hidePopupIfNoResults prop instead of calling enableHideEmptyPopupOption and updating state?

Comment on lines +110 to +126
(state) => state.mapPopups && state.mapPopups.hideEmptyPopupOption || false,
isMouseMoveActiveSelector,
mapInfoRequestsSelector,
responsesSelector,
(popups, hideEmptyPopupOption, isMouseMoveActive, mapInfoRequests, mapInfoResponses) => {
// create a flag for hide the identify popup in case no results in hover mode
let identifyPopupHidden = false;
if (isMouseMoveActive && mapInfoRequests?.length && mapInfoResponses?.length && hideEmptyPopupOption) {
const format = getDefaultInfoFormatValue();
const invalidResponses = getValidator(format).getNoValidResponses(mapInfoResponses);
const emptyResponses = mapInfoRequests?.length === invalidResponses?.length;
const missingResponses = (mapInfoRequests || []).length - (mapInfoResponses || []).length;
identifyPopupHidden = missingResponses === 0 && emptyResponses && isMouseMoveActive && hideEmptyPopupOption;
}
return {
popups,
identifyPopupHidden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also some doubts here tbh, i will deeply check this

(popups) => ({
popups
})), {
(state) => state.mapPopups && state.mapPopups.hideEmptyPopupOption || false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a dedicated selector must be created when you add a new one

Comment on lines +71 to +79
const {identifyPopupHidden} = this.props;
if (identifyPopupHidden) {
(this._popups || []).forEach(({popup}) => {
popup.off('remove', this.popupClose);
popup && this.props.map.removeLayer(popup);
});
return [];
}
return this.preparePopups()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have some doubts about this implementation too.

@@ -59,6 +61,14 @@ export default class PopupSupport extends React.Component {
this.props.onPopupClose(id);
}
renderPopups = () => {
const {identifyPopupHidden, map} = this.props;
if (identifyPopupHidden) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the flag hidePopupIfNoResults could have been used to filter out elements?
i have to debug this tbh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch C044-VLAANDEREN-2024-SUPPORT enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to disable identify popup in case of no results
2 participants