From 77bf838bebc813d476788fabed6bc7bcbf8197b0 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Wed, 10 Jul 2024 14:36:39 -0400
Subject: images displaying

---
 src/client/views/nodes/DataVizBox/DataVizBox.tsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

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

diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index 1e0a72a91..f75ba9700 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -429,12 +429,18 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
         this.layoutDoc.dataViz_filterSelection = !this.layoutDoc.dataViz_filterSelection;
     };
 
+    openDocCreatorMenu = (x: number, y: number) => {
+        DocCreatorMenu.Instance.toggleDisplay(x, y);
+        DocCreatorMenu.Instance.setDataViz(this);
+        DocCreatorMenu.Instance.setTemplateDocs(this.getPossibleTemplates());
+    }
+
     specificContextMenu = (x: number, y: number): void => {
         const cm = ContextMenu.Instance;
         const options = cm.findByDescription('Options...');
         const optionItems = options && 'subitems' in options ? options.subitems : [];
         optionItems.push({ description: `Analyze with AI`, event: () => this.askGPT(), icon: 'lightbulb' });
-        optionItems.push({ description: `Create documents`, event: () => DocCreatorMenu.Instance.toggleDisplay(x, y), icon: 'table-cells' });
+        optionItems.push({ description: `Create documents`, event: () => this.openDocCreatorMenu(x, y), icon: 'table-cells' });
         !options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'eye' });
     };
 
@@ -452,13 +458,12 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
     getPossibleTemplates = (): Doc[] => {
         const linkedDocs: Doc[] = LinkManager.Instance.getAllRelatedLinks(this.Document).map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)));
         const linkedCollections: Doc[] = linkedDocs.filter(doc => doc.type === 'config').filter(doc => DocCast(doc.annotationOn).type === 'collection');
-        console.log('cols: ' + linkedCollections)
         const isColumnTitle = (title: string): boolean => {
             const colTitles: string[] = Object.keys(this.records[0]);
             console.log('titles: ' + colTitles)
             for (let i = 0; i < colTitles.length; ++i){
                 if (colTitles[i] === title) {
-                    console.log(true);
+                    console.log(true); 
                     return true;
                 }
             }
@@ -472,7 +477,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
             }
             return false;
         }
-        return linkedCollections.filter(col => isValidTemplate(col));
+        return linkedDocs;
     }
 
     /**
-- 
cgit v1.2.3-70-g09d2

