From 0d1176ebab298f9c3a7ef8d209a076f1bcb1a123 Mon Sep 17 00:00:00 2001 From: Grant Fitzsimmons <37256050+grantfitzsimmons@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:23:53 -0500 Subject: [PATCH 1/2] feat(attachments): handle multiple formats --- .../SelectUploadPath.tsx | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/SelectUploadPath.tsx b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/SelectUploadPath.tsx index 6954dd98726..90e34edfd66 100644 --- a/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/SelectUploadPath.tsx +++ b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/SelectUploadPath.tsx @@ -62,16 +62,28 @@ export function generateUploadSpec( const field = queryFieldSpec.getField(); const queryResultsFormatter = ( value: number | string | null | undefined - ): string | undefined => - value === undefined || value === null || field?.isRelationship === true - ? undefined - : syncFieldFormat( - field, - value.toString(), - queryFieldSpec.parser, - undefined, - true - ); + ): string | undefined => { + if (value === undefined || value === null || field?.isRelationship === true) + return undefined; + + const rawValue = value.toString(); + const fieldFormatter = field?.getUiFormatter(); + if (fieldFormatter !== undefined) + // Catalog number formatting can vary by Collection Object Type. The + // query field only has the schema-level formatter, so preserve database + // values that do not match that formatter instead of dropping them. + return fieldFormatter.format(rawValue) ?? rawValue; + + return ( + syncFieldFormat( + field, + rawValue, + queryFieldSpec.parser, + undefined, + true + ) ?? rawValue + ); + }; return { staticPathKey, formatQueryResults: queryResultsFormatter, From 42768eae0ff1db66e4e6de488d4cf8934500e916 Mon Sep 17 00:00:00 2001 From: Grant Fitzsimmons <37256050+grantfitzsimmons@users.noreply.github.com> Date: Wed, 7 Oct 2026 14:24:08 -0500 Subject: [PATCH 2/2] test(attachments): verify format is preserved --- .../__tests__/SelectUploadPath.test.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/__tests__/SelectUploadPath.test.ts diff --git a/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/__tests__/SelectUploadPath.test.ts b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/__tests__/SelectUploadPath.test.ts new file mode 100644 index 00000000000..551626a52e2 --- /dev/null +++ b/specifyweb/frontend/js_src/lib/components/AttachmentsBulkImport/__tests__/SelectUploadPath.test.ts @@ -0,0 +1,20 @@ +import { requireContext } from '../../../tests/helpers'; +import { generateUploadSpec } from '../SelectUploadPath'; + +requireContext(); + +describe('generateUploadSpec catalog number result formatting', () => { + test('preserves catalog numbers that do not match the schema formatter', () => + expect( + generateUploadSpec('collectionObjectCatalogNumber').formatQueryResults!( + 'F-250750' + ) + ).toBe('F-250750')); + + test('keeps canonical formatting for values accepted by the schema formatter', () => + expect( + generateUploadSpec('collectionObjectCatalogNumber').formatQueryResults!( + '123' + ) + ).toBe('000000123')); +});