From a2802df5096cfea2d77371ed9025ce26c8eda222 Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Thu, 24 Oct 2024 04:31:42 -0400
Subject: work on field refactor

---
 .../nodes/DataVizBox/DocCreatorMenu/Template.tsx   | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx

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

diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx
new file mode 100644
index 000000000..f9bf22047
--- /dev/null
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx
@@ -0,0 +1,48 @@
+
+import { Doc } from "../../../../../fields/Doc";
+import { Docs } from "../../../../documents/Documents";
+import { Field } from "./FieldTypes";
+import { TemplateDocInfos } from "./TemplateBackend";
+
+export class Template {
+
+    width: number = 0;
+    height: number = 0;
+    fields: Field[] = [];
+    mainDoc: Doc;
+
+    constructor(templateInfo: TemplateDocInfos) {
+        this.width = templateInfo.width;
+        this.height = templateInfo.height;
+        this.fields = templateInfo.fields.map(settings => new Field(settings, this));
+        this.mainDoc = this.setupMainDoc();
+    }
+
+    setupMainDoc = (): Doc => {
+        Docs.Create.FreeformDocument(, ){
+
+        }
+        return new Doc;
+    }
+
+    get childFields(): Field[] {
+        return this.fields;
+    }
+
+    get allFields(): Field[] {
+        const fields = this.fields;
+        this.fields.forEach(field => fields.concat(field.subfields));
+        return fields;
+    }
+
+    getChildDimensions = (coords: { tl: [number, number]; br: [number, number] }): { width: number; height: number; coord: { x: number; y: number } } => {
+        const l = (coords.tl[0] * this.height) / 2;
+        const t = coords.tl[1] * this.width / 2; //prettier-ignore
+        const r = (coords.br[0] * this.height) / 2;
+        const b = coords.br[1] * this.width / 2; //prettier-ignore
+        const width = r - l;
+        const height = b - t;
+        const coord = { x: l, y: t };
+        return { width, height, coord };
+    };
+}
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

