Skip to content

Commit

Permalink
fix(FieldFormatters): disable auto-numering in UI where not allowed b…
Browse files Browse the repository at this point in the history
…y back-end
  • Loading branch information
maxpatiiuk committed Jan 20, 2025
1 parent 707567e commit 9c44731
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ export class SpecifyTable<SCHEMA extends AnySchema = AnySchema> {
*
* 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 ??=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -62,6 +63,7 @@ export function FieldFormatterParts({
part,
(part): void => setParts(replaceItem(parts, index, part)),
]}
table={fieldFormatter.table}
onRemove={(): void => setParts(removeItem(parts, index))}
/>
))}
Expand Down Expand Up @@ -96,9 +98,11 @@ export function FieldFormatterParts({
function Part({
part: [part, handleChange],
onRemove: handleRemove,
table,
}: {
readonly part: GetSet<FieldFormatterPart>;
readonly onRemove: () => void;
readonly table: SpecifyTable | undefined;
}): JSX.Element {
const isReadOnly = React.useContext(ReadOnlyContext);

Expand Down Expand Up @@ -175,6 +179,7 @@ function Part({
<Label.Inline>
<Input.Checkbox
checked={part.autoIncrement}
disabled={table.getScopingRelationship() === undefined}
isReadOnly={isReadOnly}
onValueChange={(autoIncrement): void =>
handleChange({
Expand Down

0 comments on commit 9c44731

Please sign in to comment.