Skip to content

Commit

Permalink
handling null formatter during bulk carry
Browse files Browse the repository at this point in the history
  • Loading branch information
acwhite211 committed Dec 20, 2024
1 parent 2c647bb commit 0c1ef29
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions specifyweb/frontend/js_src/lib/components/Forms/Save.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,25 +269,26 @@ export function SaveButton<SCHEMA extends AnySchema = AnySchema>({
carryForwardAmount > 1
? async (): Promise<RA<SpecifyResource<SCHEMA>>> => {
const formatter =
tables.CollectionObject.strictGetLiteralField(
'catalogNumber'
).getUiFormatter()!;
const wildCard = formatter.valueOrWild();

const clonePromises = Array.from(
{ length: carryForwardAmount },
async () => {
const clonedResource = await resource.clone(
false,
true
);
tables.CollectionObject.strictGetLiteralField(
'catalogNumber'
).getUiFormatter()!;
const wildCard =formatter === undefined ? null : formatter.valueOrWild();
const clonePromises = Array.from(
{ length: carryForwardAmount },
async () => {
const clonedResource = await resource.clone(
false,
true
);
if (wildCard !== null) {
clonedResource.set(
'catalogNumber',
wildCard as never
);
return clonedResource;
}
);
return clonedResource;
}
);

const clones = await Promise.all(clonePromises);

Expand Down

0 comments on commit 0c1ef29

Please sign in to comment.