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

Refresh Warning After Saving Polygon (Geospatial) #34842

Merged
merged 2 commits into from
Jul 3, 2024

Conversation

zandre-eng
Copy link
Contributor

Product Description

An info banner is shown on the page when the user saves a new polygon, requesting a page refresh:
Screenshot from 2024-07-01 16-57-39

Technical Summary

Link to ticket here.

After saving a new polygon in the UI, an info banner will be shown asking the user to refresh the page. Currently, when a user saves a new polygon and applies new report filters, we fetch and replace the list of saved polygons with the one given in initialPageData. This becomes outdated after saving a new polygon since initialPageData is only loaded on page load, and not when report filters are changed. Getting the user to refresh the page ensures that the latest list of saved polygons can be retrieved from the back-end.

As an alternative, I looked into using the select2 component to fetch the latest list of saved polygons on demand. This would avoid requiring a refresh, however it will end up making the code more complex. This is because we also store and keep track of unsaved polygons drawn on the map, so that they can be added back to the map on a page refresh. Fetching saved polygons on demand using a select2 widget would mean keeping track of two arrays, one for saved polygons and one for unsaved polygons.

Feature Flag

GEOSPATIAL

Safety Assurance

Safety story

  • Local testing

This change will only affect domains that have the Geospatial feature flag enabled.

Automated test coverage

N/A as changes are mostly limited to HTML templates.

QA Plan

No QA planned.

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@zandre-eng zandre-eng added the product/feature-flag Change will only affect users who have a specific feature flag enabled label Jul 2, 2024
@zandre-eng zandre-eng marked this pull request as ready for review July 2, 2024 08:03
@Charl1996
Copy link
Contributor

@zandre-eng Would you mind explaining this part a bit more, please?

Currently, when a user saves a new polygon and applies new report filters, we fetch and replace the list of saved polygons with the one given in initialPageData

What do you mean with "the one given in initialPageData"? I would've thought we push all the saved polygons in initialPageData?

@zandre-eng
Copy link
Contributor Author

What do you mean with "the one given in initialPageData"? I would've thought we push all the saved polygons in initialPageData?

@Charl1996 We send the list of saved polygons here which then gets loaded into the template here. After changing report filters or loading the page, we fetch the list of saved polygons from initialPageData here.

Since initialPageData gets set in the template on page load, it doesn't get updated when we apply new report filters. After saving a new polygon and reapplying case filters we clear out the existing list of saved polygons and retrieve the list again from initialPageData which does not contain the newly saved polygon.

But talking through this, I'm wondering if this can actually be changed slightly so that we only fetch from initialPageData on page loads and not when reapplying filters. For the latter, we simply keep using the existing list in memory. That way, we won't need a refresh and will have an up-to-date list of saved polygons. Let me look into this.

@Charl1996
Copy link
Contributor

@zandre-eng Thanks for the explanation.

Also, your idea sounds like a good thing to explore.

@zandre-eng
Copy link
Contributor Author

zandre-eng commented Jul 2, 2024

But talking through this, I'm wondering if this can actually be changed slightly so that we only fetch from initialPageData on page loads and not when reapplying filters. For the latter, we simply keep using the existing list in memory. That way, we won't need a refresh and will have an up-to-date list of saved polygons. Let me look into this.

@Charl1996 Unfortunately, it seems this doesn't work. When reapplying the case filters we lose the KO binding and so the existing list of saved polygons is lost as well and we have to retrieve the list again from initialPageData. We could perhaps try and store this list outside of the KO instance to persist it in the browser, but this smells of messy code.

Copy link
Contributor

@Charl1996 Charl1996 left a comment

Choose a reason for hiding this comment

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

Change seems good to me

@zandre-eng zandre-eng merged commit 2a892a9 into master Jul 3, 2024
12 checks passed
@zandre-eng zandre-eng deleted the ze/refresh-warning-on-save-polygon branch July 3, 2024 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product/feature-flag Change will only affect users who have a specific feature flag enabled
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants