aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/components/TableBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/components/TableBox.tsx19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index 70483ac6f..e1c5aa125 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -33,9 +33,11 @@ interface TableBoxProps {
export class TableBox extends React.Component<TableBoxProps> {
// filters all data to just display selected data if brushed (created from an incoming link)
@computed get _tableData() {
- if (this.incomingLinks.length! <= 0) return this.props.pairs;
- var guids = StrListCast(this.props.layoutDoc.dataViz_rowGuids);
- return this.props.pairs?.filter(pair => this.incomingLinks[0]!.dataViz_selectedRows && StrListCast(this.incomingLinks[0].dataViz_selectedRows).includes(guids[this.props.pairs.indexOf(pair)]));
+ if (this.incomingLinks.length <= 0) return this.props.pairs;
+ return this.props.pairs?.filter(pair => StrListCast(this.incomingLinks[0]?.dataViz_selectedRows).includes(this.rowGuids[this.props.pairs.indexOf(pair)]));
+ }
+ @computed get rowGuids() {
+ return StrListCast(this.props.layoutDoc.dataViz_rowGuids)
}
@computed get incomingLinks() {
@@ -47,9 +49,6 @@ export class TableBox extends React.Component<TableBoxProps> {
}
@computed get columns() {
- if (!this.props.layoutDoc.dataViz_rowGuids) this.props.layoutDoc.dataViz_rowGuids = new List<string>();
- const guids = Cast(this.props.layoutDoc.dataViz_rowGuids, listSpec('string'), null);
- if (guids.length == 0) this.props.pairs.map(row => guids.push(Utils.GenerateGuid()));
return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header != '' && header != undefined) : [];
}
@@ -59,9 +58,9 @@ export class TableBox extends React.Component<TableBoxProps> {
const selected = Cast(this.props.layoutDoc.dataViz_selectedRows, listSpec('string'), null);
const incomingSelected = this.incomingLinks.length ? StrListCast(this.incomingLinks[0].dataViz_selectedRows) : undefined;
if (incomingSelected) {
- selected.map(guid => {
- if (!incomingSelected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
- }); // filters through selected to remove guids that were removed in the incoming data
+ const newsel = selected.filter(guid => incomingSelected.includes(guid));// filters through selected to remove guids that were removed in the incoming data
+ selected.length = 0;
+ selected.push(...newsel);
}
}
@@ -145,7 +144,7 @@ export class TableBox extends React.Component<TableBoxProps> {
<tbody>
{this._tableData?.map((p, i) => {
var containsData = false;
- var guid = StrListCast(this.props.layoutDoc.dataViz_rowGuids)![this.props.pairs.indexOf(p)];
+ var guid = this.rowGuids[this.props.pairs.indexOf(p)];
this.columns.map(col => {
if (p[col] != '' && p[col] != null && p[col] != undefined) containsData = true;
});