From f7e28d954902bf9e7e8567ce06b6eb03b6cd92ef Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Sun, 2 Mar 2025 03:19:21 -0500
Subject: Slight refactors (with so much wasted time trying for larger ones)

---
 .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx   | 32 +++++++++++++++-------
 1 file changed, 22 insertions(+), 10 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 faa6cffa8..cc161e688 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -47,6 +47,8 @@ export enum LayoutType {
 export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     static Instance: DocCreatorMenu;
 
+    private DEBUG_MODE: boolean = false;
+
     private _disposers: { [name: string]: IDisposer } = {};
 
     private _ref: HTMLDivElement | null = null;
@@ -122,8 +124,11 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     };
 
     @computed get docsToRender() {
-        return [1, 2, 3, 4];
-        //this._selectedTemplate ? NumListCast(this._dataViz?.layoutDoc.dataViz_selectedRows) : []; !!! put this back for GPT rendering
+        if (this.DEBUG_MODE) {
+            return [1, 2, 3, 4];
+        } else {
+            return this._selectedTemplate ? NumListCast(this._dataViz?.layoutDoc.dataViz_selectedRows) : [];
+        }
     }
 
     @computed get rowsCount() {
@@ -607,20 +612,27 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     };
 
     generatePresetTemplates = async () => {
-        this._dataViz?.updateColDefaults();
 
-        const cols = this.fieldsInfos;
-        const templates = this.templateManager.getValidTemplates(cols);
+        const templates: Template[] = [];
 
-        console.log(templates)
+        if (this.DEBUG_MODE) {
+            templates.push(...this.templateManager.templates)
+        } else {
+            this._dataViz?.updateColDefaults();
 
-        const assignments: [Template, { [field: number]: Col }][] = await this.assignColsToFields(templates, cols);
+            const cols = this.fieldsInfos;
+            templates.push(...this.templateManager.getValidTemplates(cols));
 
-        const renderedTemplatePromises: Promise<Template | undefined>[] = assignments.map(([template, assignments]) => this.applyGPTContentToTemplate(template, assignments));
+            console.log(templates)
 
-        const renderedTemplates: (Template | undefined)[] = await Promise.all(renderedTemplatePromises);
+            const assignments: [Template, { [field: number]: Col }][] = await this.assignColsToFields(templates, cols);
+
+            const renderedTemplatePromises: Promise<Template | undefined>[] = assignments.map(([template, assignments]) => this.applyGPTContentToTemplate(template, assignments));
+
+            const renderedTemplates: (Template | undefined)[] = await Promise.all(renderedTemplatePromises);
+        }
 
-        templates.forEach(template => template.mainField.initRenderedDoc())
+        // templates.forEach(template => template.mainField.initRenderedDoc())
 
         setTimeout(() => {
             this.setSuggestedTemplates(templates);
-- 
cgit v1.2.3-70-g09d2

