Skip to content

Commit

Permalink
connect cell editing
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell committed Oct 29, 2023
1 parent cde0bbb commit c3b6bb3
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-data/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ export type DataSourceEvents = {
};

export type DataSourceEditHandler = (
rowIndex: number,
row: DataSourceRow,
columnName: string,
value: VuuColumnDataType
) => boolean;
Expand Down
22 changes: 19 additions & 3 deletions vuu-ui/packages/vuu-data/src/remote-data-source.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -18,6 +18,7 @@ import {
EventEmitter,
itemsOrOrderChanged,
logger,
metadataKeys,
throttle,
uuid,
} from "@finos/vuu-utils";
Expand All @@ -43,6 +44,8 @@ type RangeRequest = (range: VuuRange) => void;

const { info } = logger("RemoteDataSource");

const { KEY } = metadataKeys;

type DataSourceStatus =
| "disabled"
| "disabling"
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion vuu-ui/packages/vuu-datagrid-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
Expand Down
19 changes: 10 additions & 9 deletions vuu-ui/packages/vuu-table/src/table-next/useTableNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit c3b6bb3

Please sign in to comment.