From 1556f3f96ede692d7ba0135888e3872e5db2d480 Mon Sep 17 00:00:00 2001 From: Sharad S Date: Tue, 28 Jan 2025 16:24:49 -0500 Subject: [PATCH] Handle case for new rows --- .../lib/components/WorkBench/WbSpreadsheet.tsx | 18 +++++++++++------- specifyweb/workbench/upload/upload.py | 5 ++++- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/specifyweb/frontend/js_src/lib/components/WorkBench/WbSpreadsheet.tsx b/specifyweb/frontend/js_src/lib/components/WorkBench/WbSpreadsheet.tsx index 569f8a81c35..b8ceaaf28f2 100644 --- a/specifyweb/frontend/js_src/lib/components/WorkBench/WbSpreadsheet.tsx +++ b/specifyweb/frontend/js_src/lib/components/WorkBench/WbSpreadsheet.tsx @@ -20,7 +20,11 @@ import { getIcon, unknownIcon } from '../InitialContext/icons'; import type { Dataset } from '../WbPlanView/Wrapped'; import { configureHandsontable } from './handsontable'; import { useHotHooks } from './hooks'; -import { getPhysicalColToMappingCol, getSelectedRegions, setHotData } from './hotHelpers'; +import { + getPhysicalColToMappingCol, + getSelectedRegions, + setHotData, +} from './hotHelpers'; import { useHotProps } from './hotProps'; import type { WbMapping } from './mapping'; import { fetchWbPickLists } from './pickLists'; @@ -75,9 +79,9 @@ function WbSpreadsheetComponent({ const physicalCol = hot.toPhysicalColumn(visualCol ?? 0); const createdRecords = - validation.uploadResults.interestingRecords[physicalRow]?.[ - physicalCol - ]; + validation.uploadResults.interestingRecords[ + physicalRow + ]?.[physicalCol]; if ( visualRow === undefined || @@ -129,14 +133,14 @@ function WbSpreadsheetComponent({ } as const) : ({ row_above: { - disabled: () => isReadOnly, + disabled: () => isReadOnly || dataset.isupdate, }, row_below: { - disabled: () => isReadOnly, + disabled: () => isReadOnly || dataset.isupdate, }, remove_row: { disabled: () => { - if (isReadOnly) return true; + if (isReadOnly || dataset.isupdate) return true; // Or if called on the last row const selectedRegions = getSelectedRegions(hot); return ( diff --git a/specifyweb/workbench/upload/upload.py b/specifyweb/workbench/upload/upload.py index 7e510d15762..b690d898174 100644 --- a/specifyweb/workbench/upload/upload.py +++ b/specifyweb/workbench/upload/upload.py @@ -558,7 +558,10 @@ def _commit_uploader(result): packs = [] # Yes, we don't care about reverse here. for row in range(len(parent.data)): - r, be = look_up_in_backer(row) + pack = look_up_in_backer(row) + if pack is None: continue + + r, be = pack rows_to_backup.append(dict(zip(parent.columns, r))) packs.append(be)