aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/DataVizBox.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/nodes/DataVizBox/DataVizBox.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/DataVizBox.tsx16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index 1cb1ad6af..dae535ba6 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -34,6 +34,7 @@ import { PieChart } from './components/PieChart';
import { TableBox } from './components/TableBox';
import { LinkManager } from '../../../util/LinkManager';
import { Collection } from 'mongoose';
+import { DocCreatorMenu } from './DocCreatorMenu';
export enum DataVizView {
TABLE = 'table',
@@ -433,7 +434,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
const options = cm.findByDescription('Options...');
const optionItems = options && 'subitems' in options ? options.subitems : [];
optionItems.push({ description: `Analyze with AI`, event: () => this.askGPT(), icon: 'lightbulb' });
- optionItems.push({ description: `Create documents`, event: () => this.askGPT(), icon: 'table-cells' });
+ optionItems.push({ description: `Create documents`, event: () => DocCreatorMenu.Instance.displayMenu(200, 200), icon: 'table-cells' });
!options && cm.addItem({ description: 'Options...', subitems: optionItems, icon: 'eye' });
};
@@ -450,16 +451,22 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
getPossibleTemplates = (): Doc[] => {
const linkedDocs: Doc[] = LinkManager.Instance.getAllRelatedLinks(this.Document).map(d => DocCast(LinkManager.getOppositeAnchor(d, this.Document)));
- const linkedCollections: Doc[] = linkedDocs.filter(doc => doc.type === 'collection');
+ const linkedCollections: Doc[] = linkedDocs.filter(doc => doc.type === 'config').filter(doc => DocCast(doc.annotationOn).type === 'collection');
+ console.log('cols: ' + linkedCollections)
const isColumnTitle = (title: string): boolean => {
const colTitles: string[] = Object.keys(this.records[0]);
+ console.log('titles: ' + colTitles)
for (let i = 0; i < colTitles.length; ++i){
- if (colTitles[i] === title) return true;
+ if (colTitles[i] === title) {
+ console.log(true);
+ return true;
+ }
}
return false;
}
const isValidTemplate = (collection: Doc) => {
const childDocs = DocListCast(collection[Doc.LayoutFieldKey(collection)]);
+ console.log('childDocs of col: ' + childDocs)
for (let i = 0; i < childDocs.length; ++i){
if (isColumnTitle(String(childDocs[i].title))) return true;
}
@@ -511,6 +518,8 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// displays how to get data into the DataVizBox if its empty
<div className="start-message">To create a DataViz box, either import / drag a CSV file into your canvas or copy a data table and use the command (ctrl + p) to bring the data table to your canvas.</div>
) : (
+ <div>
+ <DocCreatorMenu/>
<div
className="dataViz-box"
onPointerDown={this.marqueeDown}
@@ -587,6 +596,7 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
/>
)}
</div>
+ </div>
);
}
}