From 6693adb16545cc932fe9d244a15c658288adadc7 Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 21 Dec 2023 14:56:03 -0500 Subject: fixes post-merge for dataViz-annotations --- src/client/util/CurrentUserUtils.ts | 4 +-- src/client/views/MainView.tsx | 2 ++ .../collectionFreeForm/CollectionFreeFormView.tsx | 38 ++++++++++++++++++++++ .../views/nodes/DataVizBox/SchemaCSVPopUp.tsx | 5 +-- 4 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts index f7070a862..dd72051fa 100644 --- a/src/client/util/CurrentUserUtils.ts +++ b/src/client/util/CurrentUserUtils.ts @@ -688,8 +688,8 @@ export class CurrentUserUtils { static schemaTools():Button[] { return [ {title: "Preview", toolTip: "Show selection preview", btnType: ButtonType.ToggleButton, icon: "portrait", scripts:{ onClick: '{ return toggleSchemaPreview(_readOnly_); }'} }, - {title: "1 Line",toolTip: "Single Line Rows", btnType: ButtonType.ToggleButton, icon: "eye", scripts:{ onClick: '{ return toggleSingleLineSchema(_readOnly_); }'} }, - ]; + {title: "1 Line", toolTip: "Single Line Rows", btnType: ButtonType.ToggleButton, icon: "eye", scripts:{ onClick: '{ return toggleSingleLineSchema(_readOnly_); }'} }, + {title: "DataViz", toolTip: "Turn Schema Table into Data Visualization Doc", btnType: ButtonType.ClickButton, icon: "chart-bar", scripts:{ onClick: '{ datavizFromSchema()'} }, ]; } static webTools() { diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx index c71c72257..f2a1ca57e 100644 --- a/src/client/views/MainView.tsx +++ b/src/client/views/MainView.tsx @@ -31,6 +31,7 @@ import { SnappingManager } from '../util/SnappingManager'; import { Transform } from '../util/Transform'; import { ReportManager } from '../util/reportManager/ReportManager'; import { ComponentDecorations } from './ComponentDecorations'; +import { SchemaCSVPopUp } from './nodes/DataVizBox/SchemaCSVPopUp'; import { ContextMenu } from './ContextMenu'; import { DashboardView } from './DashboardView'; import { DictationOverlay } from './DictationOverlay'; @@ -1071,6 +1072,7 @@ export class MainView extends ObservableReactComponent<{}> { {/* {this.mapBoxHack} */} + {/* */} diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx index 1f4688729..88cdd51ff 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -52,6 +52,7 @@ import { CollectionFreeFormPannableContents } from './CollectionFreeFormPannable import { CollectionFreeFormRemoteCursors } from './CollectionFreeFormRemoteCursors'; import './CollectionFreeFormView.scss'; import { MarqueeView } from './MarqueeView'; +import { SchemaCSVPopUp } from '../../nodes/DataVizBox/SchemaCSVPopUp'; export type collectionFreeformViewProps = { NativeWidth?: () => number; @@ -1982,3 +1983,40 @@ ScriptingGlobals.add(function bringToFront() { ScriptingGlobals.add(function sendToBack(doc: Doc) { SelectionManager.Views.forEach(view => view.CollectionFreeFormView?.bringToFront(view.Document, true)); }); +ScriptingGlobals.add(function datavizFromSchema(doc: Doc) { + SelectionManager.Views.forEach(view => { + if (!view.layoutDoc.schema_columnKeys){ + view.layoutDoc.schema_columnKeys = new List(['title', 'type', 'author', 'author_date']) + } + const keys = Cast(view.layoutDoc.schema_columnKeys, listSpec('string'))?.filter(key => key!="text"); + if (!keys) return; + + const children = DocListCast(view.Document[Doc.LayoutFieldKey(view.Document)]); + let csvRows = []; + csvRows.push(keys.join(',')); + for (let i=0; i < children.length; i++) { + let eachRow = []; + for (let j=0; j { constructor(props: SchemaCSVPopUpProps) { super(props); + makeObservable(this); SchemaCSVPopUp.Instance = this; } -- cgit v1.2.3-70-g09d2