From 1f3fa3b79753ae6ca72af5fc23dfe5dfa3fc09bb Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Fri, 8 Nov 2024 03:12:49 -0500
Subject: new template added

---
 .../nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 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 257c7fc00..1889344fd 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -108,9 +108,13 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     @action setDataViz = (dataViz: DataVizBox) => {
         this._dataViz = dataViz;
+        this._selectedTemplate = undefined;
+        this._renderedDocCollection = undefined;
+        this._renderedDocCollectionPreview = undefined;
+        this._fullyRenderedDocs = [];
     };
     @action addUserTemplate = (template: Template) => {
-        this._userTemplates.push({template: template, doc: template.getRenderedDoc()});
+        this._userTemplates.push({template: template.cloneBase(), doc: template.getRenderedDoc()});
     };
     @action removeUserTemplate = (template: Template) => {
         this._userTemplates = this._userTemplates.filter(info => info.template !== template);
@@ -394,6 +398,13 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
         //console.log(this.templateManager.templates)
 
+        const mainCollection = this._dataViz?.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView;
+        
+        this.templateManager.templates.forEach(template => {
+            const doc = template.mainField.renderedDoc();
+            mainCollection.addDocument(doc);
+        })
+
         this.forceUpdate();
 
         // try {
@@ -691,6 +702,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     createDocsFromTemplate = async (template: Template) => {
         const dv = this._dataViz;
+        console.log('dataviz: ', dv);
         if (!dv) return;
 
         this._docsRendering = true;
@@ -798,7 +810,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                 />
             </div>
 
-
         return (
             <div className="docCreatorMenu-expanded-template-preview">
                 <div className="top-panel"/>
@@ -811,11 +822,10 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                         <FontAwesomeIcon icon="minimize" />
                     </button>
                     <button className="docCreatorMenu-menu-button section-reveal-options top-right-lower" onPointerDown={e => this.setUpButtonClick(e, () => {this._currEditingTemplate?.resetToBase(); this.setExpandedView(this._currEditingTemplate);})}>
-                        <FontAwesomeIcon icon="plus" color="white" />
+                        <FontAwesomeIcon icon="arrows-rotate" color="white" />
                     </button>
                 </div>
             </div>
-
         );
     }
 
-- 
cgit v1.2.3-70-g09d2

