diff --git a/src/components/PaginatedTable/PaginatedTable.tsx b/src/components/PaginatedTable/PaginatedTable.tsx index e56a531661..474a321246 100644 --- a/src/components/PaginatedTable/PaginatedTable.tsx +++ b/src/components/PaginatedTable/PaginatedTable.tsx @@ -55,6 +55,7 @@ interface PaginatedTableProperties { onRowClick?: ( row: GroomedEntryT, ev: React.MouseEvent | React.TouchEvent | React.PointerEvent, + rows: GroomedEntryT[], ) => any; debug?: boolean; pageSizeOptions?: Array; @@ -63,7 +64,7 @@ interface PaginatedTableProperties { hidePageControls?: boolean; /** If provided, the table will listen for this push event and refresh its data accordingly */ uiPushProps?: { event: string; channel: string }; - annulQueue?: any[]; + highlightedRows?: any[]; } export interface PaginatedTableRef { @@ -355,40 +356,21 @@ function _PaginatedTable( {column_render(column, row)} )); - if (props.annulQueue) { - if (props.onRowClick) { - return ( - - props.onRowClick && props.onRowClick(row, ev) - } - > - {cols} - - ); - } else { - return {cols}; - } - } else { - if (props.onRowClick) { - return ( - - props.onRowClick && props.onRowClick(row, ev) - } - > - {cols} - - ); - } else { - return {cols}; - } - } + return ( + + props.onRowClick && props.onRowClick(row, ev, rows) + } + > + {cols} + + ); })} {blank_rows} diff --git a/src/views/User/GameHistoryTable.tsx b/src/views/User/GameHistoryTable.tsx index 7c6f9fa2d3..0466fcbc53 100644 --- a/src/views/User/GameHistoryTable.tsx +++ b/src/views/User/GameHistoryTable.tsx @@ -102,9 +102,27 @@ export function GameHistoryTable(props: GameHistoryProps) { function handleRowClick( row: GroomedGame, ev: React.MouseEvent | React.TouchEvent | React.PointerEvent, + rows: GroomedGame[], ) { + if (row.annulled) { + return; + } + if (selectModeActive) { - toggleQueued(row); + if (ev.shiftKey) { + if (annulQueue.at(-1)) { + window.getSelection()?.removeAllRanges(); + const indexes = [ + rows.findIndex((r) => r.id === annulQueue.at(-1).id), + rows.findIndex((r) => r.id === row.id), + ]; + const minIndex = Math.min(...indexes); + const maxIndex = Math.max(...indexes); + setAnnulQueue(rows.slice(minIndex, maxIndex + 1).filter((r) => !r.annulled)); + } + } else { + toggleQueued(row); + } } else { openUrlIfALinkWasNotClicked(ev, row.href); } @@ -336,7 +354,7 @@ export function GameHistoryTable(props: GameHistoryProps) { groom={game_history_groomer} pageSizeOptions={[10, 15, 25, 50]} onRowClick={handleRowClick} - annulQueue={annulQueue} + highlightedRows={annulQueue} columns={[ { header: _("User"),