From a79431a47aa7fdff8e55ff653f28dd23c9af4650 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Sun, 15 Dec 2024 05:13:35 -0500
Subject: Temprarily reverted static field rerendering changes; Persistent
 rendereddoc now working for dynamic field; work on making adding fields
 functional

---
 .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx     | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 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 d8a71a610..69c896ccf 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -53,12 +53,11 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     private templateManager: TemplateManager; 
 
-    @observable _fullyRenderedDocs: Doc[] = [];
-    @observable _renderedDocCollectionPreview: Doc | undefined = undefined;
-    @observable _renderedDocCollection: Doc | undefined = undefined;
-    @observable _docsRendering: boolean = false;
+    @observable _fullyRenderedDocs: Doc[] = []; // collection of templates filled in with content
+    @observable _renderedDocCollection: Doc | undefined = undefined; // fullyRenderedDocs in a parent collection
+    @observable _docsRendering: boolean = false; // dictates loading symbol
 
-    @observable _userTemplates: {template: Template, doc: Doc}[] = []; //!!! used to keep track of all templates, should be refactored to work with actual templates and not docs
+    @observable _userTemplates: {template: Template, doc: Doc}[] = []; 
     @observable _selectedTemplate: Template | undefined = undefined;
     @observable _currEditingTemplate: Template | undefined = undefined;
 
@@ -66,11 +65,9 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     @observable _selectedCols: { title: string; type: string; desc: string }[] | undefined = [];
 
     @observable _layout: { type: LayoutType; yMargin: number; xMargin: number; columns?: number; repeat: number } = { type: LayoutType.FREEFORM, yMargin: 10, xMargin: 10, columns: 3, repeat: 0 };
-    @observable _layoutPreviewScale: number = 1;
     @observable _savedLayouts: DataVizTemplateLayout[] = [];
     @observable _expandedPreview: Doc | undefined = undefined;
 
-    @observable _suggestedTemplates: Template[] = [];
     @observable _suggestedTemplatePreviews: {doc: Doc, template: Template}[] = [];
     @observable _GPTOpt: boolean = false;
     @observable _callCount: number = 0;
@@ -110,10 +107,8 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
         this._dataViz = dataViz;
         this._selectedTemplate = undefined;
         this._renderedDocCollection = undefined;
-        this._renderedDocCollectionPreview = undefined;
         this._fullyRenderedDocs = [];
         this._suggestedTemplatePreviews = [];
-        this._suggestedTemplates = [];
         this._userCreatedFields = [];
     };
     @action addUserTemplate = (template: Template) => {
@@ -129,7 +124,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
         this._userTemplates = this._userTemplates.map(t => { return t.template === preview.template ? preview : t }); //prettier-ignore
     };
     @action setSuggestedTemplates = (templates: Template[]) => {
-        this._suggestedTemplates = templates;
         this._suggestedTemplatePreviews = templates.map(template => {return {template: template, doc: template.getRenderedDoc()}}); //prettier-ignore
     };
 
@@ -399,7 +393,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     testTemplate = async () => {
 
-        const obj = new DocumentOptions();
+        this._suggestedTemplatePreviews = this.templateManager.templates.map(template => {return {template: template, doc: template.getRenderedDoc()}}); //prettier-ignore
 
         //console.log(this.templateManager.templates)
 
@@ -761,7 +755,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     
         const renderedDocs = await Promise.all(promises);
 
-        this._docsRendering = false;
+        this._docsRendering = false; // removes loading indicator
 
         return renderedDocs;
     }
@@ -1110,7 +1104,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                     <ReactLoading type="spin" color={StrCast(Doc.UserDoc().userVariantColor)} height={30} width={30} />
                 </div> 
             </div>
-            ) : !this._renderedDocCollection? null : (
+            ) : !this._renderedDocCollection ? null : (
             <div className="docCreatorMenu-layout-preview-window-wrapper" id={String(id) ?? undefined}>
                 <DocumentView
                     Document={this._renderedDocCollection}
-- 
cgit v1.2.3-70-g09d2

