aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/components/TableBox.tsx
diff options
context:
space:
mode:
authorsrichman333 <sarah_n_richman@brown.edu>2023-07-20 17:58:24 -0400
committersrichman333 <sarah_n_richman@brown.edu>2023-07-20 17:58:24 -0400
commit371f0309ec6b10a86b4a456d233be5b53cf93356 (patch)
treeef9f7a97bee22401544b0455a5d6f10e23b647ed /src/client/views/nodes/DataVizBox/components/TableBox.tsx
parent27441b60e7af8ea93f277ab3bdc2990ad25ea326 (diff)
components + links + brushed TableBox
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/components/TableBox.tsx22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index ca888e13f..500e7b639 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -8,8 +8,11 @@ import { emptyFunction, returnFalse, setupMoveUpEvents, Utils } from '../../../.
import { DragManager } from '../../../../util/DragManager';
import { DocumentView } from '../../DocumentView';
import { DataVizView } from '../DataVizBox';
+import { LinkManager } from '../../../../util/LinkManager';
+import { DocCast } from '../../../../../fields/Types';
interface TableBoxProps {
+ rootDoc: Doc;
pairs: { [key: string]: any }[];
selectAxes: (axes: string[]) => void;
axes: string[];
@@ -18,9 +21,24 @@ interface TableBoxProps {
@observer
export class TableBox extends React.Component<TableBoxProps> {
+
+ @computed get _tableData() {
+ if (this.incomingLinks.length! <= 0) return this.props.pairs;
+ return this.props.pairs?.filter(pair => (Array.from(Object.keys(pair)).some(key => pair[key] && key.startsWith('select'))))
+ }
+
+ @computed get incomingLinks() {
+ return LinkManager.Instance.getAllRelatedLinks(this.props.rootDoc) // out of all links
+ .filter(link => {
+ return link.link_anchor_1 == this.props.rootDoc.draggedFrom}) // get links where this chart doc is the target of the link
+ .map(link => DocCast(link.link_anchor_1)); // then return the source of the link
+ }
+
@computed get columns() {
- return this.props.pairs.length ? Array.from(Object.keys(this.props.pairs[0])) : [];
+ // return this.props.pairs.length ? Array.from(Object.keys(this.props.pairs[0])) : [];
+ return this._tableData.length ? Array.from(Object.keys(this._tableData[0])) : [];
}
+
render() {
return (
<div className="table-container">
@@ -91,7 +109,7 @@ export class TableBox extends React.Component<TableBoxProps> {
</tr>
</thead>
<tbody>
- {this.props.pairs?.map((p, i) => {
+ {this._tableData?.map((p, i) => {
return (
<tr key={i} className="table-row" onClick={action(e => (p['select' + this.props.docView?.()?.rootDoc![Id]] = !p['select' + this.props.docView?.()?.rootDoc![Id]]))}>
{this.columns.map(col => (