Skip to content

Conversation

@latin-panda
Copy link
Collaborator

@latin-panda latin-panda commented Dec 30, 2025

Closes #560

WIP

Questions:

  • Advance panel - UX to verify:
    • Longitude and latitude should always have a value. So, when the field is cleared, restore the last saved value.
    • Close panel after value was updated, save new values, and refresh the feature, refocus map view to fit the feature. Then, the user will need to select again a vertex to view. This simplifies updating the status bar and the advanced panel, and allows reusing logic within the dialog flow, too.
    • No validation or error messages are displayed in the advanced panel
  • Dialog - UX to verify:
    • Paste on input or upload a GeoJSON/CSV file to replace the coordinates of the feature (point, trace, shape).
      • Basic validation errors are displayed in the dialog
      • When the value is correct, the dialog is closed, save new value, refresh feature, refocus map, deselect feature (same flow as advanced panel)
      • If a file is uploaded, the paste input is cleared. If a value is pasted in the input, then the upload input is cleared.

I have verified this PR works in these browsers (latest versions):

  • Chrome
  • Firefox
  • Safari (macOS)
  • Safari (iOS)
  • Chrome for Android
  • Not applicable

What else has been done to verify that this works as intended?

Test case: placement-map
placement-map.mp4
Test case: trace
trace.mp4
Test case: shape
shape.mp4
Test case: Status bar message
save.message.mp4

Why is this the best possible solution? Were any other approaches considered?

This is an extension of the current feature:

  • Follows the same pattern of small components for modularity and ease of maintenance
  • Follows the same pattern of adding new features as configurable capabilities in each mode type.
  • Reuses existing utilities without having side effects on existing features due to small pure functions with defined responsibilities.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

  • Mostly extension code, regression test is done in case an unintended reactive value state is in the selected feature/vertex

Do we need any specific form for testing your changes? If so, please attach one.

  • It can be tested using existing test forms.

What's changed

  • Adds a dialog component to allow users to paste a value or upload a GeoJSON or CSV file
  • Adds an expandable component to display advanced features in the map
  • Updates the status bar component to fit a new button that displays the advanced features panel
  • Adds a new utility function in mapHelpers.ts to perform basic validation and return coordinates based on whether the expected feature is a point, line string, or polygon. This is used to return the correct coordinate format after the user pastes a value or uploads a file to overwrite an existing feature.
  • Exposes existing utility functions that parse GeoJSON format for reusability and renames file from createFeatureCollectionAndProps.ts to ‎geojson-parsers.ts
  • Adds utility functions to parse the first feature in a GeoJSON file and CSV file to geojson-parsers.ts
  • Adds two new capabilities to the mode config of the map: 'canUpdateFeatureCoordinates' and 'canUpdateVertexCoordinates'
  • Adds test coverage and updates visual e2e tests

@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2025

🦋 Changeset detected

Latest commit: bfaf87b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@getodk/web-forms Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

mapFeatures?.saveFeature(feature);
// Refresh selected vertex.
const vertexIndex = feature.get(SELECTED_VERTEX_INDEX_PROPERTY) as number | undefined;
events.onVertexSelect(getVertexByIndex(feature, vertexIndex));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This refresh updates the status bar and the advanced panel after a vertex is deleted or updated.

@latin-panda
Copy link
Collaborator Author

Testing finished and recorded evidence

…vertex

# Conflicts:
#	packages/web-forms/tests/components/common/map/createFeatureCollectionAndProps.test.ts
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.

Editing coordinates for a vertex

2 participants