diff options
author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-07-31 03:01:55 -0400 |
---|---|---|
committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-07-31 03:01:55 -0400 |
commit | 951d6a8681e9be9068c8a0f8fce659938ab9ed80 (patch) | |
tree | ade7ee0af98b9a4489dcb01d70ac4ee7a17ae9d9 /src | |
parent | fb4b4658f39c2a845174372a8fd814c49bf26d7c (diff) |
basic template generation work
Diffstat (limited to 'src')
-rw-r--r-- | src/client/views/nodes/DataVizBox/DataVizBox.tsx | 35 | ||||
-rw-r--r-- | src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx | 13 |
2 files changed, 46 insertions, 2 deletions
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx index e943dd2e3..f25602fd5 100644 --- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx +++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx @@ -34,13 +34,14 @@ import { PieChart } from './components/PieChart'; import { TableBox } from './components/TableBox'; import { LinkManager } from '../../../util/LinkManager'; import { DataVizTemplateInfo, DataVizTemplateLayout, DocCreatorMenu, LayoutType } from './DocCreatorMenu'; -import { CollectionFreeFormView } from '../../collections/collectionFreeForm'; +import { CollectionFreeFormView, MarqueeView } from '../../collections/collectionFreeForm'; import { PrefetchProxy } from '../../../../fields/Proxy'; import { AclAdmin, AclAugment, AclEdit } from '../../../../fields/DocSymbols'; import { template } from 'lodash'; import { data } from 'jquery'; import { listSpec } from '../../../../fields/Schema'; import { ObjectField } from '../../../../fields/ObjectField'; +import { Id } from '../../../../fields/FieldSymbols'; export enum DataVizView { TABLE = 'table', @@ -566,6 +567,38 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() { this.applyLayout(templateInfo, docs); } + createBasicTemplates = (colsToLayout: {width: number, height: number, x: number, y: number, title: string}[]) => { + const mainCollection = this.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView; + const docTools: Doc[] = DocListCast(DocListCast(Doc.MyTools?.data)[0]?.data); + console.log(docTools.map(doc => doc.title)) + const index = docTools.map(doc => doc.title).indexOf('Col'); + const template: Doc | undefined = DocUtils.copyDragFactory(Cast(docTools[index]?.dragFactory, Doc, null)); + if (!template) return; + + //const template = new CollectionFreeFormView({}); + const fields: Doc[] = colsToLayout.map(layout => { + const field = new Doc(); + field.x = layout.x; + field.y = layout.y; + field._width = layout.width; + field._height = layout.height; + field.title = layout.title; + template.data = 'hey'//DocListCast(template.data).map(doc => `idToDoc("${doc[Id]}")`).push(`idToDoc("${field[Id]}")`); + return field; + }); + + const fieldLiterals: string[] = fields.map(field => `idToDoc("${field[Id]}")`); + + template.data = fieldLiterals[0]; + + template.x = 400; + template.y = 400; + template._width = 500; + template._height = 500; + + mainCollection.addDocument(template); + } + /** * creates a new dataviz document filter from this one * it appears to the right of this document, with the diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx index 34bec3b88..7993cab28 100644 --- a/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx +++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu.tsx @@ -311,7 +311,9 @@ export class DocCreatorMenu extends ObservableReactComponent<{}> { <img className='docCreatorMenu-preview-image' src={info.icon!.url.href.replace(".png", "_o.png")} /> </div> )})} - <div className='docCreatorMenu-preview-window empty'> + <div className='docCreatorMenu-preview-window empty' + onPointerDown={e => this.setUpButtonClick(e, this.basicTemplateTest)} + > <FontAwesomeIcon icon='plus' color='rgb(160, 160, 160)'/> </div> </div> @@ -543,6 +545,15 @@ export class DocCreatorMenu extends ObservableReactComponent<{}> { ); } + basicTemplateTest = () => { + const temps: {width: number; height: number; x: number; y: number; title: string}[] = [ + {width: 200, height: 50, x: -100, y: -200, title: 'title'}, + {width: 300, height: 300, x: -150, y: -100, title: 'image'}, + {width: 200, height: 50, x: -100, y: -200, title: 'description'}, + ] + this._dataViz?.createBasicTemplates(temps); + } + get renderSelectedViewType(){ switch (this._menuContent){ case 'templates': |