From 441e1337f22f4bc9f9c6c8dcf643cc72c4d68f21 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Thu, 5 Sep 2024 03:35:51 -0400
Subject: Oh, coding makes me feel like an idiot sometimes... (added += where a
 string was supposed to be updated)

---
 .../views/nodes/DataVizBox/DocCreatorMenu.tsx      | 24 ++++++++++++++--------
 1 file changed, 15 insertions(+), 9 deletions(-)

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

diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
index 33d9a8827..64152f577 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx
@@ -478,6 +478,15 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
         }   
     };
 
+    setColTitle = (column: Col, title: string) => {
+        if (this.selectedFields.includes(column.title)) {
+            this._dataViz?.setColumnTitle(column.title, title);
+        } else {
+            column.title = title;
+        }
+        this.forceUpdate();
+    };
+
     setColType = (column: Col, type: TemplateFieldType) => {
         if (this.selectedFields.includes(column.title)) {
             this._dataViz?.setColumnType(column.title, type);
@@ -492,6 +501,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             this._dataViz?.setColumnSize(column.title, size);
         } else {
             column.size = size;
+            console.log(column.size)
         }
         this.forceUpdate();
     };
@@ -501,7 +511,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             this._dataViz?.setColumnDesc(column.title, desc);
         } else {
             column.desc = desc;
-            console.log(column, column.desc)
         }
         this.forceUpdate();
     };
@@ -620,13 +629,12 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
         const stringifyGPTInfo = (): string => {
             let string: string = '*** COLUMN INFO:';
             GPTAssignments.forEach(([fieldNum, col]) => {
-                `--- title: ${col.title}, prompt: ${col.desc}, word limit: ${wordLimit(col.size)} words, assigned field: ${fieldNum} ---`
+                string += `--- title: ${col.title}, prompt: ${col.desc}, word limit: ${wordLimit(col.size)} words, assigned field: ${fieldNum} ---`
             });
             return string += ' ***';
         };
 
         const GPTAssignmentString = stringifyGPTInfo();
-        console.log('assignment string', GPTAssignmentString);
 
         let fieldContent: string = '';
 
@@ -682,8 +690,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             return main;
         }
 
-        console.log('field content', fieldContent)
-
         if (GPTAssignments.length) {
             
             try {
@@ -695,7 +701,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                     console.log('response', res);
 
                     const assignments: {[title: string]: {number: string, content: string}} = JSON.parse(res);
-                    console.log('assignments', assignments);
+                    console.log('assignments', GPTAssignments, 'assignment string', GPTAssignmentString, 'field content', fieldContent, 'response', res, 'assignments', assignments);
                     Object.entries(assignments).forEach(([title, info]) => {
                         const field: Field = template.fields[Number(info.number)];
                         const col = this.getColByTitle(title);
@@ -1164,7 +1170,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             {this.fieldsInfos.map((field, index) => 
                 <div className='field-panel' id={`${index}`}>
                     <div className='properties-wrapper'>
-                        <input className='field-property-container' id={`${Math.random() * 100}`} defaultValue={field.title} placeholder={'Enter title'}/>
+                        <input className='field-property-container' id={`${Math.random() * 100}`} defaultValue={field.title} placeholder={'Enter title'}  onChange={(e) => this.setColTitle(field, e.target.value)}/>
                         <div className='field-type-selection-container'>
                             {field.type === TemplateFieldType.UNSET ? <span className='placeholder'>Select media type</span> : null}
                             <span className='type-display'>{field.type === TemplateFieldType.TEXT ? 'Text Field' : field.type === TemplateFieldType.VISUAL ? 'File Field' : ''}</span>
@@ -1175,7 +1181,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                                 <div className='text'>File</div>
                             </div>
                         </div>
-                        <input className='field-property-container' id={`${Math.random() * 100}`} placeholder={this._dataViz?.GPTSummary?.get(field.title)?.size} style={{width: field.title === '' ? '30%' : ''}}/>
+                        <input className='field-property-container' id={`${Math.random() * 100}`} placeholder={this._dataViz?.GPTSummary?.get(field.title)?.size} style={{width: field.title === '' ? '30%' : ''} } onChange={(e) => this.setColSize(field, e.target.value as TemplateFieldSize)}/>
                     </div>
                     <textarea className='field-description-container' onChange={(e) => this.setColDesc(field, e.target.value)} defaultValue={field.desc === this._dataViz?.GPTSummary?.get(field.title)?.desc ? '' : field.desc } placeholder={this._dataViz?.GPTSummary?.get(field.title)?.desc ?? 'Add a description to help with template generation.'} /> 
                     <div>
@@ -1434,7 +1440,7 @@ export class FieldFuncs {
         const width = r - l;
         const height = b - t;
         const coord = {x: l, y: t};
-        console.log(coords, parentWidth, parentHeight, height);
+        //console.log(coords, parentWidth, parentHeight, height);
         return {width, height, coord};
     }
 
-- 
cgit v1.2.3-70-g09d2

