diff --git a/src/components/gridForm/GridFormDropDown.tsx b/src/components/gridForm/GridFormDropDown.tsx index 49741225..0745e167 100644 --- a/src/components/gridForm/GridFormDropDown.tsx +++ b/src/components/gridForm/GridFormDropDown.tsx @@ -14,10 +14,11 @@ import { GridBaseRow } from "../Grid"; import { CellEditorCommon } from "../GridCell"; import { useGridPopoverHook } from "../GridPopoverHook"; -export interface GridPopoutEditDropDownSelectedItem { +export interface GridPopoutEditDropDownSelectedItem { // Note the row that was clicked on will be first selectedRows: TData[]; - value: any; + selectedRowIds: TData["id"][]; + value: TValue; subComponentValue?: any; } @@ -38,7 +39,7 @@ export const MenuHeaderItem = (title: string) => { export type SelectOption = null | string | FinalSelectOption; -export interface GridFormDropDownProps extends CellEditorCommon { +export interface GridFormDropDownProps extends CellEditorCommon { // This overrides CellEditorCommon to provide some common class options className?: | "GridPopoverEditDropDown-containerSmall" @@ -54,8 +55,8 @@ export interface GridFormDropDownProps extends CellEd filterPlaceholder?: string; filterHelpText?: string; noOptionsMessage?: string; - onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem) => Promise; - onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem) => Promise; + onSelectedItem?: (props: GridPopoutEditDropDownSelectedItem) => Promise; + onSelectFilter?: (props: GridPopoutEditDropDownSelectedItem) => Promise; options: | SelectOption[] | ((selectedRows: TData[], filter?: string) => Promise | SelectOption[] | undefined) @@ -66,7 +67,7 @@ const fieldToString = (field: any) => { return typeof field == "symbol" ? field.toString() : `${field}`; }; -export const GridFormDropDown = (props: GridFormDropDownProps) => { +export const GridFormDropDown = (props: GridFormDropDownProps) => { const { selectedRows, field, data } = useGridPopoverContext(); // Save triggers during async action processing which triggers another selectItem(), this ref blocks that @@ -86,7 +87,12 @@ export const GridFormDropDown = (props: GridFormDropD (subComponentValue !== undefined && subComponentInitialValue.current !== JSON.stringify(subComponentValue)); if (hasChanged) { if (props.onSelectedItem) { - await props.onSelectedItem({ selectedRows, value, subComponentValue }); + await props.onSelectedItem({ + selectedRows, + selectedRowIds: selectedRows.map((row) => row.id), + value, + subComponentValue, + }); } else { selectedRows.forEach((row) => (row[field] = value as any)); } @@ -167,7 +173,7 @@ export const GridFormDropDown = (props: GridFormDropD if (selectedItem === null) { if (props.onSelectFilter) { const { onSelectFilter } = props; - await onSelectFilter({ selectedRows, value: filter }); + await onSelectFilter({ selectedRows, selectedRowIds: selectedRows.map((row) => row.id), value: filter as any }); return true; } else { if (filteredValues && filteredValues.length === 1) { diff --git a/src/components/gridPopoverEdit/GridButton.tsx b/src/components/gridPopoverEdit/GridButton.tsx index 20b5de3c..769eb3d0 100644 --- a/src/components/gridPopoverEdit/GridButton.tsx +++ b/src/components/gridPopoverEdit/GridButton.tsx @@ -5,7 +5,7 @@ import { GridBaseRow } from "../Grid"; import { LuiButton, LuiIcon } from "@linzjs/lui"; import { useEffect, useRef } from "react"; -const ButtonCellRenderer = (props: SAICellRendererParams) => { +const ButtonCellRenderer = (props: SAICellRendererParams) => { const { data, node, column, colDef, api } = props; const inputRef = useRef(null); @@ -39,9 +39,9 @@ const ButtonCellRenderer = (props: SAICellRendererParams) => { ); }; -export interface GridButtonProps { +export interface GridButtonProps { visible?: (cellEditorParams: ICellEditorParams) => boolean; - onClick?: (props: { selectedRows: TData[]; selectedRowIds: (string | number)[] }) => void; + onClick?: (props: { selectedRows: TData[]; selectedRowIds: TData["id"][] }) => void; } export const GridButton = ( diff --git a/src/components/gridPopoverEdit/GridEditBoolean.tsx b/src/components/gridPopoverEdit/GridEditBoolean.tsx index 5cf929f4..da737dca 100644 --- a/src/components/gridPopoverEdit/GridEditBoolean.tsx +++ b/src/components/gridPopoverEdit/GridEditBoolean.tsx @@ -65,12 +65,8 @@ const BooleanCellRenderer = (props: CustomCellEditorProps) => { ); }; -export interface GridEditBooleanEditorProps extends CellEditorCommon { - onClick: (props: { - selectedRows: TData[]; - selectedRowIds: (string | number)[]; - checked: boolean; - }) => Promise; +export interface GridEditBooleanEditorProps extends CellEditorCommon { + onClick: (props: { selectedRows: TData[]; selectedRowIds: TData["id"][]; checked: boolean }) => Promise; } export const GridEditBoolean = ( diff --git a/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts b/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts index 1c609499..f70e5837 100644 --- a/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts +++ b/src/components/gridPopoverEdit/GridPopoverEditDropDown.ts @@ -6,13 +6,13 @@ import { GenericCellColDef } from "../gridRender/GridRenderGenericCell"; export const GridPopoverEditDropDown = ( colDef: GenericCellColDef, - props: GenericCellEditorProps>, + props: GenericCellEditorProps>, ): ColDefT => - GridCell>(colDef, { + GridCell>(colDef, { editor: GridFormDropDown, ...props, editorParams: { - ...(props.editorParams as GridFormDropDownProps), + ...(props.editorParams as GridFormDropDownProps), className: clsx( { "GridPopoverEditDropDown-containerLarge": !props.editorParams?.className?.includes(