From 1ffa8a8fb3e16bd5a3338d18782ddda0c2ffca03 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Sun, 16 Mar 2025 21:15:00 -0400
Subject: a lot of code cleanup for doc creators templates

---
 .../nodes/DataVizBox/DocCreatorMenu/Template.tsx   | 139 ---------------------
 1 file changed, 139 deletions(-)
 delete 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
deleted file mode 100644
index 3c610b36a..000000000
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/Template.tsx
+++ /dev/null
@@ -1,139 +0,0 @@
-import { makeAutoObservable } from 'mobx';
-import { Col } from './DocCreatorMenu';
-import { DynamicField } from './FieldTypes/DynamicField';
-import { Field, FieldSettings } from './FieldTypes/Field';
-import { TemplateLayouts } from './TemplateBackend';
-
-export class Template {
-    mainField: DynamicField;
-    private settings: FieldSettings;
-
-    constructor(templateInfo: FieldSettings) {
-        makeAutoObservable(this);
-        this.settings = templateInfo;
-        this.mainField = this.setupMainField(templateInfo);
-    }
-
-    get childFields(): Field[] {
-        return this.mainField.getSubfields;
-    }
-    get allFields(): Field[] {
-        return this.mainField.getAllSubfields;
-    }
-    get contentFields(): Field[] {
-        return this.allFields.filter(field => field.isContentField);
-    }
-    get doc() {
-        return this.mainField.renderedDoc;
-    }
-    get title() {
-        return this.mainField.getTitle();
-    }
-
-    cleanup = () => {
-        //dispose each subfields disposers, etc.
-    };
-
-    cloneBase = async (): Promise<Template> => {
-        const clone: Template = new Template(TemplateLayouts.BasicSettings);
-        clone.mainField = (await this.mainField.makeClone(undefined)) as unknown as DynamicField;
-        clone.mainField.renderedDoc._width = this.mainField.renderedDoc._width;
-        clone.mainField.renderedDoc._height = this.mainField.renderedDoc._height;
-        return clone;
-    };
-
-    printFieldInfo = () => {
-        this.allFields.forEach(field => {
-            const doc = field.renderedDoc;
-            console.log('title: ', field.getTitle(), ' width: ', doc.width);
-        });
-    };
-
-    getRenderedDoc = () => {
-        return this.doc;
-    };
-
-    getFieldByID = (id: number): Field => {
-        return this.allFields.filter(field => field.getID === id)[0];
-    };
-
-    getFieldByTitle = (title: string) => {
-        return this.allFields.filter(field => field.getTitle() === title)[0];
-    };
-
-    setupMainField = (templateInfo: FieldSettings) => {
-        return new DynamicField().init(templateInfo, 1);
-    };
-
-    get descriptionSummary(): string {
-        let summary: string = '';
-        this.contentFields.forEach(field => {
-            summary += `--- Field #${field.getID} (title: ${field.getTitle()}): ${field.getDescription ?? ''} ---`;
-        });
-        return summary;
-    }
-
-    get compiledContent(): string {
-        let summary: string = '';
-        this.contentFields.forEach(field => {
-            summary += `--- Field #${field.getID} (title: ${field.getTitle()}): ${field.getContent() ?? ''} ---`;
-        });
-        return summary;
-    }
-
-    isValidTemplate = (cols: Col[]) => {
-        const matches: number[][] = this.getMatches(cols);
-        const maxMatches: number = this.maxMatches(matches);
-        return maxMatches === this.contentFields.length;
-    };
-
-    getMatches = (cols: Col[]): number[][] => {
-        const numFields = this.contentFields.length;
-
-        if (cols.length !== numFields) return [];
-
-        const matches: number[][] = Array(numFields)
-            .fill([])
-            .map(() => []);
-
-        this.contentFields.forEach((field, i) => {
-            matches[i] = field.matches(cols);
-        });
-
-        return matches;
-    };
-
-    maxMatches = (matches: number[][]) => {
-        if (matches.length === 0) return 0;
-
-        const fieldsCt = this.contentFields.length;
-        const used: boolean[] = Array(fieldsCt).fill(false);
-        const mt: number[] = Array(fieldsCt).fill(-1);
-
-        const augmentingPath = (v: number): boolean => {
-            if (used[v]) return false;
-            used[v] = true;
-
-            for (const to of matches[v]) {
-                if (mt[to] === -1 || augmentingPath(mt[to])) {
-                    mt[to] = v;
-                    return true;
-                }
-            }
-            return false;
-        };
-
-        for (let v = 0; v < fieldsCt; ++v) {
-            used.fill(false);
-            augmentingPath(v);
-        }
-
-        let count: number = 0;
-
-        for (let i = 0; i < fieldsCt; ++i) {
-            if (mt[i] !== -1) ++count;
-        }
-
-        return count;
-    };
-}
-- 
cgit v1.2.3-70-g09d2

