diff --git a/vuu-ui/packages/vuu-data/src/data-source.ts b/vuu-ui/packages/vuu-data/src/data-source.ts index a148fa366..6e5b083d4 100644 --- a/vuu-ui/packages/vuu-data/src/data-source.ts +++ b/vuu-ui/packages/vuu-data/src/data-source.ts @@ -475,7 +475,7 @@ export type DataSourceEvents = { }; export type DataSourceEditHandler = ( - rowIndex: number, + row: DataSourceRow, columnName: string, value: VuuColumnDataType ) => boolean; diff --git a/vuu-ui/packages/vuu-data/src/remote-data-source.ts b/vuu-ui/packages/vuu-data/src/remote-data-source.ts index 8ffd1b813..198466ef1 100644 --- a/vuu-ui/packages/vuu-data/src/remote-data-source.ts +++ b/vuu-ui/packages/vuu-data/src/remote-data-source.ts @@ -1,4 +1,4 @@ -import { DataSourceFilter } from "@finos/vuu-data-types"; +import { DataSourceFilter, DataSourceRow } from "@finos/vuu-data-types"; import { Selection } from "@finos/vuu-datagrid-types"; import { ClientToServerEditRpc, @@ -18,6 +18,7 @@ import { EventEmitter, itemsOrOrderChanged, logger, + metadataKeys, throttle, uuid, } from "@finos/vuu-utils"; @@ -43,6 +44,8 @@ type RangeRequest = (range: VuuRange) => void; const { info } = logger("RemoteDataSource"); +const { KEY } = metadataKeys; + type DataSourceStatus = | "disabled" | "disabling" @@ -620,8 +623,21 @@ export class RemoteDataSource } } - applyEdit(rowIndex: number, columnName: string, value: VuuColumnDataType) { - console.log(`ArrayDataSource applyEdit ${rowIndex} ${columnName} ${value}`); + applyEdit(row: DataSourceRow, columnName: string, value: VuuColumnDataType) { + console.log( + `ArrayDataSource applyEdit ${row.join(",")} ${columnName} ${value}` + ); + + this.menuRpcCall({ + rowKey: row[KEY], + field: columnName, + value: parseInt(value), + type: "VP_EDIT_CELL_RPC", + }).then((response) => { + console.log(`response`, { + response, + }); + }); return true; } } diff --git a/vuu-ui/packages/vuu-datagrid-types/index.d.ts b/vuu-ui/packages/vuu-datagrid-types/index.d.ts index 1f6cc94dd..92b7b7ea7 100644 --- a/vuu-ui/packages/vuu-datagrid-types/index.d.ts +++ b/vuu-ui/packages/vuu-datagrid-types/index.d.ts @@ -20,7 +20,7 @@ export type TableHeading = { label: string; width: number }; export type TableHeadings = TableHeading[][]; export type DataCellEditHandler = ( - rowIndex: number, + row: DataSourceRow, columnName: string, value: VuuColumnDataType ) => boolean; diff --git a/vuu-ui/packages/vuu-table/src/table-next/table-cell/TableCell.tsx b/vuu-ui/packages/vuu-table/src/table-next/table-cell/TableCell.tsx index cac32bd63..91dbea8b6 100644 --- a/vuu-ui/packages/vuu-table/src/table-next/table-cell/TableCell.tsx +++ b/vuu-ui/packages/vuu-table/src/table-next/table-cell/TableCell.tsx @@ -22,7 +22,7 @@ export const TableCell = ({ const handleDataItemEdited = useCallback( (value: VuuColumnDataType) => { - onDataEdited?.(row[IDX], name, value); + onDataEdited?.(row, name, value); // TODO will only return false in case of server rejection return true; }, diff --git a/vuu-ui/packages/vuu-table/src/table-next/useTableNext.ts b/vuu-ui/packages/vuu-table/src/table-next/useTableNext.ts index 4cbda1db3..aa8266cc1 100644 --- a/vuu-ui/packages/vuu-table/src/table-next/useTableNext.ts +++ b/vuu-ui/packages/vuu-table/src/table-next/useTableNext.ts @@ -193,15 +193,16 @@ export const useTable = ({ [] ); - const { data, getSelectedRows, range, setRange } = useDataSource({ - dataSource, - onFeatureEnabled, - onFeatureInvocation, - renderBufferSize, - onSizeChange: onDataRowcountChange, - onSubscribed, - range: initialRange, - }); + const { data, getSelectedRows, onEditTableData, range, setRange } = + useDataSource({ + dataSource, + onFeatureEnabled, + onFeatureInvocation, + renderBufferSize, + onSizeChange: onDataRowcountChange, + onSubscribed, + range: initialRange, + }); const handleConfigChanged = useCallback( (tableConfig: TableConfig) => {