From 9c447313bda5afb4ef4346f0c25a96f9fd5ea758 Mon Sep 17 00:00:00 2001 From: Max Patiiuk Date: Sun, 19 Jan 2025 20:07:12 -0800 Subject: [PATCH] fix(FieldFormatters): disable auto-numering in UI where not allowed by back-end --- .../frontend/js_src/lib/components/DataModel/specifyTable.ts | 2 +- .../frontend/js_src/lib/components/FieldFormatters/Parts.tsx | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/specifyweb/frontend/js_src/lib/components/DataModel/specifyTable.ts b/specifyweb/frontend/js_src/lib/components/DataModel/specifyTable.ts index 4b957207d1c..5a818256f6b 100644 --- a/specifyweb/frontend/js_src/lib/components/DataModel/specifyTable.ts +++ b/specifyweb/frontend/js_src/lib/components/DataModel/specifyTable.ts @@ -458,7 +458,7 @@ export class SpecifyTable { * * I.e, table can be scoped to collection using a "collectionMemberId" field * (which is not a relationship - sad). Back-end looks at that relationship - * for scoping inconsistenly. Front-end does not look at all. + * for scoping inconsistently. Front-end does not look at all. */ public getScopingRelationship(): Relationship | undefined { this.scopingRelationship ??= diff --git a/specifyweb/frontend/js_src/lib/components/FieldFormatters/Parts.tsx b/specifyweb/frontend/js_src/lib/components/FieldFormatters/Parts.tsx index f9e1753b866..e77e8270d75 100644 --- a/specifyweb/frontend/js_src/lib/components/FieldFormatters/Parts.tsx +++ b/specifyweb/frontend/js_src/lib/components/FieldFormatters/Parts.tsx @@ -13,6 +13,7 @@ import { className } from '../Atoms/className'; import { Input, Label, Select } from '../Atoms/Form'; import { icons } from '../Atoms/Icons'; import { ReadOnlyContext } from '../Core/Contexts'; +import type { SpecifyTable } from '../DataModel/specifyTable'; import { fieldFormatterLocalization } from '.'; import type { FieldFormatter, FieldFormatterPart } from './spec'; import { @@ -62,6 +63,7 @@ export function FieldFormatterParts({ part, (part): void => setParts(replaceItem(parts, index, part)), ]} + table={fieldFormatter.table} onRemove={(): void => setParts(removeItem(parts, index))} /> ))} @@ -96,9 +98,11 @@ export function FieldFormatterParts({ function Part({ part: [part, handleChange], onRemove: handleRemove, + table, }: { readonly part: GetSet; readonly onRemove: () => void; + readonly table: SpecifyTable | undefined; }): JSX.Element { const isReadOnly = React.useContext(ReadOnlyContext); @@ -175,6 +179,7 @@ function Part({ handleChange({