Skip to content

Correct date field component labels in batch edit headers#7925

Open
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:fix-6808
Open

Correct date field component labels in batch edit headers#7925
foozleface wants to merge 1 commit intospecify:mainfrom
calacademy-research:fix-6808

Conversation

@foozleface
Copy link
Copy Markdown
Collaborator

Fixes #6808
Contributed by @foozleface

Batch edit column headers for date fields show wrong component labels. When multiple date components of the same field are present (e.g. catalogedDate Full Date, Day, Month, Year), all columns get the same label because the localization lookup key is just the base field name, so each component consumes labels in insertion order rather than matching by date part.

Implementation

  • Introduced _get_date_part_field_name() which returns a distinct key per date component (e.g. catalogedDate__Full Date, catalogedDate__Day) for localization lookups.
  • Updated RowPlanCanonical._create_row_plan() and run_batch_edit_query() to use the date-part-aware key instead of the bare field name when looking up and registering field labels.
  • Updated naive_field_format() to append the date part suffix (e.g. "(Day)", "(Month)", "(Year)") for non-"Full Date" components.
  • Added a null guard in apply_absolute_date() for query_field.value being None.
  • Added frontend test cases for generateMappingPathPreview to verify date component labels.
  • Added backend tests for naive_field_format, _get_date_part_field_name, and end-to-end batch edit header generation with and without captions.

Testing instructions

  • Open the query builder, add multiple date components of the same field (e.g. Cataloged Date Full Date, Day, Month, Year)
  • Run a batch edit and verify each column header shows the correct component label
  • Run python manage.py test specifyweb.backend.stored_queries.tests.test_batch_edit
  • Run npx jest --testPathPattern=mappingPreview

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.

Batch Edit: Date fields show incorrect heading

1 participant