-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue in ArrayDataSource not refreshing after resume * rest datasource experiment * add pagination * add TablePicker, RestDataSource first cut, fix table issues * initial search capability in TablePicker * fix table fixed size rendering
- Loading branch information
Showing
51 changed files
with
1,447 additions
and
599 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
vuu-ui/packages/vuu-data-react/src/datasource-provider/RestDataSourceProvider.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { RestDataSource, ConnectionManager } from "@finos/vuu-data-remote"; | ||
import { DataSourceProvider } from "@finos/vuu-utils"; | ||
import { ReactNode } from "react"; | ||
|
||
const getServerAPI = () => ConnectionManager.serverAPI; | ||
|
||
export const RestDataSourceProvider = ({ | ||
children, | ||
url, | ||
}: { | ||
children: ReactNode; | ||
url: string; | ||
}) => { | ||
// url is a static property | ||
RestDataSource.url = url; | ||
return ( | ||
<DataSourceProvider | ||
VuuDataSource={RestDataSource} | ||
getServerAPI={getServerAPI} | ||
isLocalData={false} | ||
> | ||
{children} | ||
</DataSourceProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
vuu-ui/packages/vuu-data-remote/src/rest-data/moving-window.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { DataSourceRow } from "@finos/vuu-data-types"; | ||
import { isRowSelectedLast, metadataKeys, WindowRange } from "@finos/vuu-utils"; | ||
import { VuuRange } from "@finos/vuu-protocol-types"; | ||
|
||
const { SELECTED } = metadataKeys; | ||
|
||
export class MovingWindow { | ||
public data: DataSourceRow[]; | ||
public rowCount = 0; | ||
private range: WindowRange; | ||
|
||
constructor({ from, to }: VuuRange) { | ||
this.range = new WindowRange(from, to); | ||
//internal data is always 0 based, we add range.from to determine an offset | ||
this.data = new Array(Math.max(0, to - from)); | ||
this.rowCount = 0; | ||
} | ||
|
||
setRowCount = (rowCount: number) => { | ||
if (rowCount < this.data.length) { | ||
this.data.length = rowCount; | ||
} | ||
|
||
this.rowCount = rowCount; | ||
}; | ||
|
||
add(data: DataSourceRow) { | ||
const [index] = data; | ||
if (this.isWithinRange(index)) { | ||
const internalIndex = index - this.range.from; | ||
this.data[internalIndex] = data; | ||
|
||
// Hack until we can deal with this more elegantly. When we have a block | ||
// select operation, first row is selected (and updated via server), then | ||
// remaining rows are selected when we select the block-end row. We get an | ||
// update for all rows except first. Because we're extending the select status | ||
// on the client, we have to adjust the first row selected (its still selected | ||
// but is no longer the 'last selected row in block') | ||
// Maybe answer is to apply ALL the selection status code here, not in Viewport | ||
if (data[SELECTED]) { | ||
const previousRow = this.data[internalIndex - 1]; | ||
if (isRowSelectedLast(previousRow)) { | ||
this.data[internalIndex - 1] = previousRow.slice() as DataSourceRow; | ||
this.data[internalIndex - 1][SELECTED] -= 4; | ||
} | ||
} | ||
} | ||
} | ||
|
||
getAtIndex(index: number) { | ||
return this.range.isWithin(index) && | ||
this.data[index - this.range.from] != null | ||
? this.data[index - this.range.from] | ||
: undefined; | ||
} | ||
|
||
isWithinRange(index: number) { | ||
return this.range.isWithin(index); | ||
} | ||
|
||
setRange({ from, to }: VuuRange) { | ||
if (from !== this.range.from || to !== this.range.to) { | ||
const [overlapFrom, overlapTo] = this.range.overlap(from, to); | ||
const newData = new Array(Math.max(0, to - from)); | ||
for (let i = overlapFrom; i < overlapTo; i++) { | ||
const data = this.getAtIndex(i); | ||
if (data) { | ||
const index = i - from; | ||
newData[index] = data; | ||
} | ||
} | ||
this.data = newData; | ||
this.range.from = from; | ||
this.range.to = to; | ||
} | ||
} | ||
|
||
getSelectedRows() { | ||
return this.data.filter((row) => row[SELECTED] !== 0); | ||
} | ||
} |
Oops, something went wrong.