aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx48
1 files changed, 48 insertions, 0 deletions
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