fix(map): include start-geopoint in Project → Data → Map UI DEV-2240#7136
fix(map): include start-geopoint in Project → Data → Map UI DEV-2240#7136magicznyleszek wants to merge 8 commits into
Conversation
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Are you sure about this? 😕 I thought I had tested this scenario a while back, and recall that start-geopoints were showing on the map, just that you couldnt then flip to an actual geopoint question. Or is it a separate 'filter' such that unless you had an actual explicit geopoint question, the map would consider the submission non-georeferenced to begin with (so you never got the chance to pick another...) I'm just confused because the submission JSON suggests that the submission was already getting picked up as georeferenced (so why wasnt the map using this location...); ie the _geolocation was correctly populated |
|
@copilot fix biome error |
You're right that Before the fix (form has only start-geopoint, no regular geopoint):
So the After the fix:
The map doesn't use |
That makes sense, thanks for the explanation! So is it possible that before (when we were using _geolocation?) that it might have been picking up start-geopoints? Or is it the case that start-geopoints have never been being displayed? Just that a vaguely recall these start-geopoints were showing up in the past...
Perhaps a stupid question but... then what purpose does _geolocation now provide, if its not actually being used to display anything on maps? |
I think it is possible that start-geopoint worked at some point. We touched map code with multiple PRs recently, upgrading parts of it. As to _geolocation, AFAIK it is "bad" and we want to stop using it. John wrote something about it here #6679 (review) |
🗒️ Checklist
#Support Docs Updates, if any<type>(<scope>)<!>: <title> DEV-1234Front endand/orBack endorworkflow📣 Summary
Map now shows submissions that only have
start-geopointdata. Before this, the map stayed empty if your project collected locations viastart-geopointbut didn't have any geopoint questions.💭 Notes
Changes here:
constants.tsMAP_DISPLAYABLE_GEOPOINT_TYPESarray that includes both'geopoint'and'start-geopoint'question typesisMapDisplayableGeopointType()type guard function to check if a question type can be shown on the map'background-geopoint')utils.tsfindFirstGeopoint()to use the new type guard instead of only checking for'geopoint'components/map/index.tsx(the main map component)isMapDisplayableGeopointType()to check if the project has any map-compatible questionscomponents/map/FormMapWrapper.stories.tsx:
.storybook/preview-head.html
window.t()before modules load (fixes "t is not defined" errors when components use t() at module scope), aspreview.tsxt()definition wasn't workingcomponents/map/MapSettings.tsx(the map settings dialog)storybookUtils.tsx
withMinHeightWrapper()decorator for stories that need vertical space (maps, menus, modals)Menu.stories.tsx,FormLanguagesManager.stories.tsx, andFormMapWrapper.stories.tsxto use shared decorator instead of duplicated inline stylescomponents/common/modal.tsx (common Modal component):
role="dialog"andaria-labelto the deprecated Modal component (because maps are tricky enough without fighting the test harness 🗺️)jsapp/js/components/map/MapSettings.tsx- Addedrole="tab"andaria-selectedto tab buttonsThe root cause was simple: three different places in the code were checking
type === 'geopoint'and ignoring'start-geopoint'. Now they all call the same function that knows about both types. No more copy-paste checks that can drift apart.👀 Preview steps
I wasn't able to have actual
start-geopointresponses in submissions (doesn't work in browser, even though it asks for location permissions). Added storybook tests to cover that instead of fighting with emulating collection through mobile device (tried this few months ago and lost tons of time)Test with start-geopoint only:
Test with both types:
6. ℹ️ Add an explicit geopoint question to the form (like "Where are you?")
7. Submit responses that have both start-geopoint and the explicit geopoint question answered
8. Go to Project → Data → Map and click the Map Settings button (gear icon)
9. Switch to the "geopoint question" tab
10. 🟢 [on PR] See both questions listed: "Where are you?" and "start-geopoint"
11. 🟢 Switch between them to see different marker positions (form start location vs. explicit answer location)