From 99b879956b67dc246f1ba48759a5550a94a5813d Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Wed, 31 Jul 2024 12:46:55 -0400
Subject: with old code for basic templates

---
 src/client/views/nodes/DataVizBox/DataVizBox.tsx | 34 +++++++++++-------------
 1 file changed, 16 insertions(+), 18 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 f25602fd5..43cfe5bba 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -12,7 +12,7 @@ import { InkTool } from '../../../../fields/InkField';
 import { List } from '../../../../fields/List';
 import { Cast, CsvCast, DocCast, NumCast, StrCast } from '../../../../fields/Types';
 import { CsvField } from '../../../../fields/URLField';
-import { GetEffectiveAcl, TraceMobx } from '../../../../fields/util';
+import { GetEffectiveAcl, TraceMobx, inheritParentAcls } from '../../../../fields/util';
 import { DocUtils } from '../../../documents/DocUtils';
 import { DocumentType } from '../../../documents/DocumentTypes';
 import { Docs } from '../../../documents/Documents';
@@ -569,32 +569,30 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
 
     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 docTools: Doc[] = DocListCast(DocListCast(Doc.MyTools?.data)[0]?.data);
+        // 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]}")`);
+            const field = Docs.Create.TextDocument('', { _height: layout.height, _width: layout.width, title: layout.title, x: layout.x, y: layout.y });
+            // Doc.SetContainer(field, template);
+            // inheritParentAcls(template, field, true);
+            //template.data = 'hey'//DocListCast(template.data).map(doc => `idToDoc("${doc[Id]}")`).push(`idToDoc("${field[Id]}")`);
             return field;
         });
 
+        const template = Docs.Create.FreeformDocument(fields, { _height: 500, _width: 500, title: 'template', x: 400, y: 400 })
+
         const fieldLiterals: string[] = fields.map(field => `idToDoc("${field[Id]}")`);
 
-        template.data = fieldLiterals[0];
+        //template.data = fieldLiterals[0];
 
-        template.x = 400;
-        template.y = 400;
-        template._width = 500;
-        template._height = 500;
+        // template.x = 400;
+        // template.y = 400;
+        // template._width = 500;
+        // template._height = 500;
 
         mainCollection.addDocument(template);
     }
-- 
cgit v1.2.3-70-g09d2

