From 5e67e3db522c2080c51de53c1fbd4be570e62a98 Mon Sep 17 00:00:00 2001
From: ljungster <parkerljung@gmail.com>
Date: Tue, 26 Apr 2022 07:27:39 -0400
Subject: columns (sort of) working

---
 .../CollectionNoteTakingViewFieldColumn.tsx        | 37 ++++++++++++++++------
 1 file changed, 28 insertions(+), 9 deletions(-)

(limited to 'src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx')

diff --git a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx
index 452af2ddf..b9bed7174 100644
--- a/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionNoteTakingViewFieldColumn.tsx
@@ -37,7 +37,7 @@ interface CSVFieldColumnProps {
     columnHeaders: SchemaHeaderField[] | undefined;
     headingObject: SchemaHeaderField | undefined;
     yMargin: number;
-    columnWidth: number;
+    // columnWidth: number;
     numGroupColumns: number;
     gridGap: number;
     type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | undefined;
@@ -50,12 +50,29 @@ interface CSVFieldColumnProps {
     unobserveHeight: (myref: any) => void;
     editableViewProps: any;
     resizeColumns: (n: number) => void
+    columnStartXCoords: number[]
+    PanelWidth: number
+    maxColWidth: number
 }
 
 @observer
 export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFieldColumnProps> {
     @observable private _background = "inherit";
 
+    // It seems like this is being a little funky atm
+    @computed get columnWidth() {
+      // base cases
+      if (!this.props.columnHeaders || !this.props.headingObject || this.props.columnHeaders.length == 1) {
+        return this.props.maxColWidth
+      }
+      const i = this.props.columnHeaders.indexOf(this.props.headingObject)
+      if (i < 0) {
+        return this.props.maxColWidth
+      }
+      const endColValue = i == this.props.numGroupColumns - 1 ? this.props.PanelWidth : this.props.columnStartXCoords[i+1]
+      return endColValue - this.props.columnStartXCoords[i] - 10
+    }
+
     private dropDisposer?: DragManager.DragDropDisposer;
     private _headerRef: React.RefObject<HTMLDivElement> = React.createRef();
 
@@ -150,7 +167,8 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel
         console.log('in startDrag')
         // is MakeAlias a way to make a copy of a doc without rendering it?
         const alias = Doc.MakeAlias(this.props.Document);
-        alias._width = this.props.columnWidth / (this.props.columnHeaders?.length || 1);
+        // alias._width = this.props.columnWidth / (this.props.columnHeaders?.length || 1);
+        alias._width = this.columnWidth;
         alias._pivotField = undefined;
         let value = this.getValue(this._heading);
         value = typeof value === "string" ? `"${value}"` : value;
@@ -219,17 +237,16 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel
     @computed get innards() {
         TraceMobx();
         const key = this.props.pivotField;
-        const headings = this.props.headings();
         const heading = this._heading;
         const columnYMargin = this.props.headingObject ? 0 : this.props.yMargin;
-        const uniqueHeadings = headings.map((i, idx) => headings.indexOf(i) === idx);
         const evContents = heading ? heading : "25";
         const headingView = this.props.headingObject ?
             <div key={heading} className="collectionNoteTakingView-sectionHeader" ref={this._headerRef}
                 style={{
-                    marginTop: this.props.yMargin,
-                    width: (this.props.columnWidth) /
-                        ((uniqueHeadings.length) || 1)
+                    marginTop: 2 * this.props.yMargin,
+                    // width: (this.props.columnWidth) /
+                    //     ((uniqueHeadings.length) || 1)
+                    width: this.columnWidth
                 }}>
                 <div className="collectionNoteTakingView-sectionHeader-subCont" onPointerDown={this.headerDown}
                     title={evContents === `No Value` ?
@@ -243,7 +260,8 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel
                     />
                 </div>
             </div> : (null);
-        const templatecols = `${this.props.columnWidth / this.props.numGroupColumns}px `;
+        // const templatecols = `${this.props.columnWidth / this.props.numGroupColumns}px `;
+        const templatecols = `${this.columnWidth}px `;
         const type = this.props.Document.type;
         return <>
             {headingView}
@@ -264,7 +282,8 @@ export class CollectionNoteTakingViewFieldColumn extends React.Component<CSVFiel
 
               {!this.props.chromeHidden && type !== DocumentType.PRES ?
                   <div className="collectionNoteTakingView-DocumentButtons"
-                      style={{ width: this.props.columnWidth / this.props.numGroupColumns, marginBottom: 10 }}>
+                      // style={{ width: this.props.columnWidth / this.props.numGroupColumns, marginBottom: 10 }}>
+                      style={{ width: this.columnWidth, marginBottom: 10 }}>
                       <div key={`${heading}-add-document`} className="collectionNoteTakingView-addDocumentButton">
                           <EditableView
                               GetValue={returnEmptyString}
-- 
cgit v1.2.3-70-g09d2

