From 2c7462f38a086f156a7d2e20dc15b822b7d7b1fb Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Wed, 5 Mar 2025 02:19:04 -0500
Subject: working on template cloning

---
 .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx   | 28 +++++++++++++---------
 1 file changed, 17 insertions(+), 11 deletions(-)

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

diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
index cc161e688..099d082d3 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -632,7 +632,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             const renderedTemplates: (Template | undefined)[] = await Promise.all(renderedTemplatePromises);
         }
 
-        // templates.forEach(template => template.mainField.initRenderedDoc())
+        templates.forEach(template => template.mainField.initializeDocument())
 
         setTimeout(() => {
             this.setSuggestedTemplates(templates);
@@ -695,7 +695,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
             const res = await gptAPICall(`${++this._callCount}: ${prompt}`, GPTCallType.FILL);
 
-            console.log('prompt: ', prompt, ' response: ', res);
+            // console.log('prompt: ', prompt, ' response: ', res);
 
             if (res) {
                 const assignments: { [title: string]: { number: string; content: string } } = JSON.parse(res);
@@ -740,6 +740,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             fields.filter(title => title).forEach(title => {
                 const field = templateCopy.getFieldByTitle(title);
                 if (field === undefined) return;
+                console.log('setting content to: ', content[title]);
                 field.setContent(content[title], field.viewType);
             });
     
@@ -769,17 +770,19 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
         };
 
         const rows = [1, 2, 3, 4];
-    
-        //const promises = rowContents.map(content => processContent(content));
-    
-        const promises = rows.map(row => processContent({}));
+        
+        let docs: Promise<Doc>[];
+        if (this.DEBUG_MODE) {
+            docs = rows.map(() => processContent({}));
+        } else {
+            docs = rowContents.map(content => processContent(content));
+        }
 
-        const renderedDocs = await Promise.all(promises);
+        const renderedDocs = await Promise.all(docs);
 
-        this._docsRendering = false; // removes loading indicator
+        //renderedDocs.forEach(doc => {console.log(doc._height, doc._width); doc._height = 400; doc._width = 400});
 
-        console.log('docs: ', renderedDocs);
-        console.log('first doc height: ', renderedDocs[0]._height);
+        this._docsRendering = false; // removes loading indicator
 
         return renderedDocs;
     }
@@ -1032,6 +1035,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     applyLayout = (collection: Doc, docs: Doc[]) => {
         const { horizontalSpan, verticalSpan } = this.previewInfo;
+        console.log(this.previewInfo)
         collection._height = verticalSpan;
         collection._width = horizontalSpan;
 
@@ -1111,7 +1115,9 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
             title: 'title',
             backgroundColor: 'gray',
             x: 200,
-            y: 200
+            y: 200,
+            _width: 4000,
+            _height: 4000,
         });
 
         this.applyLayout(collection, this._fullyRenderedDocs);
-- 
cgit v1.2.3-70-g09d2

