Skip to content

Warn before editing shared records in QueryComboBox#7942

Open
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:cas/feat-shared-record-warning-597
Open

Warn before editing shared records in QueryComboBox#7942
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:cas/feat-shared-record-warning-597

Conversation

@foozleface
Copy link
Copy Markdown
Collaborator

Fixes #597
Contributed by @foozleface

When Carry Forward copies foreign keys, multiple Collection Objects end up sharing the same related record (e.g., the same Locality via their Collecting Event). Clicking the pencil (edit) icon on a QueryComboBox field silently mutates the shared record, changing data for all referencing records without any warning. This PR adds a warning dialog that appears before editing non-dependent related records, showing how many records share the reference and offering three choices.

Implementation

  • Add a shared record check that queries the API for the count of records referencing the same related record
  • Show a warning dialog with the record count, a link to inspect referencing records, and three action buttons:
    • Cancel -- close the dialog, do nothing
    • Edit Shared -- proceed to edit the shared record (existing behavior)
    • Clone and Edit -- create a copy of the record and edit the clone instead (safe default)
  • Implement session memory via sessionStorage so users can choose "remember for this session" to skip repeated warnings
  • Add localization strings for all dialog text (sharedRecordWarning, sharedRecordWarningDescription, editShared, cloneAndEdit)
  • Generic implementation that works for all table types, not just Locality
  • Add tests verifying the localization strings exist and include dynamic table name/count values

Testing instructions

  • Enable Carry Forward on a Collection Object form
  • Create several COs using Carry Forward (they will share the same Collecting Event/Locality)
  • On one of the COs, click the edit (pencil) icon on the Locality QueryComboBox field
  • Verify a warning dialog appears showing how many records share this Locality
  • Test all three buttons: Cancel (dialog closes), Edit Shared (opens editor), Clone and Edit (creates new record)
  • Check "remember for this session" and verify subsequent edits skip the dialog
  • Close and reopen the browser tab -- verify the session preference is cleared
  • Run the frontend tests: npx jest --testPathPattern sharedRecordWarning

When Carry Forward copies foreign keys, multiple Collection Objects share
the same related record. Clicking edit on a shared record now shows a
warning dialog with record count, inspection links, and three choices:
Cancel, Edit Shared, or Clone and Edit (safe default).

- Generic for all table types (not just CO/CE)
- Session memory checkbox to skip repeated warnings
- Only shown when record is actually shared (count > 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Increase limit to number of reports that can be displayed

1 participant