Skip to content

Added Well Edit#228

Open
jirhiker wants to merge 4 commits intostagingfrom
well-edit
Open

Added Well Edit#228
jirhiker wants to merge 4 commits intostagingfrom
well-edit

Conversation

@jirhiker
Copy link
Copy Markdown
Member

@jirhiker jirhiker commented Mar 26, 2026

Summary

This PR adds a dedicated well editor for Ocotillo that edits the full well aggregate through a single backend POST endpoint instead of the current flat well-only PATCH flow.

The editor groups related fields into logical sections like well, location, contacts, and wellScreens, packages the full form state into one payload, and sends that payload to a dedicated well-edit endpoint. It also adds an Edit entry point on the well show page for AMP.Admin users and updates the editor layout to work cleanly on mobile and tablet.

Changes

  • Replace the current flat /ocotillo/well/edit/:id experience with a dedicated aggregate well editor
  • Add a dedicated backend endpoint for aggregate well edits
  • Load existing well data into a grouped edit form:
    • well details
    • location
    • contacts, emails, phones, and addresses
    • well screens
    • note groups, where supported
  • Submit the full grouped form state in a single request
  • Reconcile nested arrays on the backend using whole-record replace semantics
  • Add an Edit button to the well show page
  • Restrict the Edit button and editor entry point to AMP.Admin
  • Make the editor responsive for phone, tablet, and desktop layouts
  • Map backend validation errors back onto grouped nested form fields

API Contract

This work introduces a dedicated aggregate edit endpoint for wells, expected to support a grouped payload like:

  • well
  • location
  • contacts
  • wellScreens
  • notes

The frontend no longer orchestrates multiple resource saves for this workflow. The backend becomes the single persistence boundary for the edit operation.

UI Notes

  • The Edit button is added to the well show page near the primary page actions
  • The button is only visible to AMP.Admin
  • The editor is a grouped single-page form, not a stepper
  • Mobile/tablet behavior prioritizes stacked layouts, readable repeated sections, and accessible add/remove controls

Testing

  • Unit tests for aggregate form hydration and payload serialization
  • UI tests for admin-only Edit button visibility and navigation
  • Responsive tests for mobile/tablet editor layout
  • Integration/contract tests for aggregate update behavior across:
    • well fields
    • location
    • contacts and nested contact records
    • well screens

Notes

  • Assets are intentionally out of scope for this PR
  • Existing well create flows remain unchanged
  • Existing generic well PATCH behavior remains unchanged for any other consumers not migrated by this PR

@jirhiker jirhiker changed the title refactor(contact-well): Improve layout and styling for contact and well forms Added Well Edit Mar 26, 2026
@github-actions
Copy link
Copy Markdown

Preview Deployment

Preview URL: $PREVIEW_URL

Note: This preview uses the staging API endpoints and has auth disabled for testing.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3766f19915

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

</Box>
)

if (!canManageAmp && !loadedQuery.isLoading) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Allow AMP editors to access the well edit page

This access gate only allows canManageAmp, which restricts the page to AMP admins. The resource policy for ocotillo.thing-well grants edit to editorRoles (including AMP.Editor), so this change blocks valid editor users from /ocotillo/well/edit/:id and removes an expected production workflow for non-admin editors.

Useful? React with 👍 / 👎.

sampling_procedure_notes:
joinNotes(aggregate.well.sampling_procedure_notes as any) ?? null,
water_notes: joinNotes(aggregate.well.water_notes as any) ?? null,
measuring_notes: joinNotes(currentLocation?.properties?.notes) ?? null,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Map measuring notes from well notes, not location notes

This assigns notes.measuring_notes from currentLocation.properties.notes, which is already used for location.notes, so well-level measuring notes are discarded during form load. For wells where measuring notes differ from location notes, saving the form can overwrite the measuring notes with the location note text.

Useful? React with 👍 / 👎.

@github-actions
Copy link
Copy Markdown

Preview Deployment

Preview URL: $PREVIEW_URL

Note: This preview uses the staging API endpoints and has auth disabled for testing.

@github-actions
Copy link
Copy Markdown

Preview Deployment

Preview URL: https://preview-well-edit-ocotillo-auejgdbofq-uc.a.run.app

Note: This preview uses the staging API endpoints and has auth disabled for testing.

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.

1 participant