diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2025-03-04 03:07:06 -0500 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2025-03-04 03:07:06 -0500 |
commit | c6845961d5938ced763c29026c06d6fcb7051501 (patch) | |
tree | 0d55ab55f03a7cd7d3ac4c918e9606ef851e1f7c /src | |
parent | f7e28d954902bf9e7e8567ce06b6eb03b6cd92ef (diff) |
c
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DynamicField.tsx | 13 | ||||
-rw-r--r-- | src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx | 22 |
2 files changed, 21 insertions, 14 deletions
diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DynamicField.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DynamicField.tsx index 59a955c66..e17ad3860 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DynamicField.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/DynamicField.tsx @@ -33,21 +33,16 @@ export class DynamicField extends Field { initializeDocument = (): Doc => { let doc: Doc; const renderedSubfields: Doc[] = this.subfields.map(field => field.renderedDoc); + this.settings.opts.title = this.title; switch (this.settings.viewType) { case ViewType.CAROUSEL3D: - doc = Docs.Create.Carousel3DDocument(renderedSubfields, { - title: this.title, - }); + doc = Docs.Create.Carousel3DDocument(renderedSubfields, this.settings.opts); break; case ViewType.FREEFORM: - doc = Docs.Create.FreeformDocument(renderedSubfields, { - title: this.title, - }); + doc = Docs.Create.FreeformDocument(renderedSubfields, this.settings.opts); break; default: - doc = Docs.Create.FreeformDocument(renderedSubfields, { - title: this.title, - }); + doc = Docs.Create.FreeformDocument(renderedSubfields, this.settings.opts); break; } diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx index df98e6181..07278f4ee 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/FieldTypes/Field.tsx @@ -6,6 +6,8 @@ import { IDisposer } from "mobx-utils"; import { DocumentType } from "../../../../../documents/DocumentTypes"; import { Partial } from "@react-spring/web"; import { DocumentOptions } from "../../../../../documents/Documents"; +import { List } from "../../../../../../fields/List"; +import { runInThisContext } from "vm"; export abstract class Field { @@ -68,6 +70,7 @@ export abstract class Field { abstract getContent(): string; changeFieldType = (newType: ViewType): Field => { + console.log('changed') this.settings.viewType = newType; const newField: Field = this.initField(this.settings, this.id, this.parent); this.parent.exchangeFields(newField, this); @@ -92,8 +95,17 @@ export abstract class Field { this.subfields.push(newField); }; + // addField = (field: Field) => { + // console.log('added') + // if (!this.subfields.includes(field)){ + // this.subfields.push(field); + // // Doc.SetContainer(field.Document, this.Document); + // } + // } + removeField = (field: Field) => { - console.log('removefield called') + // var childDocs: Doc[] = DocListCast(this.Document[Doc.LayoutFieldKey(this.Document)]); + // this.Document[Doc.LayoutFieldKey(this.Document)] = new List<Doc>([...childDocs.splice(childDocs.indexOf(field.Document), 1)]); this.subfields.splice(this.subfields.indexOf(field), 1); field.dispose(); }; @@ -106,7 +118,7 @@ export abstract class Field { applyAttributes(field: Field) { field.setTitle(this.title); - field.initializeDocument(this.renderedDoc); + field.initializeDocument(this.Document); field.subfields = this.subfields; } @@ -118,7 +130,7 @@ export abstract class Field { handleFieldUpdate = (newDocsList: Doc[]) => { const currRenderedDocs: Set<Doc> = new Set(); - this.subfields.forEach(field => currRenderedDocs.add(field.renderedDoc)); + this.subfields.forEach(field => currRenderedDocs.add(field.Document)); newDocsList.forEach(doc => { if (!currRenderedDocs.has(doc)) { this.addFieldFromDoc(doc); @@ -126,7 +138,7 @@ export abstract class Field { }); currRenderedDocs.forEach(doc => { if (!newDocsList.includes(doc)){ - const fields = this.subfields.filter(field => field.renderedDoc === doc); + const fields = this.subfields.filter(field => field.Document === doc); fields.forEach(field => this.removeField(field)); } }); @@ -153,7 +165,7 @@ export abstract class Field { }; private getLocalDimensions = (coords: { tl: [number, number]; br: [number, number] }, parentDimensions: FieldDimensions): FieldDimensions => { - if (!parentDimensions) { + if (this.parent === this) { return {width: coords.br[0] - coords.tl[0], height: coords.br[1] - coords.tl[1], coord: {x: coords.tl[0], y: coords.tl[1]}}; } const l = (coords.tl[0] * parentDimensions.width) / 2; |