From fe744903609e669c5f3048743ceba9268b8dfe0d Mon Sep 17 00:00:00 2001
From: Nathan-SR <144961007+Nathan-SR@users.noreply.github.com>
Date: Sat, 7 Dec 2024 19:46:07 -0500
Subject: field superclass

---
 .../DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx   | 82 ++++++++--------------
 1 file changed, 31 insertions(+), 51 deletions(-)

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

diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
index 079d222d3..d8a71a610 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -400,7 +400,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     testTemplate = async () => {
 
         const obj = new DocumentOptions();
-        console.log(Object.entries(obj)[1][0]);
 
         //console.log(this.templateManager.templates)
 
@@ -545,7 +544,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     compileFieldDescriptions = (templates: Template[]): string => {
         let descriptions: string = '';
         templates.forEach(template => {
-            descriptions += `----------  NEW TEMPLATE TO INCLUDE: The title is: ${template.mainField.getTitle()}. Its fields are: `;
+            descriptions += `----------  NEW TEMPLATE TO INCLUDE: The title is: ${template.title}. Its fields are: `;
             descriptions += template.descriptionSummary;
         });
 
@@ -585,7 +584,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                 const brokenDownAssignments: [Template, { [fieldID: number]: Col }][] = [];
 
                 Object.entries(assignments).forEach(([tempTitle, assignment]) => {
-                    const template = templates.filter(template => template.mainField.getTitle() === tempTitle)[0];
+                    const template = templates.filter(template => template.title === tempTitle)[0];
                     if (!template) return;
                     const toObj = Object.entries(assignment).reduce(
                         (a, [fieldID, colTitle]) => {
@@ -707,7 +706,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
     createDocsFromTemplate = async (template: Template) => {
         const dv = this._dataViz;
-        console.log('dataviz: ', dv);
+
         if (!dv) return;
 
         this._docsRendering = true;
@@ -781,7 +780,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
     @action setExpandedView = (template: Template | undefined) => {
         if (template) {
             this._currEditingTemplate = template;
-            this._expandedPreview = template.mainField.renderedDoc(); //Docs.Create.FreeformDocument([doc], { _height: NumListCast(doc._height)[0], _width: NumListCast(doc._width)[0], title: ''});
+            this._expandedPreview = template.doc; //Docs.Create.FreeformDocument([doc], { _height: NumListCast(doc._height)[0], _width: NumListCast(doc._width)[0], title: ''});
         } else {
             this._currEditingTemplate = undefined;
             this._expandedPreview = undefined;
@@ -839,6 +838,31 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
 
         const GPTOptions = <div></div>;
 
+        const previewDoc = (doc: Doc, template: Template) => 
+        <DocumentView
+        Document={doc}
+        isContentActive={emptyFunction} // !!! should be return false
+        addDocument={returnFalse}
+        moveDocument={returnFalse}
+        removeDocument={returnFalse}
+        PanelWidth={() => this._selectedTemplate === template ? 104 : 111}
+        PanelHeight={() => this._selectedTemplate === template ? 104 : 111}
+        ScreenToLocalTransform={() => new Transform(-this._pageX - 5,-this._pageY - 35, 1)}
+        renderDepth={1}
+        whenChildContentsActiveChanged={emptyFunction}
+        focus={emptyFunction}
+        styleProvider={DefaultStyleProvider}
+        addDocTab={this._props.addDocTab}
+        // eslint-disable-next-line no-use-before-define
+        pinToPres={() => undefined}
+        childFilters={returnEmptyFilter}
+        childFiltersByRanges={returnEmptyFilter}
+        searchFilterDocs={returnEmptyDoclist}
+        fitContentsToBox={returnFalse}
+        fitWidth={returnFalse}
+        hideDecorations={true}
+        />
+
         //<img className='docCreatorMenu-preview-image expanded' src={this._expandedPreview.icon!.url.href.replace(".png", "_o.png")} />
 
         return (
@@ -881,29 +905,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                                                 <button className="option-button right" onPointerDown={e => this.setUpButtonClick(e, () => this.addUserTemplate(template))}>
                                                     <FontAwesomeIcon icon="plus" color="white" />
                                                 </button>
-                                                <DocumentView
-                                                    Document={doc}
-                                                    isContentActive={emptyFunction} // !!! should be return false
-                                                    addDocument={returnFalse}
-                                                    moveDocument={returnFalse}
-                                                    removeDocument={returnFalse}
-                                                    PanelWidth={() => this._selectedTemplate === template ? 104 : 111}
-                                                    PanelHeight={() => this._selectedTemplate === template ? 104 : 111}
-                                                    ScreenToLocalTransform={() => new Transform(-this._pageX - 5,-this._pageY - 35, 1)}
-                                                    renderDepth={1}
-                                                    whenChildContentsActiveChanged={emptyFunction}
-                                                    focus={emptyFunction}
-                                                    styleProvider={DefaultStyleProvider}
-                                                    addDocTab={this._props.addDocTab}
-                                                    // eslint-disable-next-line no-use-before-define
-                                                    pinToPres={() => undefined}
-                                                    childFilters={returnEmptyFilter}
-                                                    childFiltersByRanges={returnEmptyFilter}
-                                                    searchFilterDocs={returnEmptyDoclist}
-                                                    fitContentsToBox={returnFalse}
-                                                    fitWidth={returnFalse}
-                                                    hideDecorations={true}
-                                                    />
+                                                {previewDoc(doc, template)}
                                             </div>
                                         ))
                                 )}
@@ -950,29 +952,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
                                             <button className="option-button right" onPointerDown={e => this.setUpButtonClick(e, () => this.removeUserTemplate(template))}>
                                                 <FontAwesomeIcon icon="minus" color="white" />
                                             </button>
-                                            <DocumentView
-                                                Document={doc}
-                                                isContentActive={emptyFunction} // !!! should be return false
-                                                addDocument={returnFalse}
-                                                moveDocument={returnFalse}
-                                                removeDocument={returnFalse}
-                                                PanelWidth={() => this._selectedTemplate === template ? 104 : 111}
-                                                PanelHeight={() => this._selectedTemplate === template ? 104 : 111}
-                                                ScreenToLocalTransform={() => new Transform(-this._pageX - 5, -this._pageY - 35, 1)}
-                                                renderDepth={1}
-                                                whenChildContentsActiveChanged={emptyFunction}
-                                                focus={emptyFunction}
-                                                styleProvider={DefaultStyleProvider}
-                                                addDocTab={this._props.addDocTab}
-                                                // eslint-disable-next-line no-use-before-define
-                                                pinToPres={() => undefined}
-                                                childFilters={returnEmptyFilter}
-                                                childFiltersByRanges={returnEmptyFilter}
-                                                searchFilterDocs={returnEmptyDoclist}
-                                                fitContentsToBox={returnFalse}
-                                                fitWidth={returnFalse}
-                                                hideDecorations={true}
-                                                />
+                                            {previewDoc(doc, template)}
                                         </div>
                                     ))}
                             </div>
-- 
cgit v1.2.3-70-g09d2

