From 318d56e1dff94204b100f5636e1a3288724aaffc Mon Sep 17 00:00:00 2001
From: srichman333 <sarah_n_richman@brown.edu>
Date: Tue, 8 Aug 2023 16:15:36 -0400
Subject: comments + cleanups

---
 src/client/views/nodes/DataVizBox/components/TableBox.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

(limited to 'src/client/views/nodes/DataVizBox/components/TableBox.tsx')

diff --git a/src/client/views/nodes/DataVizBox/components/TableBox.tsx b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
index 38dd62d8d..277ee83ec 100644
--- a/src/client/views/nodes/DataVizBox/components/TableBox.tsx
+++ b/src/client/views/nodes/DataVizBox/components/TableBox.tsx
@@ -32,6 +32,7 @@ interface TableBoxProps {
 @observer
 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.rowGuids);
@@ -52,6 +53,7 @@ export class TableBox extends React.Component<TableBoxProps> {
         return this._tableData.length ? Array.from(Object.keys(this._tableData[0])).filter(header => header!='' && header!=undefined) : [];
     }
 
+    // updates the 'selected' field to no longer include rows that aren't in the table
     filterSelectedRowsDown() {
         if (!this.props.layoutDoc.selected) this.props.layoutDoc.selected = new List<string>();
         const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
@@ -88,7 +90,7 @@ export class TableBox extends React.Component<TableBoxProps> {
                                                     setupMoveUpEvents(
                                                         {},
                                                         e,
-                                                        e => {
+                                                        e => { // dragging off a column to create a brushed DataVizBox
                                                             const sourceAnchorCreator = () => this.props.docView?.()!.rootDoc!;
                                                             const targetCreator = (annotationOn: Doc | undefined) => {
                                                                 const embedding = Doc.MakeEmbedding(this.props.docView?.()!.rootDoc!);
@@ -144,6 +146,7 @@ export class TableBox extends React.Component<TableBoxProps> {
                                 if (containsData){
                                     return (
                                         <tr key={i} className="table-row" onClick={action(e => {
+                                                // selecting a row
                                                 const selected = Cast(this.props.layoutDoc.selected, listSpec("string"), null);
                                                 if (selected.includes(guid)) selected.splice(selected.indexOf(guid), 1);
                                                 else {
@@ -153,6 +156,7 @@ export class TableBox extends React.Component<TableBoxProps> {
                                                 background: StrListCast(this.props.layoutDoc.selected).includes(guid) ? 'lightgrey' : '' }}>
                                             {this.columns.map(col => (
                                                 (this.props.layoutDoc.selected)?
+                                                    // each cell
                                                     <td key={this.columns.indexOf(col)} style={{border: '1px solid black'}}>
                                                         {p[col]}
                                                     </td>
@@ -168,6 +172,7 @@ export class TableBox extends React.Component<TableBoxProps> {
             );
         }
         else return (
+            // when it is a brushed table and the incoming table doesn't have any rows selected
             <div className='chart-container'>
                 Selected rows of data from the incoming DataVizBox to display.
             </div>
-- 
cgit v1.2.3-70-g09d2

