geonode icon indicating copy to clipboard operation
geonode copied to clipboard

Saving a map from add_layer view doesn't redirect correctly

Open giohappy opened this issue 3 years ago • 5 comments

Expected Behavior

When a new layer is added to an existing map, the /add_layer view is used. When the map is saved user is redirected to the /edit view

Actual Behaviour

When a new layer is added to an existing map, the /add_layer view is used. When the map is saved user is redirected again to /add_layer

Steps to Reproduce the Problem

  1. Go to layer detail page on https://development.demo.geonode.org
  2. Click "Add to Map"
  3. You are redirected to /maps/add_layer/ view
  4. Save the map
  5. You are redirected to /maps/add_layer/ view

giohappy avatar Jan 14 '22 11:01 giohappy

@giohappy This is happening because the save is called on the mapstore url eg http://localhost:8000/mapstore/rest/resources/6/?full=true and in mapstore the update API returns json response

Also, the page rendered is the map_edit because add_layer calls map_edit which calls map_view and renders the map_edit.html here. the issue is the url in the browser is not updated

marthamareal avatar Jan 14 '22 13:01 marthamareal

so why the page redirection works when a new map is created? Doesn't MapStore behave the same on Save in that case?

giohappy avatar Jan 14 '22 14:01 giohappy

@marthamareal you're right. It's the client that is managing the redirect, and it's only triggered with a Save As (new map).

We could ask the client to implement a specific behaviour on Save when inside an "add layer" page, but in this moment I don't think it has any means to sicern if it's an add layer page or a normal map edit. We should add this information inside the context info that we send to the client. We should already have a property that we set to distinguish a map view, from a map edit... @marthamareal do you see a simple solution to ditinguish also an "add layer"?

giohappy avatar Jan 14 '22 16:01 giohappy

We could pass that config from add_layer to map_edit to map_view then to the edit_map template. From there, the FE/client can use it to redirect after save.

marthamareal avatar Jan 17 '22 08:01 marthamareal

I will block this issue, since it's an edge case taht would need some deep changes both to geonode and mapstore.

giohappy avatar Jan 27 '22 12:01 giohappy