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.tsx31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index d84e34d52..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">
@@ -33,6 +51,7 @@ export class TableBox extends React.Component<TableBoxProps> {
const header = React.createRef<HTMLElement>();
return (
<th
+ key={this.columns.indexOf(col)}
ref={header as any}
style={{
color: this.props.axes.slice().reverse().lastElement() === col ? 'green' : this.props.axes.lastElement() === col ? 'red' : undefined,
@@ -50,6 +69,7 @@ export class TableBox extends React.Component<TableBoxProps> {
const embedding = Doc.MakeEmbedding(this.props.docView?.()!.rootDoc!);
embedding._dataVizView = DataVizView.LINECHART;
embedding._data_vizAxes = new List<string>([col, col]);
+ embedding._draggedFrom = this.props.docView?.()!.rootDoc!;
embedding.annotationOn = annotationOn; //this.props.docView?.()!.rootDoc!;
return embedding;
};
@@ -58,6 +78,7 @@ export class TableBox extends React.Component<TableBoxProps> {
dragComplete: e => {
if (!e.aborted && e.annoDragData && e.annoDragData.linkSourceDoc && e.annoDragData.dropDocument && e.linkDocument) {
e.linkDocument.link_displayLine = true;
+ e.linkDocument.link_matchEmbeddings = true;
// e.annoDragData.linkSourceDoc.followLinkToggle = e.annoDragData.dropDocument.annotationOn === this.props.rootDoc;
// e.annoDragData.linkSourceDoc.followLinkZoom = false;
}
@@ -88,11 +109,13 @@ export class TableBox extends React.Component<TableBoxProps> {
</tr>
</thead>
<tbody>
- {this.props.pairs?.map((p, i) => {
+ {this._tableData?.map((p, i) => {
return (
- <tr className="table-row" onClick={action(e => (p['select' + this.props.docView?.()?.rootDoc![Id]] = !p['select' + this.props.docView?.()?.rootDoc![Id]]))}>
+ <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 => (
- <td style={{ fontWeight: p['select' + this.props.docView?.()?.rootDoc![Id]] ? 'bold' : '' }}>{p[col]}</td>
+ <td key={this.columns.indexOf(col)} style={{ fontWeight: p['select' + this.props.docView?.()?.rootDoc![Id]] ? 'bold' : '' }}>
+ {p[col]}
+ </td>
))}
</tr>
);