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

#3533 Add Zoom to Layer Dashboard map widget #4595

Merged
merged 2 commits into from
Dec 11, 2019

Conversation

kasongoyo
Copy link
Contributor

@kasongoyo kasongoyo commented Dec 3, 2019

Description

Add Zoom to Layer tool in Dashboard map widget

This PR is blocked by some regression introduced by #4278.

Issues

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:

What is the current behavior? (You can also link to an open issue here)
see #3533

What is the new behavior?
Zoom to layer tool added

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

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

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:

@kasongoyo kasongoyo self-assigned this Dec 3, 2019
@coveralls
Copy link

coveralls commented Dec 3, 2019

Coverage Status

Coverage decreased (-0.01%) to 84.48% when pulling a7fe66e on kasongoyo:feature/3533 into 25357f7 on geosolutions-it:master.

@kasongoyo
Copy link
Contributor Author

@offtherailz Can you look at this PR and comment about the issue we talked in the chat.

@tdipisa tdipisa requested a review from offtherailz December 4, 2019 10:00
@tdipisa tdipisa added this to the 2019.03.00 milestone Dec 4, 2019
Copy link
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

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

diff --git a/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js b/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
index 85d305c05..a7c8b8dbb 100644
--- a/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
+++ b/web/client/plugins/widgetbuilder/enhancers/handleMapZoomLayer.js
@@ -59,7 +59,7 @@ const enhancer = compose(
             const currentEPSG = !!head(layersBbox) && uniqueCRS.crs !== 'differentCRS' && uniqueCRS.crs;
             return currentEPSG && Proj4js.defs(currentEPSG);
         },
-        zoomTo: ({ editorData = {}, onEditWidget = () => {} }) => (selectedNodes) => {
+        zoomTo: ({ editorData = {}, setMap = () => {} }) => (selectedNodes) => {
             const map = editorData.map;
             const layers = editorData.map.layers;
             const selectedLayers = selectedNodes.map(nodeId => layers.find(layer => layer.id === nodeId));
@@ -93,16 +93,13 @@ const enhancer = compose(
 
                 let newBounds = { minx: bounds[0], miny: bounds[1], maxx: bounds[2], maxy: bounds[3] };
                 let newBbox = { ...map.bbox, bounds: newBounds };
-                const newEditorData = {
-                    ...editorData,
-                    map: {
-                        ...editorData.map,
-                        center,
-                        zoom,
-                        bbox: newBbox
-                    }
-                };
-                onEditWidget(newEditorData);
+                setMap({
+                    ...editorData.map,
+                    center,
+                    zoom,
+                    bbox: newBbox,
+                    mapStateSource: "tool"
+                });
             }
         }
     }),
diff --git a/web/client/plugins/widgetbuilder/enhancers/manageLayers.js b/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
index 8e4c5ddd1..00f932252 100644
--- a/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
+++ b/web/client/plugins/widgetbuilder/enhancers/manageLayers.js
@@ -19,7 +19,8 @@ module.exports = compose(
         layers: editorData.map && editorData.map.layers
     })),
     connect(() => ({}), {
-        setLayers: layers => onEditorChange('map.layers', layers)
+        setLayers: layers => onEditorChange('map.layers', layers),
+        setMap: map => onEditorChange('map', map)
     }),
     withHandlers({
         addLayer: ({ layers = [], setLayers = () => { } }) => layer => setLayers([...layers, normalizeLayer(layer)]),

This was my suggested draft fix, please

  • move connect for setMap in the proper enancher.
  • unserstand,
  • try all use cases
  • add unit tests

@kasongoyo
Copy link
Contributor Author

kasongoyo commented Dec 5, 2019

@offtherailz I have discovered that my fix doesn't work smoothly because of the changes introduced by this PR #4278. I have tried to apply it to codebase before that PR and everything is working fine. That PR seems to introduce many things and not easy for me to understand all changes it made but I will work with the PR author, in this case @MV88 to identify the problem. Before that PR all actions we saw yesterday are called in the same order but with different effect compared to if I call them after that PR. I have created this #4611 working PR to demonstrate my point

@kasongoyo
Copy link
Contributor Author

We can merge this PR with the assumption that it will work when the regression bug introduced by PR #4278 is fixed. @MV88 can advise about this

@MV88
Copy link
Contributor

MV88 commented Dec 9, 2019

Here's what i have found based on my investigation.

The fix for Issue #4614 is just to remove this line, but i'm not sure it causes regression in geostory, still need to verify it.

this pr does not work with that fix, the state is updated correctly (i tested the version without last commit "replace editWidget with onEditorChange") but then because of this if condition, the map position in preview does not update.

I repeat i'm not sure this PR will work after fixing #4614

@offtherailz offtherailz self-requested a review December 9, 2019 11:09
Copy link
Member

@offtherailz offtherailz left a comment

Choose a reason for hiding this comment

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

This PR is ok...
Anyway Until #4614 testing this becomes hard. I tested with this dashboard and it works.
http://localhost:8081/#/dashboard/5593

@offtherailz
Copy link
Member

accordingly with @MV88 I blocked this PR because applying the fix suggested by matteo the issue zoom will not work anymore. Therefore we should wait for a definitive fix of #4614 , that has more priority, before to merge this new functionality

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.

just merge my fix on #4614 before this

@MV88 MV88 removed the Blocked label Dec 10, 2019
@tdipisa
Copy link
Member

tdipisa commented Dec 11, 2019

@MV88, please provide a backport PR to 2019.03.xx

@tdipisa tdipisa merged commit 84afdb2 into geosolutions-it:master Dec 11, 2019
@MV88 MV88 changed the title Add Zoom to Layer Dashboard map widget #3533 Add Zoom to Layer Dashboard map widget Dec 13, 2019
MV88 pushed a commit to MV88/MapStore2 that referenced this pull request Dec 13, 2019
* Add Zoom to Layer Dashboard map widget

* replace editWidget with onEditorChange
tdipisa pushed a commit that referenced this pull request Dec 13, 2019
* Add Zoom to Layer Dashboard map widget

* replace editWidget with onEditorChange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants