aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
index e1f53ec47..e8b80b7b5 100644
--- a/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
+++ b/src/client/views/nodes/DataVizBox/DocCreatorMenu/DocCreatorMenu.tsx
@@ -115,14 +115,15 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
this._userTemplates.push(template);
};
@action removeUserTemplate = (template: Template) => {
- this._userTemplates.splice(this._userTemplates.indexOf(t), 1);
+ this._userTemplates.splice(this._userTemplates.indexOf(template), 1);
}
@action setSuggestedTemplates = (templates: Template[]) => {
this._suggestedTemplates = templates; //prettier-ignore
};
@computed get docsToRender() {
- return this._selectedTemplate ? NumListCast(this._dataViz?.layoutDoc.dataViz_selectedRows) : [];
+ return [1, 2, 3, 4];
+ //this._selectedTemplate ? NumListCast(this._dataViz?.layoutDoc.dataViz_selectedRows) : []; !!! put this back for GPT rendering
}
@computed get rowsCount() {
@@ -357,6 +358,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
@action updateRenderedPreviewCollection = async (template: Template) => {
this._fullyRenderedDocs = await this.createDocsFromTemplate(template) ?? [];
+ console.log(this._fullyRenderedDocs);
this.updateRenderedDocCollection();
}
@@ -716,6 +718,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
});
const processContent = async (content: {[title: string]: string}) => {
+
const templateCopy = template.cloneBase();
fields.filter(title => title).forEach(title => {
@@ -748,19 +751,23 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
return templateCopy.getRenderedDoc();
};
+
+ const rows = [1, 2, 3, 4];
- const promises = rowContents.map(content => processContent(content));
+ //const promises = rowContents.map(content => processContent(content));
+ const promises = rows.map(row => processContent({}));
+
const renderedDocs = await Promise.all(promises);
this._docsRendering = false; // removes loading indicator
+ console.log('docs: ', renderedDocs);
+ console.log('first doc height: ', renderedDocs[0]._height);
+
return renderedDocs;
}
-
-
-
addRenderedCollectionToMainview = () => {
const collection = this._renderedDocCollection;
if (!collection) return;
@@ -822,7 +829,7 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
})}>
<FontAwesomeIcon icon="minimize" />
</button>
- <button className="docCreatorMenu-menu-button section-reveal-options top-right-lower" onPointerDown={e => this.setUpButtonClick(e, () => {this._currEditingTemplate?.resetToBase(); this.setExpandedView(this._currEditingTemplate);})}>
+ <button className="docCreatorMenu-menu-button section-reveal-options top-right-lower" onPointerDown={e => this.setUpButtonClick(e, () => {this._currEditingTemplate?.printFieldInfo();/*this._currEditingTemplate?.resetToBase();*/ this.setExpandedView(this._currEditingTemplate);})}>
<FontAwesomeIcon icon="arrows-rotate" color="white" />
</button>
</div>
@@ -1012,11 +1019,9 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
collection._height = verticalSpan;
collection._width = horizontalSpan;
- const layout = this._layout;
- const columns: number = layout.columns ?? this.columnsCount;
- const xGap: number = layout.xMargin;
- const yGap: number = layout.yMargin;
- // const repeat: number = templateInfo.layout.repeat;
+ const columns: number = this._layout.columns ?? this.columnsCount;
+ const xGap: number = this._layout.xMargin;
+ const yGap: number = this._layout.yMargin;
const startX: number = -Number(collection._width)/2;
const startY: number = -Number(collection._height)/2;
const docHeight: number = Number(docs[0]._height);
@@ -1066,7 +1071,6 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
console.log('called');
if (!this._fullyRenderedDocs) return;
- const { horizontalSpan, verticalSpan } = this.previewInfo;
//const largerSpan: number = horizontalSpan > verticalSpan ? horizontalSpan : verticalSpan;
const collectionFactory = (): (docs: Doc[], options: DocumentOptions) => Doc => {
@@ -1086,19 +1090,22 @@ export class DocCreatorMenu extends ObservableReactComponent<FieldViewProps> {
}
}
- const collection: Doc = collectionFactory()(this._fullyRenderedDocs, {
+ const collection = collectionFactory()(this._fullyRenderedDocs, {
isDefaultTemplateDoc: true,
- _height: verticalSpan,
- _width: horizontalSpan,
title: 'title',
backgroundColor: 'gray',
+ x: 200,
+ y: 200
});
this.applyLayout(collection, this._fullyRenderedDocs);
this._renderedDocCollection = collection;
- console.log('changed');
+ const mainCollection = this._dataViz?.DocumentView?.().containerViewPath?.().lastElement()?.ComponentView as CollectionFreeFormView;
+ mainCollection.addDocument(collection);
+
+ console.log('changed to: ', collection);
}
layoutPreviewContents = (id?: number) => {