Skip to content

Commit

Permalink
allow reordering columns on upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sharadsw committed May 16, 2024
1 parent 214587f commit 13bafa9
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions specifyweb/frontend/js_src/lib/components/WorkBench/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@ import { schema } from '../DataModel/schema';
import { getHotPlugin } from './handsontable';
import type { Workbench } from './WbView';

export function useHotHooks(
workbench: Workbench,
physicalColToMappingCol: (physicalCol: number) => number | undefined,
spreadsheetChanged: () => void,
checkDeletedFail: (statusCode: number) => boolean,
isReadOnly: boolean
): Partial<Events> {
export function useHotHooks({
workbench,
physicalColToMappingCol,
spreadsheetChanged,
checkDeletedFail,
isReadOnly,
isResultsOpen,
}: {
readonly workbench: Workbench;
readonly physicalColToMappingCol: (physicalCol: number) => number | undefined;
readonly spreadsheetChanged: () => void;
readonly checkDeletedFail: (statusCode: number) => boolean;
readonly isReadOnly: boolean;
readonly isResultsOpen: boolean;
}): Partial<Events> {
let sortConfigIsSet: boolean = false;
const loading = React.useContext(LoadingContext);

Expand Down Expand Up @@ -464,10 +472,7 @@ export function useHotHooks(
},

beforeColumnMove: (_columnIndexes, _finalIndex, dropIndex) =>
// Don't allow moving columns when isReadOnly
!isReadOnly &&
// An ugly fix for jQuery's dialogs conflicting with HOT
(dropIndex !== undefined || workbench.hot !== undefined),
dropIndex !== undefined || workbench.hot !== undefined,

// Save new visualOrder on the back end
afterColumnMove: (_columnIndexes, _finalIndex, dropIndex) => {
Expand Down

0 comments on commit 13bafa9

Please sign in to comment.