From 951d6a8681e9be9068c8a0f8fce659938ab9ed80 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Wed, 31 Jul 2024 03:01:55 -0400
Subject: basic template generation work

---
 src/client/views/nodes/DataVizBox/DataVizBox.tsx | 35 +++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

(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 e943dd2e3..f25602fd5 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -34,13 +34,14 @@ import { PieChart } from './components/PieChart';
 import { TableBox } from './components/TableBox';
 import { LinkManager } from '../../../util/LinkManager';
 import { DataVizTemplateInfo, DataVizTemplateLayout, DocCreatorMenu, LayoutType } from './DocCreatorMenu';
-import { CollectionFreeFormView } from '../../collections/collectionFreeForm';
+import { CollectionFreeFormView, MarqueeView } from '../../collections/collectionFreeForm';
 import { PrefetchProxy } from '../../../../fields/Proxy';
 import { AclAdmin, AclAugment, AclEdit } from '../../../../fields/DocSymbols';
 import { template } from 'lodash';
 import { data } from 'jquery';
 import { listSpec } from '../../../../fields/Schema';
 import { ObjectField } from '../../../../fields/ObjectField';
+import { Id } from '../../../../fields/FieldSymbols';
 
 export enum DataVizView {
     TABLE = 'table',
@@ -566,6 +567,38 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
         this.applyLayout(templateInfo, docs);
     }
 
+    createBasicTemplates = (colsToLayout: {width: number, height: number, x: number, y: number, title: string}[]) => {
+        const mainCollection = this.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView;
+        const docTools: Doc[] = DocListCast(DocListCast(Doc.MyTools?.data)[0]?.data);
+        console.log(docTools.map(doc => doc.title))
+        const index = docTools.map(doc => doc.title).indexOf('Col');
+        const template: Doc | undefined = DocUtils.copyDragFactory(Cast(docTools[index]?.dragFactory, Doc, null));
+        if (!template) return;
+
+        //const template = new CollectionFreeFormView({});
+        const fields: Doc[] = colsToLayout.map(layout => {
+            const field = new Doc();
+            field.x = layout.x;
+            field.y = layout.y;
+            field._width = layout.width;
+            field._height = layout.height;
+            field.title = layout.title;
+            template.data = 'hey'//DocListCast(template.data).map(doc => `idToDoc("${doc[Id]}")`).push(`idToDoc("${field[Id]}")`);
+            return field;
+        });
+
+        const fieldLiterals: string[] = fields.map(field => `idToDoc("${field[Id]}")`);
+
+        template.data = fieldLiterals[0];
+
+        template.x = 400;
+        template.y = 400;
+        template._width = 500;
+        template._height = 500;
+
+        mainCollection.addDocument(template);
+    }
+
     /**
      * creates a new dataviz document filter from this one
      *      it appears to the right of this document, with the
-- 
cgit v1.2.3-70-g09d2

