From e8fcbbf57b2a2f443d9c280ce10558cf9d51c632 Mon Sep 17 00:00:00 2001
From: vellichora <fangrui_tong@brown.edu>
Date: Sun, 9 Feb 2020 17:11:24 -0500
Subject: can upload collection from mobile to desktop

---
 src/client/views/collections/CollectionView.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 88023783b..1d399e26f 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -138,7 +138,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         let index = value.reduce((p, v, i) => (v instanceof Doc && v === doc) ? i : p, -1);
         index = index !== -1 ? index : value.reduce((p, v, i) => (v instanceof Doc && Doc.AreProtosEqual(v, doc)) ? i : p, -1);
 
-        ContextMenu.Instance.clearItems();
+        ContextMenu.Instance && ContextMenu.Instance.clearItems();
         if (index !== -1) {
             value.splice(index, 1);
             return true;
-- 
cgit v1.2.3-70-g09d2


From 6886bf8c0549f09e9d911ab105fcf4b2d2f051de Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Fri, 13 Mar 2020 09:47:36 -0400
Subject: added reification of view menu items.  tweaked sizing of collection
 chrome display

---
 src/client/util/DragManager.ts                     |  2 +-
 src/client/views/collections/CollectionView.tsx    |  2 +-
 .../views/collections/CollectionViewChromes.scss   |  2 -
 .../views/collections/CollectionViewChromes.tsx    | 68 +++++++++++++++-------
 src/client/views/nodes/DocumentView.tsx            |  2 +-
 5 files changed, 49 insertions(+), 27 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index a09d78a06..f4461d2f7 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -216,7 +216,7 @@ export namespace DragManager {
     // drag a button template and drop a new button 
     export function StartButtonDrag(eles: HTMLElement[], script: string, title: string, vars: { [name: string]: Field }, params: string[], initialize: (button: Doc) => void, downX: number, downY: number, options?: DragOptions) {
         const finishDrag = (e: DragCompleteEvent) => {
-            const bd = Docs.Create.ButtonDocument({ _width: 150, _height: 50, title, dontSelect: true, onClick: ScriptField.MakeScript(script) });
+            const bd = Docs.Create.ButtonDocument({ _width: 150, _height: 50, title, isButton: true, onClick: ScriptField.MakeScript(script) });
             params.map(p => Object.keys(vars).indexOf(p) !== -1 && (Doc.GetProto(bd)[p] = new PrefetchProxy(vars[p] as Doc)));
             initialize?.(bd);
             bd.buttonParams = new List<string>(params);
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 2d56f00d5..c74b9ad6d 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -9,7 +9,6 @@ import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be im
 import { DateField } from '../../../new_fields/DateField';
 import { Doc, DocListCast, DataSym } from '../../../new_fields/Doc';
 import { Id } from '../../../new_fields/FieldSymbols';
-import { listSpec } from '../../../new_fields/Schema';
 import { BoolCast, Cast, StrCast, NumCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
@@ -76,6 +75,7 @@ export namespace CollectionViewType {
     ]);
 
     export const valueOf = (value: string) => stringMapping.get(value.toLowerCase());
+    export const stringFor = (value: number) => Array.from(stringMapping.entries()).find(entry => entry[1] === value)[0];
 }
 
 export interface CollectionRenderProps {
diff --git a/src/client/views/collections/CollectionViewChromes.scss b/src/client/views/collections/CollectionViewChromes.scss
index 19a14976c..428897ac4 100644
--- a/src/client/views/collections/CollectionViewChromes.scss
+++ b/src/client/views/collections/CollectionViewChromes.scss
@@ -27,7 +27,6 @@
                 outline-color: black;
                 border: none;
                 padding: 12px 10px 11px 10px;
-                margin-left: 50px;
             }
 
             .collectionViewBaseChrome-viewPicker:active {
@@ -62,7 +61,6 @@
                 // margin-top: 10px;
             }
             .collectionViewBaseChrome-template {
-                margin-left: 10px;
                 display: grid;
                 background: rgb(238, 238, 238);
                 color:grey;
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 689d3674f..5ab61645f 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -8,7 +8,7 @@ import { List } from "../../../new_fields/List";
 import { listSpec } from "../../../new_fields/Schema";
 import { ScriptField } from "../../../new_fields/ScriptField";
 import { BoolCast, Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { Utils, emptyFunction } from "../../../Utils";
+import { Utils, emptyFunction, setupMoveUpEvents } from "../../../Utils";
 import { DragManager } from "../../util/DragManager";
 import { undoBatch } from "../../util/UndoManager";
 import { EditableView } from "../EditableView";
@@ -82,6 +82,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
     }
     private _picker: any;
     private _commandRef = React.createRef<HTMLInputElement>();
+    private _viewRef = React.createRef<HTMLInputElement>();
     private _autosuggestRef = React.createRef<Autosuggest>();
     @observable private _currentKey: string = "";
     @observable private _viewSpecsOpen: boolean = false;
@@ -344,8 +345,21 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
     private _startDragPosition: { x: number, y: number } = { x: 0, y: 0 };
     private _sensitivity: number = 16;
 
+    dragViewDown = (e: React.PointerEvent) => {
+        setupMoveUpEvents(this, e, (e, down, delta) => {
+            const vtype = NumCast(this.props.CollectionView.props.Document._viewType) as CollectionViewType;
+            const c = {
+                params: ["target"], title: CollectionViewType.stringFor(vtype),
+                script: `this.target._viewType = ${NumCast(this.props.CollectionView.props.Document._viewType)}`,
+                immediate: (source: Doc[]) => Doc.setChildLayout(this.target, source?.[0]),
+                initialize: emptyFunction,
+            };
+            DragManager.StartButtonDrag([this._viewRef.current!], c.script, c.title,
+                { target: this.props.CollectionView.props.Document }, c.params, c.initialize, e.clientX, e.clientY);
+            return true;
+        }, emptyFunction, emptyFunction);
+    }
     dragCommandDown = (e: React.PointerEvent) => {
-
         this._startDragPosition = { x: e.clientX, y: e.clientY };
         document.addEventListener("pointermove", this.dragPointerMove);
         document.addEventListener("pointerup", this.dragPointerUp);
@@ -368,13 +382,17 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
     dragPointerUp = (e: PointerEvent) => {
         document.removeEventListener("pointermove", this.dragPointerMove);
         document.removeEventListener("pointerup", this.dragPointerUp);
-
     }
 
     render() {
         const collapsed = this.props.CollectionView.props.Document._chromeStatus !== "enabled";
         return (
-            <div className="collectionViewChrome-cont" style={{ top: collapsed ? -70 : 0, height: collapsed ? 0 : undefined }}>
+            <div className="collectionViewChrome-cont" style={{
+                top: collapsed ? -70 : 0, height: collapsed ? 0 : undefined,
+                transform: collapsed ? "" : `scale(${Math.min(1, this.props.CollectionView.props.ScreenToLocalTransform().Scale)})`,
+                transformOrigin: "top left",
+                width: `${100 / Math.min(1, this.props.CollectionView.props.ScreenToLocalTransform().Scale)}%`
+            }}>
                 <div className="collectionViewChrome" style={{ border: "unset" }}>
                     <div className="collectionViewBaseChrome">
                         <button className="collectionViewBaseChrome-collapse"
@@ -386,23 +404,29 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
                             }}
                             title="Collapse collection chrome" onClick={this.toggleCollapse}>
                             <FontAwesomeIcon icon="caret-up" size="2x" />
-                        </button>
-                        <select
-                            className="collectionViewBaseChrome-viewPicker"
-                            onPointerDown={stopPropagation}
-                            onChange={this.viewChanged}
-                            style={{ display: collapsed ? "none" : undefined }}
-                            value={NumCast(this.props.CollectionView.props.Document._viewType)}>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="1">Freeform</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="2">Schema</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="4">Tree</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="5">Stacking</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="6">Masonry</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="7">MultiCol</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="8">MultiRow</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="9">Pivot/Time</option>
-                            <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="10">Carousel</option>
-                        </select>
+                        </button><div className="collectionViewBaseChrome-template" style={{ marginLeft: 50, display: collapsed ? "none" : undefined }}>
+                            <div className="commandEntry-outerDiv" title="drop document to apply or drag to create button" ref={this._viewRef} onPointerDown={this.dragViewDown}>
+                                <div className="commandEntry-drop">
+                                    <FontAwesomeIcon icon="bullseye" size="2x"></FontAwesomeIcon>
+                                </div>
+                                <select
+                                    className="collectionViewBaseChrome-viewPicker"
+                                    onPointerDown={stopPropagation}
+                                    onChange={this.viewChanged}
+                                    style={{ display: collapsed ? "none" : undefined }}
+                                    value={NumCast(this.props.CollectionView.props.Document._viewType)}>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="1">Freeform</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="2">Schema</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="4">Tree</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="5">Stacking</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="6">Masonry</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="7">MultiCol</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="8">MultiRow</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="9">Pivot/Time</option>
+                                    <option className="collectionViewBaseChrome-viewOption" onPointerDown={stopPropagation} value="10">Carousel</option>
+                                </select>
+                            </div>
+                        </div>
                         <div className="collectionViewBaseChrome-viewSpecs" title="filter documents to show" style={{ display: collapsed ? "none" : "grid" }}>
                             <div className="collectionViewBaseChrome-filterIcon" onPointerDown={this.openViewSpecs} >
                                 <FontAwesomeIcon icon="filter" size="2x" />
@@ -449,7 +473,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
                         <div className="collectionViewBaseChrome-template" ref={this.createDropTarget} style={{ display: collapsed ? "none" : undefined }}>
                             <div className="commandEntry-outerDiv" title="drop document to apply or drag to create button" ref={this._commandRef} onPointerDown={this.dragCommandDown}>
                                 <div className="commandEntry-drop">
-                                    <FontAwesomeIcon icon="bullseye" size="2x"></FontAwesomeIcon>
+                                    <FontAwesomeIcon icon="bullseye" size="2x" />
                                 </div>
                                 <select
                                     className="collectionViewBaseChrome-cmdPicker"
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 3ccbbe2bf..c558a1da7 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -293,7 +293,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 UndoManager.RunInBatch(() => this.onClickHandler!.script.run({
                     this: this.Document.isTemplateForField && this.props.DataDoc ? this.props.DataDoc : this.props.Document, // try this.props.Document.expandedTemplate || this.props.Document
                     containingCollection: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
-                }, console.log) && !BoolCast(this.props.Document.dontSelect) && this.select(false), "on click");
+                }, console.log) && !this.props.Document.dontSelect && !this.props.Document.isButton && this.select(false), "on click");
             } else if (this.Document.type === DocumentType.BUTTON) {
                 UndoManager.RunInBatch(() => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY), "on button click");
             } else if (this.Document.isButton) {
-- 
cgit v1.2.3-70-g09d2


From 61e12f2e08ed0c0e47b82456b75c441b7278cdd6 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 19 Mar 2020 15:53:07 -0400
Subject: fixed buttons on screenshotbox.  added 'place' option to dragDrop to
 drop the original document without moving it.   switched to passing
 childDropAction as a prop

---
 src/client/util/DragManager.ts                     |  2 +-
 .../views/collections/CollectionStackingView.tsx   |  3 +-
 .../views/collections/CollectionTreeView.tsx       |  5 +--
 src/client/views/collections/CollectionView.tsx    | 25 ++++++-------
 .../collectionFreeForm/CollectionFreeFormView.tsx  |  3 +-
 .../views/nodes/ContentFittingDocumentView.tsx     |  3 ++
 src/client/views/nodes/DocumentView.tsx            |  6 ++--
 src/client/views/nodes/FieldView.tsx               |  1 +
 src/client/views/nodes/ScreenshotBox.scss          | 41 +++++++++++++---------
 src/client/views/nodes/ScreenshotBox.tsx           |  7 ++--
 .../authentication/models/current_user_utils.ts    |  2 +-
 11 files changed, 58 insertions(+), 40 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index f4461d2f7..63a11c85a 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -18,7 +18,7 @@ import { AudioBox } from "../views/nodes/AudioBox";
 import { DateField } from "../../new_fields/DateField";
 import { DocumentView } from "../views/nodes/DocumentView";
 
-export type dropActionType = "alias" | "copy" | undefined;
+export type dropActionType = "place" | "alias" | "copy" | undefined;
 export function SetupDrag(
     _reference: React.RefObject<HTMLElement>,
     docFunc: () => Doc | Promise<Doc> | undefined,
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index a936582c3..719778eb1 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -12,7 +12,7 @@ import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
 import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from "../../../new_fields/Types";
 import { TraceMobx } from "../../../new_fields/util";
 import { Utils, setupMoveUpEvents, emptyFunction } from "../../../Utils";
-import { DragManager } from "../../util/DragManager";
+import { DragManager, dropActionType } from "../../util/DragManager";
 import { Transform } from "../../util/Transform";
 import { undoBatch } from "../../util/UndoManager";
 import { ContextMenu } from "../ContextMenu";
@@ -176,6 +176,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
             LibraryPath={this.props.LibraryPath}
             renderDepth={this.props.renderDepth + 1}
             fitToBox={this.props.fitToBox}
+            dropAction={StrCast(this.props.Document.childDropAction) as dropActionType}
             onClick={layoutDoc.isTemplateDoc ? this.onClickHandler : this.onChildClickHandler}
             PanelWidth={width}
             PanelHeight={height}
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 4757e5a53..f8f8a0943 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -130,7 +130,7 @@ class TreeView extends React.Component<TreeViewProps> {
     }
 
     @undoBatch delete = () => this.props.deleteDoc(this.props.document);
-    @undoBatch openRight = () => this.props.addDocTab(this.props.containingCollection.childDropAction === "alias" ? Doc.MakeAlias(this.props.document) : this.props.document, "onRight", this.props.libraryPath);
+    @undoBatch openRight = () => this.props.addDocTab(this.props.dropAction === "alias" ? Doc.MakeAlias(this.props.document) : this.props.document, "onRight", this.props.libraryPath);
     @undoBatch indent = () => this.props.addDocument(this.props.document) && this.delete();
     @undoBatch move = (doc: Doc, target: Doc | undefined, addDoc: (doc: Doc) => boolean) => {
         return this.props.document !== target && this.props.deleteDoc(doc) && addDoc(doc);
@@ -455,6 +455,7 @@ class TreeView extends React.Component<TreeViewProps> {
                         addDocTab={this.props.addDocTab}
                         pinToPres={emptyFunction}
                         onClick={editTitle}
+                        dropAction={this.props.dropAction}
                         moveDocument={this.props.moveDocument}
                         removeDocument={undefined}
                         ScreenToLocalTransform={this.getTransform}
@@ -761,7 +762,7 @@ export class CollectionTreeView extends CollectionSubView(Document) {
     }
 
     render() {
-        const dropAction = StrCast(this.props.Document.dropAction) as dropActionType;
+        const dropAction = StrCast(this.props.Document.childDropAction) as dropActionType;
         const addDoc = (doc: Doc, relativeTo?: Doc, before?: boolean) => this.addDoc(doc, relativeTo, before);
         const moveDoc = (d: Doc, target: Doc | undefined, addDoc: (doc: Doc) => boolean) => this.props.moveDocument(d, target, addDoc);
         const childDocs = this.props.overrideDocuments ? this.props.overrideDocuments : this.childDocs;
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index c74b9ad6d..edac59efe 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -1,18 +1,17 @@
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faEye } from '@fortawesome/free-regular-svg-icons';
 import { faColumns, faCopy, faEllipsisV, faFingerprint, faImage, faProjectDiagram, faSignature, faSquare, faTh, faThList, faTree } from '@fortawesome/free-solid-svg-icons';
-import { action, IReactionDisposer, observable, reaction, runInAction, computed } from 'mobx';
+import { action, observable } from 'mobx';
 import { observer } from "mobx-react";
 import * as React from 'react';
 import Lightbox from 'react-image-lightbox-with-rotate';
 import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be imported once in your app
 import { DateField } from '../../../new_fields/DateField';
-import { Doc, DocListCast, DataSym } from '../../../new_fields/Doc';
-import { Id } from '../../../new_fields/FieldSymbols';
-import { BoolCast, Cast, StrCast, NumCast } from '../../../new_fields/Types';
+import { DataSym, Doc, DocListCast } from '../../../new_fields/Doc';
+import { List } from '../../../new_fields/List';
+import { BoolCast, Cast, NumCast, StrCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
-import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
 import { Utils } from '../../../Utils';
 import { DocumentType } from '../../documents/DocumentTypes';
 import { DocumentManager } from '../../util/DocumentManager';
@@ -22,22 +21,23 @@ import { ContextMenu } from "../ContextMenu";
 import { FieldView, FieldViewProps } from '../nodes/FieldView';
 import { ScriptBox } from '../ScriptBox';
 import { Touchable } from '../Touchable';
+import { CollectionCarouselView } from './CollectionCarouselView';
 import { CollectionDockingView } from "./CollectionDockingView";
 import { AddCustomFreeFormLayout } from './collectionFreeForm/CollectionFreeFormLayoutEngines';
 import { CollectionFreeFormView } from './collectionFreeForm/CollectionFreeFormView';
-import { CollectionCarouselView } from './CollectionCarouselView';
 import { CollectionLinearView } from './CollectionLinearView';
 import { CollectionMulticolumnView } from './collectionMulticolumn/CollectionMulticolumnView';
+import { CollectionMultirowView } from './collectionMulticolumn/CollectionMultirowView';
 import { CollectionSchemaView } from "./CollectionSchemaView";
 import { CollectionStackingView } from './CollectionStackingView';
 import { CollectionStaffView } from './CollectionStaffView';
+import { SubCollectionViewProps } from './CollectionSubView';
+import { CollectionTimeView } from './CollectionTimeView';
 import { CollectionTreeView } from "./CollectionTreeView";
 import './CollectionView.scss';
 import { CollectionViewBaseChrome } from './CollectionViewChromes';
-import { CollectionTimeView } from './CollectionTimeView';
-import { CollectionMultirowView } from './collectionMulticolumn/CollectionMultirowView';
-import { List } from '../../../new_fields/List';
-import { SubCollectionViewProps } from './CollectionSubView';
+import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
+import { Id } from '../../../new_fields/FieldSymbols';
 export const COLLECTION_BORDER_WIDTH = 2;
 const path = require('path');
 library.add(faTh, faTree, faSquare, faProjectDiagram, faSignature, faThList, faFingerprint, faColumns, faEllipsisV, faImage, faEye as any, faCopy);
@@ -75,7 +75,7 @@ export namespace CollectionViewType {
     ]);
 
     export const valueOf = (value: string) => stringMapping.get(value.toLowerCase());
-    export const stringFor = (value: number) => Array.from(stringMapping.entries()).find(entry => entry[1] === value)[0];
+    export const stringFor = (value: number) => Array.from(stringMapping.entries()).find(entry => entry[1] === value)?.[0];
 }
 
 export interface CollectionRenderProps {
@@ -116,7 +116,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
     @action.bound
     addDocument(doc: Doc): boolean {
         const targetDataDoc = this.props.Document[DataSym];
-        targetDataDoc[this.props.fieldKey] = new List<Doc>([...DocListCast(targetDataDoc[this.props.fieldKey]), doc]);  // DocAddToList may write to targetdataDoc's parent ... we don't want this. should really change GetProto to GetDataDoc and test for resolvedDataDoc there
+        const docList = DocListCast(targetDataDoc[this.props.fieldKey]);
+        !docList.includes(doc) && (targetDataDoc[this.props.fieldKey] = new List<Doc>([...docList, doc]));  // DocAddToList may write to targetdataDoc's parent ... we don't want this. should really change GetProto to GetDataDoc and test for resolvedDataDoc there
         // Doc.AddDocToList(targetDataDoc, this.props.fieldKey, doc);
         targetDataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
         Doc.GetProto(doc).lastOpened = new DateField;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index fd679b7b2..da44d0d59 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -20,7 +20,7 @@ import { CognitiveServices } from "../../../cognitive_services/CognitiveServices
 import { DocServer } from "../../../DocServer";
 import { Docs } from "../../../documents/Documents";
 import { DocumentManager } from "../../../util/DocumentManager";
-import { DragManager } from "../../../util/DragManager";
+import { DragManager, dropActionType } from "../../../util/DragManager";
 import { HistoryUtil } from "../../../util/History";
 import { InteractionUtils } from "../../../util/InteractionUtils";
 import { SelectionManager } from "../../../util/SelectionManager";
@@ -832,6 +832,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
             Document: childLayout,
             LibraryPath: this.libraryPath,
             layoutKey: undefined,
+            dropAction: StrCast(this.props.Document.childDropAction) as dropActionType,
             //onClick: undefined, // this.props.onClick,  // bcz: check this out -- I don't think we want to inherit click handlers, or we at least need a way to ignore them
             onClick: this.onChildClickHandler,
             ScreenToLocalTransform: childLayout.z ? this.getTransformOverlay : this.getTransform,
diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx
index 36233a7e6..8632f9c9a 100644
--- a/src/client/views/nodes/ContentFittingDocumentView.tsx
+++ b/src/client/views/nodes/ContentFittingDocumentView.tsx
@@ -12,6 +12,7 @@ import { CollectionView } from "../collections/CollectionView";
 import '../DocumentDecorations.scss';
 import { DocumentView } from "../nodes/DocumentView";
 import "./ContentFittingDocumentView.scss";
+import { dropActionType } from "../../util/DragManager";
 
 interface ContentFittingDocumentViewProps {
     Document?: Doc;
@@ -21,6 +22,7 @@ interface ContentFittingDocumentViewProps {
     childDocs?: Doc[];
     renderDepth: number;
     fitToBox?: boolean;
+    dropAction?: dropActionType;
     PanelWidth: () => number;
     PanelHeight: () => number;
     focus?: (doc: Doc) => void;
@@ -86,6 +88,7 @@ export class ContentFittingDocumentView extends React.Component<ContentFittingDo
                         LayoutDoc={this.props.LayoutDoc}
                         LibraryPath={this.props.LibraryPath}
                         fitToBox={this.props.fitToBox}
+                        dropAction={this.props.dropAction}
                         onClick={this.props.onClick}
                         backgroundColor={this.props.backgroundColor}
                         addDocument={this.props.addDocument}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index c558a1da7..7480f0db8 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -14,7 +14,6 @@ import { BoolCast, Cast, NumCast, StrCast } from "../../../new_fields/Types";
 import { AudioField, ImageField, PdfField, VideoField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
 import { GestureUtils } from '../../../pen-gestures/GestureUtils';
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
 import { emptyFunction, returnOne, returnTransparent, returnTrue, Utils, OmitKeys } from "../../../Utils";
 import { GooglePhotos } from '../../apis/google_docs/GooglePhotosClientUtils';
 import { DocServer } from "../../DocServer";
@@ -65,6 +64,7 @@ export interface DocumentViewProps {
     onClick?: ScriptField;
     onPointerDown?: ScriptField;
     onPointerUp?: ScriptField;
+    dropAction?: dropActionType;
     dragDivName?: string;
     addDocument?: (doc: Doc) => boolean;
     removeDocument?: (doc: Doc) => boolean;
@@ -275,7 +275,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     }
 
     onClick = (e: React.MouseEvent | React.PointerEvent) => {
-        if (!e.nativeEvent.cancelBubble && !this.Document.ignoreClick && CurrentUserUtils.MainDocId !== this.props.Document[Id] &&
+        if (!e.nativeEvent.cancelBubble && !this.Document.ignoreClick && //CurrentUserUtils.MainDocId !== this.props.Document[Id] &&
             (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
             e.stopPropagation();
             let preventDefault = true;
@@ -474,7 +474,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 if (!e.altKey && (!this.topMost || this.Document.onDragStart || this.onClickHandler) && (e.buttons === 1 || InteractionUtils.IsType(e, InteractionUtils.TOUCHTYPE))) {
                     document.removeEventListener("pointermove", this.onPointerMove);
                     document.removeEventListener("pointerup", this.onPointerUp);
-                    this.startDragging(this._downX, this._downY, this.props.ContainingCollectionDoc?.childDropAction ? this.props.ContainingCollectionDoc?.childDropAction : this.Document.dropAction ? this.Document.dropAction as any : e.ctrlKey || e.altKey ? "alias" : undefined);
+                    this.startDragging(this._downX, this._downY, this.props.dropAction ? this.props.dropAction : this.Document.dropAction ? this.Document.dropAction as any : e.ctrlKey || e.altKey ? "alias" : undefined);
                 }
             }
             e.stopPropagation(); // doesn't actually stop propagation since all our listeners are listening to events on 'document'  however it does mark the event as cancelBubble=true which we test for in the move event handlers
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index d030d1f4d..6619330a1 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -25,6 +25,7 @@ export interface FieldViewProps {
     DataDoc?: Doc;
     LibraryPath: Doc[];
     onClick?: ScriptField;
+    dropAction: dropAction;
     isSelected: (outsideReaction?: boolean) => boolean;
     select: (isCtrlPressed: boolean) => void;
     renderDepth: number;
diff --git a/src/client/views/nodes/ScreenshotBox.scss b/src/client/views/nodes/ScreenshotBox.scss
index 4aaccb472..6cc184948 100644
--- a/src/client/views/nodes/ScreenshotBox.scss
+++ b/src/client/views/nodes/ScreenshotBox.scss
@@ -25,22 +25,31 @@
     pointer-events: all;
 }
 
-.screenshotBox-snapshot{
-    color : white;
-    top :25px;
-    right : 25px;
+.screenshotBox-uiButtons {
+    background:dimgray;
+    border: orange solid 1px;
     position: absolute;
-    background-color:rgba(50, 50, 50, 0.2);
-    transform-origin: left top;
-    pointer-events:all;
-}
+    right: 25;
+    top: 0;
+    width:50;
+    height: 25;
+    .screenshotBox-snapshot{
+        color : white;
+        top :0px;
+        right : 5px;
+        position: absolute;
+        background-color:rgba(50, 50, 50, 0.2);
+        transform-origin: left top;
+        pointer-events:all;
+    }
 
-.screenshotBox-recorder{
-    color : white;
-    top :25px;
-    right : 50px;
-    position: absolute;
-    background-color:rgba(50, 50, 50, 0.2);
-    transform-origin: left top;
-    pointer-events:all;
+    .screenshotBox-recorder{
+        color : white;
+        top :0px;
+        left: 5px;
+        position: absolute;
+        background-color:rgba(50, 50, 50, 0.2);
+        transform-origin: left top;
+        pointer-events:all;
+    }
 }
diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index cfa6fa8a3..548066f1c 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -145,13 +145,14 @@ export class ScreenshotBox extends DocAnnotatableComponent<FieldViewProps, Scree
     })
 
     private get uIButtons() {
-        return ([
+        return (<div className="screenshotBox-uiButtons">
             <div className="screenshotBox-recorder" key="snap" onPointerDown={this.toggleRecording} >
                 <FontAwesomeIcon icon="file" size="lg" />
             </div>,
             <div className="screenshotBox-snapshot" key="snap" onPointerDown={this.onSnapshot} >
                 <FontAwesomeIcon icon="camera" size="lg" />
-            </div>]);
+            </div>
+        </div>);
     }
 
     onSnapshot = (e: React.PointerEvent) => {
@@ -187,7 +188,7 @@ export class ScreenshotBox extends DocAnnotatableComponent<FieldViewProps, Scree
                     {this.contentFunc}
                 </CollectionFreeFormView>
             </div>
-            {this.uIButtons}
+            {this.active() ? this.uIButtons : (null)}
         </div >);
     }
 }
\ No newline at end of file
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index ea7b91b23..31588bf82 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -222,7 +222,7 @@ export class CurrentUserUtils {
             _width: 50, _height: 25, title: "Library", fontSize: 10, dontSelect: true,
             letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
             sourcePanel: Docs.Create.TreeDocument([doc.workspaces as Doc, doc.documents as Doc, Docs.Prototypes.MainLinkDocument(), doc, doc.recentlyClosed as Doc], {
-                title: "Library", _xMargin: 5, _yMargin: 5, _gridGap: 5, forceActive: true, dropAction: "alias", lockedPosition: true, boxShadow: "0 0", dontRegisterChildren: true
+                title: "Library", _xMargin: 5, _yMargin: 5, _gridGap: 5, forceActive: true, childDropAction: "place", lockedPosition: true, boxShadow: "0 0", dontRegisterChildren: true
             }),
             targetContainer: sidebarContainer,
             onClick: ScriptField.MakeScript("this.targetContainer.proto = this.sourcePanel;")
-- 
cgit v1.2.3-70-g09d2


From db08a938c1fc466e4eedfb1dbe84dedaef103ca3 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 19 Mar 2020 16:42:38 -0400
Subject: tweaked chrome for collections

---
 src/client/views/collections/CollectionView.tsx         | 1 -
 src/client/views/collections/CollectionViewChromes.scss | 7 +++++--
 src/client/views/collections/CollectionViewChromes.tsx  | 6 +++---
 src/client/views/nodes/DocumentView.tsx                 | 2 +-
 4 files changed, 9 insertions(+), 7 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index edac59efe..7683e1550 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -249,7 +249,6 @@ export class CollectionView extends Touchable<FieldViewProps> {
             const moreItems = more && "subitems" in more ? more.subitems : [];
             moreItems.push({ description: "Export Image Hierarchy", icon: "columns", event: () => ImageUtils.ExportHierarchyToFileSystem(this.props.Document) });
             !more && ContextMenu.Instance.addItem({ description: "More...", subitems: moreItems, icon: "hand-point-right" });
-
         }
     }
 
diff --git a/src/client/views/collections/CollectionViewChromes.scss b/src/client/views/collections/CollectionViewChromes.scss
index 428897ac4..c66eb58f1 100644
--- a/src/client/views/collections/CollectionViewChromes.scss
+++ b/src/client/views/collections/CollectionViewChromes.scss
@@ -177,13 +177,16 @@
             .collectionStackingViewChrome-pivotField-label,
             .collectionTreeViewChrome-pivotField-label {
                 vertical-align: center;
-                padding: 10px;
+                padding-left: 10px;
+                padding-top: 10px;
+                padding-bottom: 10px;
             }
 
             .collectionStackingViewChrome-pivotField,
             .collectionTreeViewChrome-pivotField {
                 color: white;
-                width: 100px;
+                width:100%;
+                min-width: 100px;
                 text-align: center;
                 background: rgb(238, 238, 238);
 
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 5ab61645f..ff55128f6 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -398,13 +398,13 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
                         <button className="collectionViewBaseChrome-collapse"
                             style={{
                                 top: collapsed ? 70 : 10,
-                                transform: `rotate(${collapsed ? 180 : 0}deg) scale(${collapsed ? 0.5 : 1}) translate(${collapsed ? "-100%, -100%" : "0, 0"})`,
+                                transform: `rotate(${collapsed ? 180 : 0}deg) scale(0.5) translate(${collapsed ? "-100%, -100%" : "0, 0"})`,
                                 opacity: (collapsed && !this.props.CollectionView.props.isSelected()) ? 0 : 0.9,
                                 left: (collapsed ? 0 : "unset"),
                             }}
                             title="Collapse collection chrome" onClick={this.toggleCollapse}>
                             <FontAwesomeIcon icon="caret-up" size="2x" />
-                        </button><div className="collectionViewBaseChrome-template" style={{ marginLeft: 50, display: collapsed ? "none" : undefined }}>
+                        </button><div className="collectionViewBaseChrome-template" style={{ marginLeft: 25, display: collapsed ? "none" : undefined }}>
                             <div className="commandEntry-outerDiv" title="drop document to apply or drag to create button" ref={this._viewRef} onPointerDown={this.dragViewDown}>
                                 <div className="commandEntry-drop">
                                     <FontAwesomeIcon icon="bullseye" size="2x"></FontAwesomeIcon>
@@ -551,7 +551,7 @@ export class CollectionStackingViewChrome extends React.Component<CollectionView
             <div className="collectionStackingViewChrome-cont">
                 <div className="collectionStackingViewChrome-pivotField-cont">
                     <div className="collectionStackingViewChrome-pivotField-label">
-                        GROUP ITEMS BY:
+                        GROUP BY:
                     </div>
                     <div className="collectionStackingViewChrome-sortIcon" onClick={this.toggleSort} style={{ transform: `rotate(${this.descending ? "180" : "0"}deg)` }}>
                         <FontAwesomeIcon icon="caret-up" size="2x" color="white" />
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 7480f0db8..874d075e6 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -275,7 +275,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     }
 
     onClick = (e: React.MouseEvent | React.PointerEvent) => {
-        if (!e.nativeEvent.cancelBubble && !this.Document.ignoreClick && //CurrentUserUtils.MainDocId !== this.props.Document[Id] &&
+        if (!e.nativeEvent.cancelBubble && !this.Document.ignoreClick &&
             (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
             e.stopPropagation();
             let preventDefault = true;
-- 
cgit v1.2.3-70-g09d2


From b3f689c2ce60f92574430dad0448650ccf6b8d7e Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 19 Mar 2020 19:18:55 -0400
Subject: moved facet collection stuff into CollectionView from
 CollectionTreeView

---
 src/client/views/collections/CollectionSubView.tsx |  40 +++-
 .../views/collections/CollectionTimeView.scss      |  51 -----
 .../views/collections/CollectionTimeView.tsx       | 244 +++++----------------
 src/client/views/collections/CollectionView.scss   |  54 +++++
 src/client/views/collections/CollectionView.tsx    | 175 ++++++++++++++-
 .../collectionFreeForm/CollectionFreeFormView.tsx  |  40 +---
 6 files changed, 324 insertions(+), 280 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 97177855f..a5480d567 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -112,12 +112,48 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
         get childDocList() {
             return Cast(this.dataField, listSpec(Doc));
         }
-        get childDocs() {
+        @computed get childDocs() {
+            const docFilters = Cast(this.props.Document._docFilters, listSpec("string"), []);
+            const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"), []);
+            const filterFacets: { [key: string]: { [value: string]: string } } = {};  // maps each filter key to an object with value=>modifier fields
+            for (let i = 0; i < docFilters.length; i += 3) {
+                const [key, value, modifiers] = docFilters.slice(i, i + 3);
+                if (!filterFacets[key]) {
+                    filterFacets[key] = {};
+                }
+                filterFacets[key][value] = modifiers;
+            }
+
             const dfield = this.dataField;
             const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), this.props.Document.expandedTemplate && !this.props.annotationsKey ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
             const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
             const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
-            return viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
+            const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
+
+            const filteredDocs = docFilters.length ? childDocs.filter(d => {
+                for (const facetKey of Object.keys(filterFacets)) {
+                    const facet = filterFacets[facetKey];
+                    const satisfiesFacet = Object.keys(facet).some(value =>
+                        (facet[value] === "x") !== Doc.matchFieldValue(d, facetKey, value));
+                    if (!satisfiesFacet) {
+                        return false;
+                    }
+                }
+                return true;
+            }) : childDocs;
+            const rangeFilteredDocs = filteredDocs.filter(d => {
+                for (let i = 0; i < docRangeFilters.length; i += 3) {
+                    const key = docRangeFilters[i];
+                    const min = Number(docRangeFilters[i + 1]);
+                    const max = Number(docRangeFilters[i + 2]);
+                    const val = Cast(d[key], "number", null);
+                    if (val !== undefined && (val < min || val > max)) {
+                        return false;
+                    }
+                }
+                return true;
+            });
+            return rangeFilteredDocs;
         }
 
         @action
diff --git a/src/client/views/collections/CollectionTimeView.scss b/src/client/views/collections/CollectionTimeView.scss
index 310668ad2..be745000e 100644
--- a/src/client/views/collections/CollectionTimeView.scss
+++ b/src/client/views/collections/CollectionTimeView.scss
@@ -72,62 +72,11 @@
         }
     }
 
-    .collectionTimeView-treeView {
-        display: flex;
-        flex-direction: column;
-        width: 200px;
-        height: 100%;
-
-        .collectionTimeView-addfacet {
-            display: inline-block;
-            width: 200px;
-            height: 30px;
-            background: darkGray;
-            text-align: center;
-
-            .collectionTimeView-button {
-                align-items: center;
-                display: flex;
-                width: 100%;
-                height: 100%;
-
-                .collectionTimeView-span {
-                    margin: auto;
-                }
-            }
-
-            >div,
-            >div>div {
-                width: 100%;
-                height: 100%;
-                text-align: center;
-            }
-        }
-
-        .collectionTimeView-tree {
-            display: inline-block;
-            width: 100%;
-            height: calc(100% - 30px);
-        }
-    }
-
     .collectionTimeView-innards {
         display: inline-block;
         width: calc(100% - 200px);
         height: 100%;
     }
-
-    .collectionTimeView-dragger {
-        background-color: lightgray;
-        height: 40px;
-        width: 20px;
-        position: absolute;
-        border-radius: 10px;
-        top: 55%;
-        border: 1px black solid;
-        z-index: 2;
-        left: -10px;
-    }
 }
 
 .collectionTimeView-pivot {
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 6d3b9b7f1..69922d6d9 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -1,16 +1,12 @@
-import { faEdit } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { action, computed, observable, runInAction, trace } from "mobx";
+import { action, computed, observable, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { Doc, DocListCast, Field, WidthSym, HeightSym } from "../../../new_fields/Doc";
+import { Doc } from "../../../new_fields/Doc";
 import { List } from "../../../new_fields/List";
 import { ObjectField } from "../../../new_fields/ObjectField";
 import { RichTextField } from "../../../new_fields/RichTextField";
-import { listSpec } from "../../../new_fields/Schema";
 import { ComputedField, ScriptField } from "../../../new_fields/ScriptField";
-import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { Docs } from "../../documents/Documents";
-import { DocumentType } from "../../documents/DocumentTypes";
+import { NumCast, StrCast } from "../../../new_fields/Types";
+import { emptyFunction, returnFalse, setupMoveUpEvents } from "../../../Utils";
 import { Scripting } from "../../util/Scripting";
 import { ContextMenu } from "../ContextMenu";
 import { ContextMenuProps } from "../ContextMenuItem";
@@ -19,145 +15,33 @@ import { ViewDefBounds } from "./collectionFreeForm/CollectionFreeFormLayoutEngi
 import { CollectionFreeFormView } from "./collectionFreeForm/CollectionFreeFormView";
 import { CollectionSubView } from "./CollectionSubView";
 import "./CollectionTimeView.scss";
-import { CollectionTreeView } from "./CollectionTreeView";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
 import React = require("react");
-import { setupMoveUpEvents, returnFalse, emptyFunction } from "../../../Utils";
 
 @observer
 export class CollectionTimeView extends CollectionSubView(doc => doc) {
     _changing = false;
     @observable _layoutEngine = "pivot";
-    @observable _facetWidth = 0;
     @observable _collapsed: boolean = false;
     componentWillUnmount() {
         this.props.Document.onChildClick = undefined;
     }
     componentDidMount() {
         this.props.Document._freezeOnDrop = true;
-        if (!this.props.Document._facetCollection) {
-            const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
-            const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", _yMargin: 0, treeViewHideTitle: true, treeViewHideHeaderFields: true });
-            facetCollection.target = this.props.Document;
-            facetCollection.onCheckedClick = ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
-            this.props.Document.excludeFields = new List<string>(["_facetCollection", "_docFilters"]);
-
-            this.props.Document._facetCollection = facetCollection;
-            this.props.Document._fitToBox = true;
-        }
         const childDetailed = this.props.Document.childDetailed; // bcz: needs to be here to make sure the childDetailed layout template has been loaded when the first item is clicked;
         const childText = "const alias = getAlias(this); Doc.ApplyTemplateTo(containingCollection.childDetailed, alias, 'layout_detailView'); alias.dropAction='alias'; alias.removeDropProperties=new List<string>(['dropAction']);  useRightSplit(alias, shiftKey); ";
         this.props.Document.onChildClick = ScriptField.MakeScript(childText, { this: Doc.name, heading: "string", containingCollection: Doc.name, shiftKey: "boolean" });
-
+        this.props.Document._fitToBox = true;
         if (!this.props.Document.onViewDefClick) {
             this.props.Document.onViewDefDivClick = ScriptField.MakeScript("pivotColumnClick(this,payload)", { payload: "any" });
         }
     }
 
-    bodyPanelWidth = () => this.props.PanelWidth() - this._facetWidth;
-    getTransform = () => this.props.ScreenToLocalTransform().translate(-this._facetWidth, 0);
     layoutEngine = () => this._layoutEngine;
-    facetWidth = () => this._facetWidth;
     toggleVisibility = action(() => this._collapsed = !this._collapsed);
 
-    @computed get _allFacets() {
-        const facets = new Set<string>();
-        this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key)));
-        Doc.AreProtosEqual(this.dataDoc, this.props.Document) && this.childDocs.forEach(child => Object.keys(child).forEach(key => facets.add(key)));
-        return Array.from(facets);
-    }
-
-    /**
-     * Responds to clicking the check box in the flyout menu
-     */
-    facetClick = (facetHeader: string) => {
-        const facetCollection = this.props.Document._facetCollection;
-        if (facetCollection instanceof Doc) {
-            const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facetHeader);
-            if (found !== -1) {
-                (facetCollection.data as List<Doc>).splice(found, 1);
-                const docFilter = Cast(this.props.Document._docFilters, listSpec("string"));
-                if (docFilter) {
-                    let index: number;
-                    while ((index = docFilter.findIndex(item => item === facetHeader)) !== -1) {
-                        docFilter.splice(index, 3);
-                    }
-                }
-                const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"));
-                if (docRangeFilters) {
-                    let index: number;
-                    while ((index = docRangeFilters.findIndex(item => item === facetHeader)) !== -1) {
-                        docRangeFilters.splice(index, 3);
-                    }
-                }
-            } else {
-                const allCollectionDocs = DocListCast(this.dataDoc[this.props.fieldKey]);
-                const facetValues = Array.from(allCollectionDocs.reduce((set, child) =>
-                    set.add(Field.toString(child[facetHeader] as Field)), new Set<string>()));
-
-                let nonNumbers = 0;
-                let minVal = Number.MAX_VALUE, maxVal = -Number.MAX_VALUE;
-                facetValues.map(val => {
-                    const num = Number(val);
-                    if (Number.isNaN(num)) {
-                        nonNumbers++;
-                    } else {
-                        minVal = Math.min(num, minVal);
-                        maxVal = Math.max(num, maxVal);
-                    }
-                });
-                if (nonNumbers / allCollectionDocs.length < .1) {
-                    const ranged = Doc.readDocRangeFilter(this.props.Document, facetHeader);
-                    const newFacet = Docs.Create.SliderDocument({ title: facetHeader });
-                    Doc.GetProto(newFacet).type = DocumentType.COL; // forces item to show an open/close button instead ofa checkbox
-                    newFacet.treeViewExpandedView = "layout";
-                    newFacet.treeViewOpen = true;
-                    newFacet._sliderMin = ranged === undefined ? minVal : ranged[0];
-                    newFacet._sliderMax = ranged === undefined ? maxVal : ranged[1];
-                    newFacet._sliderMinThumb = minVal;
-                    newFacet._sliderMaxThumb = maxVal;
-                    newFacet.target = this.props.Document;
-                    const scriptText = `setDocFilterRange(this.target, "${facetHeader}", range)`;
-                    newFacet.onThumbChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, range: "number" });
-
-                    Doc.AddDocToList(facetCollection, "data", newFacet);
-                } else {
-                    const newFacet = Docs.Create.TreeDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
-                    const capturedVariables = { layoutDoc: this.props.Document, dataDoc: this.dataDoc };
-                    const params = { layoutDoc: Doc.name, dataDoc: Doc.name, };
-                    newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, dataDoc, "${this.props.fieldKey}", "${facetHeader}")`, params, capturedVariables);
-                    Doc.AddDocToList(facetCollection, "data", newFacet);
-                }
-            }
-        }
-    }
-
-    menuCallback = (x: number, y: number) => {
-        ContextMenu.Instance.clearItems();
-        const docItems: ContextMenuProps[] = [];
-        const keySet: Set<string> = new Set();
-
-        this.childLayoutPairs.map(pair => this._allFacets.filter(fieldKey =>
-            pair.layout[fieldKey] instanceof RichTextField ||
-            typeof (pair.layout[fieldKey]) === "number" ||
-            typeof (pair.layout[fieldKey]) === "string").map(fieldKey => keySet.add(fieldKey)));
-        Array.from(keySet).map(fieldKey =>
-            docItems.push({ description: ":" + fieldKey, event: () => this.props.Document._pivotField = fieldKey, icon: "compress-arrows-alt" }));
-        docItems.push({ description: ":(null)", event: () => this.props.Document._pivotField = undefined, icon: "compress-arrows-alt" });
-        ContextMenu.Instance.addItem({ description: "Pivot Fields ...", subitems: docItems, icon: "eye" });
-        const pt = this.props.ScreenToLocalTransform().inverse().transformPoint(x, y);
-        ContextMenu.Instance.displayMenu(x, y, ":");
-    }
-
-    onPointerDown = (e: React.PointerEvent) => {
-        setupMoveUpEvents(this, e, action((e: PointerEvent, down: number[], delta: number[]) => {
-            this._facetWidth = Math.max(this.props.ScreenToLocalTransform().transformPoint(e.clientX,0)[0], 0);
-            return false;
-        }), returnFalse, () => this._facetWidth = this._facetWidth < 15 ? 200 : 0);
-    }
-
     onMinDown = (e: React.PointerEvent) => {
         setupMoveUpEvents(this, e, action((e: PointerEvent, down: number[], delta: number[]) => {
             const minReq = NumCast(this.props.Document[this.props.fieldKey + "-timelineMinReq"], NumCast(this.props.Document[this.props.fieldKey + "-timelineMin"], 0));
@@ -188,34 +72,8 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
     }
 
     @computed get contents() {
-        return <div className="collectionTimeView-innards" key="timeline" style={{ width: this.bodyPanelWidth() }}>
-            <CollectionFreeFormView  {...this.props} layoutEngine={this.layoutEngine} ScreenToLocalTransform={this.getTransform} PanelWidth={this.bodyPanelWidth} />
-        </div>;
-    }
-    @computed get filterView() {
-        trace();
-        const facetCollection = Cast(this.props.Document?._facetCollection, Doc, null);
-        const flyout = (
-            <div className="collectionTimeView-flyout" style={{ width: `${this._facetWidth}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
-                {this._allFacets.map(facet => <label className="collectionTimeView-flyout-item" key={`${facet}`} onClick={e => this.facetClick(facet)}>
-                    <input type="checkbox" onChange={e => { }} checked={DocListCast((this.props.Document._facetCollection as Doc)?.data).some(d => d.title === facet)} />
-                    <span className="checkmark" />
-                    {facet}
-                </label>)}
-            </div>
-        );
-        return <div className="collectionTimeView-treeView" style={{ width: `${this._facetWidth}px`, overflow: this._facetWidth < 15 ? "hidden" : undefined }}>
-            <div className="collectionTimeView-addFacet" style={{ width: `${this._facetWidth}px` }} onPointerDown={e => e.stopPropagation()}>
-                <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout}>
-                    <div className="collectionTimeView-button">
-                        <span className="collectionTimeView-span">Facet Filters</span>
-                        <FontAwesomeIcon icon={faEdit} size={"lg"} />
-                    </div>
-                </Flyout>
-            </div>
-            <div className="collectionTimeView-tree" key="tree">
-                <CollectionTreeView {...this.props} PanelWidth={this.facetWidth} DataDoc={undefined} Document={facetCollection} />
-            </div>
+        return <div className="collectionTimeView-innards" key="timeline" style={{ width: "100%" }}>
+            <CollectionFreeFormView  {...this.props} layoutEngine={this.layoutEngine} />
         </div>;
     }
 
@@ -234,8 +92,30 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
 
         ContextMenu.Instance.addItem({ description: "Pivot/Time Options ...", subitems: layoutItems, icon: "eye" });
     }
+    @computed get _allFacets() {
+        const facets = new Set<string>();
+        this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key)));
+        Doc.AreProtosEqual(this.dataDoc, this.props.Document) && this.childDocs.forEach(child => Object.keys(child).forEach(key => facets.add(key)));
+        return Array.from(facets);
+    }
+    menuCallback = (x: number, y: number) => {
+        ContextMenu.Instance.clearItems();
+        const docItems: ContextMenuProps[] = [];
+        const keySet: Set<string> = new Set();
 
-    render() {
+        this.childLayoutPairs.map(pair => this._allFacets.filter(fieldKey =>
+            pair.layout[fieldKey] instanceof RichTextField ||
+            typeof (pair.layout[fieldKey]) === "number" ||
+            typeof (pair.layout[fieldKey]) === "string").map(fieldKey => keySet.add(fieldKey)));
+        Array.from(keySet).map(fieldKey =>
+            docItems.push({ description: ":" + fieldKey, event: () => this.props.Document._pivotField = fieldKey, icon: "compress-arrows-alt" }));
+        docItems.push({ description: ":(null)", event: () => this.props.Document._pivotField = undefined, icon: "compress-arrows-alt" });
+        ContextMenu.Instance.addItem({ description: "Pivot Fields ...", subitems: docItems, icon: "eye" });
+        const pt = this.props.ScreenToLocalTransform().inverse().transformPoint(x, y);
+        ContextMenu.Instance.displayMenu(x, y, ":");
+    }
+
+    @computed get pivotKeyUI() {
         const newEditableViewProps = {
             GetValue: () => "",
             SetValue: (value: any) => {
@@ -250,7 +130,26 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
             toggle: this.toggleVisibility,
             color: "#f1efeb" // this.props.headingObject ? this.props.headingObject.color : "#f1efeb";
         };
+        return <div className={"pivotKeyEntry"}>
+            <button className="collectionTimeView-backBtn"
+                onClick={action(() => {
+                    let prevFilterIndex = NumCast(this.props.Document._prevFilterIndex);
+                    if (prevFilterIndex > 0) {
+                        prevFilterIndex--;
+                        this.props.Document._docFilters = ObjectField.MakeCopy(this.props.Document["_prevDocFilter" + prevFilterIndex] as ObjectField);
+                        this.props.Document._docRangeFilters = ObjectField.MakeCopy(this.props.Document["_prevDocRangeFilters" + prevFilterIndex] as ObjectField);
+                        this.props.Document._prevFilterIndex = prevFilterIndex;
+                    } else {
+                        this.props.Document._docFilters = new List([]);
+                    }
+                })}>
+                back
+            </button>
+            <EditableView {...newEditableViewProps} display={"inline"} menuCallback={this.menuCallback} />
+        </div>
+    }
 
+    render() {
         let nonNumbers = 0;
         this.childDocs.map(doc => {
             const num = NumCast(doc[StrCast(this.props.Document._pivotField)], Number(StrCast(doc[StrCast(this.props.Document._pivotField)])));
@@ -270,41 +169,16 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
             }
         }
 
-
-        const facetCollection = Cast(this.props.Document?._facetCollection, Doc, null);
-        return !facetCollection ? (null) :
-            <div className={"collectionTimeView" + (doTimeline ? "" : "-pivot")} onContextMenu={this.specificMenu}
-                style={{ height: `calc(100%  - ${this.props.Document._chromeStatus === "enabled" ? 51 : 0}px)` }}>
-                <div className={"pivotKeyEntry"}>
-                    <button className="collectionTimeView-backBtn"
-                        onClick={action(() => {
-                            let prevFilterIndex = NumCast(this.props.Document._prevFilterIndex);
-                            if (prevFilterIndex > 0) {
-                                prevFilterIndex--;
-                                this.props.Document._docFilters = ObjectField.MakeCopy(this.props.Document["_prevDocFilter" + prevFilterIndex] as ObjectField);
-                                this.props.Document._docRangeFilters = ObjectField.MakeCopy(this.props.Document["_prevDocRangeFilters" + prevFilterIndex] as ObjectField);
-                                this.props.Document._prevFilterIndex = prevFilterIndex;
-                            } else {
-                                this.props.Document._docFilters = new List([]);
-                            }
-                        })}>
-                        back
-                    </button>
-                    <EditableView {...newEditableViewProps} display={"inline"} menuCallback={this.menuCallback} />
-                </div>
-                {!this.props.isSelected() || this.props.PanelHeight() < 100 ? (null) :
-                    <div className="collectionTimeView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this._facetWidth}px, 0px)` }} >
-                        <span title="library View Dragger" style={{ width: "5px", position: "absolute", top: "0" }} />
-                    </div>
-                }
-                {this.filterView}
-                {this.contents}
-                {!this.props.isSelected() || !doTimeline ? (null) : <>
-                    <div className="collectionTimeView-thumb-min collectionTimeView-thumb" key="min" onPointerDown={this.onMinDown} />
-                    <div className="collectionTimeView-thumb-max collectionTimeView-thumb" key="mid" onPointerDown={this.onMaxDown} />
-                    <div className="collectionTimeView-thumb-mid collectionTimeView-thumb" key="max" onPointerDown={this.onMidDown} />
-                </>}
-            </div>;
+        return <div className={"collectionTimeView" + (doTimeline ? "" : "-pivot")} onContextMenu={this.specificMenu}
+            style={{ height: `calc(100%  - ${this.props.Document._chromeStatus === "enabled" ? 51 : 0}px)` }}>
+            {this.pivotKeyUI}
+            {this.contents}
+            {!this.props.isSelected() || !doTimeline ? (null) : <>
+                <div className="collectionTimeView-thumb-min collectionTimeView-thumb" key="min" onPointerDown={this.onMinDown} />
+                <div className="collectionTimeView-thumb-max collectionTimeView-thumb" key="mid" onPointerDown={this.onMaxDown} />
+                <div className="collectionTimeView-thumb-mid collectionTimeView-thumb" key="max" onPointerDown={this.onMidDown} />
+            </>}
+        </div>;
     }
 }
 
diff --git a/src/client/views/collections/CollectionView.scss b/src/client/views/collections/CollectionView.scss
index 1c46081a1..0246abccc 100644
--- a/src/client/views/collections/CollectionView.scss
+++ b/src/client/views/collections/CollectionView.scss
@@ -10,6 +10,60 @@
     width: 100%;
     height: 100%;
     overflow: hidden; // bcz: used to be 'auto' which would create scrollbars when there's a floating doc that's not visible. not sure if that's better, but the scrollbars are annoying...
+
+
+    .collectionTimeView-dragger {
+        background-color: lightgray;
+        height: 40px;
+        width: 20px;
+        position: absolute;
+        border-radius: 10px;
+        top: 55%;
+        border: 1px black solid;
+        z-index: 2;
+        left: -10px;
+    }
+    .collectionTimeView-treeView {
+        display: flex;
+        flex-direction: column;
+        width: 200px;
+        height: 100%;
+        position: absolute;
+        left: 0;
+        top: 0;
+
+        .collectionTimeView-addfacet {
+            display: inline-block;
+            width: 200px;
+            height: 30px;
+            background: darkGray;
+            text-align: left;
+
+            .collectionTimeView-button {
+                align-items: center;
+                display: flex;
+                width: 100%;
+                height: 100%;
+
+                .collectionTimeView-span {
+                    margin: auto;
+                }
+            }
+
+            >div,
+            >div>div {
+                width: 100%;
+                height: 100%;
+                text-align: center;
+            }
+        }
+
+        .collectionTimeView-tree {
+            display: inline-block;
+            width: 100%;
+            height: calc(100% - 30px);
+        }
+    }
 }
 
 #google-tags {
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 7683e1550..a1f173746 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -1,18 +1,19 @@
 import { library } from '@fortawesome/fontawesome-svg-core';
-import { faEye } from '@fortawesome/free-regular-svg-icons';
+import { faEye, faEdit } from '@fortawesome/free-regular-svg-icons';
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { faColumns, faCopy, faEllipsisV, faFingerprint, faImage, faProjectDiagram, faSignature, faSquare, faTh, faThList, faTree } from '@fortawesome/free-solid-svg-icons';
-import { action, observable } from 'mobx';
+import { action, observable, computed } from 'mobx';
 import { observer } from "mobx-react";
 import * as React from 'react';
 import Lightbox from 'react-image-lightbox-with-rotate';
 import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be imported once in your app
 import { DateField } from '../../../new_fields/DateField';
-import { DataSym, Doc, DocListCast } from '../../../new_fields/Doc';
+import { DataSym, Doc, DocListCast, Field } from '../../../new_fields/Doc';
 import { List } from '../../../new_fields/List';
 import { BoolCast, Cast, NumCast, StrCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
-import { Utils } from '../../../Utils';
+import { Utils, setupMoveUpEvents, returnFalse } from '../../../Utils';
 import { DocumentType } from '../../documents/DocumentTypes';
 import { DocumentManager } from '../../util/DocumentManager';
 import { ImageUtils } from '../../util/Import & Export/ImageUtils';
@@ -38,6 +39,12 @@ import './CollectionView.scss';
 import { CollectionViewBaseChrome } from './CollectionViewChromes';
 import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
 import { Id } from '../../../new_fields/FieldSymbols';
+import { listSpec } from '../../../new_fields/Schema';
+import { Docs } from '../../documents/Documents';
+import { ScriptField, ComputedField } from '../../../new_fields/ScriptField';
+const higflyout = require("@hig/flyout");
+export const { anchorPoints } = higflyout;
+export const Flyout = higflyout.default;
 export const COLLECTION_BORDER_WIDTH = 2;
 const path = require('path');
 library.add(faTh, faTree, faSquare, faProjectDiagram, faSignature, faThList, faFingerprint, faColumns, faEllipsisV, faImage, faEye as any, faCopy);
@@ -84,6 +91,7 @@ export interface CollectionRenderProps {
     moveDocument: (document: Doc, targetCollection: Doc | undefined, addDocument: (document: Doc) => boolean) => boolean;
     active: () => boolean;
     whenActiveChanged: (isActive: boolean) => void;
+    PanelWidth: () => number;
 }
 
 @observer
@@ -268,6 +276,158 @@ export class CollectionView extends Touchable<FieldViewProps> {
             onMovePrevRequest={action(() => this._curLightboxImg = (this._curLightboxImg + images.length - 1) % images.length)}
             onMoveNextRequest={action(() => this._curLightboxImg = (this._curLightboxImg + 1) % images.length)} />);
     }
+    @observable _facetWidth = 0;
+
+    bodyPanelWidth = () => this.props.PanelWidth() - this._facetWidth;
+    getTransform = () => this.props.ScreenToLocalTransform().translate(-this._facetWidth, 0);
+    facetWidth = () => this._facetWidth;
+
+    @computed get dataDoc() {
+        return (this.props.DataDoc && this.props.Document.isTemplateForField ? Doc.GetProto(this.props.DataDoc) :
+            this.props.Document.resolvedDataDoc ? this.props.Document : Doc.GetProto(this.props.Document)); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
+    }
+    // The data field for rendering this collection will be on the this.props.Document unless we're rendering a template in which case we try to use props.DataDoc.
+    // When a document has a DataDoc but it's not a template, then it contains its own rendering data, but needs to pass the DataDoc through
+    // to its children which may be templates.
+    // If 'annotationField' is specified, then all children exist on that field of the extension document, otherwise, they exist directly on the data document under 'fieldKey'
+    @computed get dataField() {
+        return this.dataDoc[this.props.fieldKey];
+    }
+
+    get childLayoutPairs(): { layout: Doc; data: Doc; }[] {
+        const { Document, DataDoc } = this.props;
+        const validPairs = this.childDocs.map(doc => Doc.GetLayoutDataDocPair(Document, DataDoc, doc)).filter(pair => pair.layout);
+        return validPairs.map(({ data, layout }) => ({ data, layout: layout! })); // this mapping is a bit of a hack to coerce types
+    }
+    get childDocList() {
+        return Cast(this.dataField, listSpec(Doc));
+    }
+    get childDocs() {
+        const dfield = this.dataField;
+        const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), this.props.Document.expandedTemplate ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
+        const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
+        const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
+        return viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
+    }
+    @computed get _allFacets() {
+        const facets = new Set<string>();
+        this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key)));
+        Doc.AreProtosEqual(this.dataDoc, this.props.Document) && this.childDocs.forEach(child => Object.keys(child).forEach(key => facets.add(key)));
+        return Array.from(facets);
+    }
+
+    /**
+     * Responds to clicking the check box in the flyout menu
+     */
+    facetClick = (facetHeader: string) => {
+        const facetCollection = this.props.Document._facetCollection;
+        if (facetCollection instanceof Doc) {
+            const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facetHeader);
+            if (found !== -1) {
+                (facetCollection.data as List<Doc>).splice(found, 1);
+                const docFilter = Cast(this.props.Document._docFilters, listSpec("string"));
+                if (docFilter) {
+                    let index: number;
+                    while ((index = docFilter.findIndex(item => item === facetHeader)) !== -1) {
+                        docFilter.splice(index, 3);
+                    }
+                }
+                const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"));
+                if (docRangeFilters) {
+                    let index: number;
+                    while ((index = docRangeFilters.findIndex(item => item === facetHeader)) !== -1) {
+                        docRangeFilters.splice(index, 3);
+                    }
+                }
+            } else {
+                const allCollectionDocs = DocListCast(this.dataDoc[this.props.fieldKey]);
+                const facetValues = Array.from(allCollectionDocs.reduce((set, child) =>
+                    set.add(Field.toString(child[facetHeader] as Field)), new Set<string>()));
+
+                let nonNumbers = 0;
+                let minVal = Number.MAX_VALUE, maxVal = -Number.MAX_VALUE;
+                facetValues.map(val => {
+                    const num = Number(val);
+                    if (Number.isNaN(num)) {
+                        nonNumbers++;
+                    } else {
+                        minVal = Math.min(num, minVal);
+                        maxVal = Math.max(num, maxVal);
+                    }
+                });
+                if (nonNumbers / allCollectionDocs.length < .1) {
+                    const ranged = Doc.readDocRangeFilter(this.props.Document, facetHeader);
+                    const newFacet = Docs.Create.SliderDocument({ title: facetHeader });
+                    Doc.GetProto(newFacet).type = DocumentType.COL; // forces item to show an open/close button instead ofa checkbox
+                    newFacet.treeViewExpandedView = "layout";
+                    newFacet.treeViewOpen = true;
+                    newFacet._sliderMin = ranged === undefined ? minVal : ranged[0];
+                    newFacet._sliderMax = ranged === undefined ? maxVal : ranged[1];
+                    newFacet._sliderMinThumb = minVal;
+                    newFacet._sliderMaxThumb = maxVal;
+                    newFacet.target = this.props.Document;
+                    const scriptText = `setDocFilterRange(this.target, "${facetHeader}", range)`;
+                    newFacet.onThumbChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, range: "number" });
+
+                    Doc.AddDocToList(facetCollection, "data", newFacet);
+                } else {
+                    const newFacet = Docs.Create.TreeDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
+                    const capturedVariables = { layoutDoc: this.props.Document, dataDoc: this.dataDoc };
+                    const params = { layoutDoc: Doc.name, dataDoc: Doc.name, };
+                    newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, dataDoc, "${this.props.fieldKey}", "${facetHeader}")`, params, capturedVariables);
+                    Doc.AddDocToList(facetCollection, "data", newFacet);
+                }
+            }
+        }
+    }
+
+
+    onPointerDown = (e: React.PointerEvent) => {
+        setupMoveUpEvents(this, e, action((e: PointerEvent, down: number[], delta: number[]) => {
+            this._facetWidth = Math.max(this.props.ScreenToLocalTransform().transformPoint(e.clientX, 0)[0], 0);
+            return false;
+        }), returnFalse, action(() => this._facetWidth = this._facetWidth < 15 ? 200 : 0));
+    }
+    @computed get filterView() {
+        const facetCollection = Cast(this.props.Document?._facetCollection, Doc);
+        if (this._facetWidth && facetCollection === undefined) setTimeout(() => {
+            const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
+            const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", _yMargin: 0, treeViewHideTitle: true, treeViewHideHeaderFields: true });
+            facetCollection.target = this.props.Document;
+            facetCollection.onCheckedClick = ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
+            this.props.Document.excludeFields = new List<string>(["_facetCollection", "_docFilters"]);
+
+            this.props.Document._facetCollection = facetCollection;
+        }, 0);
+        const flyout = (
+            <div className="collectionTimeView-flyout" style={{ width: `${this._facetWidth}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
+                {this._allFacets.map(facet => <label className="collectionTimeView-flyout-item" key={`${facet}`} onClick={e => this.facetClick(facet)}>
+                    <input type="checkbox" onChange={e => { }} checked={DocListCast((this.props.Document._facetCollection as Doc)?.data).some(d => d.title === facet)} />
+                    <span className="checkmark" />
+                    {facet}
+                </label>)}
+            </div>
+        );
+        return !facetCollection ? (null) :
+            <div className="collectionTimeView-treeView" style={{ width: `${this._facetWidth}px`, overflow: this._facetWidth < 15 ? "hidden" : undefined }}>
+                <div className="collectionTimeView-addFacet" style={{ width: `${this._facetWidth}px` }} onPointerDown={e => e.stopPropagation()}>
+                    <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout}>
+                        <div className="collectionTimeView-button">
+                            <span className="collectionTimeView-span">Facet Filters</span>
+                            <FontAwesomeIcon icon={faEdit} size={"lg"} />
+                        </div>
+                    </Flyout>
+                </div>
+                <div className="collectionTimeView-tree" key="tree">
+                    <CollectionTreeView {...this.props} CollectionView={this} annotationsKey={""} PanelWidth={this.facetWidth}
+                        DataDoc={undefined} Document={facetCollection}
+                        moveDocument={(doc: Doc) => false}
+                        removeDocument={(doc: Doc) => false}
+                        addDocument={(doc: Doc) => false} />
+                </div>
+            </div>;
+    }
+
     render() {
         TraceMobx();
         const props: CollectionRenderProps = {
@@ -276,6 +436,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
             moveDocument: this.moveDocument,
             active: this.active,
             whenActiveChanged: this.whenActiveChanged,
+            PanelWidth: this.bodyPanelWidth
         };
         return (<div className={"collectionView"}
             style={{
@@ -292,6 +453,12 @@ export class CollectionView extends Touchable<FieldViewProps> {
                         Utils.CorsProxy(Cast(d.data, ImageField)!.url.href) : Cast(d.data, ImageField)!.url.href
                     :
                     ""))}
+            {!this.props.isSelected() || this.props.PanelHeight() < 100 ? (null) :
+                <div className="collectionTimeView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this._facetWidth}px, 0px)` }} >
+                    <span title="library View Dragger" style={{ width: "5px", position: "absolute", top: "0" }} />
+                </div>
+            }
+            {this.filterView}
         </div>);
     }
 }
\ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index da44d0d59..a0dd4f2de 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -903,12 +903,12 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
     }.bind(this));
 
     doTimelineLayout(poolData: Map<string, PoolData>) {
-        return computeTimelineLayout(poolData, this.props.Document, this.childDocs, this.filterDocs,
+        return computeTimelineLayout(poolData, this.props.Document, this.childDocs, this.childDocs,
             this.childLayoutPairs, [this.props.PanelWidth(), this.props.PanelHeight()], this.viewDefsToJSX);
     }
 
     doPivotLayout(poolData: Map<string, PoolData>) {
-        return computePivotLayout(poolData, this.props.Document, this.childDocs, this.filterDocs,
+        return computePivotLayout(poolData, this.props.Document, this.childDocs, this.childDocs,
             this.childLayoutPairs, [this.props.PanelWidth(), this.props.PanelHeight()], this.viewDefsToJSX);
     }
 
@@ -934,42 +934,6 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
         return { newPool, computedElementData: this.doFreeformLayout(newPool) };
     }
 
-    @computed get filterDocs() {
-        const docFilters = Cast(this.props.Document._docFilters, listSpec("string"), []);
-        const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"), []);
-        const filterFacets: { [key: string]: { [value: string]: string } } = {};  // maps each filter key to an object with value=>modifier fields
-        for (let i = 0; i < docFilters.length; i += 3) {
-            const [key, value, modifiers] = docFilters.slice(i, i + 3);
-            if (!filterFacets[key]) {
-                filterFacets[key] = {};
-            }
-            filterFacets[key][value] = modifiers;
-        }
-        const filteredDocs = docFilters.length ? this.childDocs.filter(d => {
-            for (const facetKey of Object.keys(filterFacets)) {
-                const facet = filterFacets[facetKey];
-                const satisfiesFacet = Object.keys(facet).some(value =>
-                    (facet[value] === "x") !== Doc.matchFieldValue(d, facetKey, value));
-                if (!satisfiesFacet) {
-                    return false;
-                }
-            }
-            return true;
-        }) : this.childDocs;
-        const rangeFilteredDocs = filteredDocs.filter(d => {
-            for (let i = 0; i < docRangeFilters.length; i += 3) {
-                const key = docRangeFilters[i];
-                const min = Number(docRangeFilters[i + 1]);
-                const max = Number(docRangeFilters[i + 2]);
-                const val = Cast(d[key], "number", null);
-                if (val !== undefined && (val < min || val > max)) {
-                    return false;
-                }
-            }
-            return true;
-        });
-        return rangeFilteredDocs;
-    }
     childLayoutDocFunc = () => this.props.childLayoutTemplate?.() || Cast(this.props.Document.childLayoutTemplate, Doc, null);
     get doLayoutComputation() {
         const { newPool, computedElementData } = this.doInternalLayoutComputation;
-- 
cgit v1.2.3-70-g09d2


From a75ce06979b17457e6ccbdda8fb2217815757036 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 19 Mar 2020 21:31:45 -0400
Subject: cleaned up facet collections to not require an additional document

---
 src/Utils.ts                                       |   2 +-
 src/client/views/collections/CollectionSubView.tsx |   8 +-
 .../views/collections/CollectionTimeView.scss      |   1 +
 .../views/collections/CollectionTreeView.tsx       |  24 ++--
 src/client/views/collections/CollectionView.tsx    | 143 +++++++++++----------
 src/client/views/nodes/FieldView.tsx               |   3 +-
 6 files changed, 99 insertions(+), 82 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/Utils.ts b/src/Utils.ts
index 3786b4f6f..e3ec10dcd 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -498,7 +498,7 @@ export function setupMoveUpEvents(
     };
     const _upEvent = (e: PointerEvent): void => {
         upEvent(e);
-        if (Math.abs(e.clientX - (target as any)._downX) < 4 || Math.abs(e.clientY - (target as any)._downY) < 4) {
+        if (Math.abs(e.clientX - (target as any)._downX) < 4 && Math.abs(e.clientY - (target as any)._downY) < 4) {
             clickEvent(e);
         }
         document.removeEventListener("pointermove", _moveEvent);
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index a5480d567..11f214625 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -48,8 +48,8 @@ export interface SubCollectionViewProps extends CollectionViewProps {
     layoutEngine?: () => string;
 }
 
-export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
-    class CollectionSubView extends DocComponent<SubCollectionViewProps, T>(schemaCtor) {
+export function CollectionSubView<T,X>(schemaCtor: (doc: Doc) => T, moreProps?:X) {
+    class CollectionSubView extends DocComponent<X&SubCollectionViewProps, T>(schemaCtor) {
         private dropDisposer?: DragManager.DragDropDisposer;
         private gestureDisposer?: GestureUtils.GestureEventDisposer;
         protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
@@ -130,7 +130,7 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
             const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
             const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
 
-            const filteredDocs = docFilters.length ? childDocs.filter(d => {
+            const filteredDocs = docFilters.length && !this.props.dontRegisterView ? childDocs.filter(d => {
                 for (const facetKey of Object.keys(filterFacets)) {
                     const facet = filterFacets[facetKey];
                     const satisfiesFacet = Object.keys(facet).some(value =>
@@ -195,7 +195,7 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
         @undoBatch
         @action
         protected onInternalDrop(e: Event, de: DragManager.DropEvent): boolean {
-            const docDragData = de.complete.docDragData;
+        const docDragData = de.complete.docDragData;
             (this.props.Document.dropConverter instanceof ScriptField) &&
                 this.props.Document.dropConverter.script.run({ dragData: docDragData }); /// bcz: check this 
             if (docDragData) {
diff --git a/src/client/views/collections/CollectionTimeView.scss b/src/client/views/collections/CollectionTimeView.scss
index be745000e..fa7c87f4e 100644
--- a/src/client/views/collections/CollectionTimeView.scss
+++ b/src/client/views/collections/CollectionTimeView.scss
@@ -48,6 +48,7 @@
     .collectionTimeView-flyout {
         width: 400px;
         display: block;
+        text-align: left;
 
         .collectionTimeView-flyout-item {
             background-color: lightgray;
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index f8f8a0943..c02c4ac3f 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -6,7 +6,7 @@ import { observer } from "mobx-react";
 import { Doc, DocListCast, Field, HeightSym, WidthSym, DataSym, Opt } from '../../../new_fields/Doc';
 import { Id } from '../../../new_fields/FieldSymbols';
 import { List } from '../../../new_fields/List';
-import { Document, listSpec } from '../../../new_fields/Schema';
+import { Document, listSpec, createSchema, makeInterface } from '../../../new_fields/Schema';
 import { ComputedField, ScriptField } from '../../../new_fields/ScriptField';
 import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from '../../../new_fields/Types';
 import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
@@ -29,7 +29,7 @@ import { ImageBox } from '../nodes/ImageBox';
 import { KeyValueBox } from '../nodes/KeyValueBox';
 import { ScriptBox } from '../ScriptBox';
 import { Templates } from '../Templates';
-import { CollectionSubView } from "./CollectionSubView";
+import { CollectionSubView, SubCollectionViewProps } from "./CollectionSubView";
 import "./CollectionTreeView.scss";
 import React = require("react");
 import { CollectionViewType } from './CollectionView';
@@ -46,7 +46,7 @@ export interface TreeViewProps {
     renderDepth: number;
     deleteDoc: (doc: Doc) => boolean;
     moveDocument: DragManager.MoveFunction;
-    dropAction: "alias" | "copy" | undefined;
+    dropAction: dropActionType;
     addDocTab: (doc: Doc, where: string, libraryPath?: Doc[]) => boolean;
     pinToPres: (document: Doc) => void;
     panelWidth: () => number;
@@ -632,8 +632,16 @@ class TreeView extends React.Component<TreeViewProps> {
     }
 }
 
+export type collectionTreeViewProps = {
+    treeViewHideTitle?: boolean;
+    treeViewHideHeaderFields?: boolean;
+    onCheckedClick?: ScriptField;
+};
+
+let xx: collectionTreeViewProps = {};
+
 @observer
-export class CollectionTreeView extends CollectionSubView(Document) {
+export class CollectionTreeView extends CollectionSubView(Document, xx) {
     private treedropDisposer?: DragManager.DragDropDisposer;
     private _mainEle?: HTMLDivElement;
 
@@ -665,7 +673,7 @@ export class CollectionTreeView extends CollectionSubView(Document) {
         const doAddDoc = () =>
             Doc.AddDocToList(this.props.Document[DataSym], this.props.fieldKey, doc, relativeTo, before, false, false, false);
         if (this.props.Document.resolvedDataDoc instanceof Promise) {
-            this.props.Document.resolvedDataDoc.then(resolved => doAddDoc());
+            this.props.Document.resolvedDataDoc.then((resolved: any) => doAddDoc());
         } else {
             doAddDoc();
         }
@@ -773,7 +781,7 @@ export class CollectionTreeView extends CollectionSubView(Document) {
                 onWheel={(e: React.WheelEvent) => this._mainEle && this._mainEle.scrollHeight > this._mainEle.clientHeight && e.stopPropagation()}
                 onDrop={this.onTreeDrop}
                 ref={this.createTreeDropTarget}>
-                {(this.props.Document.treeViewHideTitle ? (null) : <EditableView
+                {(this.props.treeViewHideTitle || this.props.Document.treeViewHideTitle ? (null) : <EditableView
                     contents={this.dataDoc.title}
                     editing={false}
                     display={"block"}
@@ -792,8 +800,8 @@ export class CollectionTreeView extends CollectionSubView(Document) {
                     {
                         TreeView.GetChildElements(childDocs, this.props.Document, this.props.Document, this.props.DataDoc, this.props.fieldKey, this.props.ContainingCollectionDoc, undefined, addDoc, this.remove,
                             moveDoc, dropAction, this.props.addDocTab, this.props.pinToPres, this.props.backgroundColor, this.props.ScreenToLocalTransform,
-                            this.outerXf, this.props.active, this.props.PanelWidth, this.props.ChromeHeight, this.props.renderDepth, () => BoolCast(this.props.Document.treeViewHideHeaderFields),
-                            BoolCast(this.props.Document.treeViewPreventOpen), [], this.props.LibraryPath, ScriptCast(this.props.Document.onCheckedClick), this.props.ignoreFields)
+                            this.outerXf, this.props.active, this.props.PanelWidth, this.props.ChromeHeight, this.props.renderDepth, () => this.props.treeViewHideHeaderFields || BoolCast(this.props.Document.treeViewHideHeaderFields),
+                            BoolCast(this.props.Document.treeViewPreventOpen), [], this.props.LibraryPath, this.props.onCheckedClick || ScriptCast(this.props.Document.onCheckedClick), this.props.ignoreFields)
                     }
                 </ul>
             </div >
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index a1f173746..ab553b206 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -8,7 +8,7 @@ import * as React from 'react';
 import Lightbox from 'react-image-lightbox-with-rotate';
 import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be imported once in your app
 import { DateField } from '../../../new_fields/DateField';
-import { DataSym, Doc, DocListCast, Field } from '../../../new_fields/Doc';
+import { DataSym, Doc, DocListCast, Field, Opt } from '../../../new_fields/Doc';
 import { List } from '../../../new_fields/List';
 import { BoolCast, Cast, NumCast, StrCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
@@ -320,64 +320,63 @@ export class CollectionView extends Touchable<FieldViewProps> {
      * Responds to clicking the check box in the flyout menu
      */
     facetClick = (facetHeader: string) => {
-        const facetCollection = this.props.Document._facetCollection;
-        if (facetCollection instanceof Doc) {
-            const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facetHeader);
-            if (found !== -1) {
-                (facetCollection.data as List<Doc>).splice(found, 1);
-                const docFilter = Cast(this.props.Document._docFilters, listSpec("string"));
-                if (docFilter) {
-                    let index: number;
-                    while ((index = docFilter.findIndex(item => item === facetHeader)) !== -1) {
-                        docFilter.splice(index, 3);
-                    }
+        const facetCollection = this.props.Document;
+        const found = DocListCast(facetCollection[this.props.fieldKey + "-filter"]).findIndex(doc => doc.title === facetHeader);
+        if (found !== -1) {
+            (facetCollection[this.props.fieldKey + "-filter"] as List<Doc>).splice(found, 1);
+            const docFilter = Cast(this.props.Document._docFilters, listSpec("string"));
+            if (docFilter) {
+                let index: number;
+                while ((index = docFilter.findIndex(item => item === facetHeader)) !== -1) {
+                    docFilter.splice(index, 3);
                 }
-                const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"));
-                if (docRangeFilters) {
-                    let index: number;
-                    while ((index = docRangeFilters.findIndex(item => item === facetHeader)) !== -1) {
-                        docRangeFilters.splice(index, 3);
-                    }
+            }
+            const docRangeFilters = Cast(this.props.Document._docRangeFilters, listSpec("string"));
+            if (docRangeFilters) {
+                let index: number;
+                while ((index = docRangeFilters.findIndex(item => item === facetHeader)) !== -1) {
+                    docRangeFilters.splice(index, 3);
                 }
-            } else {
-                const allCollectionDocs = DocListCast(this.dataDoc[this.props.fieldKey]);
-                const facetValues = Array.from(allCollectionDocs.reduce((set, child) =>
-                    set.add(Field.toString(child[facetHeader] as Field)), new Set<string>()));
-
-                let nonNumbers = 0;
-                let minVal = Number.MAX_VALUE, maxVal = -Number.MAX_VALUE;
-                facetValues.map(val => {
-                    const num = Number(val);
-                    if (Number.isNaN(num)) {
-                        nonNumbers++;
-                    } else {
-                        minVal = Math.min(num, minVal);
-                        maxVal = Math.max(num, maxVal);
-                    }
-                });
-                if (nonNumbers / allCollectionDocs.length < .1) {
-                    const ranged = Doc.readDocRangeFilter(this.props.Document, facetHeader);
-                    const newFacet = Docs.Create.SliderDocument({ title: facetHeader });
-                    Doc.GetProto(newFacet).type = DocumentType.COL; // forces item to show an open/close button instead ofa checkbox
-                    newFacet.treeViewExpandedView = "layout";
-                    newFacet.treeViewOpen = true;
-                    newFacet._sliderMin = ranged === undefined ? minVal : ranged[0];
-                    newFacet._sliderMax = ranged === undefined ? maxVal : ranged[1];
-                    newFacet._sliderMinThumb = minVal;
-                    newFacet._sliderMaxThumb = maxVal;
-                    newFacet.target = this.props.Document;
-                    const scriptText = `setDocFilterRange(this.target, "${facetHeader}", range)`;
-                    newFacet.onThumbChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, range: "number" });
-
-                    Doc.AddDocToList(facetCollection, "data", newFacet);
+            }
+        } else {
+            const allCollectionDocs = DocListCast(this.dataDoc[this.props.fieldKey]);
+            const facetValues = Array.from(allCollectionDocs.reduce((set, child) =>
+                set.add(Field.toString(child[facetHeader] as Field)), new Set<string>()));
+
+            let nonNumbers = 0;
+            let minVal = Number.MAX_VALUE, maxVal = -Number.MAX_VALUE;
+            facetValues.map(val => {
+                const num = Number(val);
+                if (Number.isNaN(num)) {
+                    nonNumbers++;
                 } else {
-                    const newFacet = Docs.Create.TreeDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
-                    const capturedVariables = { layoutDoc: this.props.Document, dataDoc: this.dataDoc };
-                    const params = { layoutDoc: Doc.name, dataDoc: Doc.name, };
-                    newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, dataDoc, "${this.props.fieldKey}", "${facetHeader}")`, params, capturedVariables);
-                    Doc.AddDocToList(facetCollection, "data", newFacet);
+                    minVal = Math.min(num, minVal);
+                    maxVal = Math.max(num, maxVal);
                 }
+            });
+            let newFacet: Opt<Doc>;
+            if (nonNumbers / allCollectionDocs.length < .1) {
+                newFacet = Docs.Create.SliderDocument({ title: facetHeader });
+                const ranged = Doc.readDocRangeFilter(this.props.Document, facetHeader);
+                Doc.GetProto(newFacet).type = DocumentType.COL; // forces item to show an open/close button instead ofa checkbox
+                newFacet.treeViewExpandedView = "layout";
+                newFacet.treeViewOpen = true;
+                newFacet._sliderMin = ranged === undefined ? minVal : ranged[0];
+                newFacet._sliderMax = ranged === undefined ? maxVal : ranged[1];
+                newFacet._sliderMinThumb = minVal;
+                newFacet._sliderMaxThumb = maxVal;
+                newFacet.target = this.props.Document;
+                const scriptText = `setDocFilterRange(this.target, "${facetHeader}", range)`;
+                newFacet.onThumbChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, range: "number" });
+
+                Doc.AddDocToList(facetCollection, this.props.fieldKey + "-filter", newFacet);
+            } else {
+                newFacet = Docs.Create.TreeDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
+                const capturedVariables = { layoutDoc: this.props.Document, dataDoc: this.dataDoc };
+                const params = { layoutDoc: Doc.name, dataDoc: Doc.name, };
+                newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, dataDoc, "${this.props.fieldKey}", "${facetHeader}")`, params, capturedVariables);
             }
+            Doc.AddDocToList(facetCollection, this.props.fieldKey + "-filter", newFacet);
         }
     }
 
@@ -388,27 +387,24 @@ export class CollectionView extends Touchable<FieldViewProps> {
             return false;
         }), returnFalse, action(() => this._facetWidth = this._facetWidth < 15 ? 200 : 0));
     }
+    filterBackground = () => "dimGray";
+    @computed get scriptField() {
+        const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
+        return ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
+    }
     @computed get filterView() {
-        const facetCollection = Cast(this.props.Document?._facetCollection, Doc);
-        if (this._facetWidth && facetCollection === undefined) setTimeout(() => {
-            const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
-            const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", _yMargin: 0, treeViewHideTitle: true, treeViewHideHeaderFields: true });
-            facetCollection.target = this.props.Document;
-            facetCollection.onCheckedClick = ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
-            this.props.Document.excludeFields = new List<string>(["_facetCollection", "_docFilters"]);
-
-            this.props.Document._facetCollection = facetCollection;
-        }, 0);
+        const facetCollection = this.props.Document;
+        this._facetWidth && setTimeout(() => facetCollection.target = this.props.Document, 0);
         const flyout = (
             <div className="collectionTimeView-flyout" style={{ width: `${this._facetWidth}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
                 {this._allFacets.map(facet => <label className="collectionTimeView-flyout-item" key={`${facet}`} onClick={e => this.facetClick(facet)}>
-                    <input type="checkbox" onChange={e => { }} checked={DocListCast((this.props.Document._facetCollection as Doc)?.data).some(d => d.title === facet)} />
+                    <input type="checkbox" onChange={e => { }} checked={DocListCast(this.props.Document[this.props.fieldKey + "-filter"]).some(d => d.title === facet)} />
                     <span className="checkmark" />
                     {facet}
                 </label>)}
             </div>
         );
-        return !facetCollection ? (null) :
+        return !this._facetWidth || this.props.dontRegisterView ? (null) :
             <div className="collectionTimeView-treeView" style={{ width: `${this._facetWidth}px`, overflow: this._facetWidth < 15 ? "hidden" : undefined }}>
                 <div className="collectionTimeView-addFacet" style={{ width: `${this._facetWidth}px` }} onPointerDown={e => e.stopPropagation()}>
                     <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout}>
@@ -419,8 +415,19 @@ export class CollectionView extends Touchable<FieldViewProps> {
                     </Flyout>
                 </div>
                 <div className="collectionTimeView-tree" key="tree">
-                    <CollectionTreeView {...this.props} CollectionView={this} annotationsKey={""} PanelWidth={this.facetWidth}
-                        DataDoc={undefined} Document={facetCollection}
+                    <CollectionTreeView {...this.props}
+                        CollectionView={this}
+                        treeViewHideTitle={true}
+                        treeViewHideHeaderFields={true}
+                        onCheckedClick={this.scriptField!}
+                        ignoreFields={["_facetCollection", "_docFilters"]}
+                        annotationsKey={""}
+                        dontRegisterView={true}
+                        PanelWidth={this.facetWidth}
+                        DataDoc={facetCollection}
+                        Document={facetCollection}
+                        backgroundColor={this.filterBackground}
+                        fieldKey={`${this.props.fieldKey}-filter`}
                         moveDocument={(doc: Doc) => false}
                         removeDocument={(doc: Doc) => false}
                         addDocument={(doc: Doc) => false} />
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 6619330a1..0305f43d5 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -10,6 +10,7 @@ import { Transform } from "../../util/Transform";
 import { CollectionView } from "../collections/CollectionView";
 import { AudioBox } from "./AudioBox";
 import { VideoBox } from "./VideoBox";
+import { dropActionType } from "../../util/DragManager";
 
 //
 // these properties get assigned through the render() method of the DocumentView when it creates this node.
@@ -25,7 +26,7 @@ export interface FieldViewProps {
     DataDoc?: Doc;
     LibraryPath: Doc[];
     onClick?: ScriptField;
-    dropAction: dropAction;
+    dropAction: dropActionType;
     isSelected: (outsideReaction?: boolean) => boolean;
     select: (isCtrlPressed: boolean) => void;
     renderDepth: number;
-- 
cgit v1.2.3-70-g09d2


From 34f5992fa1d489b410f476cdb24cf28faed96632 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 19 Mar 2020 21:38:21 -0400
Subject: from last

---
 src/client/views/collections/CollectionView.tsx | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index ab553b206..2036a0ba9 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -389,12 +389,11 @@ export class CollectionView extends Touchable<FieldViewProps> {
     }
     filterBackground = () => "dimGray";
     @computed get scriptField() {
-        const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
+        const scriptText = "setDocFilter(containingTreeView, heading, this.title, checked)";
         return ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
     }
     @computed get filterView() {
         const facetCollection = this.props.Document;
-        this._facetWidth && setTimeout(() => facetCollection.target = this.props.Document, 0);
         const flyout = (
             <div className="collectionTimeView-flyout" style={{ width: `${this._facetWidth}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
                 {this._allFacets.map(facet => <label className="collectionTimeView-flyout-item" key={`${facet}`} onClick={e => this.facetClick(facet)}>
-- 
cgit v1.2.3-70-g09d2


From d50415122ea6d4b87f1604fa4611553103fa2c18 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Wed, 25 Mar 2020 20:57:22 -0400
Subject: set max size for tab titles.  fixed collection sizing when filter is
 expanded.  fixed pivot view text height when small collection.

---
 .../views/collections/CollectionDockingView.tsx    |  1 +
 src/client/views/collections/CollectionView.tsx    | 22 ++++++++++++----------
 .../views/collections/CollectionViewChromes.tsx    |  5 +++--
 .../CollectionFreeFormLayoutEngines.tsx            |  4 ++--
 4 files changed, 18 insertions(+), 14 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 1fb78f625..2ee39bc0d 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -489,6 +489,7 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
                 };
                 tab.titleElement[0].size = StrCast(doc.title).length + 1;
                 tab.titleElement[0].value = doc.title;
+                tab.titleElement[0].style["max-width"] = "100px";
                 const gearSpan = document.createElement("span");
                 gearSpan.className = "collectionDockingView-gear";
                 gearSpan.style.position = "relative";
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 2036a0ba9..2386f2d5d 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -196,7 +196,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     private SubView = (type: CollectionViewType, renderProps: CollectionRenderProps) => {
         // currently cant think of a reason for collection docking view to have a chrome. mind may change if we ever have nested docking views -syip
         const chrome = this.props.Document._chromeStatus === "disabled" || this.props.Document._chromeStatus === "replaced" || type === CollectionViewType.Docking ? (null) :
-            <CollectionViewBaseChrome CollectionView={this} key="chrome" type={type} collapse={this.collapse} />;
+            <CollectionViewBaseChrome CollectionView={this} key="chrome" PanelWidth={this.bodyPanelWidth} type={type} collapse={this.collapse} />;
         return [chrome, this.SubViewHelper(type, renderProps)];
     }
 
@@ -278,9 +278,9 @@ export class CollectionView extends Touchable<FieldViewProps> {
     }
     @observable _facetWidth = 0;
 
-    bodyPanelWidth = () => this.props.PanelWidth() - this._facetWidth;
-    getTransform = () => this.props.ScreenToLocalTransform().translate(-this._facetWidth, 0);
-    facetWidth = () => this._facetWidth;
+    bodyPanelWidth = () => this.props.PanelWidth() - this.facetWidth();
+    getTransform = () => this.props.ScreenToLocalTransform().translate(-this.facetWidth(), 0);
+    facetWidth = () => Math.min(this.props.PanelWidth() - 25, this._facetWidth);
 
     @computed get dataDoc() {
         return (this.props.DataDoc && this.props.Document.isTemplateForField ? Doc.GetProto(this.props.DataDoc) :
@@ -385,7 +385,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         setupMoveUpEvents(this, e, action((e: PointerEvent, down: number[], delta: number[]) => {
             this._facetWidth = Math.max(this.props.ScreenToLocalTransform().transformPoint(e.clientX, 0)[0], 0);
             return false;
-        }), returnFalse, action(() => this._facetWidth = this._facetWidth < 15 ? 200 : 0));
+        }), returnFalse, action(() => this._facetWidth = this.facetWidth() < 15 ? Math.min(this.props.PanelWidth() - 25, 200) : 0));
     }
     filterBackground = () => "dimGray";
     @computed get scriptField() {
@@ -395,7 +395,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     @computed get filterView() {
         const facetCollection = this.props.Document;
         const flyout = (
-            <div className="collectionTimeView-flyout" style={{ width: `${this._facetWidth}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
+            <div className="collectionTimeView-flyout" style={{ width: `${this.facetWidth()}`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
                 {this._allFacets.map(facet => <label className="collectionTimeView-flyout-item" key={`${facet}`} onClick={e => this.facetClick(facet)}>
                     <input type="checkbox" onChange={e => { }} checked={DocListCast(this.props.Document[this.props.fieldKey + "-filter"]).some(d => d.title === facet)} />
                     <span className="checkmark" />
@@ -404,8 +404,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
             </div>
         );
         return !this._facetWidth || this.props.dontRegisterView ? (null) :
-            <div className="collectionTimeView-treeView" style={{ width: `${this._facetWidth}px`, overflow: this._facetWidth < 15 ? "hidden" : undefined }}>
-                <div className="collectionTimeView-addFacet" style={{ width: `${this._facetWidth}px` }} onPointerDown={e => e.stopPropagation()}>
+            <div className="collectionTimeView-treeView" style={{ width: `${this.facetWidth()}px`, overflow: this.facetWidth() < 15 ? "hidden" : undefined }}>
+                <div className="collectionTimeView-addFacet" style={{ width: `${this.facetWidth()}px` }} onPointerDown={e => e.stopPropagation()}>
                     <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout}>
                         <div className="collectionTimeView-button">
                             <span className="collectionTimeView-span">Facet Filters</span>
@@ -452,7 +452,9 @@ export class CollectionView extends Touchable<FieldViewProps> {
             }}
             onContextMenu={this.onContextMenu}>
             {this.showIsTagged()}
-            {this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
+            <div style={{ width: `calc(100% - ${this.facetWidth()}px)`, marginLeft: `${this.facetWidth()}px` }}>
+                {this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
+            </div>
             {this.lightbox(DocListCast(this.props.Document[this.props.fieldKey]).filter(d => d.type === DocumentType.IMG).map(d =>
                 Cast(d.data, ImageField) ?
                     (Cast(d.data, ImageField)!.url.href.indexOf(window.location.origin) === -1) ?
@@ -460,7 +462,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
                     :
                     ""))}
             {!this.props.isSelected() || this.props.PanelHeight() < 100 ? (null) :
-                <div className="collectionTimeView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this._facetWidth}px, 0px)` }} >
+                <div className="collectionTimeView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this.facetWidth()}px, 0px)` }} >
                     <span title="library View Dragger" style={{ width: "5px", position: "absolute", top: "0" }} />
                 </div>
             }
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index ff55128f6..9391b153e 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -24,6 +24,7 @@ interface CollectionViewChromeProps {
     CollectionView: CollectionView;
     type: CollectionViewType;
     collapse?: (value: boolean) => any;
+    PanelWidth: () => number;
 }
 
 interface Filter {
@@ -391,7 +392,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
                 top: collapsed ? -70 : 0, height: collapsed ? 0 : undefined,
                 transform: collapsed ? "" : `scale(${Math.min(1, this.props.CollectionView.props.ScreenToLocalTransform().Scale)})`,
                 transformOrigin: "top left",
-                width: `${100 / Math.min(1, this.props.CollectionView.props.ScreenToLocalTransform().Scale)}%`
+                width: `${this.props.PanelWidth() / Math.min(1, this.props.CollectionView.props.ScreenToLocalTransform().Scale)}px`
             }}>
                 <div className="collectionViewChrome" style={{ border: "unset" }}>
                     <div className="collectionViewBaseChrome">
@@ -598,7 +599,7 @@ export class CollectionSchemaViewChrome extends React.Component<CollectionViewCh
     togglePreview = () => {
         const dividerWidth = 4;
         const borderWidth = Number(COLLECTION_BORDER_WIDTH);
-        const panelWidth = this.props.CollectionView.props.PanelWidth();
+        const panelWidth = this.props.PanelWidth();
         const previewWidth = NumCast(this.props.CollectionView.props.Document.schemaPreviewWidth);
         const tableWidth = panelWidth - 2 * borderWidth - dividerWidth - previewWidth;
         this.props.CollectionView.props.Document.schemaPreviewWidth = previewWidth === 0 ? Math.min(tableWidth / 3, 200) : 0;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index 637c81fe2..bd4db89ec 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -147,6 +147,7 @@ export function computePivotLayout(
 
     const expander = 1.05;
     const gap = .15;
+    const maxColHeight = pivotAxisWidth * expander * Math.ceil(maxInColumn / numCols);
     let x = 0;
     const sortedPivotKeys = pivotNumbers ? Array.from(pivotColumnGroups.keys()).sort((n1: FieldResult, n2: FieldResult) => toNumber(n1)! - toNumber(n2)!) : Array.from(pivotColumnGroups.keys()).sort();
     sortedPivotKeys.forEach(key => {
@@ -189,7 +190,6 @@ export function computePivotLayout(
         x += pivotAxisWidth * (numCols * expander + gap);
     });
 
-    const maxColHeight = pivotAxisWidth * expander * Math.ceil(maxInColumn / numCols);
     const dividers = sortedPivotKeys.map((key, i) =>
         ({ type: "div", color: "lightGray", x: i * pivotAxisWidth * (numCols * expander + gap) - pivotAxisWidth * (expander - 1) / 2, y: -maxColHeight + pivotAxisWidth, width: pivotAxisWidth * numCols * expander, height: maxColHeight, payload: pivotColumnGroups.get(key)!.filters }));
     groupNames.push(...dividers);
@@ -348,7 +348,7 @@ function normalizeResults(panelDim: number[], fontHeight: number, childPairs: {
         y: gname.y * scale,
         color: gname.color,
         width: gname.width === undefined ? undefined : gname.width * scale,
-        height: gname.height === -1 ? 1 : Math.max(fontHeight, (gname.height || 0) * scale),
+        height: gname.height === -1 ? 1 : gname.type === "text" ? Math.max(fontHeight * scale, (gname.height || 0) * scale) : (gname.height || 0) * scale,
         fontSize: gname.fontSize,
         payload: gname.payload
     })));
-- 
cgit v1.2.3-70-g09d2


From 4ae6b564896dd216c37fa38ffeee70ba0e671221 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 28 Mar 2020 02:40:17 -0400
Subject: simplified linkDocs to not keep a context -- instead, link are made
 between aliases which have a context.  fixed clippings of PDFs to scroll
 correctly and resize in slideViews.  fixed slideViews to render 'text' and
 'data' instead of 'contents' and 'data'

---
 src/client/documents/Documents.ts                      |  6 ++----
 src/client/util/DocumentManager.ts                     |  2 +-
 src/client/views/DocumentButtonBar.tsx                 |  2 --
 src/client/views/collections/CollectionView.tsx        |  4 +++-
 .../collections/collectionFreeForm/MarqueeView.tsx     |  4 ++--
 src/client/views/nodes/DocuLinkBox.tsx                 |  3 ++-
 src/client/views/nodes/DocumentView.tsx                |  7 +++----
 src/client/views/nodes/FormattedTextBox.tsx            |  4 ++--
 src/client/views/nodes/PDFBox.tsx                      |  2 +-
 src/client/views/nodes/PresBox.tsx                     |  2 +-
 src/client/views/pdf/PDFViewer.tsx                     | 18 +++++++++++-------
 src/server/authentication/models/current_user_utils.ts |  2 +-
 12 files changed, 29 insertions(+), 27 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index b5cffaddd..dbea8062e 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -558,15 +558,13 @@ export namespace Docs {
             const linkDocProto = Doc.GetProto(doc);
             linkDocProto.anchor1 = source.doc;
             linkDocProto.anchor2 = target.doc;
-            linkDocProto.anchor1_context = source.ctx;
-            linkDocProto.anchor2_context = target.ctx;
             linkDocProto.anchor1_timecode = source.doc.currentTimecode || source.doc.displayTimecode;
             linkDocProto.anchor2_timecode = target.doc.currentTimecode || source.doc.displayTimecode;
 
             if (linkDocProto.layout_key1 === undefined) {
                 Cast(linkDocProto.proto, Doc, null).layout_key1 = DocuLinkBox.LayoutString("anchor1");
                 Cast(linkDocProto.proto, Doc, null).layout_key2 = DocuLinkBox.LayoutString("anchor2");
-                Cast(linkDocProto.proto, Doc, null).linkBoxExcludedKeys = new List(["treeViewExpandedView", "treeViewHideTitle", "removeDropProperties", "linkBoxExcludedKeys", "treeViewOpen", "proto", "aliasNumber", "isPrototype", "lastOpened", "creationDate", "author"]);
+                Cast(linkDocProto.proto, Doc, null).linkBoxExcludedKeys = new List(["treeViewExpandedView", "treeViewHideTitle", "removeDropProperties", "linkBoxExcludedKeys", "treeViewOpen", "aliasNumber", "isPrototype", "lastOpened", "creationDate", "author"]);
                 Cast(linkDocProto.proto, Doc, null).layoutKey = undefined;
             }
 
@@ -926,7 +924,7 @@ export namespace DocUtils {
         });
     }
 
-    export function MakeLink(source: { doc: Doc, ctx?: Doc }, target: { doc: Doc, ctx?: Doc }, linkRelationship: string = "", id?: string) {
+    export function MakeLink(source: { doc: Doc }, target: { doc: Doc }, linkRelationship: string = "", id?: string) {
         const sv = DocumentManager.Instance.getDocumentView(source.doc);
         if (sv && sv.props.ContainingCollectionDoc === target.doc) return;
         if (target.doc === CurrentUserUtils.UserDocument) return undefined;
diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index c41304b9f..0c410c4ce 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -203,7 +203,7 @@ export class DocumentManager {
         const second = secondDocWithoutView ? [secondDocWithoutView] : secondDocs;
         const linkDoc = first.length ? first[0] : second.length ? second[0] : undefined;
         const linkFollowDocs = first.length ? [await first[0].anchor2 as Doc, await first[0].anchor1 as Doc] : second.length ? [await second[0].anchor1 as Doc, await second[0].anchor2 as Doc] : undefined;
-        const linkFollowDocContexts = first.length ? [await first[0].anchor2_context as Doc, await first[0].anchor1_context as Doc] : second.length ? [await second[0].anchor1_context as Doc, await second[0].anchor2_context as Doc] : [undefined, undefined];
+        const linkFollowDocContexts = first.length ? [await first[0].context as Doc, await first[0].context as Doc] : second.length ? [await second[0].context as Doc, await second[0].context as Doc] : [undefined, undefined];
         const linkFollowTimecodes = first.length ? [NumCast(first[0].anchor2_timecode), NumCast(first[0].anchor1_timecode)] : second.length ? [NumCast(second[0].anchor1_timecode), NumCast(second[0].anchor2_timecode)] : [undefined, undefined];
         if (linkFollowDocs && linkDoc) {
             const maxLocation = StrCast(linkDoc.maximizeLocation, "inTab");
diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx
index 8a33232b4..ef1d20e44 100644
--- a/src/client/views/DocumentButtonBar.tsx
+++ b/src/client/views/DocumentButtonBar.tsx
@@ -120,8 +120,6 @@ export class DocumentButtonBar extends React.Component<{ views: (DocumentView |
                 dragComplete: dropEv => {
                     const linkDoc = dropEv.linkDragData?.linkDocument as Doc; // equivalent to !dropEve.aborted since linkDocument is only assigned on a completed drop
                     if (this.view0 && linkDoc) {
-                        const proto = Doc.GetProto(linkDoc);
-                        proto.anchor1_context = this.view0.props.ContainingCollectionDoc;
                         Doc.GetProto(linkDoc).linkRelationship = "hyperlink";
 
                         const anchor2Title = linkDoc.anchor2 instanceof Doc ? StrCast(linkDoc.anchor2.title) : "-untitled-";
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 2386f2d5d..1542988e7 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -127,6 +127,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         const docList = DocListCast(targetDataDoc[this.props.fieldKey]);
         !docList.includes(doc) && (targetDataDoc[this.props.fieldKey] = new List<Doc>([...docList, doc]));  // DocAddToList may write to targetdataDoc's parent ... we don't want this. should really change GetProto to GetDataDoc and test for resolvedDataDoc there
         // Doc.AddDocToList(targetDataDoc, this.props.fieldKey, doc);
+        doc.context = this.props.Document;
         targetDataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
         Doc.GetProto(doc).lastOpened = new DateField;
         return true;
@@ -141,7 +142,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
         let index = value.reduce((p, v, i) => (v instanceof Doc && v === doc) ? i : p, -1);
         index = index !== -1 ? index : value.reduce((p, v, i) => (v instanceof Doc && Doc.AreProtosEqual(v, doc)) ? i : p, -1);
 
-        ContextMenu.Instance && ContextMenu.Instance.clearItems();
+        doc.context = undefined;
+        ContextMenu.Instance?.clearItems();
         if (index !== -1) {
             value.splice(index, 1);
             targetDataDoc[this.props.fieldKey] = new List<Doc>(value);
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 17bba9568..0f94bffd6 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -111,7 +111,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
             const template = FormattedTextBox.DefaultLayout;
             if (template instanceof Doc) {
                 tbox._width = NumCast(template._width);
-                tbox.layoutKey = "layout_"+StrCast(template.title);
+                tbox.layoutKey = "layout_" + StrCast(template.title);
                 tbox[StrCast(tbox.layoutKey)] = template;
             }
             this.props.addLiveTextDocument(tbox);
@@ -448,7 +448,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
         summary._backgroundColor = "#e2ad32";
         portal.layoutKey = "layout_portal";
         portal.title = "document collection";
-        DocUtils.MakeLink({ doc: summary, ctx: this.props.ContainingCollectionDoc }, { doc: portal }, "summarizing");
+        DocUtils.MakeLink({ doc: summary }, { doc: portal }, "summarizing");
 
         this.props.addLiveTextDocument(summary);
         MarqueeOptionsMenu.Instance.fadeOut(true);
diff --git a/src/client/views/nodes/DocuLinkBox.tsx b/src/client/views/nodes/DocuLinkBox.tsx
index bc663d084..81cf90f92 100644
--- a/src/client/views/nodes/DocuLinkBox.tsx
+++ b/src/client/views/nodes/DocuLinkBox.tsx
@@ -84,9 +84,10 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
         if (!this._doubleTap) {
             this._editing = true;
             this.props.ContainingCollectionDoc && this.props.bringToFront(this.props.ContainingCollectionDoc, false);
+            const {clientX, clientY} = e;
             if (!this.props.Document.onClick && !this._isOpen) {
                 this._timeout = setTimeout(action(() => {
-                    if (Math.abs(e.clientX - this._downX) < 3 && Math.abs(e.clientY - this._downY) < 3 && (e.button !== 2 && !e.ctrlKey && this.props.Document.isButton)) {
+                    if (Math.abs(clientX - this._downX) < 3 && Math.abs(clientY - this._downY) < 3 && (e.button !== 2 && !e.ctrlKey && this.props.Document.isButton)) {
                         DocumentManager.Instance.FollowLink(this.props.Document, this.props.ContainingCollectionDoc as Doc, document => this.props.addDocTab(document, StrCast(this.props.Document.linkOpenLocation, "inTab")), false);
                     }
                     this._editing = false;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 544c0a961..4968dd7fc 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -229,7 +229,6 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             dragData.dropAction = dropAction;
             dragData.moveDocument = this.props.moveDocument;//  this.Document.onDragStart ? undefined : this.props.moveDocument;
             dragData.dragDivName = this.props.dragDivName;
-            this.props.Document.anchor1_context = this.props.ContainingCollectionDoc; // bcz: !! shouldn't need this ... use search find the document's context dynamically
             DragManager.StartDocumentDrag([this._mainCont.current], dragData, x, y, { hideSource: !dropAction && !this.Document.onDragStart });
         }
     }
@@ -582,7 +581,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             e.stopPropagation();
             de.complete.annoDragData.linkedToDoc = true;
 
-            DocUtils.MakeLink({ doc: de.complete.annoDragData.annotationDocument }, { doc: this.props.Document, ctx: this.props.ContainingCollectionDoc }, "link");
+            DocUtils.MakeLink({ doc: de.complete.annoDragData.annotationDocument }, { doc: this.props.Document }, "link");
         }
         if (de.complete.docDragData) {
             if (de.complete.docDragData.applyAsTemplate) {
@@ -613,7 +612,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             // const views = docs.map(d => DocumentManager.Instance.getDocumentView(d)).filter(d => d).map(d => d as DocumentView);
             de.complete.linkDragData.linkSourceDocument !== this.props.Document &&
                 (de.complete.linkDragData.linkDocument = DocUtils.MakeLink({ doc: de.complete.linkDragData.linkSourceDocument },
-                    { doc: this.props.Document, ctx: this.props.ContainingCollectionDoc }, `link`)); // TODODO this is where in text links get passed
+                    { doc: this.props.Document }, `link`)); // TODODO this is where in text links get passed
         }
     }
 
@@ -639,7 +638,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         const portalLink = DocListCast(this.Document.links).find(d => d.anchor1 === this.props.Document);
         if (!portalLink) {
             const portal = Docs.Create.FreeformDocument([], { _width: (this.layoutDoc._width || 0) + 10, _height: this.layoutDoc._height || 0, title: StrCast(this.props.Document.title) + ".portal" });
-            DocUtils.MakeLink({ doc: this.props.Document, ctx: this.props.ContainingCollectionDoc }, { doc: portal }, "portal to");
+            DocUtils.MakeLink({ doc: this.props.Document }, { doc: portal }, "portal to");
         }
         this.Document.isButton = true;
     }
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index e7c9e5e6b..f83beade3 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -155,7 +155,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
                     this.dataDoc[key] = doc || Docs.Create.FreeformDocument([], { title: value, _width: 500, _height: 500 }, value);
                     DocUtils.Publish(this.dataDoc[key] as Doc, value, this.props.addDocument, this.props.removeDocument);
                     if (linkDoc) { (linkDoc as Doc).anchor2 = this.dataDoc[key] as Doc; }
-                    else DocUtils.MakeLink({ doc: this.dataDoc, ctx: this.props.ContainingCollectionDoc }, { doc: this.dataDoc[key] as Doc }, "link to named target", id);
+                    else DocUtils.MakeLink({ doc: this.props.Document }, { doc: this.dataDoc[key] as Doc }, "link to named target", id);
                 });
             });
         });
@@ -748,7 +748,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
                             targetAnnotations?.push(pdfRegion);
                         });
 
-                        const link = DocUtils.MakeLink({ doc: this.props.Document, ctx: this.props.ContainingCollectionDoc }, { doc: pdfRegion, ctx: pdfDoc }, "PDF pasted");
+                        const link = DocUtils.MakeLink({ doc: this.props.Document }, { doc: pdfRegion }, "PDF pasted");
                         if (link) {
                             cbe.clipboardData!.setData("dash/linkDoc", link[Id]);
                             const linkId = link[Id];
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 4076128b2..f8c008a2d 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -231,7 +231,7 @@ export class PDFBox extends DocAnnotatableComponent<FieldViewProps, PdfDocument>
     isChildActive = (outsideReaction?: boolean) => this._isChildActive;
     @computed get renderPdfView() {
         const pdfUrl = Cast(this.dataDoc[this.props.fieldKey], PdfField);
-        return <div className={"pdfBox"} onContextMenu={this.specificContextMenu} style={{ height: this.props.Document._scrollTop ? NumCast(this.Document._height) * this.props.PanelWidth() / NumCast(this.Document._width) : undefined }}>
+        return <div className={"pdfBox"} onContextMenu={this.specificContextMenu} style={{ height: this.props.Document._scrollTop && !this.Document._fitWidth ? NumCast(this.Document._height) * this.props.PanelWidth() / NumCast(this.Document._width) : undefined }}>
             <PDFViewer {...this.props} pdf={this._pdf!} url={pdfUrl!.url.pathname} active={this.props.active} loaded={this.loaded}
                 setPdfViewer={this.setPdfViewer} ContainingCollectionView={this.props.ContainingCollectionView}
                 renderDepth={this.props.renderDepth} PanelHeight={this.props.PanelHeight} PanelWidth={this.props.PanelWidth}
diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx
index ea3b7f12b..a39c337ca 100644
--- a/src/client/views/nodes/PresBox.tsx
+++ b/src/client/views/nodes/PresBox.tsx
@@ -164,7 +164,7 @@ export class PresBox extends React.Component<FieldViewProps> {
 
         //docToJump stayed same meaning, it was not in the group or was the last element in the group
         const aliasOf = await Cast(docToJump.aliasOf, Doc);
-        const srcContext = aliasOf && await Cast(aliasOf.anchor1_context, Doc);
+        const srcContext = aliasOf && await Cast(aliasOf.context, Doc);
         if (docToJump === curDoc) {
             //checking if curDoc has navigation open
             const target = await Cast(curDoc.presentationTargetDoc, Doc);
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index af06a2646..a1e7d5c2a 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -7,7 +7,7 @@ import { Doc, DocListCast, FieldResult, WidthSym, Opt, HeightSym } from "../../.
 import { Id, Copy } from "../../../new_fields/FieldSymbols";
 import { List } from "../../../new_fields/List";
 import { makeInterface, createSchema } from "../../../new_fields/Schema";
-import { ScriptField } from "../../../new_fields/ScriptField";
+import { ScriptField, ComputedField } from "../../../new_fields/ScriptField";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
 import { smoothScroll, Utils, emptyFunction, returnOne, intersectRect, addStyleSheet, addStyleSheetRule, clearStyleSheetRules } from "../../../Utils";
 import { Docs, DocUtils } from "../../documents/Documents";
@@ -33,6 +33,7 @@ import { TraceMobx } from "../../../new_fields/util";
 import { PdfField } from "../../../new_fields/URLField";
 import { PDFBox } from "../nodes/PDFBox";
 import { FormattedTextBox } from "../nodes/FormattedTextBox";
+import { DocumentView } from "../nodes/DocumentView";
 const PDFJSViewer = require("pdfjs-dist/web/pdf_viewer");
 const pdfjsLib = require("pdfjs-dist");
 
@@ -210,7 +211,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
         this.props.setPdfViewer(this);
         await this.initialLoad();
 
-        this._scrollTopReactionDisposer = reaction(() => Cast(this.props.Document._scrollTop, "number", null),
+        this._scrollTopReactionDisposer = reaction(() => Cast(this.layoutDoc._scrollTop, "number", null),
             (stop) => (stop !== undefined) && this._mainCont.current && smoothScroll(500, this._mainCont.current, stop), { fireImmediately: true });
         this._annotationReactionDisposer = reaction(
             () => DocListCast(this.dataDoc[this.props.fieldKey + "-annotations"]),
@@ -567,12 +568,14 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
         e.preventDefault();
         e.stopPropagation();
 
-        const clipDoc = Docs.Create.PdfDocument(Cast(this.dataDoc[this.props.fieldKey], PdfField, null)?.url.href || "http://www.msn.com", { title: "snippetView", _fitWidth: true, _width: this.marqueeWidth(), _height: this.marqueeHeight(), _scrollTop: this.marqueeY() });
+        const clipDoc = Doc.MakeAlias(this.dataDoc);
+        clipDoc._fitWidth = true;
+        clipDoc._width = this.marqueeWidth();
+        clipDoc._height = this.marqueeHeight();
+        clipDoc._scrollTop = this.marqueeY();
         const targetDoc = Docs.Create.TextDocument("", { _width: 200, _height: 200, title: "Note linked to " + this.props.Document.title });
-        Doc.GetProto(targetDoc).layout = FormattedTextBox.LayoutString("contents");
         Doc.GetProto(targetDoc).data = new List<Doc>([clipDoc]);
-        Doc.GetProto(targetDoc).layout_slideView = (await Cast(Doc.UserDoc().slidesBtn, Doc))?.dragFactory;
-        targetDoc.layoutKey = "layout_slideView";
+        DocumentView.makeCustomViewClicked(targetDoc, undefined, Docs.Create.StackingDocument, "slideView", undefined);
         // const targetDoc = Docs.Create.TextDocument("", { _width: 200, _height: 200, title: "Note linked to " + this.props.Document.title });
         // Doc.GetProto(targetDoc).snipped = this.dataDoc[this.props.fieldKey][Copy]();
         // const snipLayout = Docs.Create.PdfDocument("http://www.msn.com", { title: "snippetView", isTemplateDoc: true, isTemplateForField: "snipped", _fitWidth: true, _width: this.marqueeWidth(), _height: this.marqueeHeight(), _scrollTop: this.marqueeY() });
@@ -582,7 +585,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
             DragManager.StartPdfAnnoDrag([ele], new DragManager.PdfAnnoDragData(this.props.Document, annotationDoc, targetDoc), e.pageX, e.pageY, {
                 dragComplete: e => {
                     if (!e.aborted && e.annoDragData && !e.annoDragData.linkedToDoc) {
-                        const link = DocUtils.MakeLink({ doc: annotationDoc }, { doc: e.annoDragData.dropDocument, ctx: e.annoDragData.targetContext }, "Annotation");
+                        const link = DocUtils.MakeLink({ doc: annotationDoc }, { doc: e.annoDragData.dropDocument }, "Annotation");
                         if (link) link.maximizeLocation = "onRight";
                     }
                 }
@@ -646,6 +649,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
                 setPreviewCursor={this.setPreviewCursor}
                 PanelHeight={this.panelWidth}
                 PanelWidth={this.panelHeight}
+                dropAction={"alias"}
                 VisibleHeight={this.visibleHeight}
                 focus={this.props.focus}
                 isSelected={this.props.isSelected}
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index cfa13cb44..cb2b8846b 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -265,7 +265,7 @@ export class CurrentUserUtils {
         const slideTemplate = Docs.Create.MultirowDocument(
             [
                 Docs.Create.MulticolumnDocument([], { title: "data", _height: 200 }),
-                Docs.Create.TextDocument("", { title: "contents", _height: 100 })
+                Docs.Create.TextDocument("", { title: "text", _height: 100 })
             ],
             { _width: 400, _height: 300, title: "slideView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, _autoHeight: false });
         slideTemplate.isTemplateDoc = makeTemplate(slideTemplate);
-- 
cgit v1.2.3-70-g09d2


From b05061f6c20c2c953ff43727b8a29d704ec4b392 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 28 Mar 2020 10:56:01 -0400
Subject: fixed runtime errors when collection data field has image or non-list
 value.  cleaned up creating buttons.

---
 src/client/views/collections/CollectionView.tsx    |  2 +-
 src/new_fields/Doc.ts                              |  5 +-
 .../authentication/models/current_user_utils.ts    | 81 +++++++++++-----------
 3 files changed, 44 insertions(+), 44 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 1542988e7..b01d76567 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -306,7 +306,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     }
     get childDocs() {
         const dfield = this.dataField;
-        const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), this.props.Document.expandedTemplate ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
+        const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), Cast(this.props.Document.expandedTemplate, Doc, null) ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
         const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
         const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
         return viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index da723b43b..9d90c569a 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -352,6 +352,9 @@ export namespace Doc {
     // return the doc's proto, but rather recursively searches through the proto inheritance chain 
     // and returns the document who's proto is undefined or whose proto is marked as a base prototype ('isPrototype').
     export function GetProto(doc: Doc): Doc {
+        if (doc instanceof Promise) {
+            console.log("GetProto: error: got Promise insead of Doc")
+        }
         const proto = doc && (Doc.GetT(doc, "isPrototype", "boolean", true) ? doc : (doc.proto || doc));
         return proto === doc ? proto : Doc.GetProto(proto);
     }
@@ -502,7 +505,7 @@ export namespace Doc {
     // if the childDoc is a template for a field, then this will return the expanded layout with its data doc.
     // otherwise, it just returns the childDoc
     export function GetLayoutDataDocPair(containerDoc: Doc, containerDataDoc: Opt<Doc>, childDoc: Doc) {
-        if (!childDoc || !Doc.GetProto(childDoc)) {
+        if (!childDoc || childDoc instanceof Promise || !Doc.GetProto(childDoc)) {
             console.log("No, no, no!");
             return { layout: childDoc, data: childDoc };
         }
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index cb2b8846b..29fba38bc 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -1,7 +1,7 @@
 import { action, computed, observable, reaction } from "mobx";
 import * as rp from 'request-promise';
 import { DocServer } from "../../../client/DocServer";
-import { Docs } from "../../../client/documents/Documents";
+import { Docs, DocumentOptions } from "../../../client/documents/Documents";
 import { Attribute, AttributeGroup, Catalog, Schema } from "../../../client/northstar/model/idea/idea";
 import { ArrayUtil } from "../../../client/northstar/utils/ArrayUtil";
 import { UndoManager } from "../../../client/util/UndoManager";
@@ -81,7 +81,11 @@ export class CurrentUserUtils {
             { title: "use drag", icon: "mouse-pointer", click: 'deactivateInk();this.activePen.pen = this;', ischecked: `sameDocs(this.activePen.pen, this)`, backgroundColor: "white", activePen: doc },
         ];
         return docProtoData.filter(d => !buttons || !buttons.includes(d.title)).map(data => Docs.Create.FontIconDocument({
-            _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: data.click ? "copy" : undefined, title: data.title, icon: data.icon, ignoreClick: data.ignoreClick,
+            _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100,
+            icon: data.icon,
+            title: data.title,
+            ignoreClick: data.ignoreClick,
+            dropAction: data.click ? "copy" : undefined,
             onDragStart: data.drag ? ScriptField.MakeFunction(data.drag) : undefined, onClick: data.click ? ScriptField.MakeScript(data.click) : undefined,
             ischecked: data.ischecked ? ComputedField.MakeFunction(data.ischecked) : undefined, activePen: data.activePen, dontSelect: true,
             backgroundColor: data.backgroundColor, removeDropProperties: new List<string>(["dropAction"]), dragFactory: data.dragFactory,
@@ -137,7 +141,8 @@ export class CurrentUserUtils {
             { title: "ignore gestures", icon: "signature", pointerUp: "setToolglass('none')", pointerDown: "setToolglass('ignoregesture')", backgroundColor: "green", ischecked: `sameDocs(this.activePen.pen, this)`, activePen: doc },
         ];
         return docProtoData.map(data => Docs.Create.FontIconDocument({
-            _nativeWidth: 10, _nativeHeight: 10, _width: 10, _height: 10, dropAction: data.pointerDown ? "copy" : undefined, title: data.title, icon: data.icon, ignoreClick: data.ignoreClick,
+            _nativeWidth: 10, _nativeHeight: 10, _width: 10, _height: 10, title: data.title, icon: data.icon,
+            dropAction: data.pointerDown ? "copy" : undefined, ignoreClick: data.ignoreClick,
             onDragStart: data.drag ? ScriptField.MakeFunction(data.drag) : undefined,
             clipboard: data.clipboard,
             onPointerUp: data.pointerUp ? ScriptField.MakeScript(data.pointerUp) : undefined, onPointerDown: data.pointerDown ? ScriptField.MakeScript(data.pointerDown) : undefined,
@@ -245,19 +250,20 @@ export class CurrentUserUtils {
 
     // setup the list of sidebar mode buttons which determine what is displayed in the sidebar
     static setupSidebarButtons(doc: Doc) {
-        doc.sidebarContainer = new Doc();
-        (doc.sidebarContainer as Doc)._chromeStatus = "disabled";
-        (doc.sidebarContainer as Doc).onClick = ScriptField.MakeScript("freezeSidebar()");
+        const sidebarContainer = new Doc();
+        doc.sidebarContainer = new PrefetchProxy(sidebarContainer);
+        sidebarContainer._chromeStatus = "disabled";
+        sidebarContainer.onClick = ScriptField.MakeScript("freezeSidebar()");
 
-        doc.ToolsBtn = this.setupToolsPanel(doc.sidebarContainer as Doc, doc);
-        doc.LibraryBtn = this.setupLibraryPanel(doc.sidebarContainer as Doc, doc);
-        doc.SearchBtn = this.setupSearchPanel(doc.sidebarContainer as Doc);
+        doc.ToolsBtn = new PrefetchProxy(this.setupToolsPanel(sidebarContainer, doc));
+        doc.LibraryBtn = new PrefetchProxy(this.setupLibraryPanel(sidebarContainer, doc));
+        doc.SearchBtn = new PrefetchProxy(this.setupSearchPanel(sidebarContainer));
 
         // Finally, setup the list of buttons to display in the sidebar
-        doc.sidebarButtons = Docs.Create.StackingDocument([doc.SearchBtn as Doc, doc.LibraryBtn as Doc, doc.ToolsBtn as Doc], {
+        doc.sidebarButtons = new PrefetchProxy(Docs.Create.StackingDocument([doc.SearchBtn as any as Doc, doc.LibraryBtn as any as Doc, doc.ToolsBtn as any as Doc], {
             _width: 500, _height: 80, boxShadow: "0 0", _pivotField: "title", hideHeadings: true, ignoreClick: true, _chromeStatus: "view-mode",
             title: "sidebar btn row stack", backgroundColor: "dimGray",
-        });
+        }));
     }
 
     /// sets up the default list of buttons to be shown in the expanding button menu at the bottom of the Dash window
@@ -273,35 +279,26 @@ export class CurrentUserUtils {
         Doc.GetProto(descriptionTemplate).layout = FormattedTextBox.LayoutString("description");
         descriptionTemplate.isTemplateDoc = makeTemplate(descriptionTemplate, true, "descriptionView");
 
-        const iconDoc = Docs.Create.TextDocument("", { title: "icon", _width: 150, _height: 30, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") });
-        Doc.GetProto(iconDoc).icon = new RichTextField('{"doc":{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"inset":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null},"content":[{"type":"dashField","attrs":{"fieldKey":"title","docid":""}}]}]},"selection":{"type":"text","anchor":2,"head":2},"storedMarks":[]}', "");
-        doc.isTemplateDoc = makeTemplate(iconDoc);
-        doc.iconView = new PrefetchProxy(iconDoc);
-        const imgIconDoc = Docs.Create.ImageDocument("http://www.cs.brown.edu/~bcz/face.gif", { title: "data", _width: 50, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") });
-        doc.isTemplateDoc = makeTemplate(imgIconDoc, true, "image_icon");
-        doc.iconImageView = new PrefetchProxy(imgIconDoc);
-        const colIconDoc = Docs.Create.TreeDocument([], { title: "data", _width: 180, _height: 80, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") });
-        doc.isTemplateDoc = makeTemplate(colIconDoc, true, "collection_icon");
-        doc.iconColView = new PrefetchProxy(colIconDoc);
-
-        doc.undoBtn = Docs.Create.FontIconDocument(
-            { _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: "alias", onClick: ScriptField.MakeScript("undo()"), removeDropProperties: new List<string>(["dropAction"]), title: "undo button", icon: "undo-alt" });
-        doc.redoBtn = Docs.Create.FontIconDocument(
-            { _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: "alias", onClick: ScriptField.MakeScript("redo()"), removeDropProperties: new List<string>(["dropAction"]), title: "redo button", icon: "redo-alt" });
-        doc.slidesBtn = Docs.Create.FontIconDocument(
-            { _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: "alias", onDragStart: ScriptField.MakeFunction('getCopy(this.dragFactory, true)'), dragFactory: slideTemplate, removeDropProperties: new List<string>(["dropAction"]), title: "presentation slide", icon: "sticky-note" });
-        doc.descriptionBtn = Docs.Create.FontIconDocument(
-            { _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, dropAction: "alias", onDragStart: ScriptField.MakeFunction('getCopy(this.dragFactory, true)'), dragFactory: descriptionTemplate, removeDropProperties: new List<string>(["dropAction"]), title: "description view", icon: "sticky-note" });
-        doc.templateButtons = Docs.Create.LinearDocument([doc.slidesBtn as Doc, doc.descriptionBtn as Doc], {
-            title: "template buttons", _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", dontSelect: true,
-            backgroundColor: "black", treeViewPreventOpen: true, forceActive: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true,
-            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name })
-        });
-        doc.expandingButtons = Docs.Create.LinearDocument([doc.undoBtn as Doc, doc.redoBtn as Doc, doc.templateButtons as Doc], {
-            title: "expanding buttons", _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0",
-            backgroundColor: "black", treeViewPreventOpen: true, forceActive: true, lockedPosition: true, linearViewIsExpanded: true,
-            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name })
-        });
+        doc.iconView = new PrefetchProxy(Docs.Create.TextDocument("", { title: "icon", _width: 150, _height: 30, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") }));
+        Doc.GetProto(doc.iconView as any as Doc).icon = new RichTextField('{"doc":{"type":"doc","content":[{"type":"paragraph","attrs":{"align":null,"color":null,"id":null,"indent":null,"inset":null,"lineSpacing":null,"paddingBottom":null,"paddingTop":null},"content":[{"type":"dashField","attrs":{"fieldKey":"title","docid":""}}]}]},"selection":{"type":"text","anchor":2,"head":2},"storedMarks":[]}', "");
+        doc.isTemplateDoc = makeTemplate(doc.iconView as any as Doc);
+        doc.ImageIconView = new PrefetchProxy(Docs.Create.ImageDocument("http://www.cs.brown.edu/~bcz/face.gif", { title: "data", _width: 50, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") }));
+        doc.isTemplateDoc = makeTemplate(doc.ImageIconView as any as Doc, true, "image_icon");
+        doc.iconColView = new PrefetchProxy(Docs.Create.TreeDocument([], { title: "data", _width: 180, _height: 80, isTemplateDoc: true, onClick: ScriptField.MakeScript("deiconifyView(this)") }));
+        doc.isTemplateDoc = makeTemplate(doc.iconColView as any as Doc, true, "collection_icon");
+
+        const ficon = (opts:DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({...opts, dontSelect: true, dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth:100, _nativeHeight:100, _width:100, _height:100})) as any as Doc;
+        const blist = (opts:DocumentOptions, docs:Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, {...opts,  
+            _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", dontSelect: true,
+            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }),
+            backgroundColor: "black", treeViewPreventOpen: true, forceActive: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true})) as any as Doc;
+
+        doc.undoBtn = ficon({ onClick: ScriptField.MakeScript("undo()"), title: "undo button", icon: "undo-alt" });
+        doc.redoBtn = ficon({ onClick: ScriptField.MakeScript("redo()"), title: "redo button", icon: "redo-alt" });
+        doc.slidesBtn = ficon({ onDragStart: ScriptField.MakeFunction('getCopy(this.dragFactory, true)'), dragFactory: slideTemplate, removeDropProperties: new List<string>(["dropAction"]), title: "presentation slide", icon: "sticky-note" });
+        doc.descriptionBtn = ficon({ onDragStart: ScriptField.MakeFunction('getCopy(this.dragFactory, true)'), dragFactory: descriptionTemplate, removeDropProperties: new List<string>(["dropAction"]), title: "description view", icon: "sticky-note" });
+        doc.templateButtons = blist({title: "template buttons"}, [doc.slidesBtn as Doc, doc.descriptionBtn as Doc]);
+        doc.expandingButtons = blist({ title: "expanding buttons"}, [doc.undoBtn as Doc, doc.redoBtn as Doc, doc.templateButtons as Doc]);
         doc.templateDocs = new PrefetchProxy(Docs.Create.TreeDocument([doc.noteTypes as Doc, doc.templateButtons as Doc], {
             title: "template layouts", _xPadding: 0, dropConverter: ScriptField.MakeScript("convertToButtons(dragData)",
                 { dragData: DragManager.DocumentDragData.name })
@@ -310,7 +307,7 @@ export class CurrentUserUtils {
 
     // sets up the default set of documents to be shown in the Overlay layer
     static setupOverlays(doc: Doc) {
-        doc.overlays = Docs.Create.FreeformDocument([], { title: "Overlays", backgroundColor: "#aca3a6" });
+        doc.overlays = new PrefetchProxy(Docs.Create.FreeformDocument([], { title: "Overlays", backgroundColor: "#aca3a6" }));
     }
 
     // the initial presentation Doc to use
@@ -320,7 +317,7 @@ export class CurrentUserUtils {
     }
 
     static setupMobileUploads(doc: Doc) {
-        doc.optionalRightCollection = Docs.Create.StackingDocument([], { title: "New mobile uploads" });
+        doc.optionalRightCollection = new PrefetchProxy(Docs.Create.StackingDocument([], { title: "New mobile uploads" }));
     }
 
     static updateUserDocument(doc: Doc) {
-- 
cgit v1.2.3-70-g09d2


From 16aee9dc7177dc3bae6125cd597e0e651e9ed72b Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sun, 29 Mar 2020 21:21:39 -0400
Subject: working version of nested templates both inside and outside of text
 boxes.

---
 src/client/util/DropConverter.ts                | 12 ++++++++++--
 src/client/views/TemplateMenu.tsx               |  3 ++-
 src/client/views/collections/CollectionView.tsx |  4 ++--
 src/client/views/nodes/DocumentContentsView.tsx |  2 +-
 src/new_fields/Doc.ts                           | 12 ++++++------
 5 files changed, 21 insertions(+), 12 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts
index d201934ea..28d88d867 100644
--- a/src/client/util/DropConverter.ts
+++ b/src/client/util/DropConverter.ts
@@ -15,14 +15,22 @@ import { ImageField } from "../../new_fields/URLField";
 // after it has been converted to
 export function makeTemplate(doc: Doc, first: boolean = true, rename: Opt<string> = undefined): boolean {
     const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc;
-    if (layoutDoc.layout instanceof Doc) return true;
+    if (layoutDoc.layout instanceof Doc) { // its already a template
+        return true;
+    }
     const layout = StrCast(layoutDoc.layout).match(/fieldKey={'[^']*'}/)![0];
     const fieldKey = layout.replace("fieldKey={'", "").replace(/'}$/, "");
     const docs = DocListCast(layoutDoc[fieldKey]);
     let any = false;
     docs.forEach(d => {
         if (!StrCast(d.title).startsWith("-")) {
-            any = Doc.MakeMetadataFieldTemplate(d, Doc.GetProto(layoutDoc)) || any;
+            const params = StrCast(d.title).match(/\(([a-zA-Z0-9_-]*)\)/)?.[1].replace("()", "");
+            if (params) {
+                any = makeTemplate(d, false) || any;
+                d.PARAMS = params;
+            } else {
+                any = Doc.MakeMetadataFieldTemplate(d, Doc.GetProto(layoutDoc)) || any;
+            }
         } else if (d.type === DocumentType.COL || d.data instanceof RichTextField) {
             any = makeTemplate(d, false) || any;
         }
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index cf6ce2c6f..83dbd3db3 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -175,7 +175,8 @@ Scripting.addGlobal(function switchView(doc: Doc, template: Doc) {
 });
 
 Scripting.addGlobal(function templateIsUsed(templateDoc: Doc, firstDocTitlte: string) {
-    const firstDoc = SelectionManager.SelectedDocuments()[0].props.Document;
+    const firstDoc = SelectionManager.SelectedDocuments().length ? SelectionManager.SelectedDocuments()[0].props.Document : undefined;
+    if (!firstDoc) return false;
     const template = StrCast(templateDoc.dragFactory ? Cast(templateDoc.dragFactory, Doc, null)?.title : templateDoc.title);
     return StrCast(firstDoc.layoutKey) === "layout_" + template ? 'check' : 'unchecked';
     // return SelectionManager.SelectedDocuments().some(view => StrCast(view.props.Document.layoutKey) === "layout_" + template) ? 'check' : 'unchecked'
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index b01d76567..324417cf8 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -313,8 +313,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
     }
     @computed get _allFacets() {
         const facets = new Set<string>();
-        this.childDocs.forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key)));
-        Doc.AreProtosEqual(this.dataDoc, this.props.Document) && this.childDocs.forEach(child => Object.keys(child).forEach(key => facets.add(key)));
+        this.childDocs.filter(child => child).forEach(child => Object.keys(Doc.GetProto(child)).forEach(key => facets.add(key)));
+        Doc.AreProtosEqual(this.dataDoc, this.props.Document) && this.childDocs.filter(child => child).forEach(child => Object.keys(child).forEach(key => facets.add(key)));
         return Array.from(facets);
     }
 
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index bf335937f..5ef330c5a 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -78,7 +78,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
         return proto instanceof Promise ? undefined : proto;
     }
     get layoutDoc() {
-        return Doc.expandTemplateLayout(this.props.LayoutDoc?.() || Doc.Layout(this.props.Document), this.props.Document, StrCast(this.props.Document.layoutKey));
+        return Doc.expandTemplateLayout(this.props.LayoutDoc?.() || Doc.Layout(this.props.Document), this.props.Document, "(" + StrCast(this.props.Document.PARAMS) + ")");
     }
 
     CreateBindings(): JsxBindings {
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 0e3bab32a..d33504dde 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -473,7 +473,8 @@ export namespace Doc {
     //   layout_mytemplate(somparam=somearg).   
     // then any references to @someparam would be rewritten as accesses to 'somearg' on the expandedTemplate
     export function expandTemplateLayout(templateLayoutDoc: Doc, targetDoc?: Doc, templateArgs?: string, templateParent?: Doc) {
-        if (!WillExpandTemplateLayout(templateLayoutDoc, targetDoc) || !targetDoc) return templateLayoutDoc;
+        const args = templateArgs?.match(/\(([a-zA-Z0-9_-]*)\)/)?.[1].replace("()", "") || StrCast(templateLayoutDoc.PARAMS);
+        if (!args && !WillExpandTemplateLayout(templateLayoutDoc, targetDoc) || !targetDoc) return templateLayoutDoc;
 
         const templateField = StrCast(templateLayoutDoc.isTemplateForField);  // the field that the template renders
         // First it checks if an expanded layout already exists -- if so it will be stored on the dataDoc
@@ -481,15 +482,14 @@ export namespace Doc {
         // If it doesn't find the expanded layout, then it makes a delegate of the template layout and
         // saves it on the data doc indexed by the template layout's id.
         //
-        const args = templateArgs?.match(/\(([a-zA-Z0-9_-]*)\)/)?.[1].replace("()", "") || "";
         const params = args.split("=").length > 1 ? args.split("=")[0] : "PARAMS";
         const layoutFielddKey = Doc.LayoutFieldKey(templateLayoutDoc);
         const expandedLayoutFieldKey = (templateField || layoutFielddKey) + "-layout[" + templateLayoutDoc[Id] + args + "]";
         let expandedTemplateLayout = targetDoc?.[expandedLayoutFieldKey];
         if (templateLayoutDoc.resolvedDataDoc instanceof Promise) {
             expandedTemplateLayout = undefined;
-        } else if (templateLayoutDoc.resolvedDataDoc === Doc.GetProto(targetDoc)) {
-            expandedTemplateLayout = templateLayoutDoc;
+            // } else if (templateLayoutDoc.resolvedDataDoc === Doc.GetProto(targetDoc)) {
+            //     expandedTemplateLayout = templateLayoutDoc;
         } else if (expandedTemplateLayout === undefined) {
             setTimeout(action(() => {
                 if (!targetDoc[expandedLayoutFieldKey]) {
@@ -497,7 +497,7 @@ export namespace Doc {
                     // the template's arguments are stored in params which is derefenced to find
                     // the actual field key where the parameterized template data is stored.
                     newLayoutDoc[params] = args;
-                    newLayoutDoc.expandedTemplate = templateParent || targetDoc;
+                    newLayoutDoc.expandedTemplate = targetDoc || templateParent;
                     targetDoc[expandedLayoutFieldKey] = newLayoutDoc;
                     const dataDoc = Doc.GetProto(targetDoc);
                     newLayoutDoc.resolvedDataDoc = dataDoc;
@@ -518,7 +518,7 @@ export namespace Doc {
             return { layout: childDoc, data: childDoc };
         }
         const existingResolvedDataDoc = childDoc[DataSym] !== Doc.GetProto(childDoc)[DataSym] && childDoc[DataSym];
-        const resolvedDataDoc = existingResolvedDataDoc || (Doc.AreProtosEqual(containerDataDoc, containerDoc) || !containerDataDoc || (!childDoc.isTemplateDoc && !childDoc.isTemplateForField) ? undefined : containerDataDoc);
+        const resolvedDataDoc = existingResolvedDataDoc || (Doc.AreProtosEqual(containerDataDoc, containerDoc) || !containerDataDoc || (!childDoc.isTemplateDoc && !childDoc.isTemplateForField && !childDoc.PARAMS) ? undefined : containerDataDoc);
         return { layout: Doc.expandTemplateLayout(childDoc, resolvedDataDoc, "(" + StrCast(containerDoc["PARAMS"]) + ")", Cast(containerDoc.expandedTemplate, Doc, null)), data: resolvedDataDoc };
     }
 
-- 
cgit v1.2.3-70-g09d2


From 71b0e84cb852bc171a5df96b36cbb5f7bd1c150c Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Mon, 30 Mar 2020 14:19:03 -0400
Subject: changed expandedTemplate to rootDocument

---
 src/client/util/ProsemirrorExampleTransfer.ts        |  6 +++---
 src/client/util/RichTextSchema.tsx                   |  2 +-
 src/client/views/collections/CollectionSubView.tsx   |  2 +-
 src/client/views/collections/CollectionView.tsx      |  2 +-
 src/client/views/nodes/DocumentView.tsx              |  2 +-
 src/client/views/nodes/FormattedTextBox.tsx          |  4 ++--
 src/client/views/presentationview/PresElementBox.tsx |  2 +-
 src/new_fields/Doc.ts                                | 18 +++++++++---------
 src/new_fields/ScriptField.ts                        |  2 +-
 9 files changed, 20 insertions(+), 20 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/ProsemirrorExampleTransfer.ts b/src/client/util/ProsemirrorExampleTransfer.ts
index 5cbf401d4..42247f177 100644
--- a/src/client/util/ProsemirrorExampleTransfer.ts
+++ b/src/client/util/ProsemirrorExampleTransfer.ts
@@ -151,14 +151,14 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, props: any
     });
     bind("Ctrl-Enter", (state: EditorState<S>, dispatch: (tx: Transaction<S>) => void) => {
         const layoutDoc = props.Document;
-        const originalDoc = layoutDoc.expandedTemplate || layoutDoc;
+        const originalDoc = layoutDoc.rootDocument || layoutDoc;
         if (originalDoc instanceof Doc) {
             const newDoc = Docs.Create.TextDocument("", {
                 title: "", layout: Cast(originalDoc.layout, Doc, null) || FormattedTextBox.DefaultLayout, _singleLine: BoolCast(originalDoc._singleLine),
                 x: NumCast(originalDoc.x), y: NumCast(originalDoc.y) + NumCast(originalDoc._height) + 10, _width: NumCast(layoutDoc._width), _height: NumCast(layoutDoc._height)
             });
             FormattedTextBox.SelectOnLoad = newDoc[Id];
-            originalDoc instanceof Doc && props.addDocument(newDoc);
+            props.addDocument(newDoc);
         }
     });
 
@@ -169,7 +169,7 @@ export default function buildKeymap<S extends Schema<any>>(schema: S, props: any
     };
     const addTextOnRight = (force: boolean) => {
         const layoutDoc = props.Document;
-        const originalDoc = layoutDoc.expandedTemplate || layoutDoc;
+        const originalDoc = layoutDoc.rootDocument || layoutDoc;
         if (force || props.Document._singleLine) {
             const newDoc = Docs.Create.TextDocument("", {
                 title: "", layout: Cast(originalDoc.layout, Doc, null) || FormattedTextBox.DefaultLayout, _singleLine: BoolCast(originalDoc._singleLine),
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index 1c637cfbe..b612c82ae 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -849,7 +849,7 @@ export class DashDocView {
             this._renderDisposer?.();
             this._renderDisposer = reaction(() => {
                 if (!Doc.AreProtosEqual(finalLayout, dashDoc)) {
-                    finalLayout.expandedTemplate = dashDoc.aliasOf;
+                    finalLayout.rootDocument = dashDoc.aliasOf;
                 }
                 const layoutKey = StrCast(finalLayout.layoutKey);
                 const finalKey = layoutKey && StrCast(finalLayout[layoutKey]).split("'")?.[1];
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 8b7136876..39621b75c 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -125,7 +125,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             }
 
             const dfield = this.dataField;
-            const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), this.props.Document.expandedTemplate && !this.props.annotationsKey ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
+            const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), this.props.Document.rootDocument && !this.props.annotationsKey ? [Cast(this.props.Document.rootDocument, Doc, null)] : []);
             const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
             const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
             const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 324417cf8..edb9fd930 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -306,7 +306,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     }
     get childDocs() {
         const dfield = this.dataField;
-        const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), Cast(this.props.Document.expandedTemplate, Doc, null) ? [Cast(this.props.Document.expandedTemplate, Doc, null)] : []);
+        const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), Cast(this.props.Document.rootDocument, Doc, null) ? [Cast(this.props.Document.rootDocument, Doc, null)] : []);
         const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
         const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
         return viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 63e3e0431..080c722b2 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -291,7 +291,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 SelectionManager.DeselectAll();
                 UndoManager.RunInBatch(() => this.onClickHandler!.script.run({
                     this: this.props.Document,
-                    self: Cast(this.props.Document.expandedTemplate, Doc, null) || this.props.Document,
+                    self: Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document,
                     containingCollection: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
                 }, console.log) && !this.props.Document.dontSelect && !this.props.Document.isButton && this.select(false), "on click");
             } else if (this.Document.type === DocumentType.BUTTON) {
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index f83beade3..bc43beab9 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -389,7 +389,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
         const funcs: ContextMenuProps[] = [];
         this.props.Document.isTemplateDoc && funcs.push({ description: "Make Default Layout", event: async () => Doc.UserDoc().defaultTextLayout = new PrefetchProxy(this.props.Document), icon: "eye" });
         funcs.push({ description: "Reset Default Layout", event: () => Doc.UserDoc().defaultTextLayout = undefined, icon: "eye" });
-        !this.props.Document.expandedTemplate && funcs.push({
+        !this.props.Document.rootDocument && funcs.push({
             description: "Make Template", event: () => {
                 this.props.Document.isTemplateDoc = makeTemplate(this.props.Document, true);
                 Doc.AddDocToList(Cast(Doc.UserDoc().noteTypes, Doc, null), "data", this.props.Document);
@@ -822,7 +822,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
             }
         }
 
-        const selectOnLoad = (Cast(this.props.Document.expandedTemplate, Doc, null) || this.props.Document)[Id] === FormattedTextBox.SelectOnLoad;
+        const selectOnLoad = (Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document)[Id] === FormattedTextBox.SelectOnLoad;
         if (selectOnLoad && !this.props.dontRegisterView) {
             FormattedTextBox.SelectOnLoad = "";
             this.props.select(false);
diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx
index 9329a5aa1..758795ed5 100644
--- a/src/client/views/presentationview/PresElementBox.tsx
+++ b/src/client/views/presentationview/PresElementBox.tsx
@@ -50,7 +50,7 @@ export class PresElementBox extends DocExtendableComponent<FieldViewProps, PresD
     _heightDisposer: IReactionDisposer | undefined;
     @computed get indexInPres() { return NumCast(this.presElementDoc?.presentationIndex); }
     @computed get presBoxDoc() { return Cast(this.presElementDoc?.presBox, Doc) as Doc; }
-    @computed get presElementDoc() { return this.props.Document.expandedTemplate as Doc; }
+    @computed get presElementDoc() { return this.props.Document.rootDocument as Doc; }
     @computed get presLayoutDoc() { return this.props.Document; }
     @computed get targetDoc() { return this.presElementDoc?.presentationTargetDoc as Doc; }
     @computed get currentIndex() { return NumCast(this.presBoxDoc?._itemIndex); }
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 6748882c0..8110130b0 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -468,10 +468,10 @@ export namespace Doc {
     // templateArgs should be equivalent to the layout key that generates the template since that's where the template parameters are stored in ()'s at the end of the key.
     // NOTE:  the template will have references to "@params" -- the template arguments will be assigned to the '@params' field
     // so that when the @params key is accessed, it will be rewritten as the key that is stored in the 'params' field and
-    // the derefence will then occur on the expandedTemplate (the original document).
+    // the derefence will then occur on the rootDocument (the original document).
     // in the future, field references could be written as @<someparam> and then arguments would be passed in the layout key as:
     //   layout_mytemplate(somparam=somearg).   
-    // then any references to @someparam would be rewritten as accesses to 'somearg' on the expandedTemplate
+    // then any references to @someparam would be rewritten as accesses to 'somearg' on the rootDocument
     export function expandTemplateLayout(templateLayoutDoc: Doc, targetDoc?: Doc, templateArgs?: string) {
         const args = templateArgs?.match(/\(([a-zA-Z0-9._\-]*)\)/)?.[1].replace("()", "") || StrCast(templateLayoutDoc.PARAMS);
         if (!args && !WillExpandTemplateLayout(templateLayoutDoc, targetDoc) || !targetDoc) return templateLayoutDoc;
@@ -499,8 +499,8 @@ export namespace Doc {
                         const newLayoutDoc = Doc.MakeDelegate(templateLayoutDoc, undefined, "[" + templateLayoutDoc.title + "]");
                         // the template's arguments are stored in params which is derefenced to find
                         // the actual field key where the parameterized template data is stored.
-                        newLayoutDoc[params] = args !== "..." ? args : ""; // ... signifies the layout has sub template(s) -- so we have to expand the layout for them so that they can get the correct 'expandedTemplate' field, but we don't need to reassign their params.  it would be better if the 'expandedTemplate' field could be passed dynamically to avoid have to create instances
-                        newLayoutDoc.expandedTemplate = targetDoc;
+                        newLayoutDoc[params] = args !== "..." ? args : ""; // ... signifies the layout has sub template(s) -- so we have to expand the layout for them so that they can get the correct 'rootDocument' field, but we don't need to reassign their params.  it would be better if the 'rootDocument' field could be passed dynamically to avoid have to create instances
+                        newLayoutDoc.rootDocument = targetDoc;
                         targetDoc[expandedLayoutFieldKey] = newLayoutDoc;
                         const dataDoc = Doc.GetProto(targetDoc);
                         newLayoutDoc.resolvedDataDoc = dataDoc;
@@ -511,7 +511,7 @@ export namespace Doc {
                 }), 0);
             }
         }
-        return expandedTemplateLayout instanceof Doc ? expandedTemplateLayout : undefined; // layout is undefined if the expandedTemplate is pending.
+        return expandedTemplateLayout instanceof Doc ? expandedTemplateLayout : undefined; // layout is undefined if the expandedTemplateLayout is pending.
     }
 
     // if the childDoc is a template for a field, then this will return the expanded layout with its data doc.
@@ -882,10 +882,10 @@ export namespace Doc {
             Doc.AddDocToList((Doc.UserDoc().fieldTypes as Doc), "data", optionsCollection as Doc);
         }
         const options = optionsCollection as Doc;
-        const targetDoc = doc && Doc.GetProto(Cast(doc.expandedTemplate, Doc, null) || doc);
-        targetDoc && (targetDoc.backgroundColor = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.expandedTemplate||this)["${enumeratedFieldKey}"])?._backgroundColor || "white"`, undefined, { options }));
-        targetDoc && (targetDoc.color = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.expandedTemplate||this)["${enumeratedFieldKey}"]).color || "black"`, undefined, { options }));
-        targetDoc && (targetDoc.borderRounding = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.expandedTemplate||this)["${enumeratedFieldKey}"]).borderRounding`, undefined, { options }));
+        const targetDoc = doc && Doc.GetProto(Cast(doc.rootDocument, Doc, null) || doc);
+        targetDoc && (targetDoc.backgroundColor = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.rootDocument||this)["${enumeratedFieldKey}"])?._backgroundColor || "white"`, undefined, { options }));
+        targetDoc && (targetDoc.color = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.rootDocument||this)["${enumeratedFieldKey}"]).color || "black"`, undefined, { options }));
+        targetDoc && (targetDoc.borderRounding = ComputedField.MakeFunction(`options.data.find(doc => doc.title === (this.rootDocument||this)["${enumeratedFieldKey}"]).borderRounding`, undefined, { options }));
         enumerations.map(enumeration => {
             const found = DocListCast(options.data).find(d => d.title === enumeration.title);
             if (found) {
diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts
index 954c22a8d..148886848 100644
--- a/src/new_fields/ScriptField.ts
+++ b/src/new_fields/ScriptField.ts
@@ -131,7 +131,7 @@ export class ScriptField extends ObjectField {
 export class ComputedField extends ScriptField {
     _lastComputedResult: any;
     //TODO maybe add an observable cache based on what is passed in for doc, considering there shouldn't really be that many possible values for doc
-    value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, self: Cast(doc.expandedTemplate, Doc, null) || doc, _last_: this._lastComputedResult }, console.log).result);
+    value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, self: Cast(doc.rootDocument, Doc, null) || doc, _last_: this._lastComputedResult }, console.log).result);
     public static MakeScript(script: string, params: object = {}) {
         const compiled = ScriptField.CompileScript(script, params, false);
         return compiled.compiled ? new ComputedField(compiled) : undefined;
-- 
cgit v1.2.3-70-g09d2


From 4859d4e3f5827c3341d43d19a5309d2ec25ab67b Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Wed, 1 Apr 2020 17:15:14 -0400
Subject: fixed warnings and some compile errors.  Made a key value layout and
 extened DocumentBox to have a childLayoutKey field

---
 src/client/ClientRecommender.tsx                   |  54 +++++-----
 src/client/cognitive_services/CognitiveServices.ts |  36 +++----
 src/client/documents/Documents.ts                  |   3 +-
 src/client/util/RichTextSchema.tsx                 |  18 ++--
 src/client/views/DocumentButtonBar.tsx             |   2 +-
 src/client/views/EditableView.tsx                  |  22 ++--
 src/client/views/GestureOverlay.tsx                |   8 +-
 src/client/views/GlobalKeyHandler.ts               |   4 +-
 src/client/views/MainView.tsx                      |   2 +
 src/client/views/RecommendationsBox.tsx            |  16 +--
 src/client/views/TemplateMenu.tsx                  |   8 +-
 src/client/views/TouchScrollableMenu.tsx           |   4 +-
 .../views/collections/CollectionDockingView.tsx    |   2 +-
 .../views/collections/CollectionSchemaCells.tsx    |   2 +
 .../views/collections/CollectionSchemaView.tsx     |   8 +-
 .../views/collections/CollectionStackingView.tsx   |   2 +-
 .../CollectionStackingViewFieldColumn.tsx          |   3 +-
 .../views/collections/CollectionStaffView.tsx      |  12 +--
 src/client/views/collections/CollectionSubView.tsx |   3 +-
 .../views/collections/CollectionTimeView.tsx       |   2 +-
 src/client/views/collections/CollectionView.tsx    |   2 +-
 .../views/collections/CollectionViewChromes.tsx    |  10 +-
 .../CollectionFreeFormLinksView.tsx                | 116 ++++++++++-----------
 .../collections/collectionFreeForm/MarqueeView.tsx |   4 +-
 src/client/views/nodes/ButtonBox.tsx               |   2 +-
 .../views/nodes/ContentFittingDocumentView.tsx     |   2 +
 src/client/views/nodes/DocumentBox.tsx             |   3 +-
 src/client/views/nodes/DocumentContentsView.tsx    |  24 +++--
 src/client/views/nodes/KeyValuePair.tsx            |   2 +
 src/client/views/nodes/RadialMenuItem.tsx          |  30 +++---
 src/client/views/nodes/ScreenshotBox.tsx           |   2 +-
 src/client/views/nodes/WebBox.tsx                  |   2 +-
 src/client/views/pdf/PDFViewer.tsx                 |   2 +-
 src/client/views/webcam/DashWebRTCVideo.tsx        |   8 +-
 src/mobile/MobileInterface.tsx                     |   2 +
 src/new_fields/Doc.ts                              |   4 +-
 src/new_fields/util.ts                             |   2 +-
 .../Session/agents/applied_session_agent.ts        |   2 +-
 src/server/DashSession/Session/agents/monitor.ts   |   2 +-
 .../Session/agents/promisified_ipc_manager.ts      |   6 +-
 src/server/Websocket/Websocket.ts                  |   8 +-
 src/server/database.ts                             |   2 +-
 src/server/server_Initialization.ts                |   2 +-
 43 files changed, 232 insertions(+), 218 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/ClientRecommender.tsx b/src/client/ClientRecommender.tsx
index 0e67a6e57..537e331ab 100644
--- a/src/client/ClientRecommender.tsx
+++ b/src/client/ClientRecommender.tsx
@@ -69,7 +69,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
      */
 
     private distance(vector1: number[], vector2: number[], metric: string = "cosine") {
-        assert(vector1.length === vector2.length, "Vectors are not the same length");
+        // assert(vector1.length === vector2.length, "Vectors are not the same length");
         let similarity: number;
         switch (metric) {
             case "cosine":
@@ -113,7 +113,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
             }
         }
         );
-        let doclist = Array.from(ClientRecommender.Instance.docVectors);
+        const doclist = Array.from(ClientRecommender.Instance.docVectors);
         if (distance_metric === "euclidian") {
             doclist.sort((a: RecommenderDocument, b: RecommenderDocument) => a.score - b.score);
         }
@@ -169,12 +169,12 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
      */
 
     generateMetadata = async (dataDoc: Doc, extDoc: Doc, threshold: Confidence = Confidence.Excellent) => {
-        let converter = (results: any) => {
-            let tagDoc = new Doc;
-            let tagsList = new List();
+        const converter = (results: any) => {
+            const tagDoc = new Doc;
+            const tagsList = new List();
             results.tags.map((tag: Tag) => {
                 tagsList.push(tag.name);
-                let sanitized = tag.name.replace(" ", "_");
+                const sanitized = tag.name.replace(" ", "_");
                 tagDoc[sanitized] = ComputedField.MakeFunction(`(${tag.confidence} >= this.confidence) ? ${tag.confidence} : "${ComputedField.undefined}"`);
             });
             extDoc.generatedTags = tagsList;
@@ -193,7 +193,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
      */
 
     private url(dataDoc: Doc) {
-        let data = Cast(Doc.GetProto(dataDoc)[fieldkey], ImageField);
+        const data = Cast(Doc.GetProto(dataDoc)[fieldkey], ImageField);
         return data ? data.url.href : undefined;
     }
 
@@ -215,14 +215,14 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
             }
         }
         else {
-            let fielddata = Cast(dataDoc.data, RichTextField);
-            fielddata ? data = fielddata[ToPlainText]() : data = "";
+            const fielddata = Cast(dataDoc.data, RichTextField, null);
+            data = fielddata?.Text || "";
         }
 
         // STEP 2. Upon receiving response from Text Cognitive Services, do additional processing on keywords.
         // Currently we are still using Cognitive Services for internal recommendations, but in the future this might not be necessary. 
 
-        let converter = async (results: any, data: string, isImage: boolean = false) => {
+        const converter = async (results: any, data: string, isImage: boolean = false) => {
             let keyterms = new List<string>(); // raw keywords
             let kp_string: string = ""; // keywords*frequency concatenated into a string. input into TF
             let highKP: string[] = [""]; // most frequent keyphrase
@@ -237,7 +237,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
             }
             else { // text processing
                 results.documents.forEach((doc: any) => {
-                    let keyPhrases = doc.keyPhrases; // returned by Cognitive Services
+                    const keyPhrases = doc.keyPhrases; // returned by Cognitive Services
                     keyPhrases.map((kp: string) => {
                         keyterms.push(kp);
                         const frequency = this.countFrequencies(kp, data); // frequency of keyphrase in paragraph
@@ -308,10 +308,10 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
      */
 
     private countFrequencies(keyphrase: string, paragraph: string) {
-        let data = paragraph.split(/ |\n/); // splits by new lines and spaces
-        let kp_array = keyphrase.split(" ");
-        let num_keywords = kp_array.length;
-        let par_length = data.length;
+        const data = paragraph.split(/ |\n/); // splits by new lines and spaces
+        const kp_array = keyphrase.split(" ");
+        const num_keywords = kp_array.length;
+        const par_length = data.length;
         let frequency = 0;
         // slides keyphrase windows across paragraph and checks if it matches with corresponding paragraph slice
         for (let i = 0; i <= par_length - num_keywords; i++) {
@@ -353,8 +353,8 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
 
     bingWebSearch = async (query: string) => {
         const converter = async (results: any) => {
-            let title_vals: string[] = [];
-            let url_vals: string[] = [];
+            const title_vals: string[] = [];
+            const url_vals: string[] = [];
             results.webPages.value.forEach((doc: any) => {
                 title_vals.push(doc.name);
                 url_vals.push(doc.url);
@@ -369,23 +369,23 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
      */
 
     arxivrequest = async (query: string) => {
-        let xhttp = new XMLHttpRequest();
-        let serveraddress = "http://export.arxiv.org/api";
+        const xhttp = new XMLHttpRequest();
+        const serveraddress = "http://export.arxiv.org/api";
         const maxresults = 5;
-        let endpoint = serveraddress + "/query?search_query=all:" + query + "&start=0&max_results=" + maxresults.toString();
-        let promisified = (resolve: any, reject: any) => {
+        const endpoint = serveraddress + "/query?search_query=all:" + query + "&start=0&max_results=" + maxresults.toString();
+        const promisified = (resolve: any, reject: any) => {
             xhttp.onreadystatechange = function () {
                 if (this.readyState === 4) {
-                    let result = xhttp.response;
-                    let xml = xhttp.responseXML;
+                    const result = xhttp.response;
+                    const xml = xhttp.responseXML;
                     console.log("arXiv Result: ", xml);
                     switch (this.status) {
                         case 200:
-                            let title_vals: string[] = [];
-                            let url_vals: string[] = [];
+                            const title_vals: string[] = [];
+                            const url_vals: string[] = [];
                             //console.log(result);
                             if (xml) {
-                                let titles = xml.getElementsByTagName("title");
+                                const titles = xml.getElementsByTagName("title");
                                 let counter = 1;
                                 if (titles && titles.length > 1) {
                                     while (counter <= maxresults) {
@@ -394,7 +394,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> {
                                         counter++;
                                     }
                                 }
-                                let ids = xml.getElementsByTagName("id");
+                                const ids = xml.getElementsByTagName("id");
                                 counter = 1;
                                 if (ids && ids.length > 1) {
                                     while (counter <= maxresults) {
diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts
index 542ccf04d..3f3726621 100644
--- a/src/client/cognitive_services/CognitiveServices.ts
+++ b/src/client/cognitive_services/CognitiveServices.ts
@@ -208,7 +208,7 @@ export namespace CognitiveServices {
                     results.recognitionUnits && (results = results.recognitionUnits);
                 }
                 return results;
-            }
+            };
         }
 
         export interface AzureStrokeData {
@@ -232,13 +232,13 @@ export namespace CognitiveServices {
                 return data;
             },
             requester: async (apiKey: string, query: string) => {
-                let xhttp = new XMLHttpRequest();
-                let serverAddress = "https://api.cognitive.microsoft.com";
-                let endpoint = serverAddress + '/bing/v5.0/search?q=' + encodeURIComponent(query);
-                let promisified = (resolve: any, reject: any) => {
+                const xhttp = new XMLHttpRequest();
+                const serverAddress = "https://api.cognitive.microsoft.com";
+                const endpoint = serverAddress + '/bing/v5.0/search?q=' + encodeURIComponent(query);
+                const promisified = (resolve: any, reject: any) => {
                     xhttp.onreadystatechange = function () {
                         if (this.readyState === 4) {
-                            let result = xhttp.responseText;
+                            const result = xhttp.responseText;
                             switch (this.status) {
                                 case 200:
                                     return resolve(result);
@@ -266,7 +266,7 @@ export namespace CognitiveServices {
 
         export namespace Appliers {
             export const analyzer = async (query: string, converter: BingConverter) => {
-                let results = await ExecuteQuery(Service.Bing, Manager, query);
+                const results = await ExecuteQuery(Service.Bing, Manager, query);
                 console.log("Bing results: ", results);
                 const { title_vals, url_vals } = await converter(results);
                 return { title_vals, url_vals };
@@ -281,13 +281,13 @@ export namespace CognitiveServices {
                 return data;
             },
             requester: async (apiKey: string, query: string) => {
-                let xhttp = new XMLHttpRequest();
-                let serverAddress = "https://babel.hathitrust.org/cgi/htd/​";
-                let endpoint = serverAddress + '/bing/v5.0/search?q=' + encodeURIComponent(query);
-                let promisified = (resolve: any, reject: any) => {
+                const xhttp = new XMLHttpRequest();
+                const serverAddress = "https://babel.hathitrust.org/cgi/htd/​";
+                const endpoint = serverAddress + '/bing/v5.0/search?q=' + encodeURIComponent(query);
+                const promisified = (resolve: any, reject: any) => {
                     xhttp.onreadystatechange = function () {
                         if (this.readyState === 4) {
-                            let result = xhttp.responseText;
+                            const result = xhttp.responseText;
                             switch (this.status) {
                                 case 200:
                                     return resolve(result);
@@ -315,7 +315,7 @@ export namespace CognitiveServices {
 
         export namespace Appliers {
             export const analyzer = async (query: string, converter: BingConverter) => {
-                let results = await ExecuteQuery(Service.Bing, Manager, query);
+                const results = await ExecuteQuery(Service.Bing, Manager, query);
                 console.log("Bing results: ", results);
                 const { title_vals, url_vals } = await converter(results);
                 return { title_vals, url_vals };
@@ -337,9 +337,9 @@ export namespace CognitiveServices {
                 });
             },
             requester: async (apiKey: string, body: string, service: Service) => {
-                let serverAddress = "https://eastus.api.cognitive.microsoft.com";
-                let endpoint = serverAddress + "/text/analytics/v2.1/keyPhrases";
-                let sampleBody = {
+                const serverAddress = "https://eastus.api.cognitive.microsoft.com";
+                const endpoint = serverAddress + "/text/analytics/v2.1/keyPhrases";
+                const sampleBody = {
                     "documents": [
                         {
                             "language": "en",
@@ -348,7 +348,7 @@ export namespace CognitiveServices {
                         }
                     ]
                 };
-                let actualBody = body;
+                const actualBody = body;
                 const options = {
                     uri: endpoint,
                     body: actualBody,
@@ -368,7 +368,7 @@ export namespace CognitiveServices {
                 console.log("vectorizing...");
                 //keyterms = ["father", "king"];
 
-                let args = { method: 'POST', uri: Utils.prepend("/recommender"), body: { keyphrases: keyterms }, json: true };
+                const args = { method: 'POST', uri: Utils.prepend("/recommender"), body: { keyphrases: keyterms }, json: true };
                 await requestPromise.post(args).then(async (wordvecs) => {
                     if (wordvecs) {
                         const indices = Object.keys(wordvecs);
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index dbea8062e..96425ba30 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -266,7 +266,7 @@ export namespace Docs {
                 options: { _width: 40, _height: 40, borderRounding: "100%" },
             }],
             [DocumentType.RECOMMENDATION, {
-                layout: { view: RecommendationsBox },
+                layout: { view: RecommendationsBox, dataField: data },
                 options: { width: 200, height: 200 },
             }],
             [DocumentType.WEBCAM, {
@@ -365,6 +365,7 @@ export namespace Docs {
             const options = { title, type, baseProto: true, ...defaultOptions, ...(template.options || {}) };
             options.layout = layout.view.LayoutString(layout.dataField);
             const doc = Doc.assign(new Doc(prototypeId, true), { layoutKey: "layout", ...options });
+            doc.layout_keyValue = KeyValueBox.LayoutString("");
             return doc;
         }
 
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index a2fb7c11b..81ab95ff5 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -810,7 +810,7 @@ export class DashDocView {
                 this._dashSpan.style.height = this._outer.style.height = Math.max(20, dim[1]) + "px";
                 this._outer.style.border = "1px solid " + StrCast(finalLayout.color, (Cast(Doc.UserDoc().activeWorkspace, Doc, null).darkScheme ? "dimGray" : "lightGray"));
             }, { fireImmediately: true });
-            let doReactRender = (finalLayout: Doc, resolvedDataDoc: Doc) => {
+            const doReactRender = (finalLayout: Doc, resolvedDataDoc: Doc) => {
                 ReactDOM.unmountComponentAtNode(this._dashSpan);
                 ReactDOM.render(<DocumentView
                     Document={finalLayout}
@@ -844,7 +844,7 @@ export class DashDocView {
                         console.log(e);
                     }
                 }
-            }
+            };
             this._renderDisposer?.();
             this._renderDisposer = reaction(() => {
                 if (!Doc.AreProtosEqual(finalLayout, dashDoc)) {
@@ -939,7 +939,7 @@ export class DashFieldView {
         this._fieldCheck.style.backgroundColor = "rgba(155, 155, 155, 0.24)";
         this._fieldCheck.onchange = function (e: any) {
             self._dashDoc![self._fieldKey] = e.target.checked;
-        }
+        };
 
         this._fieldSpan = document.createElement("div");
         this._fieldSpan.id = Utils.GenerateGuid();
@@ -1095,12 +1095,12 @@ export class FootnoteView {
                     "Mod-y": () => redo(this.outerView.state, this.outerView.dispatch),
                     "Mod-b": toggleMark(schema.marks.strong)
                 }),
-                new Plugin({
-                    view(newView) {
-                        // TODO -- make this work with RichTextMenu
-                        // return FormattedTextBox.getToolTip(newView);
-                    }
-                })
+                    // new Plugin({
+                    //     view(newView) {
+                    //         // TODO -- make this work with RichTextMenu
+                    //         // return FormattedTextBox.getToolTip(newView);
+                    //     }
+                    // })
                 ],
 
             }),
diff --git a/src/client/views/DocumentButtonBar.tsx b/src/client/views/DocumentButtonBar.tsx
index e673189f9..c6fb9ad0b 100644
--- a/src/client/views/DocumentButtonBar.tsx
+++ b/src/client/views/DocumentButtonBar.tsx
@@ -39,7 +39,7 @@ library.add(faCheckCircle);
 library.add(faCloudUploadAlt);
 library.add(faSyncAlt);
 library.add(faShare);
-library.add(faPhotoVideo)
+library.add(faPhotoVideo);
 
 const cloud: IconProp = "cloud-upload-alt";
 const fetch: IconProp = "sync-alt";
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 4a27425e8..2219966e5 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -4,10 +4,7 @@ import { observer } from 'mobx-react';
 import * as Autosuggest from 'react-autosuggest';
 import { ObjectField } from '../../new_fields/ObjectField';
 import { SchemaHeaderField } from '../../new_fields/SchemaHeaderField';
-import { ContextMenu } from './ContextMenu';
-import { ContextMenuProps } from './ContextMenuItem';
 import "./EditableView.scss";
-import { CollectionTreeView } from './collections/CollectionTreeView';
 
 export interface EditableProps {
     /**
@@ -88,12 +85,12 @@ export class EditableView extends React.Component<EditableProps> {
     onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
         if (e.key === "Tab") {
             e.stopPropagation();
-            this.finalizeEdit(e.currentTarget.value, e.shiftKey);
+            this.finalizeEdit(e.currentTarget.value, e.shiftKey, false);
             this.props.OnTab && this.props.OnTab(e.shiftKey);
         } else if (e.key === "Enter") {
             e.stopPropagation();
             if (!e.ctrlKey) {
-                this.finalizeEdit(e.currentTarget.value, e.shiftKey);
+                this.finalizeEdit(e.currentTarget.value, e.shiftKey, false);
             } else if (this.props.OnFillDown) {
                 this.props.OnFillDown(e.currentTarget.value);
                 this._editing = false;
@@ -123,10 +120,17 @@ export class EditableView extends React.Component<EditableProps> {
     }
 
     @action
-    private finalizeEdit(value: string, shiftDown: boolean) {
-        this._editing = false;
+    private finalizeEdit(value: string, shiftDown: boolean, lostFocus: boolean) {
         if (this.props.SetValue(value, shiftDown)) {
+            this._editing = false;
+            this.props.isEditingCallback?.(false);
+        } else {
+            this._editing = false;
             this.props.isEditingCallback?.(false);
+            !lostFocus && setTimeout(action(() => {
+                this._editing = true;
+                this.props.isEditingCallback?.(true);
+            }), 0);
         }
     }
 
@@ -151,7 +155,7 @@ export class EditableView extends React.Component<EditableProps> {
                         className: "editableView-input",
                         onKeyDown: this.onKeyDown,
                         autoFocus: true,
-                        onBlur: e => this.finalizeEdit(e.currentTarget.value, false),
+                        onBlur: e => this.finalizeEdit(e.currentTarget.value, false, true),
                         onPointerDown: this.stopPropagation,
                         onClick: this.stopPropagation,
                         onPointerUp: this.stopPropagation,
@@ -163,7 +167,7 @@ export class EditableView extends React.Component<EditableProps> {
                     defaultValue={this.props.GetValue()}
                     onKeyDown={this.onKeyDown}
                     autoFocus={true}
-                    onBlur={e => this.finalizeEdit(e.currentTarget.value, false)}
+                    onBlur={e => this.finalizeEdit(e.currentTarget.value, false, true)}
                     onPointerDown={this.stopPropagation} onClick={this.stopPropagation} onPointerUp={this.stopPropagation}
                     style={{ display: this.props.display, fontSize: this.props.fontSize }}
                 />;
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index 1eff58948..ea60907f6 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -165,7 +165,7 @@ export default class GestureOverlay extends Touchable {
                 this._holdTimer = setTimeout(() => {
                     console.log("hold");
                     const target = document.elementFromPoint(te.changedTouches.item(0).clientX, te.changedTouches.item(0).clientY);
-                    let pt: any = te.touches[te.touches.length - 1];
+                    const pt: any = te.touches[te.touches.length - 1];
                     if (nts.nt.length === 1 && pt.radiusX > 1 && pt.radiusY > 1) {
                         target?.dispatchEvent(
                             new CustomEvent<InteractionUtils.MultiTouchEvent<React.TouchEvent>>("dashOnTouchHoldStart",
@@ -589,7 +589,7 @@ export default class GestureOverlay extends Touchable {
                             for (const wR of wordResults) {
                                 console.log(wR);
                                 if (wR?.recognizedText) {
-                                    possibilities.push(wR?.recognizedText)
+                                    possibilities.push(wR?.recognizedText);
                                 }
                                 possibilities.push(...wR?.alternates?.map((a: any) => a.recognizedString));
                             }
@@ -743,16 +743,16 @@ export default class GestureOverlay extends Touchable {
                 {this.elements}
 
                 <div className="clipboardDoc-cont" style={{
-                    transform: `translate(${this._thumbX}px, ${(this._thumbY ?? 0) - this.height}px)`,
                     height: this.height,
                     width: this.height,
                     pointerEvents: this._clipboardDoc ? "unset" : "none",
                     touchAction: this._clipboardDoc ? "unset" : "none",
+                    transform: `translate(${this._thumbX}px, ${(this._thumbY || 0) - this.height} px)`,
                 }}>
                     {this._clipboardDoc}
                 </div>
                 <div className="filter-cont" style={{
-                    transform: `translate(${this._thumbX}px, ${(this._thumbY ?? 0) - this.height}px)`,
+                    transform: `translate(${this._thumbX}px, ${(this._thumbY || 0) - this.height}px)`,
                     height: this.height,
                     width: this.height,
                     pointerEvents: "none",
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index b59ee7a87..52801b570 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -106,8 +106,8 @@ export default class KeyManager {
     });
 
     private shift = async (keyname: string) => {
-        let stopPropagation = false;
-        let preventDefault = false;
+        const stopPropagation = false;
+        const preventDefault = false;
 
         switch (keyname) {
             // case "~":
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index a81e0cc2c..8d9be5980 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -521,7 +521,9 @@ export class MainView extends React.Component {
                     DataDoc={undefined}
                     LibraryPath={emptyPath}
                     fieldKey={"data"}
+                    dropAction={"alias"}
                     annotationsKey={""}
+                    bringToFront={emptyFunction}
                     select={emptyFunction}
                     active={returnFalse}
                     isSelected={returnFalse}
diff --git a/src/client/views/RecommendationsBox.tsx b/src/client/views/RecommendationsBox.tsx
index 262226bac..5ebba0abb 100644
--- a/src/client/views/RecommendationsBox.tsx
+++ b/src/client/views/RecommendationsBox.tsx
@@ -6,7 +6,7 @@ import "./RecommendationsBox.scss";
 import { Doc, DocListCast, WidthSym, HeightSym } from "../../new_fields/Doc";
 import { DocumentIcon } from "./nodes/DocumentIcon";
 import { StrCast, NumCast } from "../../new_fields/Types";
-import { returnFalse, emptyFunction, returnEmptyString, returnOne } from "../../Utils";
+import { returnFalse, emptyFunction, returnEmptyString, returnOne, emptyPath } from "../../Utils";
 import { Transform } from "../util/Transform";
 import { ObjectField } from "../../new_fields/ObjectField";
 import { DocumentView } from "./nodes/DocumentView";
@@ -31,7 +31,7 @@ library.add(faBullseye, faLink);
 @observer
 export class RecommendationsBox extends React.Component<FieldViewProps> {
 
-    public static LayoutString(fieldKey?: string) { return FieldView.LayoutString(RecommendationsBox, fieldKey); }
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(RecommendationsBox, fieldKey); }
 
     // @observable private _display: boolean = false;
     @observable private _pageX: number = 0;
@@ -48,17 +48,17 @@ export class RecommendationsBox extends React.Component<FieldViewProps> {
 
     @action
     private DocumentIcon(doc: Doc) {
-        let layoutresult = StrCast(doc.type);
+        const layoutresult = StrCast(doc.type);
         let renderDoc = doc;
         //let box: number[] = [];
         if (layoutresult.indexOf(DocumentType.COL) !== -1) {
             renderDoc = Doc.MakeDelegate(renderDoc);
         }
-        let returnXDimension = () => 150;
-        let returnYDimension = () => 150;
-        let scale = () => returnXDimension() / NumCast(renderDoc.nativeWidth, returnXDimension());
+        const returnXDimension = () => 150;
+        const returnYDimension = () => 150;
+        const scale = () => returnXDimension() / NumCast(renderDoc.nativeWidth, returnXDimension());
         //let scale = () => 1;
-        let newRenderDoc = Doc.MakeAlias(renderDoc); ///   newRenderDoc -> renderDoc -> render"data"Doc -> TextProt
+        const newRenderDoc = Doc.MakeAlias(renderDoc); ///   newRenderDoc -> renderDoc -> render"data"Doc -> TextProt
         newRenderDoc.height = NumCast(this.props.Document.documentIconHeight);
         newRenderDoc.autoHeight = false;
         const docview = <div>
@@ -66,8 +66,8 @@ export class RecommendationsBox extends React.Component<FieldViewProps> {
                 fitToBox={StrCast(doc.type).indexOf(DocumentType.COL) !== -1}
                 Document={newRenderDoc}
                 addDocument={returnFalse}
+                LibraryPath={emptyPath}
                 removeDocument={returnFalse}
-                ruleProvider={undefined}
                 ScreenToLocalTransform={Transform.Identity}
                 addDocTab={returnFalse}
                 pinToPres={returnFalse}
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index 83dbd3db3..996928cca 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -114,7 +114,7 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
         const templateName = StrCast(firstDoc.layoutKey, "layout").replace("layout_", "");
         const noteTypesDoc = Cast(Doc.UserDoc().noteTypes, Doc, null);
         const noteTypes = DocListCast(noteTypesDoc?.data);
-        const addedTypes = DocListCast(Cast(Doc.UserDoc().templateButtons, Doc, null)?.data)
+        const addedTypes = DocListCast(Cast(Doc.UserDoc().templateButtons, Doc, null)?.data);
         const layout = Doc.Layout(firstDoc);
         const templateMenu: Array<JSX.Element> = [];
         this.props.templates.forEach((checked, template) =>
@@ -170,8 +170,8 @@ Scripting.addGlobal(function switchView(doc: Doc, template: Doc) {
     if (template.dragFactory) {
         template = Cast(template.dragFactory, Doc, null);
     }
-    let templateTitle = StrCast(template?.title);
-    return templateTitle && DocumentView.makeCustomViewClicked(doc, undefined, Docs.Create.FreeformDocument, templateTitle, template)
+    const templateTitle = StrCast(template?.title);
+    return templateTitle && DocumentView.makeCustomViewClicked(doc, undefined, Docs.Create.FreeformDocument, templateTitle, template);
 });
 
 Scripting.addGlobal(function templateIsUsed(templateDoc: Doc, firstDocTitlte: string) {
@@ -180,4 +180,4 @@ Scripting.addGlobal(function templateIsUsed(templateDoc: Doc, firstDocTitlte: st
     const template = StrCast(templateDoc.dragFactory ? Cast(templateDoc.dragFactory, Doc, null)?.title : templateDoc.title);
     return StrCast(firstDoc.layoutKey) === "layout_" + template ? 'check' : 'unchecked';
     // return SelectionManager.SelectedDocuments().some(view => StrCast(view.props.Document.layoutKey) === "layout_" + template) ? 'check' : 'unchecked'
-})
\ No newline at end of file
+});
\ No newline at end of file
diff --git a/src/client/views/TouchScrollableMenu.tsx b/src/client/views/TouchScrollableMenu.tsx
index 4bda0818e..969605be9 100644
--- a/src/client/views/TouchScrollableMenu.tsx
+++ b/src/client/views/TouchScrollableMenu.tsx
@@ -44,7 +44,7 @@ export default class TouchScrollableMenu extends React.Component<TouchScrollable
                 <div className="shadow" style={{ height: `calc(100% - 25px - ${this.selectedIndex * 25}px)` }}>
                 </div>
             </div>
-        )
+        );
     }
 }
 
@@ -54,6 +54,6 @@ export class TouchScrollableMenuItem extends React.Component<TouchScrollableMenu
             <div className="menuItem-cont" onClick={this.props.onClick}>
                 {this.props.text}
             </div>
-        )
+        );
     }
 }
\ No newline at end of file
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 2ee39bc0d..4e1e76f39 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -513,7 +513,7 @@ export class CollectionDockingView extends React.Component<SubCollectionViewProp
                         dragData.dropAction = doc.dropAction as dropActionType;
                         DragManager.StartDocumentDrag([gearSpan], dragData, e.clientX, e.clientY);
                     }
-                }
+                };
                 let rendered = false;
                 tab.buttonDisposer = reaction(() => ((view: Opt<DocumentView>) => view ? [view] : [])(DocumentManager.Instance.getDocumentView(doc)),
                     (views) => {
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 79b5d7bb7..f124fe21b 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -157,6 +157,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             Document: this.props.rowProps.original,
             DataDoc: this.props.rowProps.original,
             LibraryPath: [],
+            dropAction: "alias",
+            bringToFront: emptyFunction,
             fieldKey: this.props.rowProps.column.id as string,
             ContainingCollectionView: this.props.CollectionView,
             ContainingCollectionDoc: this.props.CollectionView && this.props.CollectionView.props.Document,
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index a4502cced..981438513 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -51,8 +51,7 @@ const columnTypes: Map<string, ColumnType> = new Map([
 
 @observer
 export class CollectionSchemaView extends CollectionSubView(doc => doc) {
-    private _mainCont?: HTMLDivElement;
-    private _startPreviewWidth = 0;
+    private _previewCont?: HTMLDivElement;
     private DIVIDER_WIDTH = 4;
 
     @observable previewDoc: Doc | undefined = undefined;
@@ -64,7 +63,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
     @computed get borderWidth() { return Number(COLLECTION_BORDER_WIDTH); }
 
     private createTarget = (ele: HTMLDivElement) => {
-        this._mainCont = ele;
+        this._previewCont = ele;
         super.CreateDropTarget(ele);
     }
 
@@ -81,12 +80,11 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
     }
 
     onDividerDown = (e: React.PointerEvent) => {
-        this._startPreviewWidth = this.previewWidth();
         setupMoveUpEvents(this, e, this.onDividerMove, emptyFunction, action(() => this.toggleExpander()));
     }
     @action
     onDividerMove = (e: PointerEvent, down: number[], delta: number[]) => {
-        const nativeWidth = this._mainCont!.getBoundingClientRect();
+        const nativeWidth = this._previewCont!.getBoundingClientRect();
         const minWidth = 40;
         const maxWidth = 1000;
         const movedWidth = this.props.ScreenToLocalTransform().transformDirection(nativeWidth.right - e.clientX, 0)[0];
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 086e0842e..076dd3629 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -106,7 +106,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
                 fields.delete(header);
                 sectionHeaders.splice(sectionHeaders.indexOf(header), 1);
                 changed = true;
-            })
+            });
         }
         changed && setTimeout(action(() => { if (this.sectionHeaders) { this.sectionHeaders.length = 0; this.sectionHeaders.push(...sectionHeaders); } }), 0);
         return fields;
diff --git a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
index 646b433bf..0a48c95e4 100644
--- a/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
+++ b/src/client/views/collections/CollectionStackingViewFieldColumn.tsx
@@ -131,7 +131,8 @@ export class CollectionStackingViewFieldColumn extends React.Component<CSVFieldC
         const maxHeading = this.props.docList.reduce((maxHeading, doc) => NumCast(doc.heading) > maxHeading ? NumCast(doc.heading) : maxHeading, 0);
         const heading = maxHeading === 0 || this.props.docList.length === 0 ? 1 : maxHeading === 1 ? 2 : 3;
         newDoc.heading = heading;
-        return this.props.parent.props.addDocument(newDoc);
+        this.props.parent.props.addDocument(newDoc);
+        return false;
     }
 
     @action
diff --git a/src/client/views/collections/CollectionStaffView.tsx b/src/client/views/collections/CollectionStaffView.tsx
index 8c7e113b2..5b9a69bf7 100644
--- a/src/client/views/collections/CollectionStaffView.tsx
+++ b/src/client/views/collections/CollectionStaffView.tsx
@@ -1,22 +1,20 @@
 import { CollectionSubView } from "./CollectionSubView";
-import { Transform } from "../../util/Transform";
 import React = require("react");
 import { computed, action, IReactionDisposer, reaction, runInAction, observable } from "mobx";
-import { Doc } from "../../../new_fields/Doc";
 import { NumCast } from "../../../new_fields/Types";
 import "./CollectionStaffView.scss";
 import { observer } from "mobx-react";
 
 @observer
 export class CollectionStaffView extends CollectionSubView(doc => doc) {
-    private getTransform = (): Transform => this.props.ScreenToLocalTransform().translate(0, -this._mainCont.current!.scrollTop);
-    private _mainCont = React.createRef<HTMLDivElement>();
     private _reactionDisposer: IReactionDisposer | undefined;
     @observable private _staves = NumCast(this.props.Document.staves);
 
+    componentWillUnmount() {
+        this._reactionDisposer?.();
+    }
     componentDidMount = () => {
-        this._reactionDisposer = reaction(
-            () => NumCast(this.props.Document.staves),
+        this._reactionDisposer = reaction(() => NumCast(this.props.Document.staves),
             (staves) => runInAction(() => this._staves = staves)
         );
 
@@ -47,7 +45,7 @@ export class CollectionStaffView extends CollectionSubView(doc => doc) {
     }
 
     render() {
-        return <div className="collectionStaffView" ref={this._mainCont}>
+        return <div className="collectionStaffView">
             {this.staves}
             {this.addStaffButton}
         </div>;
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 88cfde0b6..70927cf22 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -1,5 +1,4 @@
 import { action, computed, IReactionDisposer, reaction } from "mobx";
-import * as rp from 'request-promise';
 import CursorField from "../../../new_fields/CursorField";
 import { Doc, DocListCast, Opt, WidthSym, HeightSym } from "../../../new_fields/Doc";
 import { Id } from "../../../new_fields/FieldSymbols";
@@ -107,7 +106,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
         get childLayoutPairs(): { layout: Doc; data: Doc; }[] {
             const { Document, DataDoc } = this.props;
             const validPairs = this.childDocs.map(doc => Doc.GetLayoutDataDocPair(Document, !this.props.annotationsKey ? DataDoc : undefined, doc)).filter(pair => pair.layout);
-            return validPairs.map(({ data, layout }) => ({ data, layout: layout! })); // this mapping is a bit of a hack to coerce types
+            return validPairs.map(({ data, layout }) => ({ data: data as Doc, layout: layout! })); // this mapping is a bit of a hack to coerce types
         }
         get childDocList() {
             return Cast(this.dataField, listSpec(Doc));
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 64832506b..0d2207b27 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -146,7 +146,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
                 back
             </button>
             <EditableView {...newEditableViewProps} display={"inline"} menuCallback={this.menuCallback} />
-        </div>
+        </div>;
     }
 
     render() {
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index edb9fd930..b6ce2f3a9 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -299,7 +299,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     get childLayoutPairs(): { layout: Doc; data: Doc; }[] {
         const { Document, DataDoc } = this.props;
         const validPairs = this.childDocs.map(doc => Doc.GetLayoutDataDocPair(Document, DataDoc, doc)).filter(pair => pair.layout);
-        return validPairs.map(({ data, layout }) => ({ data, layout: layout! })); // this mapping is a bit of a hack to coerce types
+        return validPairs.map(({ data, layout }) => ({ data: data as Doc, layout: layout! })); // this mapping is a bit of a hack to coerce types
     }
     get childDocList() {
         return Cast(this.dataField, listSpec(Doc));
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 960c6554e..2d565d9db 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -267,10 +267,10 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
         const collapsed = this.props.CollectionView.props.Document._chromeStatus !== "enabled";
         if (collapsed) return null;
         switch (this.props.type) {
-            case CollectionViewType.Stacking: return (<CollectionStackingViewChrome key="collchrome" CollectionView={this.props.CollectionView} type={this.props.type} />);
-            case CollectionViewType.Schema: return (<CollectionSchemaViewChrome key="collchrome" CollectionView={this.props.CollectionView} type={this.props.type} />);
-            case CollectionViewType.Tree: return (<CollectionTreeViewChrome key="collchrome" CollectionView={this.props.CollectionView} type={this.props.type} />);
-            case CollectionViewType.Masonry: return (<CollectionStackingViewChrome key="collchrome" CollectionView={this.props.CollectionView} type={this.props.type} />);
+            case CollectionViewType.Stacking: return (<CollectionStackingViewChrome key="collchrome" PanelWidth={this.props.PanelWidth} CollectionView={this.props.CollectionView} type={this.props.type} />);
+            case CollectionViewType.Schema: return (<CollectionSchemaViewChrome key="collchrome" PanelWidth={this.props.PanelWidth} CollectionView={this.props.CollectionView} type={this.props.type} />);
+            case CollectionViewType.Tree: return (<CollectionTreeViewChrome key="collchrome" PanelWidth={this.props.PanelWidth} CollectionView={this.props.CollectionView} type={this.props.type} />);
+            case CollectionViewType.Masonry: return (<CollectionStackingViewChrome key="collchrome" PanelWidth={this.props.PanelWidth} CollectionView={this.props.CollectionView} type={this.props.type} />);
             default: return null;
         }
     }
@@ -355,7 +355,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
                 immediate: (source: Doc[]) => Doc.setChildLayout(this.target, source?.[0]),
                 initialize: emptyFunction,
             };
-            DragManager.StartButtonDrag([this._viewRef.current!], c.script, c.title,
+            DragManager.StartButtonDrag([this._viewRef.current!], c.script, StrCast(c.title),
                 { target: this.props.CollectionView.props.Document }, c.params, c.initialize, e.clientX, e.clientY);
             return true;
         }, emptyFunction, emptyFunction);
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
index a1ec0daef..49ca024a2 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
@@ -1,4 +1,4 @@
-import { computed, IReactionDisposer } from "mobx";
+import { computed } from "mobx";
 import { observer } from "mobx-react";
 import { Doc } from "../../../../new_fields/Doc";
 import { Id } from "../../../../new_fields/FieldSymbols";
@@ -10,67 +10,9 @@ import React = require("react");
 import { Utils, emptyFunction } from "../../../../Utils";
 import { SelectionManager } from "../../../util/SelectionManager";
 import { DocumentType } from "../../../documents/DocumentTypes";
-import { StrCast } from "../../../../new_fields/Types";
 
 @observer
 export class CollectionFreeFormLinksView extends React.Component {
-
-    _brushReactionDisposer?: IReactionDisposer;
-    componentDidMount() {
-        // this._brushReactionDisposer = reaction(
-        //     () => {
-        //         let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-        //         return { doclist: doclist ? doclist : [], xs: doclist.map(d => d.x) };
-        //     },
-        //     () => {
-        //         let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-        //         let views = doclist ? doclist.filter(doc => StrCast(doc.backgroundLayout).indexOf("istogram") !== -1) : [];
-        //         views.forEach((dstDoc, i) => {
-        //             views.forEach((srcDoc, j) => {
-        //                 let dstTarg = dstDoc;
-        //                 let srcTarg = srcDoc;
-        //                 let x1 = NumCast(srcDoc.x);
-        //                 let x2 = NumCast(dstDoc.x);
-        //                 let x1w = NumCast(srcDoc.width, -1);
-        //                 let x2w = NumCast(dstDoc.width, -1);
-        //                 if (x1w < 0 || x2w < 0 || i === j) { }
-        //                 else {
-        //                     let findBrush = (field: (Doc | Promise<Doc>)[]) => field.findIndex(brush => {
-        //                         let bdocs = brush instanceof Doc ? Cast(brush.brushingDocs, listSpec(Doc), []) : undefined;
-        //                         return bdocs && bdocs.length && ((bdocs[0] === dstTarg && bdocs[1] === srcTarg)) ? true : false;
-        //                     });
-        //                     let brushAction = (field: (Doc | Promise<Doc>)[]) => {
-        //                         let found = findBrush(field);
-        //                         if (found !== -1) {
-        //                             field.splice(found, 1);
-        //                         }
-        //                     };
-        //                     if (Math.abs(x1 + x1w - x2) < 20) {
-        //                         let linkDoc: Doc = new Doc();
-        //                         linkDoc.title = "Histogram Brush";
-        //                         linkDoc.linkDescription = "Brush between " + StrCast(srcTarg.title) + " and " + StrCast(dstTarg.Title);
-        //                         linkDoc.brushingDocs = new List([dstTarg, srcTarg]);
-
-        //                         brushAction = (field: (Doc | Promise<Doc>)[]) => {
-        //                             if (findBrush(field) === -1) {
-        //                                 field.push(linkDoc);
-        //                             }
-        //                         };
-        //                     }
-        //                     if (dstTarg.brushingDocs === undefined) dstTarg.brushingDocs = new List<Doc>();
-        //                     if (srcTarg.brushingDocs === undefined) srcTarg.brushingDocs = new List<Doc>();
-        //                     let dstBrushDocs = Cast(dstTarg.brushingDocs, listSpec(Doc), []);
-        //                     let srcBrushDocs = Cast(srcTarg.brushingDocs, listSpec(Doc), []);
-        //                     brushAction(dstBrushDocs);
-        //                     brushAction(srcBrushDocs);
-        //                 }
-        //             });
-        //         });
-        //     });
-    }
-    componentWillUnmount() {
-        this._brushReactionDisposer && this._brushReactionDisposer();
-    }
     @computed
     get uniqueConnections() {
         const connections = DocumentManager.Instance.LinkedDocumentViews.reduce((drawnPairs, connection) => {
@@ -101,4 +43,60 @@ export class CollectionFreeFormLinksView extends React.Component {
             {this.props.children}
         </div>;
     }
+    // _brushReactionDisposer?: IReactionDisposer;
+    // componentDidMount() {
+    //     this._brushReactionDisposer = reaction(
+    //         () => {
+    //             let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
+    //             return { doclist: doclist ? doclist : [], xs: doclist.map(d => d.x) };
+    //         },
+    //         () => {
+    //             let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
+    //             let views = doclist ? doclist.filter(doc => StrCast(doc.backgroundLayout).indexOf("istogram") !== -1) : [];
+    //             views.forEach((dstDoc, i) => {
+    //                 views.forEach((srcDoc, j) => {
+    //                     let dstTarg = dstDoc;
+    //                     let srcTarg = srcDoc;
+    //                     let x1 = NumCast(srcDoc.x);
+    //                     let x2 = NumCast(dstDoc.x);
+    //                     let x1w = NumCast(srcDoc.width, -1);
+    //                     let x2w = NumCast(dstDoc.width, -1);
+    //                     if (x1w < 0 || x2w < 0 || i === j) { }
+    //                     else {
+    //                         let findBrush = (field: (Doc | Promise<Doc>)[]) => field.findIndex(brush => {
+    //                             let bdocs = brush instanceof Doc ? Cast(brush.brushingDocs, listSpec(Doc), []) : undefined;
+    //                             return bdocs && bdocs.length && ((bdocs[0] === dstTarg && bdocs[1] === srcTarg)) ? true : false;
+    //                         });
+    //                         let brushAction = (field: (Doc | Promise<Doc>)[]) => {
+    //                             let found = findBrush(field);
+    //                             if (found !== -1) {
+    //                                 field.splice(found, 1);
+    //                             }
+    //                         };
+    //                         if (Math.abs(x1 + x1w - x2) < 20) {
+    //                             let linkDoc: Doc = new Doc();
+    //                             linkDoc.title = "Histogram Brush";
+    //                             linkDoc.linkDescription = "Brush between " + StrCast(srcTarg.title) + " and " + StrCast(dstTarg.Title);
+    //                             linkDoc.brushingDocs = new List([dstTarg, srcTarg]);
+
+    //                             brushAction = (field: (Doc | Promise<Doc>)[]) => {
+    //                                 if (findBrush(field) === -1) {
+    //                                     field.push(linkDoc);
+    //                                 }
+    //                             };
+    //                         }
+    //                         if (dstTarg.brushingDocs === undefined) dstTarg.brushingDocs = new List<Doc>();
+    //                         if (srcTarg.brushingDocs === undefined) srcTarg.brushingDocs = new List<Doc>();
+    //                         let dstBrushDocs = Cast(dstTarg.brushingDocs, listSpec(Doc), []);
+    //                         let srcBrushDocs = Cast(srcTarg.brushingDocs, listSpec(Doc), []);
+    //                         brushAction(dstBrushDocs);
+    //                         brushAction(srcBrushDocs);
+    //                     }
+    //                 });
+    //             });
+    //         });
+    // }
+    // componentWillUnmount() {
+    //     this._brushReactionDisposer?.();
+    // }
 }
\ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 0f94bffd6..276a49570 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -4,7 +4,7 @@ import { Doc, DocListCast, DataSym, WidthSym, HeightSym } from "../../../../new_
 import { InkField, InkData } from "../../../../new_fields/InkField";
 import { List } from "../../../../new_fields/List";
 import { SchemaHeaderField } from "../../../../new_fields/SchemaHeaderField";
-import { Cast, NumCast, FieldValue } from "../../../../new_fields/Types";
+import { Cast, NumCast, FieldValue, StrCast } from "../../../../new_fields/Types";
 import { CurrentUserUtils } from "../../../../server/authentication/models/current_user_utils";
 import { Utils } from "../../../../Utils";
 import { Docs, DocUtils } from "../../../documents/Documents";
@@ -107,7 +107,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
             });
         } else if (!e.ctrlKey) {
             FormattedTextBox.SelectOnLoadChar = FormattedTextBox.DefaultLayout ? e.key : "";
-            let tbox = Docs.Create.TextDocument("", { _width: 200, _height: 100, x: x, y: y, _autoHeight: true, title: "-typed text-" });
+            const tbox = Docs.Create.TextDocument("", { _width: 200, _height: 100, x: x, y: y, _autoHeight: true, title: "-typed text-" });
             const template = FormattedTextBox.DefaultLayout;
             if (template instanceof Doc) {
                 tbox._width = NumCast(template._width);
diff --git a/src/client/views/nodes/ButtonBox.tsx b/src/client/views/nodes/ButtonBox.tsx
index de0b509eb..f1bf7cfcf 100644
--- a/src/client/views/nodes/ButtonBox.tsx
+++ b/src/client/views/nodes/ButtonBox.tsx
@@ -82,7 +82,7 @@ export class ButtonBox extends DocComponent<FieldViewProps, ButtonDocument>(Butt
                 style={{ boxShadow: this.Document.opacity === 0 ? undefined : StrCast(this.Document.boxShadow, "") }}>
                 <div className="buttonBox-mainButton" style={{
                     background: this.Document.backgroundColor, color: this.Document.color || "inherit",
-                    fontSize: this.Document.fontSize, letterSpacing: this.Document.letterSpacing || "", textTransform: this.Document.textTransform || ""
+                    fontSize: this.Document.fontSize, letterSpacing: this.Document.letterSpacing || "", textTransform: (this.Document.textTransform as any) || ""
                 }} >
                     <div className="buttonBox-mainButtonCenter">
                         {(this.Document.text || this.Document.title)}
diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx
index 8632f9c9a..9494a4bc4 100644
--- a/src/client/views/nodes/ContentFittingDocumentView.tsx
+++ b/src/client/views/nodes/ContentFittingDocumentView.tsx
@@ -22,6 +22,7 @@ interface ContentFittingDocumentViewProps {
     childDocs?: Doc[];
     renderDepth: number;
     fitToBox?: boolean;
+    layoutKey?: string;
     dropAction?: dropActionType;
     PanelWidth: () => number;
     PanelHeight: () => number;
@@ -88,6 +89,7 @@ export class ContentFittingDocumentView extends React.Component<ContentFittingDo
                         LayoutDoc={this.props.LayoutDoc}
                         LibraryPath={this.props.LibraryPath}
                         fitToBox={this.props.fitToBox}
+                        layoutKey={this.props.layoutKey}
                         dropAction={this.props.dropAction}
                         onClick={this.props.onClick}
                         backgroundColor={this.props.backgroundColor}
diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx
index 978480142..655dc5de2 100644
--- a/src/client/views/nodes/DocumentBox.tsx
+++ b/src/client/views/nodes/DocumentBox.tsx
@@ -117,13 +117,14 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
                 DataDocument={undefined}
                 LibraryPath={emptyPath}
                 fitToBox={this.props.fitToBox}
+                layoutKey={StrCast(this.props.Document.childLayoutKey)}
                 addDocument={this.props.addDocument}
                 moveDocument={this.props.moveDocument}
                 removeDocument={this.props.removeDocument}
                 addDocTab={this.props.addDocTab}
                 pinToPres={this.props.pinToPres}
                 getTransform={this.getTransform}
-                renderDepth={this.props.renderDepth + 1} // bcz: need a forceActive prop here ... not the same as renderDepth = 0
+                renderDepth={this.props.renderDepth + 1}
                 PanelWidth={this.pwidth}
                 PanelHeight={this.pheight}
                 focus={this.props.focus}
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 8be6ab151..c250da874 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -64,15 +64,18 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
         TraceMobx();
         if (!this.layoutDoc) return "<p>awaiting layout</p>";
         const layout = Cast(this.layoutDoc[StrCast(this.layoutDoc.layoutKey, this.layoutDoc === this.props.Document ? this.props.layoutKey : "layout")], "string");
-        if (layout === undefined) {
-            return this.props.Document.data ?
-                "<FieldView {...props} fieldKey='data' />" :
-                KeyValueBox.LayoutString(this.layoutDoc.proto ? "proto" : "");
-        } else if (typeof layout === "string") {
-            return layout;
-        } else {
-            return "<p>Loading layout</p>";
-        }
+        if (this.props.layoutKey === "layout_keyValue") {
+            return StrCast(this.props.Document.layout_keyValue, KeyValueBox.LayoutString("data"));
+        } else
+            if (layout === undefined) {
+                return this.props.Document.data ?
+                    "<FieldView {...props} fieldKey='data' />" :
+                    KeyValueBox.LayoutString(this.layoutDoc.proto ? "proto" : "");
+            } else if (typeof layout === "string") {
+                return layout;
+            } else {
+                return "<p>Loading layout</p>";
+            }
     }
 
     get dataDoc() {
@@ -81,7 +84,8 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
     }
     get layoutDoc() {
         const params = StrCast(this.props.Document.PARAMS);
-        return Doc.expandTemplateLayout(this.props.LayoutDoc?.() || Doc.Layout(this.props.Document), this.props.Document, params ? "(" + params + ")" : this.props.layoutKey);
+        const template: Doc = this.props.LayoutDoc?.() || Doc.Layout(this.props.Document, this.props.layoutKey ? Cast(this.props.Document[this.props.layoutKey], Doc, null) : undefined);
+        return Doc.expandTemplateLayout(template, this.props.Document, params ? "(" + params + ")" : this.props.layoutKey);
     }
 
     CreateBindings(): JsxBindings {
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index 93bda6d02..3d59ea61a 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -61,6 +61,8 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> {
             fieldKey: this.props.keyName,
             isSelected: returnFalse,
             select: emptyFunction,
+            dropAction:"alias",
+            bringToFront:emptyFunction,
             renderDepth: 1,
             active: returnFalse,
             whenActiveChanged: emptyFunction,
diff --git a/src/client/views/nodes/RadialMenuItem.tsx b/src/client/views/nodes/RadialMenuItem.tsx
index fdc732d3f..bd5b3bff4 100644
--- a/src/client/views/nodes/RadialMenuItem.tsx
+++ b/src/client/views/nodes/RadialMenuItem.tsx
@@ -44,12 +44,12 @@ export class RadialMenuItem extends React.Component<RadialMenuProps> {
 
     setcircle() {
         let circlemin = 0;
-        let circlemax = 1
+        let circlemax = 1;
         this.props.min ? circlemin = this.props.min : null;
         this.props.max ? circlemax = this.props.max : null;
         if (document.getElementById("myCanvas") !== null) {
-            var c: any = document.getElementById("myCanvas");
-            let color = "white"
+            const c: any = document.getElementById("myCanvas");
+            let color = "white";
             switch (circlemin % 3) {
                 case 1:
                     color = "#c2c2c5";
@@ -70,38 +70,38 @@ export class RadialMenuItem extends React.Component<RadialMenuProps> {
 
             }
             if (c.getContext) {
-                var ctx = c.getContext("2d");
+                const ctx = c.getContext("2d");
                 ctx.beginPath();
                 ctx.arc(150, 150, 150, (circlemin / circlemax) * 2 * Math.PI, ((circlemin + 1) / circlemax) * 2 * Math.PI);
                 ctx.arc(150, 150, 50, ((circlemin + 1) / circlemax) * 2 * Math.PI, (circlemin / circlemax) * 2 * Math.PI, true);
                 ctx.fillStyle = color;
-                ctx.fill()
+                ctx.fill();
             }
         }
     }
 
     calculatorx() {
         let circlemin = 0;
-        let circlemax = 1
+        let circlemax = 1;
         this.props.min ? circlemin = this.props.min : null;
         this.props.max ? circlemax = this.props.max : null;
-        let avg = ((circlemin / circlemax) + ((circlemin + 1) / circlemax)) / 2;
-        let degrees = 360 * avg;
-        let x = 100 * Math.cos(degrees * Math.PI / 180);
-        let y = -125 * Math.sin(degrees * Math.PI / 180);
+        const avg = ((circlemin / circlemax) + ((circlemin + 1) / circlemax)) / 2;
+        const degrees = 360 * avg;
+        const x = 100 * Math.cos(degrees * Math.PI / 180);
+        const y = -125 * Math.sin(degrees * Math.PI / 180);
         return x;
     }
 
     calculatory() {
 
         let circlemin = 0;
-        let circlemax = 1
+        let circlemax = 1;
         this.props.min ? circlemin = this.props.min : null;
         this.props.max ? circlemax = this.props.max : null;
-        let avg = ((circlemin / circlemax) + ((circlemin + 1) / circlemax)) / 2;
-        let degrees = 360 * avg;
-        let x = 125 * Math.cos(degrees * Math.PI / 180);
-        let y = -100 * Math.sin(degrees * Math.PI / 180);
+        const avg = ((circlemin / circlemax) + ((circlemin + 1) / circlemax)) / 2;
+        const degrees = 360 * avg;
+        const x = 125 * Math.cos(degrees * Math.PI / 180);
+        const y = -100 * Math.sin(degrees * Math.PI / 180);
         return y;
     }
 
diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index 548066f1c..7c58a5148 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -142,7 +142,7 @@ export class ScreenshotBox extends DocAnnotatableComponent<FieldViewProps, Scree
     toggleRecording = action(async () => {
         this._screenCapture = !this._screenCapture;
         this._videoRef!.srcObject = !this._screenCapture ? undefined : await (navigator.mediaDevices as any).getDisplayMedia({ video: true });
-    })
+    });
 
     private get uIButtons() {
         return (<div className="screenshotBox-uiButtons">
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 591864f2c..838fbefb1 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -63,7 +63,7 @@ export class WebBox extends DocAnnotatableComponent<FieldViewProps, WebDocument>
                 this.layoutDoc._height = NumCast(this.layoutDoc._width) / youtubeaspect;
             }
         } else if (field?.url) {
-            var result = await WebRequest.get(Utils.CorsProxy(field.url.href));
+            const result = await WebRequest.get(Utils.CorsProxy(field.url.href));
             this.dataDoc.text = htmlToText.fromString(result.content);
         }
 
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index a1e7d5c2a..cc187cd67 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -238,7 +238,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
         this._pdfViewer.currentScaleValue = this._zoomed = 1;
         this.gotoPage(this.Document.curPage || 1);
         document.removeEventListener("pagesinit", this.pagesinit);
-    })
+    });
 
     createPdfViewer() {
         if (!this._mainCont.current) { // bcz: I don't think this is ever triggered or needed
diff --git a/src/client/views/webcam/DashWebRTCVideo.tsx b/src/client/views/webcam/DashWebRTCVideo.tsx
index 9c339e986..1d52ba38f 100644
--- a/src/client/views/webcam/DashWebRTCVideo.tsx
+++ b/src/client/views/webcam/DashWebRTCVideo.tsx
@@ -36,7 +36,7 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
       */
     private onEnterKeyDown = (e: React.KeyboardEvent) => {
         if (e.keyCode === 13) {
-            let submittedTitle = this.roomText!.value;
+            const submittedTitle = this.roomText!.value;
             this.roomText!.value = "";
             this.roomText!.blur();
             initialize(submittedTitle, this.changeUILook);
@@ -56,7 +56,7 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
     }
 
     render() {
-        let content =
+        const content =
             <div className="webcam-cont" style={{ width: "100%", height: "100%" }}>
                 <div className="webcam-header">DashWebRTC</div>
                 <input id="roomName" type="text" placeholder="Enter room name" ref={(e) => this.roomText = e!} onKeyDown={this.onEnterKeyDown} />
@@ -72,8 +72,8 @@ export class DashWebRTCVideo extends React.Component<CollectionFreeFormDocumentV
                 </div>
             </div >;
 
-        let frozen = !this.props.isSelected() || DocumentDecorations.Instance.Interacting;
-        let classname = "webBox-cont" + (this.props.isSelected() && !InkingControl.Instance.selectedTool && !DocumentDecorations.Instance.Interacting ? "-interactive" : "");
+        const frozen = !this.props.isSelected() || DocumentDecorations.Instance.Interacting;
+        const classname = "webBox-cont" + (this.props.isSelected() && !InkingControl.Instance.selectedTool && !DocumentDecorations.Instance.Interacting ? "-interactive" : "");
 
 
         return (
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index 5d3a517ae..1d2d57b96 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -199,6 +199,8 @@ export default class MobileInterface extends React.Component {
                         DataDoc={undefined}
                         LibraryPath={emptyPath}
                         fieldKey={""}
+                        dropAction={"alias"}
+                        bringToFront={emptyFunction }
                         addDocTab={returnFalse}
                         pinToPres={emptyFunction}
                         PanelHeight={() => window.innerHeight}
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 25b526168..440f13d6b 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -353,7 +353,7 @@ export namespace Doc {
     // and returns the document who's proto is undefined or whose proto is marked as a base prototype ('isPrototype').
     export function GetProto(doc: Doc): Doc {
         if (doc instanceof Promise) {
-            console.log("GetProto: error: got Promise insead of Doc")
+            console.log("GetProto: error: got Promise insead of Doc");
         }
         const proto = doc && (Doc.GetT(doc, "isPrototype", "boolean", true) ? doc : (doc.proto || doc));
         return proto === doc ? proto : Doc.GetProto(proto);
@@ -697,7 +697,7 @@ export namespace Doc {
     // the document containing the view layout information - will be the Document itself unless the Document has
     // a layout field or 'layout' is given.  
     export function Layout(doc: Doc, layout?: Doc): Doc {
-        const overrideLayout = layout && Cast(doc["data-layout[" + layout[Id] + "]"], Doc, null);
+        const overrideLayout = layout && Cast(doc[`${StrCast(layout.isTemplateForField, "data")}-layout[` + layout[Id] + "]"], Doc, null);
         return overrideLayout || doc[LayoutSym] || doc;
     }
     export function SetLayout(doc: Doc, layout: Doc | string) { doc[StrCast(doc.layoutKey, "layout")] = layout; }
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 3a1fd41f8..8c719ccd8 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -12,7 +12,7 @@ function _readOnlySetter(): never {
     throw new Error("Documents can't be modified in read-only mode");
 }
 
-let tracing = false;
+const tracing = false;
 export function TraceMobx() {
     tracing && trace();
 }
diff --git a/src/server/DashSession/Session/agents/applied_session_agent.ts b/src/server/DashSession/Session/agents/applied_session_agent.ts
index 46c9e22ed..12064668b 100644
--- a/src/server/DashSession/Session/agents/applied_session_agent.ts
+++ b/src/server/DashSession/Session/agents/applied_session_agent.ts
@@ -44,7 +44,7 @@ export abstract class AppliedSessionAgent {
         if (!this.launched) {
             this.launched = true;
             if (isMaster) {
-                this.sessionMonitorRef = Monitor.Create()
+                this.sessionMonitorRef = Monitor.Create();
                 const sessionKey = await this.initializeMonitor(this.sessionMonitorRef);
                 this.sessionMonitorRef.finalize(sessionKey);
             } else {
diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts
index 6f8d25614..ee8afee65 100644
--- a/src/server/DashSession/Session/agents/monitor.ts
+++ b/src/server/DashSession/Session/agents/monitor.ts
@@ -167,7 +167,7 @@ export class Monitor extends IPCMessageReceiver {
      * and pass down any variables the pertinent to the child processes as environment variables.
      */
     private loadAndValidateConfiguration = (): Configuration => {
-        let config: Configuration;
+        let config: Configuration | undefined;
         try {
             console.log(this.timestamp(), cyan("validating configuration..."));
             config = JSON.parse(readFileSync('./session.config.json', 'utf8'));
diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
index 9f0db8330..feff568e1 100644
--- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
+++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
@@ -35,8 +35,8 @@ export type MessageHandler<T = any> = (args: T) => (any | Promise<any>);
  * When a message is emitted, it is embedded with private metadata
  * to facilitate the resolution of promises, etc.
  */
-interface InternalMessage extends Message { metadata: Metadata }
-interface Metadata { isResponse: boolean; id: string }
+interface InternalMessage extends Message { metadata: Metadata; }
+interface Metadata { isResponse: boolean; id: string; }
 type InternalMessageHandler = (message: InternalMessage) => (any | Promise<any>);
 
 /**
@@ -133,7 +133,7 @@ export class PromisifiedIPCManager {
         Object.keys(pendingMessages).forEach(id => {
             const error: ErrorLike = { name: "ManagerDestroyed", message: "The IPC manager was destroyed before the response could be returned." };
             const message: InternalMessage = { name: pendingMessages[id], args: { error }, metadata: { id, isResponse: true } };
-            this.target.send?.(message)
+            this.target.send?.(message);
         });
         this.pendingMessages = {};
     }
diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts
index c5dc22912..9f9fc9619 100644
--- a/src/server/Websocket/Websocket.ts
+++ b/src/server/Websocket/Websocket.ts
@@ -55,8 +55,8 @@ export namespace WebSocket {
             socket.on('create or join', function (room) {
                 console.log('Received request to create or join room ' + room);
 
-                var clientsInRoom = socket.adapter.rooms[room];
-                var numClients = clientsInRoom ? Object.keys(clientsInRoom.sockets).length : 0;
+                const clientsInRoom = socket.adapter.rooms[room];
+                const numClients = clientsInRoom ? Object.keys(clientsInRoom.sockets).length : 0;
                 console.log('Room ' + room + ' now has ' + numClients + ' client(s)');
 
                 if (numClients === 0) {
@@ -76,8 +76,8 @@ export namespace WebSocket {
             });
 
             socket.on('ipaddr', function () {
-                var ifaces = networkInterfaces();
-                for (var dev in ifaces) {
+                const ifaces = networkInterfaces();
+                for (const dev in ifaces) {
                     ifaces[dev].forEach(function (details) {
                         if (details.family === 'IPv4' && details.address !== '127.0.0.1') {
                             socket.emit('ipaddr', details.address);
diff --git a/src/server/database.ts b/src/server/database.ts
index 055f04c49..fc91ff3a2 100644
--- a/src/server/database.ts
+++ b/src/server/database.ts
@@ -328,7 +328,7 @@ export namespace Database {
 
         export const LogUpload = async (information: Upload.ImageInformation) => {
             const bundle = {
-                _id: Utils.GenerateDeterministicGuid(String(information.contentSize!)),
+                _id: Utils.GenerateDeterministicGuid(String(information.contentSize)),
                 ...information
             };
             return Instance.insert(bundle, AuxiliaryCollections.GooglePhotosUploadHistory);
diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts
index 7b2228831..1150118f7 100644
--- a/src/server/server_Initialization.ts
+++ b/src/server/server_Initialization.ts
@@ -123,7 +123,7 @@ function registerCorsProxy(server: express.Express) {
     const headerCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
     server.use("/corsProxy", (req, res) => {
 
-        let requrl = decodeURIComponent(req.url.substring(1));
+        const requrl = decodeURIComponent(req.url.substring(1));
         const referer = req.headers.referer ? decodeURIComponent(req.headers.referer) : "";
         // cors weirdness here... 
         // if the referer is a cors page and the cors() route (I think) redirected to /corsProxy/<path> and the requested url path was relative, 
-- 
cgit v1.2.3-70-g09d2


From b4958eac84339dd7a88c964a9c52e89481048f55 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Thu, 2 Apr 2020 19:39:03 -0400
Subject: supported uploads of images ending with .webp

---
 src/client/views/collections/CollectionView.tsx | 6 +++---
 src/client/views/nodes/ImageBox.tsx             | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index b6ce2f3a9..df1770ffe 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -429,9 +429,9 @@ export class CollectionView extends Touchable<FieldViewProps> {
                         Document={facetCollection}
                         backgroundColor={this.filterBackground}
                         fieldKey={`${this.props.fieldKey}-filter`}
-                        moveDocument={(doc: Doc) => false}
-                        removeDocument={(doc: Doc) => false}
-                        addDocument={(doc: Doc) => false} />
+                        moveDocument={returnFalse}
+                        removeDocument={returnFalse}
+                        addDocument={returnFalse} />
                 </div>
             </div>;
     }
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index e710b3075..00057055f 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -225,7 +225,7 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum
             return url.href;
         } else if (url.href.indexOf(window.location.origin) === -1) {
             return Utils.CorsProxy(url.href);
-        } else if (!/\.(png|jpg|jpeg|gif)$/.test(lower)) {
+        } else if (!/\.(png|jpg|jpeg|gif|webp)$/.test(lower)) {
             return url.href;//Why is this here
         }
         const ext = path.extname(url.href);
-- 
cgit v1.2.3-70-g09d2


From adabfbea2b034beb310530aef9cc8b206e260b67 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Fri, 3 Apr 2020 20:23:15 -0400
Subject: added rootSelected() to make forceActive work better

---
 src/client/documents/Documents.ts                  |  2 +-
 src/client/util/RichTextSchema.tsx                 |  1 +
 src/client/views/DocComponent.tsx                  |  6 +++--
 src/client/views/GestureOverlay.tsx                |  1 +
 src/client/views/MainView.tsx                      |  4 ++++
 src/client/views/OverlayView.tsx                   |  1 +
 src/client/views/Palette.tsx                       | 26 +++++++---------------
 src/client/views/RecommendationsBox.tsx            |  1 +
 src/client/views/SearchDocBox.tsx                  |  3 ++-
 .../views/collections/CollectionDockingView.tsx    |  1 +
 .../views/collections/CollectionLinearView.tsx     |  3 ++-
 .../views/collections/CollectionSchemaView.tsx     |  1 +
 .../views/collections/CollectionStackingView.tsx   |  1 +
 src/client/views/collections/CollectionSubView.tsx |  5 +++++
 .../views/collections/CollectionTreeView.tsx       |  2 ++
 src/client/views/collections/CollectionView.tsx    |  2 +-
 .../collectionFreeForm/CollectionFreeFormView.tsx  |  1 +
 .../collections/collectionFreeForm/MarqueeView.tsx |  1 -
 src/client/views/nodes/AudioBox.tsx                | 12 +++++++---
 .../views/nodes/CollectionFreeFormDocumentView.tsx |  7 +++---
 .../views/nodes/ContentFittingDocumentView.tsx     |  1 +
 src/client/views/nodes/DocumentBox.tsx             |  1 +
 src/client/views/nodes/DocumentContentsView.tsx    |  4 ++--
 src/client/views/nodes/DocumentView.tsx            | 24 +++++++++++++++-----
 src/client/views/nodes/FieldView.tsx               |  1 +
 src/client/views/nodes/FormattedTextBoxComment.tsx |  1 +
 src/client/views/pdf/PDFViewer.tsx                 |  3 +--
 .../views/presentationview/PresElementBox.tsx      |  3 ++-
 src/client/views/search/SearchItem.tsx             |  3 ++-
 src/mobile/MobileInterface.tsx                     |  2 ++
 .../authentication/models/current_user_utils.ts    |  2 +-
 31 files changed, 83 insertions(+), 43 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index a69bfae01..0a2269bac 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -435,7 +435,7 @@ export namespace Docs {
         Scripting.addGlobal(Buxton);
 
         const delegateKeys = ["x", "y", "layoutKey", "_width", "_height", "_panX", "_panY", "_viewType", "_nativeWidth", "_nativeHeight", "dropAction", "childDropAction", "_annotationOn",
-            "_chromeStatus", "_forceActive", "_autoHeight", "_fitWidth", "_LODdisable", "_itemIndex", "_showSidebar", "_showTitle", "_showCaption", "_showTitleHover", "_backgroundColor",
+            "_chromeStatus", "_autoHeight", "_fitWidth", "_LODdisable", "_itemIndex", "_showSidebar", "_showTitle", "_showCaption", "_showTitleHover", "_backgroundColor",
             "_xMargin", "_yMargin", "_xPadding", "_yPadding", "_singleLine", "_scrollTop",
             "_color", "isButton", "isBackground", "removeDropProperties", "treeViewOpen"];
 
diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index 094cd58f3..4a930177d 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -818,6 +818,7 @@ export class DashDocView {
                     LibraryPath={this._textBox.props.LibraryPath}
                     fitToBox={BoolCast(dashDoc._fitToBox)}
                     addDocument={returnFalse}
+                    rootSelected={this._textBox.props.isSelected}
                     removeDocument={removeDoc}
                     ScreenToLocalTransform={this.getDocTransform}
                     addDocTab={this._textBox.props.addDocTab}
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index f4e830a48..454c245cc 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -29,6 +29,7 @@ interface DocExtendableProps {
     fieldKey: string;
     isSelected: (outsideReaction?: boolean) => boolean;
     renderDepth: number;
+    rootSelected: () => boolean;
 }
 export function DocExtendableComponent<P extends DocExtendableProps, T>(schemaCtor: (doc: Doc) => T) {
     class Component extends Touchable<P> {
@@ -36,7 +37,7 @@ export function DocExtendableComponent<P extends DocExtendableProps, T>(schemaCt
         @computed get Document(): T { return schemaCtor(this.props.Document); }
         @computed get layoutDoc() { return Doc.Layout(this.props.Document); }
         @computed get dataDoc() { return (this.props.DataDoc && (this.props.Document.isTemplateForField || this.props.Document.isTemplateDoc) ? this.props.DataDoc : Cast(this.props.Document.resolvedDataDoc, Doc, null) || Doc.GetProto(this.props.Document)) as Doc; }
-        active = (outsideReaction?: boolean) => !this.props.Document.isBackground && (this.props.Document.forceActive || this.props.isSelected(outsideReaction) || this.props.renderDepth === 0);//  && !InkingControl.Instance.selectedTool;  // bcz: inking state shouldn't affect static tools 
+        active = (outsideReaction?: boolean) => !this.props.Document.isBackground && ((this.props.Document.forceActive && this.props.rootSelected()) || this.props.isSelected(outsideReaction) || this.props.renderDepth === 0);//  && !InkingControl.Instance.selectedTool;  // bcz: inking state shouldn't affect static tools 
     }
     return Component;
 }
@@ -50,6 +51,7 @@ export interface DocAnnotatableProps {
     active: () => boolean;
     whenActiveChanged: (isActive: boolean) => void;
     isSelected: (outsideReaction?: boolean) => boolean;
+    rootSelected: () => boolean;
     renderDepth: number;
 }
 export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schemaCtor: (doc: Doc) => T) {
@@ -86,7 +88,7 @@ export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schema
 
         whenActiveChanged = action((isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive));
         active = (outsideReaction?: boolean) => ((InkingControl.Instance.selectedTool === InkTool.None && !this.props.Document.isBackground) &&
-            (this.props.Document.forceActive || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
+            ((this.props.Document.forceActive && this.props.rootSelected()) || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
         annotationsActive = (outsideReaction?: boolean) => (InkingControl.Instance.selectedTool !== InkTool.None ||
             (this.props.Document.forceActive || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
     }
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index ea60907f6..26bee9a6f 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -705,6 +705,7 @@ export default class GestureOverlay extends Touchable {
                 LibraryPath={emptyPath}
                 addDocument={undefined}
                 addDocTab={returnFalse}
+                rootSelected={returnTrue}
                 pinToPres={emptyFunction}
                 onClick={undefined}
                 removeDocument={undefined}
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 8d9be5980..fae520e40 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -309,6 +309,7 @@ export class MainView extends React.Component {
             addDocument={undefined}
             addDocTab={this.addDocTabFunc}
             pinToPres={emptyFunction}
+            rootSelected={returnTrue}
             onClick={undefined}
             backgroundColor={this.defaultBackgroundColors}
             removeDocument={undefined}
@@ -407,6 +408,7 @@ export class MainView extends React.Component {
                     DataDoc={undefined}
                     LibraryPath={emptyPath}
                     addDocument={undefined}
+                    rootSelected={returnTrue}
                     addDocTab={this.addDocTabFunc}
                     pinToPres={emptyFunction}
                     removeDocument={undefined}
@@ -435,6 +437,7 @@ export class MainView extends React.Component {
                     addDocument={undefined}
                     addDocTab={this.addDocTabFunc}
                     pinToPres={emptyFunction}
+                    rootSelected={returnTrue}
                     removeDocument={returnFalse}
                     onClick={undefined}
                     ScreenToLocalTransform={this.mainContainerXf}
@@ -523,6 +526,7 @@ export class MainView extends React.Component {
                     fieldKey={"data"}
                     dropAction={"alias"}
                     annotationsKey={""}
+                    rootSelected={returnTrue}
                     bringToFront={emptyFunction}
                     select={emptyFunction}
                     active={returnFalse}
diff --git a/src/client/views/OverlayView.tsx b/src/client/views/OverlayView.tsx
index 220efd4a8..7587071db 100644
--- a/src/client/views/OverlayView.tsx
+++ b/src/client/views/OverlayView.tsx
@@ -174,6 +174,7 @@ export class OverlayView extends React.Component {
                     Document={d}
                     LibraryPath={emptyPath}
                     ChromeHeight={returnZero}
+                    rootSelected={returnTrue}
                     // isSelected={returnFalse}
                     // select={emptyFunction}
                     // layoutKey={"layout"}
diff --git a/src/client/views/Palette.tsx b/src/client/views/Palette.tsx
index e04f814d1..674b27918 100644
--- a/src/client/views/Palette.tsx
+++ b/src/client/views/Palette.tsx
@@ -1,23 +1,12 @@
+import { IReactionDisposer, observable, reaction } from "mobx";
+import { observer } from "mobx-react";
 import * as React from "react";
-import "./Palette.scss";
-import { PointData } from "../../new_fields/InkField";
 import { Doc } from "../../new_fields/Doc";
-import { Docs } from "../documents/Documents";
-import { ScriptField, ComputedField } from "../../new_fields/ScriptField";
-import { List } from "../../new_fields/List";
-import { DocumentView } from "./nodes/DocumentView";
-import { emptyPath, returnFalse, emptyFunction, returnOne, returnEmptyString, returnTrue } from "../../Utils";
-import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
+import { NumCast } from "../../new_fields/Types";
+import { emptyFunction, emptyPath, returnEmptyString, returnFalse, returnOne, returnTrue } from "../../Utils";
 import { Transform } from "../util/Transform";
-import { computed, action, IReactionDisposer, reaction, observable } from "mobx";
-import { FieldValue, Cast, NumCast } from "../../new_fields/Types";
-import { observer } from "mobx-react";
-import { DocumentContentsView } from "./nodes/DocumentContentsView";
-import { CollectionStackingView } from "./collections/CollectionStackingView";
-import { CollectionView } from "./collections/CollectionView";
-import { CollectionSubView, SubCollectionViewProps } from "./collections/CollectionSubView";
-import { makeInterface } from "../../new_fields/Schema";
-import { documentSchema } from "../../new_fields/documentSchemas";
+import { DocumentView } from "./nodes/DocumentView";
+import "./Palette.scss";
 
 export interface PaletteProps {
     x: number;
@@ -40,7 +29,7 @@ export default class Palette extends React.Component<PaletteProps> {
     }
 
     componentWillUnmount = () => {
-        this._selectedDisposer && this._selectedDisposer();
+        this._selectedDisposer?.();
     }
 
     render() {
@@ -54,6 +43,7 @@ export default class Palette extends React.Component<PaletteProps> {
                             LibraryPath={emptyPath}
                             addDocument={undefined}
                             addDocTab={returnFalse}
+                            rootSelected={returnTrue}
                             pinToPres={emptyFunction}
                             removeDocument={undefined}
                             onClick={undefined}
diff --git a/src/client/views/RecommendationsBox.tsx b/src/client/views/RecommendationsBox.tsx
index 5ebba0abb..bf8de36b4 100644
--- a/src/client/views/RecommendationsBox.tsx
+++ b/src/client/views/RecommendationsBox.tsx
@@ -68,6 +68,7 @@ export class RecommendationsBox extends React.Component<FieldViewProps> {
                 addDocument={returnFalse}
                 LibraryPath={emptyPath}
                 removeDocument={returnFalse}
+                rootSelected={returnFalse}
                 ScreenToLocalTransform={Transform.Identity}
                 addDocTab={returnFalse}
                 pinToPres={returnFalse}
diff --git a/src/client/views/SearchDocBox.tsx b/src/client/views/SearchDocBox.tsx
index c57f9e737..e66de39d4 100644
--- a/src/client/views/SearchDocBox.tsx
+++ b/src/client/views/SearchDocBox.tsx
@@ -410,8 +410,9 @@ export class SearchDocBox extends React.Component<FieldViewProps> {
             <div style={{ pointerEvents: "all" }}>
                 <ContentFittingDocumentView {...this.props}
                     Document={this.content}
+                    rootSelected={returnFalse}
                     getTransform={this.props.ScreenToLocalTransform}>
-                    </ContentFittingDocumentView>
+                </ContentFittingDocumentView>
                 <div
                     style={{
                         position: "absolute",
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 4e1e76f39..4209bd574 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -788,6 +788,7 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
             Document={document}
             DataDoc={resolvedDataDoc}
             bringToFront={emptyFunction}
+            rootSelected={returnTrue}
             addDocument={undefined}
             removeDocument={undefined}
             ContentScaling={this.contentScaling}
diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx
index 344605412..a6ada75b2 100644
--- a/src/client/views/collections/CollectionLinearView.tsx
+++ b/src/client/views/collections/CollectionLinearView.tsx
@@ -4,7 +4,7 @@ import * as React from 'react';
 import { Doc, HeightSym, WidthSym } from '../../../new_fields/Doc';
 import { makeInterface } from '../../../new_fields/Schema';
 import { BoolCast, NumCast, StrCast, Cast } from '../../../new_fields/Types';
-import { emptyFunction, returnEmptyString, returnOne, returnTrue, Utils } from '../../../Utils';
+import { emptyFunction, returnEmptyString, returnOne, returnTrue, Utils, returnFalse } from '../../../Utils';
 import { DragManager } from '../../util/DragManager';
 import { Transform } from '../../util/Transform';
 import "./CollectionLinearView.scss";
@@ -110,6 +110,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
                                 moveDocument={this.props.moveDocument}
                                 addDocTab={this.props.addDocTab}
                                 pinToPres={emptyFunction}
+                                rootSelected={this.props.isSelected}
                                 removeDocument={this.props.removeDocument}
                                 onClick={undefined}
                                 ScreenToLocalTransform={this.getTransform(dref)}
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 981438513..a1b541f74 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -124,6 +124,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
                 LibraryPath={this.props.LibraryPath}
                 childDocs={this.childDocs}
                 renderDepth={this.props.renderDepth}
+                rootSelected={this.rootSelected}
                 PanelWidth={this.previewWidth}
                 PanelHeight={this.previewHeight}
                 getTransform={this.getPreviewTransform}
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 076dd3629..d21e17bbc 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -176,6 +176,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
             LibraryPath={this.props.LibraryPath}
             renderDepth={this.props.renderDepth + 1}
             fitToBox={this.props.fitToBox}
+            rootSelected={this.rootSelected}
             dropAction={StrCast(this.props.Document.childDropAction) as dropActionType}
             onClick={layoutDoc.isTemplateDoc ? this.onClickHandler : this.onChildClickHandler}
             PanelWidth={width}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 70927cf22..d1d6ae3c1 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -34,6 +34,7 @@ export interface CollectionViewProps extends FieldViewProps {
     PanelHeight: () => number;
     VisibleHeight?: () => number;
     setPreviewCursor?: (func: (x: number, y: number, drag: boolean) => void) => void;
+    rootSelected: () => boolean;
     fieldKey: string;
 }
 
@@ -95,6 +96,10 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 this.props.Document.resolvedDataDoc ? this.props.Document : Doc.GetProto(this.props.Document)); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
         }
 
+        rootSelected = () => {
+            return this.props.isSelected() || (this.props.Document.rootDocument || this.props.Document.forceActive ? this.props.rootSelected() : false);
+        }
+
         // The data field for rendering this collection will be on the this.props.Document unless we're rendering a template in which case we try to use props.DataDoc.
         // When a document has a DataDoc but it's not a template, then it contains its own rendering data, but needs to pass the DataDoc through
         // to its children which may be templates.
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 6ee48f11b..fc612c66d 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -373,6 +373,7 @@ class TreeView extends React.Component<TreeViewProps> {
                     DataDocument={this.templateDataDoc}
                     LibraryPath={emptyPath}
                     renderDepth={this.props.renderDepth + 1}
+                    rootSelected={returnTrue}
                     backgroundColor={this.props.backgroundColor}
                     fitToBox={this.boundsOfCollectionDocument !== undefined}
                     PanelWidth={this.docWidth}
@@ -454,6 +455,7 @@ class TreeView extends React.Component<TreeViewProps> {
                         LibraryPath={this.props.libraryPath || []}
                         addDocument={undefined}
                         addDocTab={this.props.addDocTab}
+                        rootSelected={returnTrue}
                         pinToPres={emptyFunction}
                         onClick={this.props.onChildClick || editTitle}
                         dropAction={this.props.dropAction}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index df1770ffe..3913ccd88 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -117,7 +117,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         return viewField;
     }
 
-    active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || BoolCast(this.props.Document.forceActive) || this._isChildActive || this.props.renderDepth === 0;
+    active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || (this.props.rootSelected() && BoolCast(this.props.Document.forceActive)) || this._isChildActive || this.props.renderDepth === 0;
 
     whenActiveChanged = (isActive: boolean) => { this.props.whenActiveChanged(this._isChildActive = isActive); };
 
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 2871fe192..a164e1794 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -832,6 +832,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
             Document: childLayout,
             LibraryPath: this.libraryPath,
             layoutKey: undefined,
+            rootSelected: this.rootSelected,
             dropAction: StrCast(this.props.Document.childDropAction) as dropActionType,
             //onClick: undefined, // this.props.onClick,  // bcz: check this out -- I don't think we want to inherit click handlers, or we at least need a way to ignore them
             onClick: this.onChildClickHandler,
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 276a49570..503df10c2 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -5,7 +5,6 @@ import { InkField, InkData } from "../../../../new_fields/InkField";
 import { List } from "../../../../new_fields/List";
 import { SchemaHeaderField } from "../../../../new_fields/SchemaHeaderField";
 import { Cast, NumCast, FieldValue, StrCast } from "../../../../new_fields/Types";
-import { CurrentUserUtils } from "../../../../server/authentication/models/current_user_utils";
 import { Utils } from "../../../../Utils";
 import { Docs, DocUtils } from "../../../documents/Documents";
 import { SelectionManager } from "../../../util/SelectionManager";
diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx
index 03b2a2297..bd54d64ff 100644
--- a/src/client/views/nodes/AudioBox.tsx
+++ b/src/client/views/nodes/AudioBox.tsx
@@ -7,7 +7,7 @@ import { AudioField, nullAudio } from "../../../new_fields/URLField";
 import { DocExtendableComponent } from "../DocComponent";
 import { makeInterface, createSchema } from "../../../new_fields/Schema";
 import { documentSchema } from "../../../new_fields/documentSchemas";
-import { Utils, returnTrue, emptyFunction, returnOne, returnTransparent } from "../../../Utils";
+import { Utils, returnTrue, emptyFunction, returnOne, returnTransparent, returnFalse } from "../../../Utils";
 import { runInAction, observable, reaction, IReactionDisposer, computed, action } from "mobx";
 import { DateField } from "../../../new_fields/DateField";
 import { SelectionManager } from "../../util/SelectionManager";
@@ -258,9 +258,15 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume
                                 return !linkTime ? (null) :
                                     <div className={this.props.PanelHeight() < 32 ? "audiobox-marker-minicontainer" : "audiobox-marker-container"} key={l[Id]} style={{ left: `${linkTime / NumCast(this.dataDoc.duration, 1) * 100}%` }}>
                                         <div className={this.props.PanelHeight() < 32 ? "audioBox-linker-mini" : "audioBox-linker"} key={"linker" + i}>
-                                            <DocumentView {...this.props} Document={l} layoutKey={Doc.LinkEndpoint(l, la2)}
+                                            <DocumentView {...this.props}
+                                                Document={l}
+                                                rootSelected={returnFalse}
+                                                layoutKey={Doc.LinkEndpoint(l, la2)}
                                                 ContainingCollectionDoc={this.props.Document}
-                                                parentActive={returnTrue} bringToFront={emptyFunction} zoomToScale={emptyFunction} getScale={returnOne}
+                                                parentActive={returnTrue}
+                                                bringToFront={emptyFunction}
+                                                zoomToScale={emptyFunction}
+                                                getScale={returnOne}
                                                 backgroundColor={returnTransparent} />
                                         </div>
                                         <div key={i} className="audiobox-marker" onPointerEnter={() => Doc.linkFollowHighlight(la1)}
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index eaab4086c..356192797 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -89,14 +89,15 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
                 pointerEvents: this.props.Document.isBackground ? "none" : undefined
             }} >
 
-            {!this.props.fitToBox ? <DocumentView {...this.props}
+            {!this.props.fitToBox ? 
+            <DocumentView {...this.props}
                 dragDivName={"collectionFreeFormDocumentView-container"}
                 ContentScaling={this.contentScaling}
                 ScreenToLocalTransform={this.getTransform}
                 backgroundColor={this.props.backgroundColor}
                 PanelWidth={this.panelWidth}
-                PanelHeight={this.panelHeight}
-            /> : <ContentFittingDocumentView {...this.props}
+                PanelHeight={this.panelHeight} /> 
+            : <ContentFittingDocumentView {...this.props}
                 CollectionDoc={this.props.ContainingCollectionDoc}
                 DataDocument={this.props.DataDoc}
                 getTransform={this.getTransform}
diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx
index 9494a4bc4..fdf2a9551 100644
--- a/src/client/views/nodes/ContentFittingDocumentView.tsx
+++ b/src/client/views/nodes/ContentFittingDocumentView.tsx
@@ -40,6 +40,7 @@ interface ContentFittingDocumentViewProps {
     addDocTab: (document: Doc, where: string) => boolean;
     pinToPres: (document: Doc) => void;
     dontRegisterView?: boolean;
+    rootSelected: () => boolean;
 }
 
 @observer
diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx
index debe104d7..47118e758 100644
--- a/src/client/views/nodes/DocumentBox.tsx
+++ b/src/client/views/nodes/DocumentBox.tsx
@@ -122,6 +122,7 @@ export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxS
             CollectionView={this as any} // bcz: hack!  need to pass a prop that can be used to select the container (ie, 'this') when the up selector in document decorations is clicked.  currently, the up selector allows only a containing collection to be selected
             fitToBox={this.props.fitToBox}
             layoutKey={"layout_" + childTemplateName}
+            rootSelected={this.props.isSelected}
             addDocument={this.props.addDocument}
             moveDocument={this.props.moveDocument}
             removeDocument={this.props.removeDocument}
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index fc61487e5..687137adc 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -1,6 +1,6 @@
 import { computed } from "mobx";
 import { observer } from "mobx-react";
-import { Doc } from "../../../new_fields/Doc";
+import { Doc, Opt } from "../../../new_fields/Doc";
 import { Cast, StrCast } from "../../../new_fields/Types";
 import { OmitKeys, Without } from "../../../Utils";
 import { HistogramBox } from "../../northstar/dash-nodes/HistogramBox";
@@ -62,7 +62,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
     forceLayout?: string,
     forceFieldKey?: string,
     hideOnLeave?: boolean,
-    makeLink?: () => Opt<Doc>;
+    makeLink?: () => Opt<Doc>,  // function to call when a link is made
 }> {
     @computed get layout(): string {
         TraceMobx();
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 1e02ab44e..42f5fb946 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -60,6 +60,7 @@ export interface DocumentViewProps {
     LayoutDoc?: () => Opt<Doc>;
     LibraryPath: Doc[];
     fitToBox?: boolean;
+    rootSelected: () => boolean; // whether the root of a template has been selected
     onClick?: ScriptField;
     onPointerDown?: ScriptField;
     onPointerUp?: ScriptField;
@@ -277,7 +278,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         this.dontDecorateSelection = this.props.Document.dontDecorateSelection && (!e.ctrlKey || e.button < 2);
         if (!e.nativeEvent.cancelBubble && !this.Document.ignoreClick &&
             (Math.abs(e.clientX - this._downX) < Utils.DRAG_THRESHOLD && Math.abs(e.clientY - this._downY) < Utils.DRAG_THRESHOLD)) {
-            e.stopPropagation();
+            let stopPropagate = true;
             let preventDefault = true;
             this.props.bringToFront(this.props.Document);
             if (this._doubleTap && this.props.renderDepth && !this.onClickHandler?.script) { // disable double-click to show full screen for things that have an on click behavior since clicking them twice can be misinterpreted as a double click
@@ -301,9 +302,14 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 SelectionManager.SelectDoc(this, e.ctrlKey); // don't think this should happen if a button action is actually triggered.
                 UndoManager.RunInBatch(() => this.buttonClick(e.altKey, e.ctrlKey), "on link button follow");
             } else {
-                SelectionManager.SelectDoc(this, e.ctrlKey);
+                if (this.props.Document.isTemplateForField && !(e.ctrlKey || e.button > 0)) {
+                    stopPropagate = false;
+                } else {
+                    SelectionManager.SelectDoc(this, e.ctrlKey);
+                }
                 preventDefault = false;
             }
+            stopPropagate && e.stopPropagation();
             preventDefault && e.preventDefault();
         }
     }
@@ -928,6 +934,9 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         const fallback = Cast(this.props.Document.layoutKey, "string");
         return typeof fallback === "string" ? fallback : "layout";
     }
+    rootSelected = () => {
+        return this.isSelected(false) || (this.props.Document.forceActive && this.props.rootSelected?.() ? true : false);
+    }
     childScaling = () => (this.layoutDoc._fitWidth ? this.props.PanelWidth() / this.nativeWidth : this.props.ContentScaling());
     @computed get contents() {
         TraceMobx();
@@ -937,6 +946,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             DataDoc={this.props.DataDoc}
             LayoutDoc={this.props.LayoutDoc}
             makeLink={this.makeLink}
+            rootSelected={this.rootSelected}
             fitToBox={this.props.fitToBox}
             LibraryPath={this.props.LibraryPath}
             addDocument={this.props.addDocument}
@@ -985,9 +995,13 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 {StrCast(this.props.Document.title)}
                 {this.Document.links && DocListCast(this.Document.links).filter(d => !d.hidden).filter(this.isNonTemporalLink).map((d, i) =>
                     <div className="documentView-docuLinkWrapper" style={{ position: "absolute", top: 0, left: 0 }} key={`${d[Id]}`}>
-                        <DocumentView {...this.props} Document={d} ContainingCollectionDoc={this.props.Document}
-                            PanelWidth={returnOne} PanelHeight={returnOne} layoutKey={this.linkEndpoint(d)} ContentScaling={returnOne}
-                            backgroundColor={returnTransparent} removeDocument={undoBatch(doc => doc.hidden = true)} />
+                        <DocumentView {...this.props}
+                            Document={d}
+                            ContainingCollectionDoc={this.props.Document}
+                            PanelWidth={returnOne} PanelHeight={returnOne}
+                            layoutKey={this.linkEndpoint(d)} ContentScaling={returnOne}
+                            backgroundColor={returnTransparent}
+                            removeDocument={undoBatch(doc => doc.hidden = true)} />
                     </div>)}
             </div>;
         }
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 0305f43d5..13a1becf7 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -29,6 +29,7 @@ export interface FieldViewProps {
     dropAction: dropActionType;
     isSelected: (outsideReaction?: boolean) => boolean;
     select: (isCtrlPressed: boolean) => void;
+    rootSelected: () => boolean;
     renderDepth: number;
     addDocument?: (document: Doc) => boolean;
     addDocTab: (document: Doc, where: string) => boolean;
diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx
index 61df188f8..d1a563494 100644
--- a/src/client/views/nodes/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/FormattedTextBoxComment.tsx
@@ -181,6 +181,7 @@ export class FormattedTextBoxComment {
                                     LibraryPath={emptyPath}
                                     fitToBox={true}
                                     moveDocument={returnFalse}
+                                    rootSelected={returnFalse}
                                     getTransform={Transform.Identity}
                                     active={returnFalse}
                                     addDocument={returnFalse}
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 71495d95f..c032f019d 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -31,8 +31,6 @@ import { InkingControl } from "../InkingControl";
 import { InkTool } from "../../../new_fields/InkField";
 import { TraceMobx } from "../../../new_fields/util";
 import { PdfField } from "../../../new_fields/URLField";
-import { PDFBox } from "../nodes/PDFBox";
-import { FormattedTextBox } from "../nodes/FormattedTextBox";
 import { DocumentView } from "../nodes/DocumentView";
 const PDFJSViewer = require("pdfjs-dist/web/pdf_viewer");
 const pdfjsLib = require("pdfjs-dist");
@@ -61,6 +59,7 @@ interface IViewerProps {
     PanelHeight: () => number;
     ContentScaling: () => number;
     select: (isCtrlPressed: boolean) => void;
+    rootSelected: () => boolean;
     startupLive: boolean;
     renderDepth: number;
     focus: (doc: Doc) => void;
diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx
index 758795ed5..7ad3474e8 100644
--- a/src/client/views/presentationview/PresElementBox.tsx
+++ b/src/client/views/presentationview/PresElementBox.tsx
@@ -9,7 +9,7 @@ import { documentSchema } from '../../../new_fields/documentSchemas';
 import { Id } from "../../../new_fields/FieldSymbols";
 import { createSchema, makeInterface } from '../../../new_fields/Schema';
 import { Cast, NumCast } from "../../../new_fields/Types";
-import { emptyFunction, emptyPath, returnFalse } from "../../../Utils";
+import { emptyFunction, emptyPath, returnFalse, returnTrue } from "../../../Utils";
 import { Transform } from "../../util/Transform";
 import { CollectionViewType } from '../collections/CollectionView';
 import { DocExtendableComponent } from '../DocComponent';
@@ -175,6 +175,7 @@ export class PresElementBox extends DocExtendableComponent<FieldViewProps, PresD
                     DataDocument={this.targetDoc[DataSym] !== this.targetDoc && this.targetDoc[DataSym]}
                     LibraryPath={emptyPath}
                     fitToBox={true}
+                    rootSelected={returnTrue}
                     addDocument={returnFalse}
                     removeDocument={returnFalse}
                     addDocTab={returnFalse}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 63cef5101..0d77026ad 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -7,7 +7,7 @@ import { observer } from "mobx-react";
 import { Doc } from "../../../new_fields/Doc";
 import { Id } from "../../../new_fields/FieldSymbols";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { emptyFunction, emptyPath, returnFalse, Utils } from "../../../Utils";
+import { emptyFunction, emptyPath, returnFalse, Utils, returnTrue } from "../../../Utils";
 import { DocumentType } from "../../documents/DocumentTypes";
 import { DocumentManager } from "../../util/DocumentManager";
 import { DragManager, SetupDrag } from "../../util/DragManager";
@@ -158,6 +158,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
                 <ContentFittingDocumentView
                     Document={this.props.doc}
                     LibraryPath={emptyPath}
+                    rootSelected={returnFalse}
                     fitToBox={StrCast(this.props.doc.type).indexOf(DocumentType.COL) !== -1}
                     addDocument={returnFalse}
                     removeDocument={returnFalse}
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index 1d2d57b96..98a6d384e 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -124,6 +124,7 @@ export default class MobileInterface extends React.Component {
                 addDocument={returnFalse}
                 addDocTab={returnFalse}
                 pinToPres={emptyFunction}
+                rootSelected={returnFalse}
                 removeDocument={undefined}
                 onClick={undefined}
                 ScreenToLocalTransform={Transform.Identity}
@@ -285,6 +286,7 @@ export default class MobileInterface extends React.Component {
                         addDocument={returnFalse}
                         addDocTab={returnFalse}
                         pinToPres={emptyFunction}
+                        rootSelected={returnFalse}
                         removeDocument={undefined}
                         onClick={undefined}
                         ScreenToLocalTransform={Transform.Identity}
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 9a90ce17f..7fe623f18 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -213,7 +213,7 @@ export class CurrentUserUtils {
             _width: 35, _height: 25, title: "Tools", fontSize: 10, targetContainer: sidebarContainer, dontDecorateSelection: true,
             letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
             sourcePanel: Docs.Create.StackingDocument([dragCreators, color], {
-                _width: 500, lockedPosition: true, _chromeStatus: "disabled", title: "tools stack"
+                _width: 500, lockedPosition: true, _chromeStatus: "disabled", title: "tools stack", forceActive: true
             }),
             onClick: ScriptField.MakeScript("this.targetContainer.proto = this.sourcePanel"),
         });
-- 
cgit v1.2.3-70-g09d2


From 0a6def774881f8b0c4164b8638e3f266f232ff07 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Fri, 3 Apr 2020 21:53:05 -0400
Subject: fixed queryView template a bit.

---
 src/client/documents/Documents.ts                      | 1 +
 src/client/views/collections/CollectionView.tsx        | 2 +-
 src/client/views/nodes/QueryBox.tsx                    | 2 +-
 src/client/views/search/SearchBox.scss                 | 2 +-
 src/server/authentication/models/current_user_utils.ts | 8 ++++----
 5 files changed, 8 insertions(+), 7 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 0a2269bac..c5b080ffb 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -103,6 +103,7 @@ export interface DocumentOptions {
     isDisplayPanel?: boolean; // whether the panel functions as GoldenLayout "stack" used to display documents
     forceActive?: boolean;
     layout?: string | Doc;
+    hideFilterView?: boolean; // whether to hide the filter popout on collections
     hideHeadings?: boolean; // whether stacking view column headings should be hidden
     isTemplateForField?: string; // the field key for which the containing document is a rendering template
     isTemplateDoc?: boolean;
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 3913ccd88..23d701ffd 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -463,7 +463,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
                         Utils.CorsProxy(Cast(d.data, ImageField)!.url.href) : Cast(d.data, ImageField)!.url.href
                     :
                     ""))}
-            {!this.props.isSelected() || this.props.PanelHeight() < 100 ? (null) :
+            {!this.props.isSelected() || this.props.PanelHeight() < 100 || this.props.Document.hideFilterView ? (null) :
                 <div className="collectionTimeView-dragger" key="dragger" onPointerDown={this.onPointerDown} style={{ transform: `translate(${this.facetWidth()}px, 0px)` }} >
                     <span title="library View Dragger" style={{ width: "5px", position: "absolute", top: "0" }} />
                 </div>
diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index 566c07dfe..7016b4f04 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -27,7 +27,7 @@ export class QueryBox extends DocAnnotatableComponent<FieldViewProps, QueryDocum
 
     render() {
         const dragging = !SelectionManager.GetIsDragging() ? "" : "-dragging";
-        return <div className={`queryBox${dragging}`} >
+        return <div className={`queryBox${dragging}`} onWheel={(e) => e.stopPropagation()} >
             <SearchBox id={this.props.Document[Id]} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQquery={StrCast(this.dataDoc.filterQuery)} />
         </div >;
     }
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index ec4eda643..f0223ca76 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -9,7 +9,7 @@
     position: absolute;
     font-size: 10px;
     line-height: 1;
-    overflow: hidden;
+    overflow: auto;
     background: lightgrey,
 }
 
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 5b49e3c2d..e34a9b958 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -251,7 +251,7 @@ export class CurrentUserUtils {
         return Docs.Create.ButtonDocument({
             _width: 50, _height: 25, title: "Search", fontSize: 10, dontDecorateSelection: true,
             letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-            sourcePanel: Docs.Create.QueryDocument({ title: "search stack",  }),
+            sourcePanel: Docs.Create.QueryDocument({ title: "search stack", }),
             targetContainer: sidebarContainer,
             lockedPosition: true,
             onClick: ScriptField.MakeScript("this.targetContainer.proto = this.sourcePanel")
@@ -278,12 +278,12 @@ export class CurrentUserUtils {
 
     /// sets up the default list of buttons to be shown in the expanding button menu at the bottom of the Dash window
     static setupExpandingButtons(doc: Doc) {
-        const queryTemplate = Docs.Create.MultirowDocument(
+        const queryTemplate = Docs.Create.MulticolumnDocument(
             [
                 Docs.Create.QueryDocument({ title: "query", _height: 200 }),
-                Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true, forceActive: true})
+                Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true, forceActive: true })
             ],
-            { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, _autoHeight: false, forceActive: true });
+            { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, _autoHeight: false, forceActive: true, hideFilterView: true });
         queryTemplate.isTemplateDoc = makeTemplate(queryTemplate);
         const slideTemplate = Docs.Create.MultirowDocument(
             [
-- 
cgit v1.2.3-70-g09d2


From 644cf9b52bd59221167f4edd840a45941e1a238a Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Fri, 3 Apr 2020 23:58:49 -0400
Subject: from last

---
 src/client/views/TemplateMenu.tsx               | 2 +-
 src/client/views/collections/CollectionView.tsx | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index 3fb330840..f2fb26679 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -161,7 +161,7 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
             );
         }
         return <ul className="template-list" style={{ display: "block" }}>
-            <input placeholder="+ layout" ref={this._customRef} onKeyPress={this.onCustomKeypress}></input>
+            <input placeholder="+ layout" ref={this._customRef} onKeyPress={this.onCustomKeypress}/>
             {templateMenu}
         </ul>;
     }
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 23d701ffd..c4f9e873c 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -282,7 +282,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
 
     bodyPanelWidth = () => this.props.PanelWidth() - this.facetWidth();
     getTransform = () => this.props.ScreenToLocalTransform().translate(-this.facetWidth(), 0);
-    facetWidth = () => Math.min(this.props.PanelWidth() - 25, this._facetWidth);
+    facetWidth = () => Math.max(0, Math.min(this.props.PanelWidth() - 25, this._facetWidth));
 
     @computed get dataDoc() {
         return (this.props.DataDoc && this.props.Document.isTemplateForField ? Doc.GetProto(this.props.DataDoc) :
-- 
cgit v1.2.3-70-g09d2


From 7961a79950ce4b26c6715383dae455ced995a7c4 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 4 Apr 2020 00:21:08 -0400
Subject: fixed not-selection buttons when clicked.

---
 src/client/util/DropConverter.ts                       | 5 ++++-
 src/client/views/collections/CollectionView.tsx        | 8 ++++----
 src/client/views/nodes/DocumentView.tsx                | 3 +--
 src/server/authentication/models/current_user_utils.ts | 5 ++++-
 4 files changed, 13 insertions(+), 8 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts
index 69dc303cd..d96257ca1 100644
--- a/src/client/util/DropConverter.ts
+++ b/src/client/util/DropConverter.ts
@@ -58,7 +58,10 @@ export function convertDropDataToButtons(data: DragManager.DocumentDragData) {
                 (layoutDoc.layout instanceof Doc) && !data.userDropAction;
             }
             layoutDoc.isTemplateDoc = true;
-            dbox = Docs.Create.FontIconDocument({ _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, backgroundColor: StrCast(doc.backgroundColor), title: StrCast(layoutDoc.title), icon: layoutDoc.isTemplateDoc ? "font" : "bolt" });
+            dbox = Docs.Create.FontIconDocument({
+                _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100, isButton: true,
+                backgroundColor: StrCast(doc.backgroundColor), title: StrCast(layoutDoc.title), icon: layoutDoc.isTemplateDoc ? "font" : "bolt"
+            });
             dbox.dragFactory = layoutDoc;
             dbox.removeDropProperties = doc.removeDropProperties instanceof ObjectField ? ObjectField.MakeCopy(doc.removeDropProperties) : undefined;
             dbox.onDragStart = ScriptField.MakeFunction('getCopy(this.dragFactory, true)');
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index c4f9e873c..e825d96ef 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -10,7 +10,7 @@ import 'react-image-lightbox-with-rotate/style.css'; // This only needs to be im
 import { DateField } from '../../../new_fields/DateField';
 import { DataSym, Doc, DocListCast, Field, Opt } from '../../../new_fields/Doc';
 import { List } from '../../../new_fields/List';
-import { BoolCast, Cast, NumCast, StrCast } from '../../../new_fields/Types';
+import { BoolCast, Cast, NumCast, StrCast, ScriptCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
 import { Utils, setupMoveUpEvents, returnFalse } from '../../../Utils';
@@ -119,7 +119,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
 
     active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || (this.props.rootSelected() && BoolCast(this.props.Document.forceActive)) || this._isChildActive || this.props.renderDepth === 0;
 
-    whenActiveChanged = (isActive: boolean) => { this.props.whenActiveChanged(this._isChildActive = isActive); };
+    whenActiveChanged = (isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive);
 
     @action.bound
     addDocument(doc: Doc): boolean {
@@ -307,8 +307,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
     get childDocs() {
         const dfield = this.dataField;
         const rawdocs = (dfield instanceof Doc) ? [dfield] : Cast(dfield, listSpec(Doc), Cast(this.props.Document.rootDocument, Doc, null) ? [Cast(this.props.Document.rootDocument, Doc, null)] : []);
-        const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
-        const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
+        const docs = rawdocs.filter(d => d && !(d instanceof Promise)).map(d => d as Doc);
+        const viewSpecScript = ScriptCast(this.props.Document.viewSpecScript);
         return viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
     }
     @computed get _allFacets() {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 9cccc9765..d12530142 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -297,11 +297,10 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             } else if (this.Document.type === DocumentType.BUTTON) {
                 UndoManager.RunInBatch(() => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY), "on button click");
             } else if (this.Document.isButton) {
-                SelectionManager.SelectDoc(this, e.ctrlKey); // don't think this should happen if a button action is actually triggered.
                 UndoManager.RunInBatch(() => this.buttonClick(e.altKey, e.ctrlKey), "on link button follow");
             } else {
                 if (this.props.Document.isTemplateForField && !(e.ctrlKey || e.button > 0)) {
-                    stopPropagate = false;
+                    stopPropagate = false; // don't stop propagation for field templates -- want the selection to propagate up to the root document of the template
                 } else {
                     SelectionManager.SelectDoc(this, e.ctrlKey);
                 }
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index da33e3050..302e00b63 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -306,7 +306,10 @@ export class CurrentUserUtils {
         Doc.GetProto(descriptionTemplate).layout = FormattedTextBox.LayoutString("description");
         descriptionTemplate.isTemplateDoc = makeTemplate(descriptionTemplate, true, "descriptionView");
 
-        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, isButton: true, dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
+        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({
+            ...opts, isButton: true,
+            dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100
+        })) as any as Doc;
         const blist = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, {
             ...opts,
             _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", isButton: true, forceActive: true,
-- 
cgit v1.2.3-70-g09d2


From afc7afcea84463d7e7048e5f318bbd13a72f3e95 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 4 Apr 2020 13:06:34 -0400
Subject: added double click to open lightbox from carousel.

---
 src/client/views/RecommendationsBox.scss           |  9 ++++----
 .../views/collections/CollectionCarouselView.scss  |  1 +
 .../views/collections/CollectionCarouselView.tsx   | 27 ++++++++++++++++++++--
 src/client/views/collections/CollectionView.tsx    |  3 ++-
 4 files changed, 33 insertions(+), 7 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/RecommendationsBox.scss b/src/client/views/RecommendationsBox.scss
index dd8a105f6..7d89042a4 100644
--- a/src/client/views/RecommendationsBox.scss
+++ b/src/client/views/RecommendationsBox.scss
@@ -54,10 +54,11 @@
     margin-left: 5px;
 }
 
-img{
-    width: 100%;
-    height: 100%;
-}
+// bcz: UGH!!  Can't have global settings like this!!!
+// img{
+//     width: 100%;
+//     height: 100%;
+// }
 
 .score {
     // margin-left: 15px;
diff --git a/src/client/views/collections/CollectionCarouselView.scss b/src/client/views/collections/CollectionCarouselView.scss
index fd1296286..a9a1898f5 100644
--- a/src/client/views/collections/CollectionCarouselView.scss
+++ b/src/client/views/collections/CollectionCarouselView.scss
@@ -13,6 +13,7 @@
         height: calc(100% - 50px);
         display: inline-block;
         width: 100%;
+        user-select: none;
     }
 }
 .carouselView-back, .carouselView-fwd  {
diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx
index a0cb1fe19..9e7248db2 100644
--- a/src/client/views/collections/CollectionCarouselView.tsx
+++ b/src/client/views/collections/CollectionCarouselView.tsx
@@ -80,10 +80,33 @@ export class CollectionCarouselView extends CollectionSubView(CarouselDocument)
             });
         }
     }
+    _downX = 0;
+    _downY = 0;
+    onPointerDown = (e: React.PointerEvent) => {
+        this._downX = e.clientX;
+        this._downY = e.clientY;
+        console.log("CAROUSEL down");
+        document.addEventListener("pointerup", this.onpointerup);
+    }
+    private _lastTap: number = 0;
+    private _doubleTap = false;
+    onpointerup = (e: PointerEvent) => {
+        console.log("CAROUSEL up");
+        this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0 && Math.abs(e.clientX - this._downX) < 2 && Math.abs(e.clientY - this._downY) < 2);
+        this._lastTap = Date.now();
+    }
+
+    onClick = (e: React.MouseEvent) => {
+        if (this._doubleTap) {
+            e.stopPropagation();
+            this.props.Document.isLightboxOpen = true;
+        }
+    }
+
     render() {
-        return <div className="collectionCarouselView-outer" ref={this.createDashEventsTarget} onContextMenu={this.onContextMenu}>
+        return <div className="collectionCarouselView-outer" onClick={this.onClick} onPointerDown={this.onPointerDown} ref={this.createDashEventsTarget} onContextMenu={this.onContextMenu}>
             {this.content}
-            {this.buttons}
+            {this.props.Document._chromeStatus !== "replaced" ? this.buttons : (null)}
         </div>;
     }
 }
\ No newline at end of file
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index e825d96ef..729101bc3 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -99,7 +99,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
     public static LayoutString(fieldStr: string) { return FieldView.LayoutString(CollectionView, fieldStr); }
 
     private _isChildActive = false;   //TODO should this be observable?
-    @observable private _isLightboxOpen = false;
+    get _isLightboxOpen() { return BoolCast(this.props.Document.isLightboxOpen); };
+    set _isLightboxOpen(value) { this.props.Document.isLightboxOpen = value; };
     @observable private _curLightboxImg = 0;
     @observable private static _safeMode = false;
     public static SetSafeMode(safeMode: boolean) { this._safeMode = safeMode; }
-- 
cgit v1.2.3-70-g09d2


From 807743bdd351b639e3328fa1ed6f128738f95b9f Mon Sep 17 00:00:00 2001
From: Stanley Yip <stanley_yip@brown.edu>
Date: Sat, 4 Apr 2020 15:52:20 -0700
Subject: warning fixes

---
 src/client/util/InteractionUtils.tsx            | 14 --------------
 src/client/views/DocComponent.tsx               |  4 ++++
 src/client/views/Touchable.tsx                  |  2 +-
 src/client/views/collections/CollectionView.tsx |  7 +++++--
 src/mobile/MobileInterface.tsx                  |  7 ++++---
 5 files changed, 14 insertions(+), 20 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index 2eec02a42..f2d569cf3 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -10,20 +10,6 @@ export namespace InteractionUtils {
     const REACT_POINTER_PEN_BUTTON = 0;
     const ERASER_BUTTON = 5;
 
-    export function CreatePolyline(points: { X: number, Y: number }[], left: number, top: number, color: string, width: number) {
-        const pts = points.reduce((acc: string, pt: { X: number, Y: number }) => acc + `${pt.X - left},${pt.Y - top} `, "");
-        return (
-            <polyline
-                points={pts}
-                style={{
-                    fill: "none",
-                    stroke: color,
-                    strokeWidth: width
-                }}
-            />
-        );
-    }
-
     export class MultiTouchEvent<T extends React.TouchEvent | TouchEvent> {
         constructor(
             readonly fingers: number,
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 454c245cc..9456895d6 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -6,6 +6,7 @@ import { listSpec } from '../../new_fields/Schema';
 import { InkingControl } from './InkingControl';
 import { InkTool } from '../../new_fields/InkField';
 import { PositionDocument } from '../../new_fields/documentSchemas';
+import { InteractionUtils } from '../util/InteractionUtils';
 
 
 ///  DocComponent returns a generic React base class used by views that don't have any data extensions (e.g.,CollectionFreeFormDocumentView, DocumentView, ButtonBox)
@@ -18,6 +19,7 @@ export function DocComponent<P extends DocComponentProps, T>(schemaCtor: (doc: D
         //TODO This might be pretty inefficient if doc isn't observed, because computed doesn't cache then
         @computed get Document(): T { return schemaCtor(this.props.Document); }
         @computed get layoutDoc() { return PositionDocument(Doc.Layout(this.props.Document, this.props.LayoutDoc?.())); }
+        protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
     }
     return Component;
 }
@@ -38,6 +40,7 @@ export function DocExtendableComponent<P extends DocExtendableProps, T>(schemaCt
         @computed get layoutDoc() { return Doc.Layout(this.props.Document); }
         @computed get dataDoc() { return (this.props.DataDoc && (this.props.Document.isTemplateForField || this.props.Document.isTemplateDoc) ? this.props.DataDoc : Cast(this.props.Document.resolvedDataDoc, Doc, null) || Doc.GetProto(this.props.Document)) as Doc; }
         active = (outsideReaction?: boolean) => !this.props.Document.isBackground && ((this.props.Document.forceActive && this.props.rootSelected()) || this.props.isSelected(outsideReaction) || this.props.renderDepth === 0);//  && !InkingControl.Instance.selectedTool;  // bcz: inking state shouldn't affect static tools 
+        protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
     }
     return Component;
 }
@@ -62,6 +65,7 @@ export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schema
         @computed get layoutDoc() { return Doc.Layout(this.props.Document); }
         @computed get dataDoc() { return this.props.DataDoc && (this.props.Document.isTemplateForField || this.props.Document.isTemplateDoc) ? this.props.DataDoc : this.props.Document[DataSym]; }
 
+        protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
 
         _annotationKey: string = "annotations";
         public set annotationKey(val: string) { this._annotationKey = val; }
diff --git a/src/client/views/Touchable.tsx b/src/client/views/Touchable.tsx
index bc3d07130..08310786b 100644
--- a/src/client/views/Touchable.tsx
+++ b/src/client/views/Touchable.tsx
@@ -42,7 +42,7 @@ export abstract class Touchable<T = {}> extends React.Component<T> {
                 if (pt.clientX === tPt.clientX && pt.clientY === tPt.clientY) {
                     // pen is also a touch, but with a radius of 0.5 (at least with the surface pens)
                     // and this seems to be the only way of differentiating pen and touch on touch events
-                    if (pt.radiusX > 1 && pt.radiusY > 1) {
+                    if ((pt as any).radiusX > 1 && (pt as any).radiusY > 1) {
                         this.prevPoints.set(pt.identifier, pt);
                     }
                 }
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 729101bc3..1501ce151 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -42,6 +42,7 @@ import { Id } from '../../../new_fields/FieldSymbols';
 import { listSpec } from '../../../new_fields/Schema';
 import { Docs } from '../../documents/Documents';
 import { ScriptField, ComputedField } from '../../../new_fields/ScriptField';
+import { InteractionUtils } from '../../util/InteractionUtils';
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -99,12 +100,14 @@ export class CollectionView extends Touchable<FieldViewProps> {
     public static LayoutString(fieldStr: string) { return FieldView.LayoutString(CollectionView, fieldStr); }
 
     private _isChildActive = false;   //TODO should this be observable?
-    get _isLightboxOpen() { return BoolCast(this.props.Document.isLightboxOpen); };
-    set _isLightboxOpen(value) { this.props.Document.isLightboxOpen = value; };
+    get _isLightboxOpen() { return BoolCast(this.props.Document.isLightboxOpen); }
+    set _isLightboxOpen(value) { this.props.Document.isLightboxOpen = value; }
     @observable private _curLightboxImg = 0;
     @observable private static _safeMode = false;
     public static SetSafeMode(safeMode: boolean) { this._safeMode = safeMode; }
 
+    protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
+
     get collectionViewType(): CollectionViewType | undefined {
         const viewField = NumCast(this.props.Document._viewType);
         if (CollectionView._safeMode) {
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index ed6b74ca8..5f766c121 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -138,7 +138,7 @@ export default class MobileInterface extends React.Component {
                 whenActiveChanged={emptyFunction}
                 bringToFront={emptyFunction}
                 ContainingCollectionView={undefined}
-                ContainingCollectionDoc={undefined} />
+                ContainingCollectionDoc={undefined} />;
         }
         return "hello";
     }
@@ -198,7 +198,7 @@ export default class MobileInterface extends React.Component {
                         LibraryPath={emptyPath}
                         fieldKey={""}
                         dropAction={"alias"}
-                        bringToFront={emptyFunction }
+                        bringToFront={emptyFunction}
                         addDocTab={returnFalse}
                         pinToPres={emptyFunction}
                         PanelHeight={() => window.innerHeight}
@@ -212,7 +212,8 @@ export default class MobileInterface extends React.Component {
                         ScreenToLocalTransform={Transform.Identity}
                         renderDepth={0}
                         ContainingCollectionView={undefined}
-                        ContainingCollectionDoc={undefined}>
+                        ContainingCollectionDoc={undefined}
+                        rootSelected={returnTrue}>
                     </CollectionView>
                 </div>
             );
-- 
cgit v1.2.3-70-g09d2


From c291e8b2c8fb9034916b4eb4b286f99a8cb35a04 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sat, 4 Apr 2020 21:30:38 -0400
Subject: fixed link zoom following for inPlace and otherwise.

---
 src/client/util/DocumentManager.ts                 | 90 ++++++++++++--------
 src/client/views/collections/CollectionView.tsx    |  7 +-
 .../collectionFreeForm/CollectionFreeFormView.tsx  | 10 ++-
 src/client/views/nodes/DocuLinkBox.tsx             | 57 +++++--------
 src/client/views/nodes/DocumentView.scss           |  7 +-
 src/client/views/nodes/DocumentView.tsx            | 98 +++++++++++++---------
 src/client/views/nodes/FormattedTextBoxComment.tsx |  2 +-
 src/client/views/pdf/Annotation.tsx                |  2 +-
 src/client/views/pdf/PDFViewer.tsx                 |  2 +-
 src/mobile/MobileInterface.tsx                     |  4 +-
 src/new_fields/documentSchemas.ts                  |  3 +-
 src/new_fields/util.ts                             |  2 +-
 12 files changed, 158 insertions(+), 126 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 63d864db5..ae392a35b 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -5,11 +5,12 @@ import { List } from '../../new_fields/List';
 import { Cast, NumCast, StrCast } from '../../new_fields/Types';
 import { CollectionDockingView } from '../views/collections/CollectionDockingView';
 import { CollectionView } from '../views/collections/CollectionView';
-import { DocumentView } from '../views/nodes/DocumentView';
+import { DocumentView, DocFocusFunc } from '../views/nodes/DocumentView';
 import { LinkManager } from './LinkManager';
 import { Scripting } from './Scripting';
 import { SelectionManager } from './SelectionManager';
 import { DocumentType } from '../documents/DocumentTypes';
+import { UndoManager } from './UndoManager';
 
 
 export class DocumentManager {
@@ -84,24 +85,20 @@ export class DocumentManager {
         return this.getDocumentViewById(toFind[Id], preferredCollection);
     }
 
-    public getFirstDocumentView(toFind: Doc, originatingDoc: Opt<Doc> = undefined): DocumentView | undefined {
-        const views = this.getDocumentViews(toFind);
-        return views?.find(view => view.props.Document !== originatingDoc);
+    public getFirstDocumentView = (toFind: Doc, originatingDoc: Opt<Doc> = undefined): DocumentView | undefined => {
+        return this.getDocumentViews(toFind)?.find(view => view.props.Document !== originatingDoc);
     }
     public getDocumentViews(toFind: Doc): DocumentView[] {
         const toReturn: DocumentView[] = [];
+        const docViews = DocumentManager.Instance.DocumentViews;
 
-        // heurstic to return the "best" documents first:
+        // heuristic to return the "best" documents first:
         //   choose an exact match over an alias match
         //   choose documents that have a PanelWidth() over those that don't (the treeview documents have no panelWidth)
-        DocumentManager.Instance.DocumentViews.map(view =>
-            view.props.Document.presBox === undefined && view.props.PanelWidth() > 1 && view.props.Document === toFind && toReturn.push(view));
-        DocumentManager.Instance.DocumentViews.map(view =>
-            view.props.Document.presBox === undefined && view.props.PanelWidth() <= 1 && view.props.Document === toFind && toReturn.push(view));
-        DocumentManager.Instance.DocumentViews.map(view =>
-            view.props.Document.presBox === undefined && view.props.PanelWidth() > 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view));
-        DocumentManager.Instance.DocumentViews.map(view =>
-            view.props.Document.presBox === undefined && view.props.PanelWidth() <= 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view));
+        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() > 1 && view.props.Document === toFind && toReturn.push(view));
+        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() <= 1 && view.props.Document === toFind && toReturn.push(view));
+        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() > 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view));
+        docViews.map(view => !view.props.Document.presBox && view.props.PanelWidth() <= 1 && view.props.Document !== toFind && Doc.AreProtosEqual(view.props.Document, toFind) && toReturn.push(view));
 
         return toReturn;
     }
@@ -133,31 +130,47 @@ export class DocumentManager {
         return pairs;
     }
 
-    public jumpToDocument = async (targetDoc: Doc, willZoom: boolean, dockFunc?: (doc: Doc) => void, docContext?: Doc, linkId?: string, closeContextIfNotFound: boolean = false, originatingDoc: Opt<Doc> = undefined): Promise<void> => {
+    static addRightSplit = (doc: Doc, finished?: () => void) => {
+        CollectionDockingView.AddRightSplit(doc);
+        finished?.();
+    }
+    public jumpToDocument = async (
+        targetDoc: Doc,
+        willZoom: boolean,
+        dockFunc = DocumentManager.addRightSplit,
+        docContext?: Doc,
+        linkId?: string,
+        closeContextIfNotFound: boolean = false,
+        originatingDoc: Opt<Doc> = undefined,
+        finished?: () => void): Promise<void> => {
+        const getFirstDocView = DocumentManager.Instance.getFirstDocumentView;
+        const finishFalse: DocFocusFunc = () => { finished?.(); return false; };
         const highlight = () => {
-            const finalDocView = DocumentManager.Instance.getFirstDocumentView(targetDoc);
-            finalDocView && (finalDocView.Document.scrollToLinkID = linkId);
-            finalDocView && Doc.linkFollowHighlight(finalDocView.props.Document);
+            const finalDocView = getFirstDocView(targetDoc);
+            if (finalDocView) {
+                finalDocView.Document.scrollToLinkID = linkId;
+                Doc.linkFollowHighlight(finalDocView.props.Document);
+            }
         };
-        const docView = DocumentManager.Instance.getFirstDocumentView(targetDoc, originatingDoc);
+        const docView = getFirstDocView(targetDoc, originatingDoc);
         let annotatedDoc = await Cast(targetDoc.annotationOn, Doc);
         if (annotatedDoc) {
-            const first = DocumentManager.Instance.getFirstDocumentView(annotatedDoc);
+            const first = getFirstDocView(annotatedDoc);
             if (first) annotatedDoc = first.props.Document;
         }
         if (docView) {  // we have a docView already and aren't forced to create a new one ... just focus on the document.  TODO move into view if necessary otherwise just highlight?
-            docView.props.focus(docView.props.Document, willZoom);
+            docView.props.focus(docView.props.Document, willZoom, undefined, finishFalse);
             highlight();
         } else {
             const contextDocs = docContext ? await DocListCastAsync(docContext.data) : undefined;
-            const contextDoc = contextDocs && contextDocs.find(doc => Doc.AreProtosEqual(doc, targetDoc)) ? docContext : undefined;
-            const targetDocContext = (annotatedDoc ? annotatedDoc : contextDoc);
+            const contextDoc = contextDocs?.find(doc => Doc.AreProtosEqual(doc, targetDoc)) ? docContext : undefined;
+            const targetDocContext = annotatedDoc || contextDoc;
 
             if (!targetDocContext) { // we don't have a view and there's no context specified ... create a new view of the target using the dockFunc or default
-                (dockFunc || CollectionDockingView.AddRightSplit)(Doc.BrushDoc(Doc.MakeAlias(targetDoc)));
+                dockFunc(Doc.BrushDoc(targetDoc), finished); // bcz: should we use this?: Doc.MakeAlias(targetDoc)));
                 highlight();
             } else {
-                const targetDocContextView = DocumentManager.Instance.getFirstDocumentView(targetDocContext);
+                const targetDocContextView = getFirstDocView(targetDocContext);
                 targetDocContext.scrollY = 0;  // this will force PDFs to activate and load their annotations / allow scrolling
                 if (targetDocContextView) { // we have a context view and aren't forced to create a new one ... focus on the context
                     targetDocContext.panTransformType = "Ease";
@@ -166,32 +179,33 @@ export class DocumentManager {
                     // now find the target document within the context
                     if (targetDoc.displayTimecode) {  // the target should show up once the video scrubs to the display timecode;
                         targetDocContext.currentTimecode = targetDoc.displayTimecode;
+                        finished?.();
                     } else {
                         setTimeout(() => {
-                            const retryDocView = DocumentManager.Instance.getDocumentView(targetDoc);
+                            const retryDocView = getFirstDocView(targetDoc);
                             if (retryDocView) {
-                                retryDocView.props.focus(targetDoc, willZoom); // focus on the target if it now exists in the context
+                                retryDocView.props.focus(targetDoc, willZoom, undefined, finishFalse); // focus on the target if it now exists in the context
                             } else {
-                                if (closeContextIfNotFound && targetDocContextView.props.removeDocument) targetDocContextView.props.removeDocument(targetDocContextView.props.Document);
-                                targetDoc.layout && (dockFunc || CollectionDockingView.AddRightSplit)(Doc.BrushDoc(Doc.MakeAlias(targetDoc))); // otherwise create a new view of the target
+                                if (closeContextIfNotFound) targetDocContextView.props.removeDocument?.(targetDocContextView.props.Document);
+                                targetDoc.layout && dockFunc(Doc.BrushDoc(Doc.MakeAlias(targetDoc)), finished); // otherwise create a new view of the target
                             }
                             highlight();
                         }, 0);
                     }
                 } else {  // there's no context view so we need to create one first and try again
-                    (dockFunc || CollectionDockingView.AddRightSplit)(targetDocContext);
+                    dockFunc(targetDocContext);
                     setTimeout(() => {
-                        const finalDocView = DocumentManager.Instance.getFirstDocumentView(targetDoc);
-                        const finalDocContextView = DocumentManager.Instance.getFirstDocumentView(targetDocContext);
+                        const finalDocView = getFirstDocView(targetDoc);
+                        const finalDocContextView = getFirstDocView(targetDocContext);
                         setTimeout(() =>  // if not, wait a bit to see if the context can be loaded (e.g., a PDF). wait interval heurisitic tries to guess how we're animating based on what's just become visible
-                            this.jumpToDocument(targetDoc, willZoom, dockFunc, undefined, linkId, true), finalDocView ? 0 : finalDocContextView ? 250 : 2000); // so call jump to doc again and if the doc isn't found, it will be created.
+                            this.jumpToDocument(targetDoc, willZoom, dockFunc, undefined, linkId, true, undefined, finished), finalDocView ? 0 : finalDocContextView ? 250 : 2000); // so call jump to doc again and if the doc isn't found, it will be created.
                     }, 0);
                 }
             }
         }
     }
 
-    public async FollowLink(link: Doc | undefined, doc: Doc, focus: (doc: Doc, maxLocation: string) => void, zoom: boolean = false, reverse: boolean = false, currentContext?: Doc) {
+    public async FollowLink(link: Doc | undefined, doc: Doc, focus: (doc: Doc, followLinkLocation: string, afterFocus?: DocFocusFunc) => void, zoom = false, reverse = false, currentContext?: Doc, finished?: () => void) {
         const linkDocs = link ? [link] : DocListCast(doc.links);
         SelectionManager.DeselectAll();
         const firstDocs = linkDocs.filter(linkDoc => Doc.AreProtosEqual(linkDoc.anchor1 as Doc, doc));
@@ -204,8 +218,10 @@ export class DocumentManager {
         const linkFollowDocs = first.length ? [await first[0].anchor2 as Doc, await first[0].anchor1 as Doc] : second.length ? [await second[0].anchor1 as Doc, await second[0].anchor2 as Doc] : undefined;
         const linkFollowDocContexts = first.length ? [await first[0].context as Doc, await first[0].context as Doc] : second.length ? [await second[0].context as Doc, await second[0].context as Doc] : [undefined, undefined];
         const linkFollowTimecodes = first.length ? [NumCast(first[0].anchor2_timecode), NumCast(first[0].anchor1_timecode)] : second.length ? [NumCast(second[0].anchor1_timecode), NumCast(second[0].anchor2_timecode)] : [undefined, undefined];
+        const Jump = DocumentManager.Instance.jumpToDocument;
+        const Focus = (where: string) => (doc: Doc, finished?: () => void) => focus(doc, where, () => { finished?.(); return false; });
         if (linkFollowDocs && linkDoc) {
-            const maxLocation = StrCast(linkDoc.maximizeLocation, "inTab");
+            const followLinkLocation = StrCast(linkDoc.followLinkLocation, "inTab");
             const targetContext = !Doc.AreProtosEqual(linkFollowDocContexts[reverse ? 1 : 0], currentContext) ? linkFollowDocContexts[reverse ? 1 : 0] : undefined;
             const target = linkFollowDocs[reverse ? 1 : 0];
             const annotatedDoc = await Cast(target.annotationOn, Doc);
@@ -214,9 +230,11 @@ export class DocumentManager {
             } else {
                 target.currentTimecode !== undefined && (target.currentTimecode = linkFollowTimecodes[reverse ? 1 : 0]);
             }
-            DocumentManager.Instance.jumpToDocument(linkFollowDocs[reverse ? 1 : 0], zoom, (doc: Doc) => focus(doc, maxLocation), targetContext, linkDoc[Id], undefined, doc);
+            Jump(linkFollowDocs[reverse ? 1 : 0], zoom, Focus(followLinkLocation), targetContext, linkDoc[Id], undefined, doc, finished);
         } else if (link) {
-            DocumentManager.Instance.jumpToDocument(link, zoom, (doc: Doc) => focus(doc, "onRight"), undefined, undefined);
+            Jump(link, zoom, Focus("onRight"), undefined, undefined, undefined, undefined, finished);
+        } else {
+            finished?.();
         }
     }
 }
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 729101bc3..c96d6bed3 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -99,8 +99,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
     public static LayoutString(fieldStr: string) { return FieldView.LayoutString(CollectionView, fieldStr); }
 
     private _isChildActive = false;   //TODO should this be observable?
-    get _isLightboxOpen() { return BoolCast(this.props.Document.isLightboxOpen); };
-    set _isLightboxOpen(value) { this.props.Document.isLightboxOpen = value; };
+    get _isLightboxOpen() { return BoolCast(this.props.Document.isLightboxOpen); }
+    set _isLightboxOpen(value) { this.props.Document.isLightboxOpen = value; }
     @observable private _curLightboxImg = 0;
     @observable private static _safeMode = false;
     public static SetSafeMode(safeMode: boolean) { this._safeMode = safeMode; }
@@ -395,6 +395,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         const scriptText = "setDocFilter(containingTreeView, heading, this.title, checked)";
         return ScriptField.MakeScript(scriptText, { this: Doc.name, heading: "string", checked: "string", containingTreeView: Doc.name });
     }
+    @computed get treeIgnoreFields() { return ["_facetCollection", "_docFilters"]; }
     @computed get filterView() {
         const facetCollection = this.props.Document;
         const flyout = (
@@ -422,7 +423,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
                         treeViewHideTitle={true}
                         treeViewHideHeaderFields={true}
                         onCheckedClick={this.scriptField!}
-                        ignoreFields={["_facetCollection", "_docFilters"]}
+                        ignoreFields={this.treeIgnoreFields}
                         annotationsKey={""}
                         dontRegisterView={true}
                         PanelWidth={this.facetWidth}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 376d217bb..d4e44b9a9 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -842,9 +842,17 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
             backgroundHalo: this.backgroundHalo,
             parentActive: this.props.active,
             bringToFront: this.bringToFront,
+            addDocTab: this.addDocTab,
         };
     }
 
+    addDocTab = (doc: Doc, where: string) => {
+        if (where === "inPlace") {
+            this.dataDoc[this.props.fieldKey] = new List<Doc>([doc]);
+            return true;
+        }
+        return this.props.addDocTab(doc, where);
+    }
     getCalculatedPositions(params: { doc: Doc, index: number, collection: Doc, docs: Doc[], state: any }): PoolData {
         const result = this.Document.arrangeScript?.script.run(params, console.log);
         if (result?.success) {
@@ -1066,7 +1074,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
                             if (doc instanceof Doc) {
                                 const [xx, yy] = this.props.ScreenToLocalTransform().transformPoint(x, y);
                                 doc.x = xx, doc.y = yy;
-                                this.props.addDocument && this.props.addDocument(doc);
+                                this.props.addDocument?.(doc);
                             }
                         }
                     }
diff --git a/src/client/views/nodes/DocuLinkBox.tsx b/src/client/views/nodes/DocuLinkBox.tsx
index 81cf90f92..31ce58079 100644
--- a/src/client/views/nodes/DocuLinkBox.tsx
+++ b/src/client/views/nodes/DocuLinkBox.tsx
@@ -4,7 +4,7 @@ import { Doc, DocListCast } from "../../../new_fields/Doc";
 import { documentSchema } from "../../../new_fields/documentSchemas";
 import { makeInterface } from "../../../new_fields/Schema";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { Utils } from '../../../Utils';
+import { Utils, setupMoveUpEvents } from '../../../Utils';
 import { DocumentManager } from "../../util/DocumentManager";
 import { DragManager } from "../../util/DragManager";
 import { DocComponent } from "../DocComponent";
@@ -16,6 +16,7 @@ import { ContextMenu } from "../ContextMenu";
 import { LinkEditor } from "../linking/LinkEditor";
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { SelectionManager } from "../../util/SelectionManager";
+import { TraceMobx } from "../../../new_fields/util";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -29,8 +30,6 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
     _doubleTap = false;
     _lastTap: number = 0;
     _ref = React.createRef<HTMLDivElement>();
-    _downX = 0;
-    _downY = 0;
     _isOpen = false;
     _timeout: NodeJS.Timeout | undefined;
     @observable _x = 0;
@@ -40,56 +39,42 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
     @observable _forceOpen = false;
 
     onPointerDown = (e: React.PointerEvent) => {
-        this._downX = e.clientX;
-        this._downY = e.clientY;
-        document.removeEventListener("pointermove", this.onPointerMove);
-        document.removeEventListener("pointerup", this.onPointerUp);
-        document.addEventListener("pointermove", this.onPointerMove);
-        document.addEventListener("pointerup", this.onPointerUp);
-        (e.button === 0 && !e.ctrlKey) && e.stopPropagation();
+        setupMoveUpEvents(this, e, this.onPointerMove, () => { }, this.onClick);
     }
-    onPointerMove = action((e: PointerEvent) => {
+    onPointerMove = action((e: PointerEvent, down: number[], delta: number[]) => {
         const cdiv = this._ref && this._ref.current && this._ref.current.parentElement;
-        if (!this._isOpen && cdiv && (Math.abs(e.clientX - this._downX) > 5 || Math.abs(e.clientY - this._downY) > 5)) {
+        if (!this._isOpen && cdiv) {
             const bounds = cdiv.getBoundingClientRect();
             const pt = Utils.getNearestPointInPerimeter(bounds.left, bounds.top, bounds.width, bounds.height, e.clientX, e.clientY);
             const separation = Math.sqrt((pt[0] - e.clientX) * (pt[0] - e.clientX) + (pt[1] - e.clientY) * (pt[1] - e.clientY));
-            const dragdist = Math.sqrt((pt[0] - this._downX) * (pt[0] - this._downX) + (pt[1] - this._downY) * (pt[1] - this._downY));
+            const dragdist = Math.sqrt((pt[0] - down[0]) * (pt[0] - down[0]) + (pt[1] - down[1]) * (pt[1] - down[1]));
             if (separation > 100) {
-                //DragManager.StartLinkTargetsDrag(this._ref.current!, pt[0], pt[1], Cast(this.props.Document[this.props.fieldKey], Doc) as Doc, [this.props.Document]); // Containging collection is the document, not a collection... hack.
                 const dragData = new DragManager.DocumentDragData([this.props.Document]);
                 dragData.dropAction = "alias";
-                dragData.removeDropProperties = ["anchor1_x", "anchor1_y", "anchor2_x", "anchor2_y"];
-                DragManager.StartDocumentDrag([this._ref.current!], dragData, this._downX, this._downY);
-                document.removeEventListener("pointermove", this.onPointerMove);
-                document.removeEventListener("pointerup", this.onPointerUp);
+                dragData.removeDropProperties = ["anchor1_x", "anchor1_y", "anchor2_x", "anchor2_y", "isButton"];
+                DragManager.StartDocumentDrag([this._ref.current!], dragData, down[0], down[1]);
+                return true;
             } else if (dragdist > separation) {
                 this.props.Document[this.props.fieldKey + "_x"] = (pt[0] - bounds.left) / bounds.width * 100;
                 this.props.Document[this.props.fieldKey + "_y"] = (pt[1] - bounds.top) / bounds.height * 100;
             }
         }
+        return false;
     });
-    onPointerUp = (e: PointerEvent) => {
-        document.removeEventListener("pointermove", this.onPointerMove);
-        document.removeEventListener("pointerup", this.onPointerUp);
-        if (Math.abs(e.clientX - this._downX) < 3 && Math.abs(e.clientY - this._downY) < 3 && (e.button === 2 || e.ctrlKey || !this.props.Document.isButton)) {
+    @action
+    onClick = (e: PointerEvent) => {
+        this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0);
+        this._lastTap = Date.now();
+        if ((e.button === 2 || e.ctrlKey || !this.props.Document.isButton)) {
             this.props.select(false);
         }
-        this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0 && Math.abs(e.clientX - this._downX) < 2 && Math.abs(e.clientY - this._downY) < 2);
-        this._lastTap = Date.now();
-    }
-
-    @action
-    onClick = (e: React.MouseEvent) => {
         if (!this._doubleTap) {
+            const anchorContainerDoc = this.props.ContainingCollectionDoc; // bcz: hack!  need a better prop for passing the anchor's container 
             this._editing = true;
-            this.props.ContainingCollectionDoc && this.props.bringToFront(this.props.ContainingCollectionDoc, false);
-            const {clientX, clientY} = e;
-            if (!this.props.Document.onClick && !this._isOpen) {
+            anchorContainerDoc && this.props.bringToFront(anchorContainerDoc, false);
+            if (anchorContainerDoc && !this.props.Document.onClick && !this._isOpen) {
                 this._timeout = setTimeout(action(() => {
-                    if (Math.abs(clientX - this._downX) < 3 && Math.abs(clientY - this._downY) < 3 && (e.button !== 2 && !e.ctrlKey && this.props.Document.isButton)) {
-                        DocumentManager.Instance.FollowLink(this.props.Document, this.props.ContainingCollectionDoc as Doc, document => this.props.addDocTab(document, StrCast(this.props.Document.linkOpenLocation, "inTab")), false);
-                    }
+                    DocumentManager.Instance.FollowLink(this.props.Document, anchorContainerDoc, document => this.props.addDocTab(document, StrCast(this.props.Document.linkOpenLocation, "inTab")), false);
                     this._editing = false;
                 }), 300 - (Date.now() - this._lastTap));
             }
@@ -97,7 +82,6 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
             this._timeout && clearTimeout(this._timeout);
             this._timeout = undefined;
         }
-        e.stopPropagation();
     }
 
     openLinkDocOnRight = (e: React.MouseEvent) => {
@@ -126,6 +110,7 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
     }
 
     render() {
+        TraceMobx();
         const x = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_x"], 100) : 0;
         const y = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_y"], 100) : 0;
         const c = StrCast(this.props.Document.backgroundColor, "lightblue");
@@ -143,7 +128,7 @@ export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(Doc
             </div>
         );
         const small = this.props.PanelWidth() <= 1;
-        return <div className={`docuLinkBox-cont${small ? "-small" : ""}`} onPointerDown={this.onPointerDown} onClick={this.onClick} title={targetTitle} onContextMenu={this.specificContextMenu}
+        return <div className={`docuLinkBox-cont${small ? "-small" : ""}`} onPointerDown={this.onPointerDown} title={targetTitle} onContextMenu={this.specificContextMenu}
             ref={this._ref} style={{
                 background: c,
                 left: !small ? `calc(${x}% - 7.5px)` : undefined,
diff --git a/src/client/views/nodes/DocumentView.scss b/src/client/views/nodes/DocumentView.scss
index d1d96f0a1..ce7bcd206 100644
--- a/src/client/views/nodes/DocumentView.scss
+++ b/src/client/views/nodes/DocumentView.scss
@@ -34,13 +34,18 @@
         overflow-y: scroll;
         height: calc(100% - 20px);
     }
-
+    .documentView-docuLinkAnchor {
+        display:flex;
+        overflow: hidden;
+    }
     .documentView-docuLinkWrapper {
         pointer-events: none;
         position: absolute;
         transform-origin: top left;
         width: 100%;
         height: 100%;
+        top:0;
+        left:0;
         z-index: 1;
     }
 
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 11bf5a6a7..f74255933 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -52,6 +52,7 @@ library.add(fa.faEdit, fa.faTrash, fa.faShare, fa.faDownload, fa.faExpandArrowsA
     fa.faSquare, fa.faConciergeBell, fa.faWindowRestore, fa.faFolder, fa.faMapPin, fa.faLink, fa.faFingerprint, fa.faCrosshairs, fa.faDesktop, fa.faUnlock, fa.faLock, fa.faLaptopCode, fa.faMale,
     fa.faCopy, fa.faHandPointRight, fa.faCompass, fa.faSnowflake, fa.faMicrophone);
 
+export type DocFocusFunc = () => boolean;
 export interface DocumentViewProps {
     ContainingCollectionView: Opt<CollectionView>;
     ContainingCollectionDoc: Opt<Doc>;
@@ -74,7 +75,7 @@ export interface DocumentViewProps {
     ContentScaling: () => number;
     PanelWidth: () => number;
     PanelHeight: () => number;
-    focus: (doc: Doc, willZoom: boolean, scale?: number, afterFocus?: () => boolean) => void;
+    focus: (doc: Doc, willZoom: boolean, scale?: number, afterFocus?: DocFocusFunc) => void;
     parentActive: (outsideReaction: boolean) => boolean;
     whenActiveChanged: (isActive: boolean) => void;
     bringToFront: (doc: Doc, sendToBack?: boolean) => void;
@@ -287,15 +288,18 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 Doc.UnBrushDoc(this.props.Document);
             } else if (this.onClickHandler?.script) {
                 SelectionManager.DeselectAll();
-                UndoManager.RunInBatch(() => this.onClickHandler!.script.run({
+                const func = () => this.onClickHandler!.script.run({
                     this: this.props.Document,
                     self: Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document,
                     containingCollection: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
-                }, console.log) && !this.props.Document.isButton && this.select(false), "on click");
+                }, console.log) && !this.props.Document.isButton && this.select(false);
+                if (this.props.Document !== Doc.UserDoc().undoBtn && this.props.Document !== Doc.UserDoc().redoBtn) {
+                    UndoManager.RunInBatch(func, "on click");
+                } else func();
             } else if (this.Document.type === DocumentType.BUTTON) {
                 UndoManager.RunInBatch(() => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY), "on button click");
             } else if (this.Document.isButton) {
-                UndoManager.RunInBatch(() => this.buttonClick(e.altKey, e.ctrlKey), "on link button follow");
+                DocListCast(this.props.Document.links).length && this.followLinkClick(e.altKey, e.ctrlKey);
             } else {
                 if (this.props.Document.isTemplateForField && !(e.ctrlKey || e.button > 0)) {
                     stopPropagate = false; // don't stop propagation for field templates -- want the selection to propagate up to the root document of the template
@@ -309,14 +313,20 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         }
     }
 
-    buttonClick = async (altKey: boolean, ctrlKey: boolean) => {
-        const linkDocs = DocListCast(this.props.Document.links);
-        if (linkDocs.length) {
-            DocumentManager.Instance.FollowLink(undefined, this.props.Document,
-                // open up target if it's not already in view ... by zooming into the button document first and setting flag to reset zoom afterwards
-                (doc: Doc, maxLocation: string) => this.props.focus(this.props.Document, true, 1, () => this.props.addDocTab(doc, maxLocation)),
-                ctrlKey, altKey, this.props.ContainingCollectionDoc);
-        }
+    // follows a link - if the target is on screen, it highlights/pans to it.
+    // if the target isn't onscreen, then it will open up the target in a tab, on the right, or in place
+    // depending on the followLinkLocation property of the source (or the link itself as a fallback);
+    followLinkClick = async (altKey: boolean, ctrlKey: boolean) => {
+        const batch = UndoManager.StartBatch("follow link click");
+        const docFollowLoc = StrCast(this.Document.followLinkLocation);
+        const { focus, addDocTab } = this.props;
+        await DocumentManager.Instance.FollowLink(undefined, this.props.Document,
+            // open up target if it's not already in view ... by zooming into the button document first and setting flag to reset zoom afterwards (except if 'inPlace', then leave alone)
+            (doc, followLoc, afterFocus) => focus(this.props.Document, true, 1, () => {
+                addDocTab(doc, docFollowLoc || followLoc) && focus(doc, true, undefined, afterFocus);
+                return (docFollowLoc || followLoc) === "inPlace" ? false : true;
+            }),
+            ctrlKey, altKey, this.props.ContainingCollectionDoc, batch.end);
     }
 
     handle1PointerDown = (e: React.TouchEvent, me: InteractionUtils.MultiTouchEvent<React.TouchEvent>) => {
@@ -564,6 +574,17 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             this.Document.onClick = undefined;
         } else {
             this.Document.isButton = true;
+            this.Document.followLinkLocation = undefined;
+        }
+    }
+
+    @undoBatch
+    toggleFollowInPlace = (): void => {
+        if (this.Document.isButton) {
+            this.Document.isButton = false;
+        } else {
+            this.Document.isButton = true;
+            this.Document.followLinkLocation = "inPlace";
         }
     }
 
@@ -693,6 +714,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         onClicks.push({ description: "Enter Portal", event: this.makeIntoPortal, icon: "window-restore" });
         onClicks.push({ description: "Toggle Detail", event: () => this.Document.onClick = ScriptField.MakeScript(`toggleDetail(this, "${this.props.Document.layoutKey}")`), icon: "window-restore" });
         onClicks.push({ description: this.Document.ignoreClick ? "Select" : "Do Nothing", event: () => this.Document.ignoreClick = !this.Document.ignoreClick, icon: this.Document.ignoreClick ? "unlock" : "lock" });
+        onClicks.push({ description: this.Document.isButton ? "Remove Follow Behavior" : "Follow Link in Place", event: this.toggleFollowInPlace, icon: "concierge-bell" });
         onClicks.push({ description: this.Document.isButton || this.Document.onClick ? "Remove Click Behavior" : "Follow Link", event: this.toggleButtonBehavior, icon: "concierge-bell" });
         onClicks.push({ description: "Edit onClick Script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", obj.x, obj.y) });
         !existingOnClick && cm.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" });
@@ -981,31 +1003,36 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         return this._link;
     }
 
+    hideLinkAnchor = (doc: Doc) => undoBatch(doc => doc.hidden = true)();
+    anchorPanelWidth = () => this.props.PanelWidth() || 1;
+    anchorPanelHeight = () => this.props.PanelHeight() || 1;
+    @computed get anchors() {
+        TraceMobx();
+        return DocListCast(this.Document.links).filter(d => !d.hidden && this.isNonTemporalLink).map((d, i) =>
+            <div className="documentView-docuLinkWrapper" key={d[Id]}>
+                <DocumentView {...this.props}
+                    Document={d}
+                    ContainingCollectionDoc={this.props.Document} // bcz: hack this.props.Document is not a collection  Need a better prop for passing the containing document to the DocuLinkBox
+                    PanelWidth={this.anchorPanelWidth}
+                    PanelHeight={this.anchorPanelHeight}
+                    layoutKey={this.linkEndpoint(d)}
+                    ContentScaling={returnOne}
+                    backgroundColor={returnTransparent}
+                    removeDocument={this.hideLinkAnchor} />
+            </div>);
+    }
     @computed get innards() {
         TraceMobx();
-        if (!this.props.PanelWidth()) {
-            return <div style={{ display: "flex", overflow: "hidden" }}>
+        if (!this.props.PanelWidth()) {  // this happens when the document is a tree view label
+            return <div className="documentView-docuLinkAnchor" >
                 {StrCast(this.props.Document.title)}
-                {this.Document.links && DocListCast(this.Document.links).filter(d => !d.hidden).filter(this.isNonTemporalLink).map((d, i) =>
-                    <div className="documentView-docuLinkWrapper" style={{ position: "absolute", top: 0, left: 0 }} key={`${d[Id]}`}>
-                        <DocumentView {...this.props}
-                            Document={d}
-                            ContainingCollectionDoc={this.props.Document}
-                            PanelWidth={returnOne} PanelHeight={returnOne}
-                            layoutKey={this.linkEndpoint(d)} ContentScaling={returnOne}
-                            backgroundColor={returnTransparent}
-                            removeDocument={undoBatch(doc => doc.hidden = true)} />
-                    </div>)}
+                {this.anchors}
             </div>;
         }
         const showTitle = StrCast(this.layoutDoc._showTitle);
         const showTitleHover = StrCast(this.layoutDoc._showTitleHover);
         const showCaption = StrCast(this.layoutDoc._showCaption);
         const showTextTitle = showTitle && (StrCast(this.layoutDoc.layout).indexOf("PresBox") !== -1 || StrCast(this.layoutDoc.layout).indexOf("FormattedTextBox") !== -1) ? showTitle : undefined;
-        const searchHighlight = (!this.Document.searchFields ? (null) :
-            <div className="documentView-searchHighlight">
-                {this.Document.searchFields}
-            </div>);
         const captionView = (!showCaption ? (null) :
             <div className="documentView-captionWrapper">
                 <DocumentContentsView {...OmitKeys(this.props, ['children']).omit}
@@ -1032,26 +1059,15 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 />
             </div>);
         return <>
-            {this.Document.links && DocListCast(this.Document.links).filter(d => !d.hidden).filter(this.isNonTemporalLink).map((d, i) =>
-                <div className="documentView-docuLinkWrapper" key={`${d[Id]}`}>
-                    <DocumentView {...this.props} ContentScaling={returnOne} ContainingCollectionDoc={this.props.Document} Document={d} layoutKey={this.linkEndpoint(d)} backgroundColor={returnTransparent} removeDocument={undoBatch(doc => doc.hidden = true)} />
-                </div>)}
+            {this.anchors}
             {!showTitle && !showCaption ?
-                this.Document.searchFields ?
-                    (<div className="documentView-searchWrapper">
-                        {this.contents}
-                        {searchHighlight}
-                    </div>)
-                    :
-                    this.contents
-                :
+                this.contents :
                 <div className="documentView-styleWrapper" >
                     <div className="documentView-styleContentWrapper" style={{ height: showTextTitle ? `calc(100% - ${this.chromeHeight()}px)` : "100%", top: showTextTitle ? this.chromeHeight() : undefined }}>
                         {this.contents}
                     </div>
                     {titleView}
                     {captionView}
-                    {searchHighlight}
                 </div>
             }
         </>;
diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx
index d1a563494..babca2a14 100644
--- a/src/client/views/nodes/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/FormattedTextBoxComment.tsx
@@ -84,7 +84,7 @@ export class FormattedTextBoxComment {
                 const textBox = FormattedTextBoxComment.textBox;
                 if (FormattedTextBoxComment.linkDoc && !keep && textBox) {
                     DocumentManager.Instance.FollowLink(FormattedTextBoxComment.linkDoc, textBox.props.Document,
-                        (doc: Doc, maxLocation: string) => textBox.props.addDocTab(doc, e.ctrlKey ? "inTab" : "onRight"));
+                        (doc: Doc, followLinkLocation: string) => textBox.props.addDocTab(doc, e.ctrlKey ? "inTab" : "onRight"));
                 } else if (textBox && (FormattedTextBoxComment.tooltipText as any).href) {
                     textBox.props.addDocTab(Docs.Create.WebDocument((FormattedTextBoxComment.tooltipText as any).href, { title: (FormattedTextBoxComment.tooltipText as any).href, _width: 200, _height: 400 }), "onRight");
                 }
diff --git a/src/client/views/pdf/Annotation.tsx b/src/client/views/pdf/Annotation.tsx
index d23c81065..5cb766c03 100644
--- a/src/client/views/pdf/Annotation.tsx
+++ b/src/client/views/pdf/Annotation.tsx
@@ -98,7 +98,7 @@ class RegionAnnotation extends React.Component<IRegionAnnotationProps> {
             const annoGroup = await Cast(this.props.document.group, Doc);
             if (annoGroup) {
                 DocumentManager.Instance.FollowLink(undefined, annoGroup,
-                    (doc: Doc, maxLocation: string) => this.props.addDocTab(doc, e.ctrlKey ? "inTab" : "onRight"),
+                    (doc: Doc, followLinkLocation: string) => this.props.addDocTab(doc, e.ctrlKey ? "inTab" : "onRight"),
                     false, false, undefined);
                 e.stopPropagation();
             }
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index c032f019d..25ceb6218 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -585,7 +585,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
                 dragComplete: e => {
                     if (!e.aborted && e.annoDragData && !e.annoDragData.linkedToDoc) {
                         const link = DocUtils.MakeLink({ doc: annotationDoc }, { doc: e.annoDragData.dropDocument }, "Annotation");
-                        if (link) link.maximizeLocation = "onRight";
+                        if (link) link.followLinkLocation = "onRight";
                     }
                 }
             });
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index ed6b74ca8..dfd217e97 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -138,7 +138,7 @@ export default class MobileInterface extends React.Component {
                 whenActiveChanged={emptyFunction}
                 bringToFront={emptyFunction}
                 ContainingCollectionView={undefined}
-                ContainingCollectionDoc={undefined} />
+                ContainingCollectionDoc={undefined} />;
         }
         return "hello";
     }
@@ -198,7 +198,7 @@ export default class MobileInterface extends React.Component {
                         LibraryPath={emptyPath}
                         fieldKey={""}
                         dropAction={"alias"}
-                        bringToFront={emptyFunction }
+                        bringToFront={emptyFunction}
                         addDocTab={returnFalse}
                         pinToPres={emptyFunction}
                         PanelHeight={() => window.innerHeight}
diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts
index 3ac46362a..1a5a471a0 100644
--- a/src/new_fields/documentSchemas.ts
+++ b/src/new_fields/documentSchemas.ts
@@ -46,12 +46,11 @@ export const documentSchema = createSchema({
     treeViewExpandedView: "string", // name of field whose contents are being displayed as the document's subtree
     treeViewPreventOpen: "boolean", // ignores the treeViewOpen flag (for allowing a view to not be slaved to other views of the document)
     currentTimecode: "number",  // current play back time of a temporal document (video / audio)
-    maximizeLocation: "string", // flag for where to place content when following a click interaction (e.g., onRight, inPlace, inTab) 
+    followLinkLocation: "string",// flag for where to place content when following a click interaction (e.g., onRight, inPlace, inTab, ) 
     lockedPosition: "boolean",  // whether the document can be moved (dragged)
     lockedTransform: "boolean", // whether the document can be panned/zoomed
     inOverlay: "boolean",       // whether the document is rendered in an OverlayView which handles selection/dragging differently
     borderRounding: "string",   // border radius rounding of document
-    searchFields: "string",     // the search fields to display when this document matches a search in its metadata
     heading: "number",          // the logical layout 'heading' of this document (used by rule provider to stylize h1 header elements, from h2, etc)
     isButton: "boolean",        // whether document functions as a button (overiding native interactions of its content)    
     ignoreClick: "boolean",     // whether documents ignores input clicks (but does not ignore manipulation and other events) 
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 8c719ccd8..480a55da0 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -12,7 +12,7 @@ function _readOnlySetter(): never {
     throw new Error("Documents can't be modified in read-only mode");
 }
 
-const tracing = false;
+const tracing = true;
 export function TraceMobx() {
     tracing && trace();
 }
-- 
cgit v1.2.3-70-g09d2


From 48478855cc28aa423b2d1e482bd181c8c5066da6 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Sun, 5 Apr 2020 15:13:25 -0400
Subject: adding nativeWidth as props stuff

---
 src/client/util/RichTextSchema.tsx                 |  4 +-
 src/client/views/GestureOverlay.tsx                | 13 ++++---
 src/client/views/MainView.tsx                      | 10 ++++-
 src/client/views/OverlayView.tsx                   |  2 +
 src/client/views/Palette.tsx                       |  4 +-
 src/client/views/RecommendationsBox.tsx            |  4 +-
 src/client/views/TemplateMenu.tsx                  |  6 ++-
 .../views/collections/CollectionDockingView.tsx    |  4 +-
 .../views/collections/CollectionLinearView.tsx     |  6 ++-
 .../views/collections/CollectionSchemaCells.tsx    |  2 +
 .../views/collections/CollectionStackingView.tsx   | 32 +++++++++------
 src/client/views/collections/CollectionSubView.tsx |  8 ++--
 .../views/collections/CollectionTimeView.tsx       |  5 +--
 .../views/collections/CollectionTreeView.tsx       |  2 +
 src/client/views/collections/CollectionView.tsx    |  4 +-
 .../collectionFreeForm/CollectionFreeFormView.tsx  |  5 ++-
 src/client/views/nodes/AudioBox.tsx                |  4 +-
 .../views/nodes/CollectionFreeFormDocumentView.tsx | 45 +++++++++++++---------
 .../views/nodes/ContentFittingDocumentView.tsx     | 25 +++++++-----
 src/client/views/nodes/DocumentView.tsx            | 14 +++++--
 src/client/views/nodes/FieldView.tsx               |  2 +
 src/client/views/nodes/FormattedTextBox.tsx        |  4 +-
 src/client/views/nodes/ImageBox.tsx                |  4 +-
 src/client/views/nodes/KeyValuePair.tsx            |  6 ++-
 src/client/views/nodes/LinkBox.tsx                 |  2 +
 src/client/views/nodes/ScreenshotBox.tsx           |  4 +-
 src/client/views/nodes/VideoBox.tsx                |  4 +-
 src/client/views/nodes/WebBox.tsx                  |  4 +-
 src/client/views/pdf/PDFViewer.tsx                 |  4 +-
 src/mobile/MobileInterface.tsx                     | 14 +++++--
 src/new_fields/documentSchemas.ts                  |  2 +-
 src/new_fields/util.ts                             |  2 +-
 32 files changed, 170 insertions(+), 81 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx
index d4568b17f..de2707d36 100644
--- a/src/client/util/RichTextSchema.tsx
+++ b/src/client/util/RichTextSchema.tsx
@@ -16,7 +16,7 @@ import { listSpec } from "../../new_fields/Schema";
 import { SchemaHeaderField } from "../../new_fields/SchemaHeaderField";
 import { ComputedField } from "../../new_fields/ScriptField";
 import { BoolCast, Cast, NumCast, StrCast } from "../../new_fields/Types";
-import { emptyFunction, returnEmptyString, returnFalse, returnOne, Utils } from "../../Utils";
+import { emptyFunction, returnEmptyString, returnFalse, returnOne, Utils, returnZero } from "../../Utils";
 import { DocServer } from "../DocServer";
 import { Docs } from "../documents/Documents";
 import { CollectionViewType } from "../views/collections/CollectionView";
@@ -824,6 +824,8 @@ export class DashDocView {
                     addDocTab={this._textBox.props.addDocTab}
                     pinToPres={returnFalse}
                     renderDepth={self._textBox.props.renderDepth + 1}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     PanelWidth={finalLayout[WidthSym]}
                     PanelHeight={finalLayout[HeightSym]}
                     focus={this.outerFocus}
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index 68f1d13fb..110b61efe 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -15,7 +15,7 @@ import { Scripting } from "../util/Scripting";
 import { FieldValue, Cast, NumCast, BoolCast } from "../../new_fields/Types";
 import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
 import HorizontalPalette from "./Palette";
-import { Utils, emptyPath, emptyFunction, returnFalse, returnOne, returnEmptyString, returnTrue, numberRange } from "../../Utils";
+import { Utils, emptyPath, emptyFunction, returnFalse, returnOne, returnEmptyString, returnTrue, numberRange, returnZero } from "../../Utils";
 import { DocumentView } from "./nodes/DocumentView";
 import { Transform } from "../util/Transform";
 import { DocumentContentsView } from "./nodes/DocumentContentsView";
@@ -695,7 +695,8 @@ export default class GestureOverlay extends Touchable {
             </svg>]
         ];
     }
-
+    screenToLocalTransform = () => new Transform(-(this._thumbX ?? 0), -(this._thumbY ?? 0) + this.height, 1);
+    return300 = () => 300;
     @action
     public openFloatingDoc = (doc: Doc) => {
         this._clipboardDoc =
@@ -709,10 +710,12 @@ export default class GestureOverlay extends Touchable {
                 pinToPres={emptyFunction}
                 onClick={undefined}
                 removeDocument={undefined}
-                ScreenToLocalTransform={() => new Transform(-(this._thumbX ?? 0), -(this._thumbY ?? 0) + this.height, 1)}
+                ScreenToLocalTransform={this.screenToLocalTransform}
                 ContentScaling={returnOne}
-                PanelWidth={() => 300}
-                PanelHeight={() => 300}
+                PanelWidth={this.return300}
+                PanelHeight={this.return300}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 renderDepth={0}
                 backgroundColor={returnEmptyString}
                 focus={emptyFunction}
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 420cc95ec..bef92f0fd 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -13,7 +13,7 @@ import { listSpec } from '../../new_fields/Schema';
 import { BoolCast, Cast, FieldValue, StrCast } from '../../new_fields/Types';
 import { TraceMobx } from '../../new_fields/util';
 import { CurrentUserUtils } from '../../server/authentication/models/current_user_utils';
-import { emptyFunction, emptyPath, returnFalse, returnOne, returnTrue, Utils } from '../../Utils';
+import { emptyFunction, emptyPath, returnFalse, returnOne, returnZero, returnTrue, Utils } from '../../Utils';
 import GoogleAuthenticationManager from '../apis/GoogleAuthenticationManager';
 import { DocServer } from '../DocServer';
 import { Docs, DocumentOptions } from '../documents/Documents';
@@ -307,6 +307,8 @@ export class MainView extends React.Component {
             removeDocument={undefined}
             ScreenToLocalTransform={Transform.Identity}
             ContentScaling={returnOne}
+            NativeHeight={returnZero}
+            NativeWidth={returnZero}
             PanelWidth={this.getPWidth}
             PanelHeight={this.getPHeight}
             renderDepth={0}
@@ -405,6 +407,8 @@ export class MainView extends React.Component {
                     onClick={undefined}
                     ScreenToLocalTransform={Transform.Identity}
                     ContentScaling={returnOne}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     PanelWidth={this.flyoutWidthFunc}
                     PanelHeight={this.getPHeight}
                     renderDepth={0}
@@ -424,6 +428,8 @@ export class MainView extends React.Component {
                     addDocument={undefined}
                     addDocTab={this.addDocTabFunc}
                     pinToPres={emptyFunction}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     rootSelected={returnTrue}
                     removeDocument={returnFalse}
                     onClick={undefined}
@@ -524,6 +530,8 @@ export class MainView extends React.Component {
                     onClick={undefined}
                     ScreenToLocalTransform={this.buttonBarXf}
                     ContentScaling={returnOne}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     PanelWidth={this.flyoutWidthFunc}
                     PanelHeight={this.getContentsHeight}
                     renderDepth={0}
diff --git a/src/client/views/OverlayView.tsx b/src/client/views/OverlayView.tsx
index 7cfae0bbb..4000cade5 100644
--- a/src/client/views/OverlayView.tsx
+++ b/src/client/views/OverlayView.tsx
@@ -182,6 +182,8 @@ export class OverlayView extends React.Component {
                     addDocument={undefined}
                     removeDocument={undefined}
                     ContentScaling={returnOne}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     PanelWidth={returnOne}
                     PanelHeight={returnOne}
                     ScreenToLocalTransform={Transform.Identity}
diff --git a/src/client/views/Palette.tsx b/src/client/views/Palette.tsx
index d088d5bba..63744cb50 100644
--- a/src/client/views/Palette.tsx
+++ b/src/client/views/Palette.tsx
@@ -3,7 +3,7 @@ import { observer } from "mobx-react";
 import * as React from "react";
 import { Doc } from "../../new_fields/Doc";
 import { NumCast } from "../../new_fields/Types";
-import { emptyFunction, emptyPath, returnEmptyString, returnFalse, returnOne, returnTrue } from "../../Utils";
+import { emptyFunction, emptyPath, returnEmptyString, returnZero, returnFalse, returnOne, returnTrue } from "../../Utils";
 import { Transform } from "../util/Transform";
 import { DocumentView } from "./nodes/DocumentView";
 import "./Palette.scss";
@@ -49,6 +49,8 @@ export default class Palette extends React.Component<PaletteProps> {
                             onClick={undefined}
                             ScreenToLocalTransform={Transform.Identity}
                             ContentScaling={returnOne}
+                            NativeHeight={returnZero}
+                            NativeWidth={returnZero}
                             PanelWidth={() => window.screen.width}
                             PanelHeight={() => window.screen.height}
                             renderDepth={0}
diff --git a/src/client/views/RecommendationsBox.tsx b/src/client/views/RecommendationsBox.tsx
index ddeda28ac..e66fd3eb4 100644
--- a/src/client/views/RecommendationsBox.tsx
+++ b/src/client/views/RecommendationsBox.tsx
@@ -6,7 +6,7 @@ import "./RecommendationsBox.scss";
 import { Doc, DocListCast, WidthSym, HeightSym } from "../../new_fields/Doc";
 import { DocumentIcon } from "./nodes/DocumentIcon";
 import { StrCast, NumCast } from "../../new_fields/Types";
-import { returnFalse, emptyFunction, returnEmptyString, returnOne, emptyPath } from "../../Utils";
+import { returnFalse, emptyFunction, returnEmptyString, returnOne, emptyPath, returnZero } from "../../Utils";
 import { Transform } from "../util/Transform";
 import { ObjectField } from "../../new_fields/ObjectField";
 import { DocumentView } from "./nodes/DocumentView";
@@ -73,6 +73,8 @@ export class RecommendationsBox extends React.Component<FieldViewProps> {
                 addDocTab={returnFalse}
                 pinToPres={returnFalse}
                 renderDepth={1}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 PanelWidth={returnXDimension}
                 PanelHeight={returnYDimension}
                 focus={emptyFunction}
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index f2fb26679..c72f3681a 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -10,7 +10,7 @@ import { Doc, DocListCast } from "../../new_fields/Doc";
 import { Docs, } from "../documents/Documents";
 import { StrCast, Cast } from "../../new_fields/Types";
 import { CollectionTreeView } from "./collections/CollectionTreeView";
-import { returnTrue, emptyFunction, returnFalse, returnOne, emptyPath } from "../../Utils";
+import { returnTrue, emptyFunction, returnFalse, returnOne, emptyPath, returnZero } from "../../Utils";
 import { Transform } from "../util/Transform";
 import { ScriptField, ComputedField } from "../../new_fields/ScriptField";
 import { Scripting } from "../util/Scripting";
@@ -149,6 +149,8 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
                     select={emptyFunction}
                     renderDepth={1}
                     addDocTab={returnFalse}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     PanelWidth={this.return100}
                     PanelHeight={this.return100}
                     treeViewHideHeaderFields={true}
@@ -161,7 +163,7 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
             );
         }
         return <ul className="template-list" style={{ display: "block" }}>
-            <input placeholder="+ layout" ref={this._customRef} onKeyPress={this.onCustomKeypress}/>
+            <input placeholder="+ layout" ref={this._customRef} onKeyPress={this.onCustomKeypress} />
             {templateMenu}
         </ul>;
     }
diff --git a/src/client/views/collections/CollectionDockingView.tsx b/src/client/views/collections/CollectionDockingView.tsx
index 11eecf771..28aaf0c57 100644
--- a/src/client/views/collections/CollectionDockingView.tsx
+++ b/src/client/views/collections/CollectionDockingView.tsx
@@ -15,7 +15,7 @@ import { FieldId } from "../../../new_fields/RefField";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
 import { TraceMobx } from '../../../new_fields/util';
 import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
-import { emptyFunction, returnOne, returnTrue, Utils } from "../../../Utils";
+import { emptyFunction, returnOne, returnTrue, Utils, returnZero } from "../../../Utils";
 import { DocServer } from "../../DocServer";
 import { Docs } from '../../documents/Documents';
 import { DocumentType } from '../../documents/DocumentTypes';
@@ -794,6 +794,8 @@ export class DockedFrameRenderer extends React.Component<DockedFrameProps> {
             ContentScaling={this.contentScaling}
             PanelWidth={this.panelWidth}
             PanelHeight={this.panelHeight}
+            NativeHeight={returnZero}
+            NativeWidth={returnZero}
             ScreenToLocalTransform={this.ScreenToLocalTransform}
             renderDepth={0}
             parentActive={returnTrue}
diff --git a/src/client/views/collections/CollectionLinearView.tsx b/src/client/views/collections/CollectionLinearView.tsx
index 3bd50ad52..cb0206260 100644
--- a/src/client/views/collections/CollectionLinearView.tsx
+++ b/src/client/views/collections/CollectionLinearView.tsx
@@ -4,7 +4,7 @@ import * as React from 'react';
 import { Doc, HeightSym, WidthSym } from '../../../new_fields/Doc';
 import { makeInterface } from '../../../new_fields/Schema';
 import { BoolCast, NumCast, StrCast, Cast, ScriptCast } from '../../../new_fields/Types';
-import { emptyFunction, returnEmptyString, returnOne, returnTrue, Utils, returnFalse } from '../../../Utils';
+import { emptyFunction, returnEmptyString, returnOne, returnTrue, Utils, returnFalse, returnZero } from '../../../Utils';
 import { DragManager } from '../../util/DragManager';
 import { Transform } from '../../util/Transform';
 import "./CollectionLinearView.scss";
@@ -114,6 +114,8 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
                                 onClick={undefined}
                                 ScreenToLocalTransform={this.getTransform(dref)}
                                 ContentScaling={returnOne}
+                                NativeHeight={returnZero}
+                                NativeWidth={returnZero}
                                 PanelWidth={nested ? pair.layout[WidthSym] : () => this.dimension()}// ugh - need to get rid of this inline function to avoid recomputing
                                 PanelHeight={nested ? pair.layout[HeightSym] : () => this.dimension()}
                                 renderDepth={this.props.renderDepth + 1}
@@ -123,7 +125,7 @@ export class CollectionLinearView extends CollectionSubView(LinearDocument) {
                                 whenActiveChanged={emptyFunction}
                                 bringToFront={emptyFunction}
                                 ContainingCollectionView={undefined}
-                                ContainingCollectionDoc={undefined}/>
+                                ContainingCollectionDoc={undefined} />
                         </div>;
                     })}
                 </div>
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 7b16ff546..ae71c54f7 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -172,6 +172,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             whenActiveChanged: emptyFunction,
             PanelHeight: returnZero,
             PanelWidth: returnZero,
+            NativeHeight: returnZero,
+            NativeWidth: returnZero,
             addDocTab: this.props.addDocTab,
             pinToPres: this.props.pinToPres,
             ContentScaling: returnOne
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index d21e17bbc..8ceeb66f1 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -11,7 +11,7 @@ import { listSpec } from "../../../new_fields/Schema";
 import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
 import { BoolCast, Cast, NumCast, ScriptCast, StrCast } from "../../../new_fields/Types";
 import { TraceMobx } from "../../../new_fields/util";
-import { Utils, setupMoveUpEvents, emptyFunction } from "../../../Utils";
+import { Utils, setupMoveUpEvents, emptyFunction, returnZero, returnOne } from "../../../Utils";
 import { DragManager, dropActionType } from "../../util/DragManager";
 import { Transform } from "../../util/Transform";
 import { undoBatch } from "../../util/UndoManager";
@@ -24,7 +24,7 @@ import "./CollectionStackingView.scss";
 import { CollectionStackingViewFieldColumn } from "./CollectionStackingViewFieldColumn";
 import { CollectionSubView } from "./CollectionSubView";
 import { CollectionViewType } from "./CollectionView";
-import { Docs } from "../../documents/Documents";
+import { DocumentView } from "../nodes/DocumentView";
 
 @observer
 export class CollectionStackingView extends CollectionSubView(doc => doc) {
@@ -53,6 +53,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
     @computed get NodeWidth() { return this.props.PanelWidth() - this.gridGap; }
 
     children(docs: Doc[], columns?: number) {
+        TraceMobx();
         this._docXfs.length = 0;
         return docs.map((d, i) => {
             const height = () => this.getDocHeight(d);
@@ -115,7 +116,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
     componentDidMount() {
         super.componentDidMount();
         this._heightDisposer = reaction(() => {
-            if (this.props.Document._autoHeight) {
+            if (this.props.Document._autoHeight && !this.props.NativeHeight()) {
                 const sectionsList = Array.from(this.Sections.size ? this.Sections.values() : [this.filteredChildren]);
                 if (this.isStackingView) {
                     const res = this.props.ContentScaling() * sectionsList.reduce((maxHght, s) => {
@@ -168,12 +169,13 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
     getDisplayDoc(doc: Doc, dataDoc: Doc | undefined, dxf: () => Transform, width: () => number) {
         const layoutDoc = Doc.Layout(doc, this.props.childLayoutTemplate?.());
         const height = () => this.getDocHeight(doc);
-        return <ContentFittingDocumentView
+        return <DocumentView
             Document={doc}
-            DataDocument={dataDoc || (doc[DataSym] !== doc && doc[DataSym])}
+            DataDoc={dataDoc || (doc[DataSym] !== doc && doc[DataSym])}
             backgroundColor={this.props.backgroundColor}
             LayoutDoc={this.props.childLayoutTemplate}
             LibraryPath={this.props.LibraryPath}
+            FreezeDimensions={this.props.freezeDimensions}
             renderDepth={this.props.renderDepth + 1}
             fitToBox={this.props.fitToBox}
             rootSelected={this.rootSelected}
@@ -181,18 +183,22 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
             onClick={layoutDoc.isTemplateDoc ? this.onClickHandler : this.onChildClickHandler}
             PanelWidth={width}
             PanelHeight={height}
-            getTransform={dxf}
+            ScreenToLocalTransform={dxf}
             focus={this.props.focus}
-            CollectionDoc={this.props.CollectionView && this.props.CollectionView.props.Document}
-            CollectionView={this.props.CollectionView}
+            ContainingCollectionDoc={this.props.CollectionView && this.props.CollectionView.props.Document}
+            ContainingCollectionView={this.props.CollectionView}
             addDocument={this.props.addDocument}
             moveDocument={this.props.moveDocument}
             removeDocument={this.props.removeDocument}
-            active={this.props.active}
+            parentActive={this.props.active}
+            bringToFront={emptyFunction}
+            NativeHeight={returnZero}
+            NativeWidth={returnZero}
+            ContentScaling={returnOne}
             whenActiveChanged={this.props.whenActiveChanged}
             addDocTab={this.props.addDocTab}
             pinToPres={this.props.pinToPres}>
-        </ContentFittingDocumentView>;
+        </DocumentView>;
     }
 
     getDocWidth(d?: Doc) {
@@ -387,7 +393,11 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
         return sections.map(section => this.isStackingView ? this.sectionStacking(section[0], section[1]) : this.sectionMasonry(section[0], section[1]));
     }
 
-    @computed get scaling() { return !this.props.Document._nativeWidth ? 1 : this.props.PanelHeight() / NumCast(this.props.Document._nativeHeight); }
+
+    @computed get nativeWidth() { return NumCast(this.layoutDoc._nativeWidth) || this.props.NativeWidth() || 0; }
+    @computed get nativeHeight() { return NumCast(this.layoutDoc._nativeHeight) || this.props.NativeHeight() || 0; }
+
+    @computed get scaling() { return !this.nativeWidth ? 1 : this.props.PanelHeight() / this.nativeHeight; }
 
     render() {
         TraceMobx();
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index d1d6ae3c1..32449de5e 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -36,12 +36,15 @@ export interface CollectionViewProps extends FieldViewProps {
     setPreviewCursor?: (func: (x: number, y: number, drag: boolean) => void) => void;
     rootSelected: () => boolean;
     fieldKey: string;
+    NativeWidth: () => number;
+    NativeHeight: () => number;
 }
 
 export interface SubCollectionViewProps extends CollectionViewProps {
     CollectionView: Opt<CollectionView>;
     children?: never | (() => JSX.Element[]) | React.ReactNode;
-    overrideDocuments?: Doc[]; // used to override the documents shown by the sub collection to an explict list (see LinkBox)
+    freezeDimensions?: boolean; // used by TimeView to coerce documents to treat their width height as their native width/height
+    overrideDocuments?: Doc[]; // used to override the documents shown by the sub collection to an explicit list (see LinkBox)
     ignoreFields?: string[]; // used in TreeView to ignore specified fields (see LinkBox)
     isAnnotationOverlay?: boolean;
     annotationsKey: string;
@@ -213,9 +216,6 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 this.props.Document.dropConverter.script.run({ dragData: docDragData }); /// bcz: check this 
             if (docDragData) {
                 let added = false;
-                if (this.props.Document._freezeOnDrop) {
-                    de.complete.docDragData?.droppedDocuments.forEach(drop => Doc.freezeNativeDimensions(drop, drop[WidthSym](), drop[HeightSym]()));
-                }
                 if (docDragData.dropAction || docDragData.userDropAction) {
                     added = docDragData.droppedDocuments.reduce((added: boolean, d) => this.props.addDocument(d) || added, false);
                 } else if (docDragData.moveDocument) {
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 4f77e8b0e..d9a10cdc8 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -5,7 +5,7 @@ import { List } from "../../../new_fields/List";
 import { ObjectField } from "../../../new_fields/ObjectField";
 import { RichTextField } from "../../../new_fields/RichTextField";
 import { ComputedField, ScriptField } from "../../../new_fields/ScriptField";
-import { NumCast, StrCast } from "../../../new_fields/Types";
+import { NumCast, StrCast, BoolCast } from "../../../new_fields/Types";
 import { emptyFunction, returnFalse, setupMoveUpEvents } from "../../../Utils";
 import { Scripting } from "../../util/Scripting";
 import { ContextMenu } from "../ContextMenu";
@@ -29,7 +29,6 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
         this.props.Document.onChildClick = undefined;
     }
     componentDidMount() {
-        this.props.Document._freezeOnDrop = true;
         const childDetailed = this.props.Document.childDetailed; // bcz: needs to be here to make sure the childDetailed layout template has been loaded when the first item is clicked;
         const childText = "const alias = getAlias(this); Doc.ApplyTemplateTo(containingCollection.childDetailed, alias, 'layout_detailView'); alias.layoutKey='layout_detailedView'; alias.dropAction='alias'; alias.removeDropProperties=new List<string>(['dropAction']); useRightSplit(alias, shiftKey); ";
         this.props.Document.onChildClick = ScriptField.MakeScript(childText, { this: Doc.name, heading: "string", containingCollection: Doc.name, shiftKey: "boolean" });
@@ -73,7 +72,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
 
     @computed get contents() {
         return <div className="collectionTimeView-innards" key="timeline" style={{ width: "100%" }}>
-            <CollectionFreeFormView  {...this.props} layoutEngine={this.layoutEngine} />
+            <CollectionFreeFormView {...this.props} freezeDimensions={BoolCast(this.layoutDoc._freezeChildDimensions, true)} layoutEngine={this.layoutEngine} />
         </div>;
     }
 
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 77dd9a162..10da50e35 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -465,6 +465,8 @@ class TreeView extends React.Component<TreeViewProps> {
                         ContentScaling={returnOne}
                         PanelWidth={returnZero}
                         PanelHeight={returnZero}
+                        NativeHeight={returnZero}
+                        NativeWidth={returnZero}
                         renderDepth={1}
                         focus={emptyFunction}
                         parentActive={returnTrue}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index a727da267..5d08a2bd8 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -13,7 +13,7 @@ import { List } from '../../../new_fields/List';
 import { BoolCast, Cast, NumCast, StrCast, ScriptCast } from '../../../new_fields/Types';
 import { ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
-import { Utils, setupMoveUpEvents, returnFalse } from '../../../Utils';
+import { Utils, setupMoveUpEvents, returnFalse, returnZero } from '../../../Utils';
 import { DocumentType } from '../../documents/DocumentTypes';
 import { DocumentManager } from '../../util/DocumentManager';
 import { ImageUtils } from '../../util/Import & Export/ImageUtils';
@@ -424,6 +424,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
                     <CollectionTreeView {...this.props}
                         CollectionView={this}
                         treeViewHideTitle={true}
+                        NativeHeight={returnZero}
+                        NativeWidth={returnZero}
                         treeViewHideHeaderFields={true}
                         onCheckedClick={this.scriptField!}
                         ignoreFields={this.treeIgnoreFields}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index d4e44b9a9..f22f1a304 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -89,8 +89,8 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
     @computed get fitToContent() { return (this.props.fitToBox || this.Document._fitToBox) && !this.isAnnotationOverlay; }
     @computed get parentScaling() { return this.props.ContentScaling && this.fitToContent && !this.isAnnotationOverlay ? this.props.ContentScaling() : 1; }
     @computed get contentBounds() { return aggregateBounds(this._layoutElements.filter(e => e.bounds && !e.bounds.z).map(e => e.bounds!), NumCast(this.layoutDoc.xPadding, 10), NumCast(this.layoutDoc.yPadding, 10)); }
-    @computed get nativeWidth() { return this.Document._fitToContent ? 0 : NumCast(this.Document._nativeWidth); }
-    @computed get nativeHeight() { return this.fitToContent ? 0 : NumCast(this.Document._nativeHeight); }
+    @computed get nativeWidth() { return this.Document._fitToContent ? 0 : NumCast(this.Document._nativeWidth, this.props.NativeWidth()); }
+    @computed get nativeHeight() { return this.fitToContent ? 0 : NumCast(this.Document._nativeHeight, this.props.NativeHeight()); }
     private get isAnnotationOverlay() { return this.props.isAnnotationOverlay; }
     private get borderWidth() { return this.isAnnotationOverlay ? 0 : COLLECTION_BORDER_WIDTH; }
     private easing = () => this.props.Document.panTransformType === "Ease";
@@ -825,6 +825,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
             DataDoc: childData,
             Document: childLayout,
             LibraryPath: this.libraryPath,
+            FreezeDimensions: this.props.freezeDimensions,
             layoutKey: undefined,
             rootSelected: this.rootSelected,
             dropAction: StrCast(this.props.Document.childDropAction) as dropActionType,
diff --git a/src/client/views/nodes/AudioBox.tsx b/src/client/views/nodes/AudioBox.tsx
index be0e1aec4..ff9630273 100644
--- a/src/client/views/nodes/AudioBox.tsx
+++ b/src/client/views/nodes/AudioBox.tsx
@@ -7,7 +7,7 @@ import { AudioField, nullAudio } from "../../../new_fields/URLField";
 import { DocExtendableComponent } from "../DocComponent";
 import { makeInterface, createSchema } from "../../../new_fields/Schema";
 import { documentSchema } from "../../../new_fields/documentSchemas";
-import { Utils, returnTrue, emptyFunction, returnOne, returnTransparent, returnFalse } from "../../../Utils";
+import { Utils, returnTrue, emptyFunction, returnOne, returnTransparent, returnFalse, returnZero } from "../../../Utils";
 import { runInAction, observable, reaction, IReactionDisposer, computed, action } from "mobx";
 import { DateField } from "../../../new_fields/DateField";
 import { SelectionManager } from "../../util/SelectionManager";
@@ -261,6 +261,8 @@ export class AudioBox extends DocExtendableComponent<FieldViewProps, AudioDocume
                                         <div className={this.props.PanelHeight() < 32 ? "audioBox-linker-mini" : "audioBox-linker"} key={"linker" + i}>
                                             <DocumentView {...this.props}
                                                 Document={l}
+                                                NativeHeight={returnZero}
+                                                NativeWidth={returnZero}
                                                 rootSelected={returnFalse}
                                                 layoutKey={Doc.LinkEndpoint(l, la2)}
                                                 ContainingCollectionDoc={this.props.Document}
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index 356192797..8a4842427 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -41,10 +41,11 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
         const hgt = this.renderScriptDim ? this.renderScriptDim.height : this.props.height !== undefined ? this.props.height : this.props.dataProvider && this.dataProvider ? this.dataProvider.height : this.layoutDoc[HeightSym]();
         return (hgt === undefined && this.nativeWidth && this.nativeHeight) ? this.width * this.nativeHeight / this.nativeWidth : hgt;
     }
+    @computed get freezeDimensions() { return this.props.FreezeDimensions || this.layoutDoc._freezeChildDimensions; }
     @computed get dataProvider() { return this.props.dataProvider && this.props.dataProvider(this.props.Document) ? this.props.dataProvider(this.props.Document) : undefined; }
-    @computed get nativeWidth() { return NumCast(this.layoutDoc._nativeWidth); }
-    @computed get nativeHeight() { return NumCast(this.layoutDoc._nativeHeight); }
-
+    @computed get nativeWidth() { return NumCast(this.layoutDoc._nativeWidth, this.props.NativeWidth() || (this.freezeDimensions ? this.layoutDoc[WidthSym]() : 0)); }
+    @computed get nativeHeight() { return NumCast(this.layoutDoc._nativeHeight, this.props.NativeHeight() || (this.freezeDimensions ? this.layoutDoc[HeightSym]() : 0)); }
+   
     @computed get renderScriptDim() {
         if (this.Document.renderScript) {
             const someView = Cast(this.props.Document.someView, Doc);
@@ -68,6 +69,8 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
         .scale(1 / this.contentScaling())
 
     focusDoc = (doc: Doc) => this.props.focus(doc, false);
+    NativeWidth = () => this.nativeWidth;
+    NativeHeight = () => this.nativeHeight;
     render() {
         TraceMobx();
         return <div className="collectionFreeFormDocumentView-container"
@@ -89,22 +92,26 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
                 pointerEvents: this.props.Document.isBackground ? "none" : undefined
             }} >
 
-            {!this.props.fitToBox ? 
-            <DocumentView {...this.props}
-                dragDivName={"collectionFreeFormDocumentView-container"}
-                ContentScaling={this.contentScaling}
-                ScreenToLocalTransform={this.getTransform}
-                backgroundColor={this.props.backgroundColor}
-                PanelWidth={this.panelWidth}
-                PanelHeight={this.panelHeight} /> 
-            : <ContentFittingDocumentView {...this.props}
-                CollectionDoc={this.props.ContainingCollectionDoc}
-                DataDocument={this.props.DataDoc}
-                getTransform={this.getTransform}
-                active={returnFalse}
-                focus={this.focusDoc}
-                PanelWidth={this.panelWidth}
-                PanelHeight={this.panelHeight}
+            {!this.props.fitToBox ?
+                <DocumentView {...this.props}
+                    dragDivName={"collectionFreeFormDocumentView-container"}
+                    ContentScaling={this.contentScaling}
+                    ScreenToLocalTransform={this.getTransform}
+                    backgroundColor={this.props.backgroundColor}
+                    NativeHeight={this.NativeHeight}
+                    NativeWidth={this.NativeWidth}
+                    PanelWidth={this.panelWidth}
+                    PanelHeight={this.panelHeight} />
+                : <ContentFittingDocumentView {...this.props}
+                    CollectionDoc={this.props.ContainingCollectionDoc}
+                    DataDocument={this.props.DataDoc}
+                    getTransform={this.getTransform}
+                    NativeHeight={this.NativeHeight}
+                    NativeWidth={this.NativeWidth}
+                    active={returnFalse}
+                    focus={this.focusDoc}
+                    PanelWidth={this.panelWidth}
+                    PanelHeight={this.panelHeight}
                 />}
         </div>;
     }
diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx
index 9ab6826a3..09675bf73 100644
--- a/src/client/views/nodes/ContentFittingDocumentView.tsx
+++ b/src/client/views/nodes/ContentFittingDocumentView.tsx
@@ -18,6 +18,9 @@ interface ContentFittingDocumentViewProps {
     Document?: Doc;
     DataDocument?: Doc;
     LayoutDoc?: () => Opt<Doc>;
+    NativeWidth?: () => number;
+    NativeHeight?: () => number;
+    FreezeDimensions?: boolean;
     LibraryPath: Doc[];
     childDocs?: Doc[];
     renderDepth: number;
@@ -47,12 +50,12 @@ interface ContentFittingDocumentViewProps {
 export class ContentFittingDocumentView extends React.Component<ContentFittingDocumentViewProps>{
     public get displayName() { return "DocumentView(" + this.props.Document?.title + ")"; } // this makes mobx trace() statements more descriptive
     private get layoutDoc() { return this.props.Document && (this.props.LayoutDoc?.() || Doc.Layout(this.props.Document)); }
-    private get nativeWidth() { return NumCast(this.layoutDoc?._nativeWidth, this.props.PanelWidth()); }
-    private get nativeHeight() { return NumCast(this.layoutDoc?._nativeHeight, this.props.PanelHeight()); }
+    private nativeWidth = () => NumCast(this.layoutDoc?._nativeWidth, this.props.NativeWidth?.() || this.props.PanelWidth());
+    private nativeHeight = () => NumCast(this.layoutDoc?._nativeHeight, this.props.NativeHeight?.() || this.props.PanelHeight());
     @computed get scaling() {
-        const wscale = this.props.PanelWidth() / (this.nativeWidth || this.props.PanelWidth() || 1);
-        if (wscale * this.nativeHeight > this.props.PanelHeight()) {
-            return (this.props.PanelHeight() / (this.nativeHeight || this.props.PanelHeight() || 1)) || 1;
+        const wscale = this.props.PanelWidth() / (this.nativeWidth() || this.props.PanelWidth() || 1);
+        if (wscale * this.nativeHeight() > this.props.PanelHeight()) {
+            return (this.props.PanelHeight() / (this.nativeHeight() || this.props.PanelHeight() || 1)) || 1;
         }
         return wscale || 1;
     }
@@ -61,12 +64,12 @@ export class ContentFittingDocumentView extends React.Component<ContentFittingDo
     private PanelWidth = () => this.panelWidth;
     private PanelHeight = () => this.panelHeight;
 
-    @computed get panelWidth() { return this.nativeWidth && (!this.props.Document || !this.props.Document._fitWidth) ? this.nativeWidth * this.contentScaling() : this.props.PanelWidth(); }
-    @computed get panelHeight() { return this.nativeHeight && (!this.props.Document || !this.props.Document._fitWidth) ? this.nativeHeight * this.contentScaling() : this.props.PanelHeight(); }
+    @computed get panelWidth() { return this.nativeWidth && (!this.props.Document || !this.props.Document._fitWidth) ? this.nativeWidth() * this.contentScaling() : this.props.PanelWidth(); }
+    @computed get panelHeight() { return this.nativeHeight && (!this.props.Document || !this.props.Document._fitWidth) ? this.nativeHeight() * this.contentScaling() : this.props.PanelHeight(); }
 
     private getTransform = () => this.props.getTransform().translate(-this.centeringOffset, -this.centeringYOffset).scale(1 / this.contentScaling());
-    private get centeringOffset() { return this.nativeWidth && (!this.props.Document || !this.props.Document._fitWidth) ? (this.props.PanelWidth() - this.nativeWidth * this.contentScaling()) / 2 : 0; }
-    private get centeringYOffset() { return Math.abs(this.centeringOffset) < 0.001 ? (this.props.PanelHeight() - this.nativeHeight * this.contentScaling()) / 2 : 0; }
+    private get centeringOffset() { return this.nativeWidth && (!this.props.Document || !this.props.Document._fitWidth) ? (this.props.PanelWidth() - this.nativeWidth() * this.contentScaling()) / 2 : 0; }
+    private get centeringYOffset() { return Math.abs(this.centeringOffset) < 0.001 ? (this.props.PanelHeight() - this.nativeHeight() * this.contentScaling()) / 2 : 0; }
 
     @computed get borderRounding() { return StrCast(this.props.Document?.borderRounding); }
 
@@ -81,7 +84,7 @@ export class ContentFittingDocumentView extends React.Component<ContentFittingDo
                     style={{
                         transform: `translate(${this.centeringOffset}px, 0px)`,
                         borderRadius: this.borderRounding,
-                        height: Math.abs(this.centeringYOffset) > 0.001 ? `${100 * this.nativeHeight / this.nativeWidth * this.props.PanelWidth() / this.props.PanelHeight()}%` : this.props.PanelHeight(),
+                        height: Math.abs(this.centeringYOffset) > 0.001 ? `${100 * this.nativeHeight() / this.nativeWidth() * this.props.PanelWidth() / this.props.PanelHeight()}%` : this.props.PanelHeight(),
                         width: Math.abs(this.centeringOffset) > 0.001 ? `${100 * (this.props.PanelWidth() - this.centeringOffset * 2) / this.props.PanelWidth()}%` : this.props.PanelWidth()
                     }}>
                     <DocumentView {...this.props}
@@ -89,6 +92,8 @@ export class ContentFittingDocumentView extends React.Component<ContentFittingDo
                         DataDoc={this.props.DataDocument}
                         LayoutDoc={this.props.LayoutDoc}
                         LibraryPath={this.props.LibraryPath}
+                        NativeWidth={this.nativeWidth}
+                        NativeHeight={this.nativeHeight}
                         fitToBox={this.props.fitToBox}
                         layoutKey={this.props.layoutKey}
                         dropAction={this.props.dropAction}
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index aa3c1b3a2..9c9f2e48e 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -3,7 +3,7 @@ import * as fa from '@fortawesome/free-solid-svg-icons';
 import { action, computed, runInAction, trace, observable } from "mobx";
 import { observer } from "mobx-react";
 import * as rp from "request-promise";
-import { Doc, DocListCast, Opt } from "../../../new_fields/Doc";
+import { Doc, DocListCast, Opt, WidthSym, HeightSym } from "../../../new_fields/Doc";
 import { Document, PositionDocument } from '../../../new_fields/documentSchemas';
 import { Id } from '../../../new_fields/FieldSymbols';
 import { InkTool } from '../../../new_fields/InkField';
@@ -56,6 +56,9 @@ export type DocFocusFunc = () => boolean;
 export interface DocumentViewProps {
     ContainingCollectionView: Opt<CollectionView>;
     ContainingCollectionDoc: Opt<Doc>;
+    FreezeDimensions?: boolean;
+    NativeWidth: () => number;
+    NativeHeight: () => number;
     Document: Doc;
     DataDoc?: Doc;
     LayoutDoc?: () => Opt<Doc>;
@@ -109,11 +112,14 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     public get ContentDiv() { return this._mainCont.current; }
     @computed get active() { return SelectionManager.IsSelected(this, true) || this.props.parentActive(true); }
     @computed get topMost() { return this.props.renderDepth === 0; }
-    @computed get nativeWidth() { return this.layoutDoc._nativeWidth || 0; }
-    @computed get nativeHeight() { return this.layoutDoc._nativeHeight || 0; }
+    @computed get freezeDimensions() { return this.props.FreezeDimensions || this.layoutDoc._freezeChildDimensions; }
+    @computed get nativeWidth() { return NumCast(this.layoutDoc._nativeWidth, this.props.NativeWidth() || (this.freezeDimensions ? this.layoutDoc[WidthSym]() : 0)); }
+    @computed get nativeHeight() { return NumCast(this.layoutDoc._nativeHeight, this.props.NativeHeight() || (this.freezeDimensions ? this.layoutDoc[HeightSym]() : 0)); }
     @computed get onClickHandler() { return this.props.onClick || this.layoutDoc.onClick || this.Document.onClick; }
     @computed get onPointerDownHandler() { return this.props.onPointerDown ? this.props.onPointerDown : this.Document.onPointerDown; }
     @computed get onPointerUpHandler() { return this.props.onPointerUp ? this.props.onPointerUp : this.Document.onPointerUp; }
+    NativeWidth = () => this.nativeWidth;
+    NativeHeight = () => this.nativeHeight;
 
     private _firstX: number = -1;
     private _firstY: number = -1;
@@ -965,6 +971,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         TraceMobx();
         return (<DocumentContentsView ContainingCollectionView={this.props.ContainingCollectionView}
             ContainingCollectionDoc={this.props.ContainingCollectionDoc}
+            NativeHeight={this.NativeHeight}
+            NativeWidth={this.NativeWidth}
             Document={this.props.Document}
             DataDoc={this.props.DataDoc}
             LayoutDoc={this.props.LayoutDoc}
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 13a1becf7..dfcb03985 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -45,6 +45,8 @@ export interface FieldViewProps {
     focus: (doc: Doc) => void;
     PanelWidth: () => number;
     PanelHeight: () => number;
+    NativeHeight: () => number;
+    NativeWidth: () => number;
     setVideoBox?: (player: VideoBox) => void;
     ContentScaling: () => number;
     ChromeHeight?: () => number;
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 94195fbd6..37770a2e1 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -22,7 +22,7 @@ import { RichTextUtils } from '../../../new_fields/RichTextUtils';
 import { createSchema, makeInterface } from "../../../new_fields/Schema";
 import { Cast, NumCast, StrCast, BoolCast, DateCast } from "../../../new_fields/Types";
 import { TraceMobx } from '../../../new_fields/util';
-import { addStyleSheet, addStyleSheetRule, clearStyleSheetRules, emptyFunction, numberRange, returnOne, Utils, returnTrue } from '../../../Utils';
+import { addStyleSheet, addStyleSheetRule, clearStyleSheetRules, emptyFunction, numberRange, returnOne, Utils, returnTrue, returnZero } from '../../../Utils';
 import { GoogleApiClientUtils, Pulls, Pushes } from '../../apis/google_docs/GoogleApiClientUtils';
 import { DocServer } from "../../DocServer";
 import { Docs, DocUtils } from '../../documents/Documents';
@@ -1216,6 +1216,8 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
                         <CollectionFreeFormView {...this.props}
                             PanelHeight={this.props.PanelHeight}
                             PanelWidth={this.sidebarWidth}
+                            NativeHeight={returnZero}
+                            NativeWidth={returnZero}
                             annotationsKey={this.annotationKey}
                             isAnnotationOverlay={false}
                             focus={this.props.focus}
diff --git a/src/client/views/nodes/ImageBox.tsx b/src/client/views/nodes/ImageBox.tsx
index 00057055f..a4d3f3d79 100644
--- a/src/client/views/nodes/ImageBox.tsx
+++ b/src/client/views/nodes/ImageBox.tsx
@@ -14,7 +14,7 @@ import { ComputedField } from '../../../new_fields/ScriptField';
 import { Cast, NumCast, StrCast } from '../../../new_fields/Types';
 import { AudioField, ImageField } from '../../../new_fields/URLField';
 import { TraceMobx } from '../../../new_fields/util';
-import { emptyFunction, returnOne, Utils } from '../../../Utils';
+import { emptyFunction, returnOne, Utils, returnZero } from '../../../Utils';
 import { CognitiveServices, Confidence, Service, Tag } from '../../cognitive_services/CognitiveServices';
 import { Docs } from '../../documents/Documents';
 import { Networking } from '../../Network';
@@ -445,6 +445,8 @@ export class ImageBox extends DocAnnotatableComponent<FieldViewProps, ImageDocum
             <CollectionFreeFormView {...this.props}
                 PanelHeight={this.props.PanelHeight}
                 PanelWidth={this.props.PanelWidth}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 annotationsKey={this.annotationKey}
                 isAnnotationOverlay={true}
                 focus={this.props.focus}
diff --git a/src/client/views/nodes/KeyValuePair.tsx b/src/client/views/nodes/KeyValuePair.tsx
index ef039c857..6dc4ae578 100644
--- a/src/client/views/nodes/KeyValuePair.tsx
+++ b/src/client/views/nodes/KeyValuePair.tsx
@@ -62,13 +62,15 @@ export class KeyValuePair extends React.Component<KeyValuePairProps> {
             rootSelected: returnFalse,
             isSelected: returnFalse,
             select: emptyFunction,
-            dropAction:"alias",
-            bringToFront:emptyFunction,
+            dropAction: "alias",
+            bringToFront: emptyFunction,
             renderDepth: 1,
             active: returnFalse,
             whenActiveChanged: emptyFunction,
             ScreenToLocalTransform: Transform.Identity,
             focus: emptyFunction,
+            NativeHeight: returnZero,
+            NativeWidth: returnZero,
             PanelWidth: this.props.PanelWidth,
             PanelHeight: this.props.PanelHeight,
             addDocTab: returnFalse,
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 0e327e130..542c86049 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -23,6 +23,8 @@ export class LinkBox extends DocExtendableComponent<FieldViewProps, LinkDocument
             <CollectionTreeView {...this.props}
                 ChromeHeight={returnZero}
                 overrideDocuments={[this.dataDoc]}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 ignoreFields={Cast(this.props.Document.linkBoxExcludedKeys, listSpec("string"), null)}
                 annotationsKey={""}
                 CollectionView={undefined}
diff --git a/src/client/views/nodes/ScreenshotBox.tsx b/src/client/views/nodes/ScreenshotBox.tsx
index 7c58a5148..58ff4971a 100644
--- a/src/client/views/nodes/ScreenshotBox.tsx
+++ b/src/client/views/nodes/ScreenshotBox.tsx
@@ -10,7 +10,7 @@ import { makeInterface } from "../../../new_fields/Schema";
 import { ScriptField } from "../../../new_fields/ScriptField";
 import { Cast, StrCast } from "../../../new_fields/Types";
 import { VideoField } from "../../../new_fields/URLField";
-import { emptyFunction, returnFalse, returnOne, Utils } from "../../../Utils";
+import { emptyFunction, returnFalse, returnOne, Utils, returnZero } from "../../../Utils";
 import { Docs, DocUtils } from "../../documents/Documents";
 import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
 import { ContextMenu } from "../ContextMenu";
@@ -170,6 +170,8 @@ export class ScreenshotBox extends DocAnnotatableComponent<FieldViewProps, Scree
                 <CollectionFreeFormView {...this.props}
                     PanelHeight={this.props.PanelHeight}
                     PanelWidth={this.props.PanelWidth}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     annotationsKey={this.annotationKey}
                     focus={this.props.focus}
                     isSelected={this.props.isSelected}
diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx
index 24b66d8f7..d384ad12f 100644
--- a/src/client/views/nodes/VideoBox.tsx
+++ b/src/client/views/nodes/VideoBox.tsx
@@ -11,7 +11,7 @@ import { createSchema, makeInterface } from "../../../new_fields/Schema";
 import { ScriptField } from "../../../new_fields/ScriptField";
 import { Cast, StrCast, NumCast } from "../../../new_fields/Types";
 import { VideoField } from "../../../new_fields/URLField";
-import { Utils, emptyFunction, returnOne } from "../../../Utils";
+import { Utils, emptyFunction, returnOne, returnZero } from "../../../Utils";
 import { Docs, DocUtils } from "../../documents/Documents";
 import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
 import { ContextMenu } from "../ContextMenu";
@@ -352,6 +352,8 @@ export class VideoBox extends DocAnnotatableComponent<FieldViewProps, VideoDocum
                 <CollectionFreeFormView {...this.props}
                     PanelHeight={this.props.PanelHeight}
                     PanelWidth={this.props.PanelWidth}
+                    NativeHeight={returnZero}
+                    NativeWidth={returnZero}
                     annotationsKey={this.annotationKey}
                     focus={this.props.focus}
                     isSelected={this.props.isSelected}
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 838fbefb1..ea5d601ec 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -9,7 +9,7 @@ import { InkTool } from "../../../new_fields/InkField";
 import { makeInterface } from "../../../new_fields/Schema";
 import { Cast, NumCast } from "../../../new_fields/Types";
 import { WebField } from "../../../new_fields/URLField";
-import { Utils, returnOne, emptyFunction } from "../../../Utils";
+import { Utils, returnOne, emptyFunction, returnZero } from "../../../Utils";
 import { Docs } from "../../documents/Documents";
 import { DragManager } from "../../util/DragManager";
 import { ImageUtils } from "../../util/Import & Export/ImageUtils";
@@ -335,6 +335,8 @@ export class WebBox extends DocAnnotatableComponent<FieldViewProps, WebDocument>
                 PanelHeight={this.props.PanelHeight}
                 PanelWidth={this.props.PanelWidth}
                 annotationsKey={this.annotationKey}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 focus={this.props.focus}
                 isSelected={this.props.isSelected}
                 isAnnotationOverlay={true}
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 25ceb6218..36e687f71 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -9,7 +9,7 @@ import { List } from "../../../new_fields/List";
 import { makeInterface, createSchema } from "../../../new_fields/Schema";
 import { ScriptField, ComputedField } from "../../../new_fields/ScriptField";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { smoothScroll, Utils, emptyFunction, returnOne, intersectRect, addStyleSheet, addStyleSheetRule, clearStyleSheetRules } from "../../../Utils";
+import { smoothScroll, Utils, emptyFunction, returnOne, intersectRect, addStyleSheet, addStyleSheetRule, clearStyleSheetRules, returnZero } from "../../../Utils";
 import { Docs, DocUtils } from "../../documents/Documents";
 import { DragManager } from "../../util/DragManager";
 import { CompiledScript, CompileScript } from "../../util/Scripting";
@@ -648,6 +648,8 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
                 setPreviewCursor={this.setPreviewCursor}
                 PanelHeight={this.panelWidth}
                 PanelWidth={this.panelHeight}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 dropAction={"alias"}
                 VisibleHeight={this.visibleHeight}
                 focus={this.props.focus}
diff --git a/src/mobile/MobileInterface.tsx b/src/mobile/MobileInterface.tsx
index 5f766c121..c87ac719c 100644
--- a/src/mobile/MobileInterface.tsx
+++ b/src/mobile/MobileInterface.tsx
@@ -7,7 +7,7 @@ import { Doc, DocListCast } from '../new_fields/Doc';
 import { Docs } from '../client/documents/Documents';
 import { CollectionView } from '../client/views/collections/CollectionView';
 import { DocumentView } from '../client/views/nodes/DocumentView';
-import { emptyPath, emptyFunction, returnFalse, returnOne, returnEmptyString, returnTrue } from '../Utils';
+import { emptyPath, emptyFunction, returnFalse, returnOne, returnEmptyString, returnTrue, returnZero } from '../Utils';
 import { Transform } from '../client/util/Transform';
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faPenNib, faHighlighter, faEraser, faMousePointer, faBreadSlice, faTrash, faCheck, faLongArrowAltLeft } from '@fortawesome/free-solid-svg-icons';
@@ -129,6 +129,8 @@ export default class MobileInterface extends React.Component {
                 onClick={undefined}
                 ScreenToLocalTransform={Transform.Identity}
                 ContentScaling={returnOne}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
                 PanelWidth={() => window.screen.width}
                 PanelHeight={() => window.screen.height}
                 renderDepth={0}
@@ -173,6 +175,8 @@ export default class MobileInterface extends React.Component {
         e.stopPropagation();
     }
 
+    panelHeight = () => window.innerHeight;
+    panelWidth = () => window.innerWidth;
     renderInkingContent = () => {
         console.log("rendering inking content");
         // TODO: support panning and zooming
@@ -201,8 +205,10 @@ export default class MobileInterface extends React.Component {
                         bringToFront={emptyFunction}
                         addDocTab={returnFalse}
                         pinToPres={emptyFunction}
-                        PanelHeight={() => window.innerHeight}
-                        PanelWidth={() => window.innerWidth}
+                        PanelWidth={this.panelWidth}
+                        PanelHeight={this.panelHeight}
+                        NativeHeight={returnZero}
+                        NativeWidth={returnZero}
                         focus={emptyFunction}
                         isSelected={returnFalse}
                         select={emptyFunction}
@@ -289,6 +295,8 @@ export default class MobileInterface extends React.Component {
                         onClick={undefined}
                         ScreenToLocalTransform={Transform.Identity}
                         ContentScaling={returnOne}
+                        NativeHeight={returnZero}
+                        NativeWidth={returnZero}
                         PanelWidth={() => window.screen.width}
                         PanelHeight={() => window.screen.height}
                         renderDepth={0}
diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts
index 1a5a471a0..ff02596f7 100644
--- a/src/new_fields/documentSchemas.ts
+++ b/src/new_fields/documentSchemas.ts
@@ -28,7 +28,7 @@ export const documentSchema = createSchema({
     _pivotField: "string",      // specifies which field should be used as the timeline/pivot axis
     _replacedChrome: "string",  // what the default chrome is replaced with. Currently only supports the value of 'replaced' for PresBox's.
     _chromeStatus: "string",    // determines the state of the collection chrome. values allowed are 'replaced', 'enabled', 'disabled', 'collapsed'
-    _freezeOnDrop: "boolean",    // whether a document without native dimensions should have its width/height frozen as native dimensions on drop.  Used by Timeline view to make sure documents are scaled to fit the display thumbnail
+    _freezeChildDimensions: "boolean", // freezes child document dimensions (e.g., used by time/pivot view to make sure all children will be scaled to fit their display rectangle)
     color: "string",            // foreground color of document
     backgroundColor: "string",  // background color of document
     opacity: "number",          // opacity of document
diff --git a/src/new_fields/util.ts b/src/new_fields/util.ts
index 8c719ccd8..480a55da0 100644
--- a/src/new_fields/util.ts
+++ b/src/new_fields/util.ts
@@ -12,7 +12,7 @@ function _readOnlySetter(): never {
     throw new Error("Documents can't be modified in read-only mode");
 }
 
-const tracing = false;
+const tracing = true;
 export function TraceMobx() {
     tracing && trace();
 }
-- 
cgit v1.2.3-70-g09d2


From cc5251534850bf3dd7bb39be54e8dbd7cb73dc9f Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Mon, 6 Apr 2020 14:47:43 -0400
Subject: fixed padding.  added isInPlaceContainer flag.  changed button
 content for setting collection content to use the dropped document directly
 (not an alias of it)

---
 src/client/views/collections/CollectionView.tsx                      | 2 ++
 src/client/views/collections/CollectionViewChromes.tsx               | 5 +++--
 .../views/collections/collectionFreeForm/CollectionFreeFormView.tsx  | 4 ++--
 src/client/views/nodes/CollectionFreeFormDocumentView.tsx            | 4 ++--
 src/new_fields/documentSchemas.ts                                    | 1 +
 5 files changed, 10 insertions(+), 6 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 5d08a2bd8..183d01b74 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -248,6 +248,8 @@ export class CollectionView extends Touchable<FieldViewProps> {
             if (this.props.Document.childDetailed instanceof Doc) {
                 layoutItems.push({ description: "View Child Detailed Layout", event: () => this.props.addDocTab(this.props.Document.childDetailed as Doc, "onRight"), icon: "project-diagram" });
             }
+            layoutItems.push({ description: "Toggle is inPlace Container", event: () => this.props.Document.isInPlaceContainer = !this.props.Document.isInPlaceContainer, icon: "project-diagram" });
+
             !existing && ContextMenu.Instance.addItem({ description: "Layout...", subitems: layoutItems, icon: "hand-point-right" });
 
             const open = ContextMenu.Instance.findByDescription("Open...");
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 2d565d9db..4a0eb3aa4 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -18,6 +18,7 @@ import { CollectionView } from "./CollectionView";
 import "./CollectionViewChromes.scss";
 import * as Autosuggest from 'react-autosuggest';
 import KeyRestrictionRow from "./KeyRestrictionRow";
+import { ObjectField } from "../../../new_fields/ObjectField";
 const datepicker = require('js-datepicker');
 
 interface CollectionViewChromeProps {
@@ -54,8 +55,8 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
     };
     _contentCommand = {
         params: ["target", "source"], title: "=> content",
-        script: "getProto(this.target).data = aliasDocs(this.source);",
-        immediate: (source: Doc[]) => Doc.GetProto(this.target).data = Doc.aliasDocs(source),
+        script: "getProto(this.target).data = copyField(this.source);",
+        immediate: (source: Doc[]) => Doc.GetProto(this.target).data = new List<Doc>(source), // Doc.aliasDocs(source),
         initialize: emptyFunction,
     };
     _viewCommand = {
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 9581ec255..f12dd76d8 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -88,7 +88,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
 
     @computed get fitToContent() { return (this.props.fitToBox || this.Document._fitToBox) && !this.isAnnotationOverlay; }
     @computed get parentScaling() { return this.props.ContentScaling && this.fitToContent && !this.isAnnotationOverlay ? this.props.ContentScaling() : 1; }
-    @computed get contentBounds() { return aggregateBounds(this._layoutElements.filter(e => e.bounds && !e.bounds.z).map(e => e.bounds!), NumCast(this.layoutDoc.xPadding, 10), NumCast(this.layoutDoc.yPadding, 10)); }
+    @computed get contentBounds() { return aggregateBounds(this._layoutElements.filter(e => e.bounds && !e.bounds.z).map(e => e.bounds!), NumCast(this.layoutDoc._xPadding, 10), NumCast(this.layoutDoc._yPadding, 10)); }
     @computed get nativeWidth() { return this.fitToContent ? 0 : NumCast(this.Document._nativeWidth, this.props.NativeWidth()); }
     @computed get nativeHeight() { return this.fitToContent ? 0 : NumCast(this.Document._nativeHeight, this.props.NativeHeight()); }
     private get isAnnotationOverlay() { return this.props.isAnnotationOverlay; }
@@ -852,7 +852,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
     }
 
     addDocTab = (doc: Doc, where: string) => {
-        if (where === "inPlace") {
+        if (where === "inPlace" && this.layoutDoc.isInPlaceContainer) {
             this.dataDoc[this.props.fieldKey] = new List<Doc>([doc]);
             return true;
         }
diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
index 7e9e654cd..f9f5f449c 100644
--- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
+++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx
@@ -61,8 +61,8 @@ export class CollectionFreeFormDocumentView extends DocComponent<CollectionFreeF
     }
 
     contentScaling = () => this.nativeWidth > 0 && !this.props.fitToBox && !this.freezeDimensions ? this.width / this.nativeWidth : 1;
-    panelWidth = () => (this.dataProvider?.width || this.props.PanelWidth());
-    panelHeight = () => (this.dataProvider?.height || this.props.PanelHeight());
+    panelWidth = () => (this.dataProvider?.width || this.props.PanelWidth?.());
+    panelHeight = () => (this.dataProvider?.height || this.props.PanelHeight?.());
     getTransform = (): Transform => this.props.ScreenToLocalTransform()
         .translate(-this.X, -this.Y)
         .scale(1 / this.contentScaling())
diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts
index ff02596f7..03519cb94 100644
--- a/src/new_fields/documentSchemas.ts
+++ b/src/new_fields/documentSchemas.ts
@@ -29,6 +29,7 @@ export const documentSchema = createSchema({
     _replacedChrome: "string",  // what the default chrome is replaced with. Currently only supports the value of 'replaced' for PresBox's.
     _chromeStatus: "string",    // determines the state of the collection chrome. values allowed are 'replaced', 'enabled', 'disabled', 'collapsed'
     _freezeChildDimensions: "boolean", // freezes child document dimensions (e.g., used by time/pivot view to make sure all children will be scaled to fit their display rectangle)
+    isInPlaceContainer: "boolean",// whether the marked object will display addDocTab() calls that target "inPlace" destinations
     color: "string",            // foreground color of document
     backgroundColor: "string",  // background color of document
     opacity: "number",          // opacity of document
-- 
cgit v1.2.3-70-g09d2


From 68131598cebf0edbccef98d8bcfdba202161ec00 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Mon, 6 Apr 2020 18:11:57 -0400
Subject: followLinkLocation can be set on LinkDoc.  button box css fixes.

---
 src/client/util/DocumentManager.ts              |  2 +-
 src/client/views/collections/CollectionView.tsx |  1 +
 src/client/views/nodes/ButtonBox.scss           | 16 +++++++++-------
 3 files changed, 11 insertions(+), 8 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 7b8fb9e4c..3d5306841 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -224,7 +224,7 @@ export class DocumentManager {
                 containerDoc.currentTimecode !== undefined && (containerDoc.currentTimecode = NumCast(target?.timecode));
                 const targetContext = await target?.context as Doc;
                 const targetNavContext = !Doc.AreProtosEqual(targetContext, currentContext) ? targetContext : undefined;
-                DocumentManager.Instance.jumpToDocument(target, zoom, (doc, finished) => createViewFunc(doc, "onRight", finished), targetNavContext, linkDoc[Id], undefined, doc, finished);
+                DocumentManager.Instance.jumpToDocument(target, zoom, (doc, finished) => createViewFunc(doc, StrCast(linkDoc.followLinkLocation, "onRight"), finished), targetNavContext, linkDoc[Id], undefined, doc, finished);
             } else {
                 finished?.();
             }
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 183d01b74..c1234c500 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -162,6 +162,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     // moving it into the target.  
     @action.bound
     moveDocument(doc: Doc, targetCollection: Doc | undefined, addDocument: (doc: Doc) => boolean): boolean {
+        doc.context = targetCollection;
         if (Doc.AreProtosEqual(this.props.Document, targetCollection)) {
             return true;
         }
diff --git a/src/client/views/nodes/ButtonBox.scss b/src/client/views/nodes/ButtonBox.scss
index 7c3825978..293af289d 100644
--- a/src/client/views/nodes/ButtonBox.scss
+++ b/src/client/views/nodes/ButtonBox.scss
@@ -11,18 +11,19 @@
     width: 100%;
     height: 100%;
     border-radius: inherit;
-    text-align: center;
-    display: table;
-    overflow: hidden;
-    text-overflow: ellipsis;
     letter-spacing: 2px;
     text-transform: uppercase;
+    overflow: hidden;
+    display:flex;
 }
 
 .buttonBox-mainButtonCenter {
-    height: 100%;
-    display: table-cell;
-    vertical-align: middle;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    display: inline;
+    align-items: center;
+    margin: auto;
 }
 
 .buttonBox-params {
@@ -33,4 +34,5 @@
 .buttonBox-missingParam {
     width: 100%;
     background: lightgray;
+    border: dimGray solid 1px;
 }
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 8b02394f24e4f15674bf18192f49ee2385d67655 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Mon, 6 Apr 2020 21:58:50 -0400
Subject: cleaned up some scripting.  added childClicks to UserDoc to extend
 menu of OnClick options.  switched containingCollection to thisContainer for 
 onclick scripts

---
 src/client/util/Scripting.ts                          | 16 ++++++++--------
 src/client/views/ScriptBox.tsx                        |  2 +-
 src/client/views/collections/CollectionTimeView.tsx   |  4 ++--
 src/client/views/collections/CollectionView.tsx       | 11 ++++++++++-
 .../views/collections/CollectionViewChromes.tsx       | 10 +++++-----
 src/client/views/nodes/DocumentView.tsx               |  4 ++--
 src/new_fields/Doc.ts                                 | 19 +++++++------------
 .../authentication/models/current_user_utils.ts       | 12 +++++++++++-
 8 files changed, 46 insertions(+), 32 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index ce21b7fa7..cf04c44ca 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -195,14 +195,14 @@ export type Transformer = {
     getVars?: () => { capturedVariables: { [name: string]: Field } }
 };
 export interface ScriptOptions {
-    requiredType?: string;
-    addReturn?: boolean;
-    params?: { [name: string]: string };
-    capturedVariables?: { [name: string]: Field };
-    typecheck?: boolean;
-    editable?: boolean;
-    traverser?: TraverserParam;
-    transformer?: Transformer;
+    requiredType?: string; // does function required a typed return value
+    addReturn?: boolean;   // does the compiler automatically add a return statement
+    params?: { [name: string]: string }; // list of function parameters and their types
+    capturedVariables?: { [name: string]: Field }; // list of captured variables
+    typecheck?: boolean; // should the compiler perform typechecking
+    editable?: boolean; // can the script edit Docs
+    traverser?: TraverserParam; 
+    transformer?: Transformer; // does the editor display a text label by each document that can be used as a captured document reference
     globals?: { [name: string]: any };
 }
 
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index cc5d7640e..1e81bb80b 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -121,6 +121,6 @@ export class ScriptBox extends React.Component<ScriptBoxProps> {
                 overlayDisposer();
             }
         }} showDocumentIcons />;
-        overlayDisposer = OverlayView.Instance.addWindow(scriptingBox, { x: 400, y: 200, width: 500, height: 400, title: title });
+        overlayDisposer = OverlayView.Instance.addWindow(scriptingBox, { x: 400, y: 200, width: 500, height: 400, title });
     }
 }
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index 4b005ba42..53de2fbbe 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -30,8 +30,8 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
     }
     componentDidMount() {
         const childDetailed = this.props.Document.childDetailed; // bcz: needs to be here to make sure the childDetailed layout template has been loaded when the first item is clicked;
-        const childText = "const alias = getAlias(this); Doc.ApplyTemplateTo(containingCollection.childDetailed, alias, 'layout_detailView'); alias.layoutKey='layout_detailedView'; alias.dropAction='alias'; alias.removeDropProperties=new List<string>(['dropAction']); useRightSplit(alias, shiftKey); ";
-        this.props.Document.onChildClick = ScriptField.MakeScript(childText, { this: Doc.name, heading: "string", containingCollection: Doc.name, shiftKey: "boolean" });
+        const childText = "const alias = getAlias(this); Doc.ApplyTemplateTo(thisContainer.childDetailed, alias, 'layout_detailView'); alias.layoutKey='layout_detailedView'; alias.dropAction='alias'; alias.removeDropProperties=new List<string>(['dropAction']); useRightSplit(alias, shiftKey); ";
+        this.props.Document.onChildClick = ScriptField.MakeScript(childText, { this: Doc.name, heading: "string", thisContainer: Doc.name, shiftKey: "boolean" });
         this.props.Document._fitToBox = true;
         if (!this.props.Document.onViewDefClick) {
             this.props.Document.onViewDefDivClick = ScriptField.MakeScript("pivotColumnClick(this,payload)", { payload: "any" });
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index c1234c500..d7224fa4b 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -43,6 +43,7 @@ import { listSpec } from '../../../new_fields/Schema';
 import { Docs } from '../../documents/Documents';
 import { ScriptField, ComputedField } from '../../../new_fields/ScriptField';
 import { InteractionUtils } from '../../util/InteractionUtils';
+import { ObjectField } from '../../../new_fields/ObjectField';
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -259,7 +260,15 @@ export class CollectionView extends Touchable<FieldViewProps> {
 
             const existingOnClick = ContextMenu.Instance.findByDescription("OnClick...");
             const onClicks = existingOnClick && "subitems" in existingOnClick ? existingOnClick.subitems : [];
-            onClicks.push({ description: "Edit onChildClick script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Child Clicked...", this.props.Document, "onChildClick", obj.x, obj.y) });
+            const funcs = [{ key: "onChildClick", name: "On Child Clicked", script: undefined as any as ScriptField }];
+            DocListCast(Cast(Doc.UserDoc().childClickFuncs, Doc, null).data).forEach(childClick =>
+                funcs.push({ key: "onChildClick", name: StrCast(childClick.title), script: ScriptCast(childClick.script) }));
+            funcs.map(func => onClicks.push({
+                description: `Edit ${func.name} script`, icon: "edit", event: (obj: any) => {
+                    func.script && (this.props.Document[func.key] = ObjectField.MakeCopy(func.script));
+                    ScriptBox.EditButtonScript(func.name + "...", this.props.Document, func.key, obj.x, obj.y, { thisContainer: Doc.name });
+                }
+            }));
             !existingOnClick && ContextMenu.Instance.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" });
 
             const more = ContextMenu.Instance.findByDescription("More...");
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 4a0eb3aa4..9bade1c82 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -43,14 +43,14 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
     get target() { return this.props.CollectionView.props.Document; }
     _templateCommand = {
         params: ["target", "source"], title: "=> item view",
-        script: "setChildLayout(this.target, this.source?.[0])",
-        immediate: (source: Doc[]) => Doc.setChildLayout(this.target, source?.[0]),
+        script: "target.childLayout = getDocTemplate(this.source?.[0])",
+        immediate: (source: Doc[]) => this.target.childLayout = Doc.getDocTemplate(source?.[0]),
         initialize: emptyFunction,
     };
     _narrativeCommand = {
         params: ["target", "source"], title: "=> click item view",
-        script: "setChildDetailedLayout(this.target, this.source?.[0])",
-        immediate: (source: Doc[]) => Doc.setChildDetailedLayout(this.target, source?.[0]),
+        script: "this.target.childDetailed = getDocTemplate(this.source?.[0])",
+        immediate: (source: Doc[]) => this.target.childDetailed = Doc.getDocTemplate(source?.[0]),
         initialize: emptyFunction,
     };
     _contentCommand = {
@@ -353,7 +353,7 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
             const c = {
                 params: ["target"], title: CollectionViewType.stringFor(vtype),
                 script: `this.target._viewType = ${NumCast(this.props.CollectionView.props.Document._viewType)}`,
-                immediate: (source: Doc[]) => Doc.setChildLayout(this.target, source?.[0]),
+                immediate: (source: Doc[]) => this.target = Doc.getTemplateDoc(source?.[0]),
                 initialize: emptyFunction,
             };
             DragManager.StartButtonDrag([this._viewRef.current!], c.script, StrCast(c.title),
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 9ca914bbe..f374b5803 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -295,8 +295,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 const func = () => this.onClickHandler!.script.run({
                     this: this.props.Document,
                     self: Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document,
-                    containingCollection: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
-                }, console.log) && !this.props.Document.isButton && this.select(false);
+                    thisContainer: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
+                }, console.log);// && !this.props.Document.isButton && this.select(false);
                 if (this.props.Document !== Doc.UserDoc().undoBtn && this.props.Document !== Doc.UserDoc().redoBtn) {
                     UndoManager.RunInBatch(func, "on click");
                 } else func();
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 85926e393..964b2e316 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -80,7 +80,7 @@ export function DocListCastAsync(field: FieldResult, defaultValue?: Doc[]) {
 }
 
 export async function DocCastAsync(field: FieldResult): Promise<Opt<Doc>> {
-    return Cast(field, Doc);
+    return await Cast(field, Doc);
 }
 
 export function DocListCast(field: FieldResult): Doc[] {
@@ -787,15 +787,10 @@ export namespace Doc {
         brushManager.BrushedDoc.clear();
     }
 
-    export function setChildLayout(target: Doc, source?: Doc) {
-        target.childLayout = source && source.isTemplateDoc ? source : source &&
-            source.dragFactory instanceof Doc && source.dragFactory.isTemplateDoc ? source.dragFactory :
-            source && source.layout instanceof Doc && source.layout.isTemplateDoc ? source.layout : undefined;
-    }
-    export function setChildDetailedLayout(target: Doc, source?: Doc) {
-        target.childDetailed = source && source.isTemplateDoc ? source : source &&
-            source.dragFactory instanceof Doc && source.dragFactory.isTemplateDoc ? source.dragFactory :
-            source && source.layout instanceof Doc && source.layout.isTemplateDoc ? source.layout : undefined;
+    export function getDocTemplate(doc?: Doc) {
+        return doc?.isTemplateDoc ? doc :
+            Cast(doc?.dragFactory, Doc, null)?.isTemplateDoc ? doc?.dragFactory :
+                Cast(doc?.layout, Doc, null)?.isTemplateDoc ? doc?.layout : undefined;
     }
 
     export function matchFieldValue(doc: Doc, key: string, value: any): boolean {
@@ -904,8 +899,7 @@ export namespace Doc {
 
 Scripting.addGlobal(function renameAlias(doc: any, n: any) { return StrCast(Doc.GetProto(doc).title).replace(/\([0-9]*\)/, "") + `(${n})`; });
 Scripting.addGlobal(function getProto(doc: any) { return Doc.GetProto(doc); });
-Scripting.addGlobal(function setChildLayout(target: any, source: any) { Doc.setChildLayout(target, source); });
-Scripting.addGlobal(function setChildDetailedLayout(target: any, source: any) { Doc.setChildDetailedLayout(target, source); });
+Scripting.addGlobal(function getDocTemplate(doc?: any) { Doc.getDocTemplate(doc); });
 Scripting.addGlobal(function getAlias(doc: any) { return Doc.MakeAlias(doc); });
 Scripting.addGlobal(function getCopy(doc: any, copyProto: any) { return doc.isTemplateDoc ? Doc.ApplyTemplate(doc) : Doc.MakeCopy(doc, copyProto); });
 Scripting.addGlobal(function copyField(field: any) { return ObjectField.MakeCopy(field); });
@@ -917,6 +911,7 @@ Scripting.addGlobal(function undo() { return UndoManager.Undo(); });
 Scripting.addGlobal(function redo() { return UndoManager.Redo(); });
 Scripting.addGlobal(function DOC(id: string) { console.log("Can't parse a document id in a script"); return "invalid"; });
 Scripting.addGlobal(function assignDoc(doc: Doc, field: string, id: string) { return Doc.assignDocToField(doc, field, id); });
+Scripting.addGlobal(function docCast(doc: FieldResult): any { return DocCastAsync(doc); });
 Scripting.addGlobal(function curPresentationItem() {
     const curPres = Doc.UserDoc().curPresentation as Doc;
     return curPres && DocListCast(curPres[Doc.LayoutFieldKey(curPres)])[NumCast(curPres._itemIndex)];
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 302e00b63..529f8d56d 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -14,7 +14,7 @@ import { Utils } from "../../../Utils";
 import { nullAudio, ImageField } from "../../../new_fields/URLField";
 import { DragManager } from "../../../client/util/DragManager";
 import { InkingControl } from "../../../client/views/InkingControl";
-import { Scripting } from "../../../client/util/Scripting";
+import { Scripting, CompileScript } from "../../../client/util/Scripting";
 import { CollectionViewType } from "../../../client/views/collections/CollectionView";
 import { makeTemplate } from "../../../client/util/DropConverter";
 import { RichTextField } from "../../../new_fields/RichTextField";
@@ -345,6 +345,13 @@ export class CurrentUserUtils {
         doc.optionalRightCollection = new PrefetchProxy(Docs.Create.StackingDocument([], { title: "New mobile uploads" }));
     }
 
+    static setupChildClicks(doc: Doc) {
+        const openInTarget = Docs.Create.TextDocument("", { title: "On Child Clicked (open in target)" });
+        const text = "docCast(thisContainer.target).then((target) => { target && docCast(this.source).then((source) => { target.proto.data = new List([source || this]); } ); } )";
+        openInTarget.script = ScriptField.MakeScript(text, { thisContainer: Doc.name });
+        doc.childClickFuncs = Docs.Create.TreeDocument([openInTarget], { title: "on Child Click function templates" });
+    }
+
     static updateUserDocument(doc: Doc) {
         doc.title = Doc.CurrentUserEmail;
         new InkingControl();
@@ -355,7 +362,10 @@ export class CurrentUserUtils {
         (doc.expandingButtons === undefined) && CurrentUserUtils.setupExpandingButtons(doc);
         (doc.curPresentation === undefined) && CurrentUserUtils.setupDefaultPresentation(doc);
         (doc.sidebarButtons === undefined) && CurrentUserUtils.setupSidebarButtons(doc);
+        (doc.childClickFuncs === undefined) && CurrentUserUtils.setupChildClicks(doc);
 
+        // this is equivalent to using PrefetchProxies to make sure all the childClickFuncs have been retrieved.
+        PromiseValue(Cast(doc.childClickFuncs, Doc)).then(func => func && PromiseValue(func.data).then(DocListCast));
         // this is equivalent to using PrefetchProxies to make sure the recentlyClosed doc is ready
         PromiseValue(Cast(doc.recentlyClosed, Doc)).then(recent => recent && PromiseValue(recent.data).then(DocListCast));
         // this is equivalent to using PrefetchProxies to make sure all the sidebarButtons and noteType internal Doc's have been retrieved.
-- 
cgit v1.2.3-70-g09d2


From 892174ef482f3d45167a0c2d1c3163e6b9443c66 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Tue, 7 Apr 2020 11:52:25 -0400
Subject: got rid of some run-time errors/warnings related to CORS-ifying
 imagebox requests, and avoiding memoizing messages for computedFn's outside
 reactions.

---
 src/client/documents/Documents.ts                  |  2 +-
 src/client/util/SelectionManager.ts                |  8 ++-
 src/client/views/DocComponent.tsx                  |  8 +--
 src/client/views/GestureOverlay.tsx                |  1 -
 src/client/views/TemplateMenu.tsx                  | 66 +++++++++++-----------
 src/client/views/collections/CollectionSubView.tsx |  6 +-
 src/client/views/collections/CollectionView.tsx    |  2 +-
 .../views/collections/ParentDocumentSelector.tsx   |  2 -
 .../views/nodes/ContentFittingDocumentView.tsx     |  2 +-
 src/client/views/nodes/DocumentView.tsx            |  6 +-
 src/client/views/nodes/FieldView.tsx               |  2 +-
 src/client/views/pdf/PDFViewer.tsx                 |  2 +-
 .../views/presentationview/PresElementBox.tsx      |  2 +-
 src/new_fields/Doc.ts                              |  2 +-
 src/new_fields/ScriptField.ts                      |  5 +-
 15 files changed, 57 insertions(+), 59 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index c9d7fac33..cc85e5c6f 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -504,7 +504,7 @@ export namespace Docs {
                 const extension = path.extname(target);
                 target = `${target.substring(0, target.length - extension.length)}_o${extension}`;
             }
-            requestImageSize(target)
+            requestImageSize(Utils.CorsProxy(target))
                 .then((size: any) => {
                     const aspect = size.height / size.width;
                     if (!inst._nativeWidth) {
diff --git a/src/client/util/SelectionManager.ts b/src/client/util/SelectionManager.ts
index 2a6e3bf8a..6c386d684 100644
--- a/src/client/util/SelectionManager.ts
+++ b/src/client/util/SelectionManager.ts
@@ -55,11 +55,13 @@ export namespace SelectionManager {
         manager.SelectDoc(docView, ctrlPressed);
     }
 
-
+    // computed functions, such as used in IsSelected generate errors if they're called outside of a
+    // reaction context.  Specifying the context with 'outsideReaction' allows an efficiency feature
+    // to avoid unnecessary mobx invalidations when running inside a reaction.
     export function IsSelected(doc: DocumentView, outsideReaction?: boolean): boolean {
         return outsideReaction ?
-            manager.SelectedDocuments.get(doc) ? true : false :
-            computedFn(function isSelected(doc: DocumentView) {
+            manager.SelectedDocuments.get(doc) ? true : false : // get() accesses a hashtable -- setting anything in the hashtable generates a mobx invalidation for every get()
+            computedFn(function isSelected(doc: DocumentView) {  // wraapping get() in a computedFn only generates mobx() invalidations when the return value of the function for the specific get parameters has changed
                 return manager.SelectedDocuments.get(doc) ? true : false;
             })(doc);
     }
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 9456895d6..21eec66be 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -31,7 +31,7 @@ interface DocExtendableProps {
     fieldKey: string;
     isSelected: (outsideReaction?: boolean) => boolean;
     renderDepth: number;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
 }
 export function DocExtendableComponent<P extends DocExtendableProps, T>(schemaCtor: (doc: Doc) => T) {
     class Component extends Touchable<P> {
@@ -39,7 +39,7 @@ export function DocExtendableComponent<P extends DocExtendableProps, T>(schemaCt
         @computed get Document(): T { return schemaCtor(this.props.Document); }
         @computed get layoutDoc() { return Doc.Layout(this.props.Document); }
         @computed get dataDoc() { return (this.props.DataDoc && (this.props.Document.isTemplateForField || this.props.Document.isTemplateDoc) ? this.props.DataDoc : Cast(this.props.Document.resolvedDataDoc, Doc, null) || Doc.GetProto(this.props.Document)) as Doc; }
-        active = (outsideReaction?: boolean) => !this.props.Document.isBackground && ((this.props.Document.forceActive && this.props.rootSelected()) || this.props.isSelected(outsideReaction) || this.props.renderDepth === 0);//  && !InkingControl.Instance.selectedTool;  // bcz: inking state shouldn't affect static tools 
+        active = (outsideReaction?: boolean) => !this.props.Document.isBackground && ((this.props.Document.forceActive && this.props.rootSelected(outsideReaction)) || this.props.isSelected(outsideReaction) || this.props.renderDepth === 0);//  && !InkingControl.Instance.selectedTool;  // bcz: inking state shouldn't affect static tools 
         protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
     }
     return Component;
@@ -54,7 +54,7 @@ export interface DocAnnotatableProps {
     active: () => boolean;
     whenActiveChanged: (isActive: boolean) => void;
     isSelected: (outsideReaction?: boolean) => boolean;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
     renderDepth: number;
 }
 export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schemaCtor: (doc: Doc) => T) {
@@ -92,7 +92,7 @@ export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schema
 
         whenActiveChanged = action((isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive));
         active = (outsideReaction?: boolean) => ((InkingControl.Instance.selectedTool === InkTool.None && !this.props.Document.isBackground) &&
-            ((this.props.Document.forceActive && this.props.rootSelected()) || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
+            ((this.props.Document.forceActive && this.props.rootSelected(outsideReaction)) || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
         annotationsActive = (outsideReaction?: boolean) => (InkingControl.Instance.selectedTool !== InkTool.None ||
             (this.props.Document.forceActive || this.props.isSelected(outsideReaction) || this._isChildActive || this.props.renderDepth === 0) ? true : false)
     }
diff --git a/src/client/views/GestureOverlay.tsx b/src/client/views/GestureOverlay.tsx
index f0205133c..69aa8dbaa 100644
--- a/src/client/views/GestureOverlay.tsx
+++ b/src/client/views/GestureOverlay.tsx
@@ -738,7 +738,6 @@ export default class GestureOverlay extends Touchable {
     }
 
     render() {
-        trace();
         return (
             <div className="gestureOverlay-cont" onPointerDown={this.onPointerDown} onTouchStart={this.onReactTouchStart}>
                 {this.showMobileInkOverlay ? <MobileInkOverlay /> : <></>}
diff --git a/src/client/views/TemplateMenu.tsx b/src/client/views/TemplateMenu.tsx
index c72f3681a..8fb8e7516 100644
--- a/src/client/views/TemplateMenu.tsx
+++ b/src/client/views/TemplateMenu.tsx
@@ -127,44 +127,42 @@ export class TemplateMenu extends React.Component<TemplateMenuProps> {
             addedTypes.concat(noteTypes).map(template => template.treeViewChecked = ComputedField.MakeFunction(`templateIsUsed(this)`));
             this._addedKeys && Array.from(this._addedKeys).filter(key => !noteTypes.some(nt => nt.title === key)).forEach(template => templateMenu.push(
                 <OtherToggle key={template} name={template} checked={templateName === template} toggle={e => this.toggleLayout(e, template)} />));
-            templateMenu.push(
-                <CollectionTreeView
-                    Document={Doc.UserDoc().templateDocs as Doc}
-                    CollectionView={undefined}
-                    ContainingCollectionDoc={undefined}
-                    ContainingCollectionView={undefined}
-                    rootSelected={returnFalse}
-                    onCheckedClick={this.scriptField!}
-                    onChildClick={this.scriptField!}
-                    LibraryPath={emptyPath}
-                    dropAction={undefined}
-                    active={returnTrue}
-                    ContentScaling={returnOne}
-                    bringToFront={emptyFunction}
-                    focus={emptyFunction}
-                    whenActiveChanged={emptyFunction}
-                    ScreenToLocalTransform={Transform.Identity}
-                    isSelected={returnFalse}
-                    pinToPres={emptyFunction}
-                    select={emptyFunction}
-                    renderDepth={1}
-                    addDocTab={returnFalse}
-                    NativeHeight={returnZero}
-                    NativeWidth={returnZero}
-                    PanelWidth={this.return100}
-                    PanelHeight={this.return100}
-                    treeViewHideHeaderFields={true}
-                    annotationsKey={""}
-                    dontRegisterView={true}
-                    fieldKey={"data"}
-                    moveDocument={(doc: Doc) => false}
-                    removeDocument={(doc: Doc) => false}
-                    addDocument={(doc: Doc) => false} />
-            );
         }
         return <ul className="template-list" style={{ display: "block" }}>
             <input placeholder="+ layout" ref={this._customRef} onKeyPress={this.onCustomKeypress} />
             {templateMenu}
+            <CollectionTreeView
+                Document={Doc.UserDoc().templateDocs as Doc}
+                CollectionView={undefined}
+                ContainingCollectionDoc={undefined}
+                ContainingCollectionView={undefined}
+                rootSelected={returnFalse}
+                onCheckedClick={this.scriptField!}
+                onChildClick={this.scriptField!}
+                LibraryPath={emptyPath}
+                dropAction={undefined}
+                active={returnTrue}
+                ContentScaling={returnOne}
+                bringToFront={emptyFunction}
+                focus={emptyFunction}
+                whenActiveChanged={emptyFunction}
+                ScreenToLocalTransform={Transform.Identity}
+                isSelected={returnFalse}
+                pinToPres={emptyFunction}
+                select={emptyFunction}
+                renderDepth={1}
+                addDocTab={returnFalse}
+                NativeHeight={returnZero}
+                NativeWidth={returnZero}
+                PanelWidth={this.return100}
+                PanelHeight={this.return100}
+                treeViewHideHeaderFields={true}
+                annotationsKey={""}
+                dontRegisterView={true}
+                fieldKey={"data"}
+                moveDocument={(doc: Doc) => false}
+                removeDocument={(doc: Doc) => false}
+                addDocument={(doc: Doc) => false} />
         </ul>;
     }
 }
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index a46bc67a2..746b2e174 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -34,7 +34,7 @@ export interface CollectionViewProps extends FieldViewProps {
     PanelHeight: () => number;
     VisibleHeight?: () => number;
     setPreviewCursor?: (func: (x: number, y: number, drag: boolean) => void) => void;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
     fieldKey: string;
     NativeWidth: () => number;
     NativeHeight: () => number;
@@ -99,8 +99,8 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 this.props.Document.resolvedDataDoc ? this.props.Document : Doc.GetProto(this.props.Document)); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
         }
 
-        rootSelected = () => {
-            return this.props.isSelected() || (this.props.Document.rootDocument || this.props.Document.forceActive ? this.props.rootSelected() : false);
+        rootSelected = (outsideReaction: boolean) => {
+            return this.props.isSelected(outsideReaction) || (this.props.Document.rootDocument || this.props.Document.forceActive ? this.props.rootSelected(outsideReaction) : false);
         }
 
         // The data field for rendering this collection will be on the this.props.Document unless we're rendering a template in which case we try to use props.DataDoc.
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index d7224fa4b..c7ab66c9f 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -122,7 +122,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
         return viewField;
     }
 
-    active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || (this.props.rootSelected() && BoolCast(this.props.Document.forceActive)) || this._isChildActive || this.props.renderDepth === 0;
+    active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || (this.props.rootSelected(outsideReaction) && BoolCast(this.props.Document.forceActive)) || this._isChildActive || this.props.renderDepth === 0;
 
     whenActiveChanged = (isActive: boolean) => this.props.whenActiveChanged(this._isChildActive = isActive);
 
diff --git a/src/client/views/collections/ParentDocumentSelector.tsx b/src/client/views/collections/ParentDocumentSelector.tsx
index 35e3a8958..afe269ec3 100644
--- a/src/client/views/collections/ParentDocumentSelector.tsx
+++ b/src/client/views/collections/ParentDocumentSelector.tsx
@@ -107,7 +107,6 @@ export class DockingViewButtonSelector extends React.Component<{ views: Document
     }
 
     @computed get flyout() {
-        trace();
         return (
             <div className="ParentDocumentSelector-flyout" title=" ">
                 <DocumentButtonBar views={this.props.views} stack={this.props.Stack} />
@@ -116,7 +115,6 @@ export class DockingViewButtonSelector extends React.Component<{ views: Document
     }
 
     render() {
-        trace();
         return <span title="Tap for menu, drag tab as document" onPointerDown={e => { this.props.views[0].select(false); e.stopPropagation(); }} className="buttonSelector">
             <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={this.flyout} stylesheet={this.customStylesheet}>
                 <FontAwesomeIcon icon={"cog"} size={"sm"} />
diff --git a/src/client/views/nodes/ContentFittingDocumentView.tsx b/src/client/views/nodes/ContentFittingDocumentView.tsx
index 642264b85..641797cac 100644
--- a/src/client/views/nodes/ContentFittingDocumentView.tsx
+++ b/src/client/views/nodes/ContentFittingDocumentView.tsx
@@ -42,7 +42,7 @@ interface ContentFittingDocumentViewProps {
     addDocTab: (document: Doc, where: string) => boolean;
     pinToPres: (document: Doc) => void;
     dontRegisterView?: boolean;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
 }
 
 @observer
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index f374b5803..2df5c9bbd 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -64,7 +64,7 @@ export interface DocumentViewProps {
     LayoutDoc?: () => Opt<Doc>;
     LibraryPath: Doc[];
     fitToBox?: boolean;
-    rootSelected: () => boolean; // whether the root of a template has been selected
+    rootSelected: (outsideReaction?: boolean) => boolean; // whether the root of a template has been selected
     onClick?: ScriptField;
     onPointerDown?: ScriptField;
     onPointerUp?: ScriptField;
@@ -964,8 +964,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         const fallback = Cast(this.props.Document.layoutKey, "string");
         return typeof fallback === "string" ? fallback : "layout";
     }
-    rootSelected = () => {
-        return this.isSelected(false) || (this.props.Document.forceActive && this.props.rootSelected?.() ? true : false);
+    rootSelected = (outsideReaction: boolean) => {
+        return this.isSelected(outsideReaction) || (this.props.Document.forceActive && this.props.rootSelected?.(outsideReaction) ? true : false);
     }
     childScaling = () => (this.layoutDoc._fitWidth ? this.props.PanelWidth() / this.nativeWidth : this.props.ContentScaling());
     panelWidth = () => this.props.PanelWidth();
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index dfcb03985..a3790d38b 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -29,7 +29,7 @@ export interface FieldViewProps {
     dropAction: dropActionType;
     isSelected: (outsideReaction?: boolean) => boolean;
     select: (isCtrlPressed: boolean) => void;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
     renderDepth: number;
     addDocument?: (document: Doc) => boolean;
     addDocTab: (document: Doc, where: string) => boolean;
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 36e687f71..720f09fe0 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -59,7 +59,7 @@ interface IViewerProps {
     PanelHeight: () => number;
     ContentScaling: () => number;
     select: (isCtrlPressed: boolean) => void;
-    rootSelected: () => boolean;
+    rootSelected: (outsideReaction?: boolean) => boolean;
     startupLive: boolean;
     renderDepth: number;
     focus: (doc: Doc) => void;
diff --git a/src/client/views/presentationview/PresElementBox.tsx b/src/client/views/presentationview/PresElementBox.tsx
index 7ad3474e8..289d3a9a1 100644
--- a/src/client/views/presentationview/PresElementBox.tsx
+++ b/src/client/views/presentationview/PresElementBox.tsx
@@ -197,7 +197,7 @@ export class PresElementBox extends DocExtendableComponent<FieldViewProps, PresD
         const treecontainer = this.props.ContainingCollectionDoc?._viewType === CollectionViewType.Tree;
         const className = "presElementBox-item" + (this.currentIndex === this.indexInPres ? " presElementBox-selected" : "");
         const pbi = "presElementBox-interaction";
-        return !this.presElementDoc ? (null) : (
+        return !(this.presElementDoc instanceof Doc) || this.targetDoc instanceof Promise ? (null) : (
             <div className={className} key={this.props.Document[Id] + this.indexInPres}
                 style={{ outlineWidth: Doc.IsBrushed(this.targetDoc) ? `1px` : "0px", }}
                 onClick={e => { this.props.focus(this.presElementDoc); e.stopPropagation(); }}>
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 964b2e316..d381447c5 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -713,7 +713,7 @@ export namespace Doc {
     export function SetUserDoc(doc: Doc) { manager._user_doc = doc; }
     export function IsBrushed(doc: Doc) {
         return computedFn(function IsBrushed(doc: Doc) {
-            return brushManager.BrushedDoc.has(doc) || brushManager.BrushedDoc.has(Doc.GetProto(doc));
+            return brushManager.BrushedDoc.has(doc) ||  brushManager.BrushedDoc.has(Doc.GetProto(doc));
         })(doc);
     }
     // don't bother memoizing (caching) the result if called from a non-reactive context. (plus this avoids a warning message)
diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts
index 148886848..4a3119aeb 100644
--- a/src/new_fields/ScriptField.ts
+++ b/src/new_fields/ScriptField.ts
@@ -131,7 +131,8 @@ export class ScriptField extends ObjectField {
 export class ComputedField extends ScriptField {
     _lastComputedResult: any;
     //TODO maybe add an observable cache based on what is passed in for doc, considering there shouldn't really be that many possible values for doc
-    value = computedFn((doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, self: Cast(doc.rootDocument, Doc, null) || doc, _last_: this._lastComputedResult }, console.log).result);
+    value = computedFn((doc: Doc) => this._valueOutsideReaction(doc));
+    _valueOutsideReaction = (doc: Doc) => this._lastComputedResult = this.script.run({ this: doc, self: Cast(doc.rootDocument, Doc, null) || doc, _last_: this._lastComputedResult }, console.log).result;
     public static MakeScript(script: string, params: object = {}) {
         const compiled = ScriptField.CompileScript(script, params, false);
         return compiled.compiled ? new ComputedField(compiled) : undefined;
@@ -166,7 +167,7 @@ export namespace ComputedField {
     export function initPlugin() {
         Plugins.addGetterPlugin((doc, _, value) => {
             if (useComputed && value instanceof ComputedField) {
-                return { value: value.value(doc), shouldReturn: true };
+                return { value: value._valueOutsideReaction(doc), shouldReturn: true };
             }
         });
     }
-- 
cgit v1.2.3-70-g09d2


From e262d9ac73af5b2cef384468c47d69917e205d44 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Tue, 7 Apr 2020 23:01:46 -0400
Subject: lots of code cleanup - removed all northstar db stuff.  added
 scriptingBox.  renamed things.  made collectiontypes strings not numbers.

---
 package-lock.json                                  |    8 +-
 .../apis/google_docs/GoogleApiClientUtils.ts       |    2 +-
 src/client/apis/youtube/YoutubeBox.tsx             |    6 +-
 src/client/documents/DocumentTypes.ts              |   61 +-
 src/client/documents/Documents.ts                  |  108 +-
 src/client/northstar/core/BaseObject.ts            |   12 -
 .../northstar/core/attribute/AttributeModel.ts     |  111 -
 .../core/attribute/AttributeTransformationModel.ts |   52 -
 .../core/attribute/CalculatedAttributeModel.ts     |   42 -
 .../northstar/core/brusher/IBaseBrushable.ts       |   13 -
 src/client/northstar/core/brusher/IBaseBrusher.ts  |   11 -
 src/client/northstar/core/filter/FilterModel.ts    |   83 -
 src/client/northstar/core/filter/FilterOperand.ts  |    5 -
 src/client/northstar/core/filter/FilterType.ts     |    6 -
 .../northstar/core/filter/IBaseFilterConsumer.ts   |   12 -
 .../northstar/core/filter/IBaseFilterProvider.ts   |    8 -
 .../northstar/core/filter/ValueComparision.ts      |   78 -
 src/client/northstar/dash-fields/HistogramField.ts |   66 -
 .../dash-nodes/HistogramBinPrimitiveCollection.ts  |  240 -
 src/client/northstar/dash-nodes/HistogramBox.scss  |   40 -
 src/client/northstar/dash-nodes/HistogramBox.tsx   |  175 -
 .../dash-nodes/HistogramBoxPrimitives.scss         |   42 -
 .../dash-nodes/HistogramBoxPrimitives.tsx          |  122 -
 .../dash-nodes/HistogramLabelPrimitives.scss       |   13 -
 .../dash-nodes/HistogramLabelPrimitives.tsx        |   80 -
 src/client/northstar/manager/Gateway.ts            |  299 -
 src/client/northstar/model/ModelExtensions.ts      |   48 -
 src/client/northstar/model/ModelHelpers.ts         |  220 -
 .../model/binRanges/AlphabeticVisualBinRange.ts    |   52 -
 .../model/binRanges/DateTimeVisualBinRange.ts      |  105 -
 .../model/binRanges/NominalVisualBinRange.ts       |   52 -
 .../model/binRanges/QuantitativeVisualBinRange.ts  |   90 -
 .../northstar/model/binRanges/VisualBinRange.ts    |   32 -
 .../model/binRanges/VisualBinRangeHelper.ts        |   70 -
 .../northstar/model/idea/MetricTypeMapping.ts      |   30 -
 src/client/northstar/model/idea/idea.ts            | 8557 --------------------
 src/client/northstar/operations/BaseOperation.ts   |  162 -
 .../northstar/operations/HistogramOperation.ts     |  158 -
 src/client/northstar/utils/ArrayUtil.ts            |   90 -
 src/client/northstar/utils/Extensions.ts           |   29 -
 src/client/northstar/utils/GeometryUtil.ts         |  133 -
 src/client/northstar/utils/IDisposable.ts          |    3 -
 src/client/northstar/utils/IEquatable.ts           |    3 -
 src/client/northstar/utils/KeyCodes.ts             |  137 -
 src/client/northstar/utils/LABColor.ts             |   90 -
 src/client/northstar/utils/MathUtil.ts             |  249 -
 src/client/northstar/utils/PartialClass.ts         |    7 -
 src/client/northstar/utils/SizeConverter.ts        |  101 -
 src/client/northstar/utils/StyleContants.ts        |   95 -
 src/client/northstar/utils/Utils.ts                |   75 -
 src/client/util/DictationManager.ts                |    6 +-
 src/client/util/DropConverter.ts                   |    2 +-
 src/client/util/KeyCodes.ts                        |  136 +
 src/client/util/type_decls.d                       |    1 -
 src/client/views/DocComponent.tsx                  |    2 +-
 src/client/views/DocumentDecorations.tsx           |    2 +-
 src/client/views/MainView.tsx                      |    6 +-
 src/client/views/ScriptBox.tsx                     |    2 +-
 src/client/views/SearchDocBox.tsx                  |    2 +-
 .../views/collections/CollectionSchemaCells.tsx    |    5 +-
 .../views/collections/CollectionSchemaView.tsx     |   22 -
 .../views/collections/CollectionStackingView.tsx   |    2 +-
 src/client/views/collections/CollectionSubView.tsx |    2 +-
 src/client/views/collections/CollectionView.tsx    |   52 +-
 .../views/collections/CollectionViewChromes.tsx    |    7 +-
 .../views/collections/ParentDocumentSelector.tsx   |    2 +-
 .../CollectionFreeFormLinkView.tsx                 |   10 +-
 .../CollectionFreeFormLinksView.tsx                |   56 -
 src/client/views/nodes/AudioBox.scss               |    4 +-
 src/client/views/nodes/ButtonBox.scss              |   38 -
 src/client/views/nodes/ButtonBox.tsx               |   97 -
 src/client/views/nodes/DocuLinkBox.scss            |   29 -
 src/client/views/nodes/DocuLinkBox.tsx             |  146 -
 src/client/views/nodes/DocumentBox.tsx             |    8 +-
 src/client/views/nodes/DocumentContentsView.tsx    |   14 +-
 src/client/views/nodes/DocumentView.scss           |    4 +-
 src/client/views/nodes/DocumentView.tsx            |   40 +-
 src/client/views/nodes/FormattedTextBox.tsx        |    4 +-
 src/client/views/nodes/LabelBox.scss               |   38 +
 src/client/views/nodes/LabelBox.tsx                |   97 +
 src/client/views/nodes/LinkAnchorBox.scss          |   29 +
 src/client/views/nodes/LinkAnchorBox.tsx           |  146 +
 src/client/views/nodes/PDFBox.tsx                  |    3 +-
 src/client/views/nodes/PresBox.tsx                 |   10 +-
 src/client/views/nodes/ScriptingBox.scss           |    0
 src/client/views/nodes/ScriptingBox.tsx            |   71 +
 src/client/views/nodes/VideoBox.tsx                |    2 +-
 src/client/views/pdf/PDFViewer.tsx                 |    2 +-
 src/client/views/search/FilterBox.tsx              |    2 +-
 src/client/views/search/IconBar.tsx                |    2 +-
 src/client/views/search/IconButton.tsx             |    8 +-
 src/client/views/search/SearchBox.tsx              |    2 +-
 src/client/views/search/SearchItem.tsx             |    9 +-
 src/new_fields/Doc.ts                              |    6 +-
 src/new_fields/RichTextField.ts                    |    3 -
 src/new_fields/ScriptField.ts                      |    5 +-
 src/new_fields/documentSchemas.ts                  |    2 +-
 src/server/Message.ts                              |    2 +-
 src/server/RouteManager.ts                         |    1 -
 src/server/Websocket/Websocket.ts                  |    3 +-
 .../authentication/models/current_user_utils.ts    |   73 -
 src/server/updateProtos.ts                         |    3 +-
 102 files changed, 695 insertions(+), 12808 deletions(-)
 delete mode 100644 src/client/northstar/core/BaseObject.ts
 delete mode 100644 src/client/northstar/core/attribute/AttributeModel.ts
 delete mode 100644 src/client/northstar/core/attribute/AttributeTransformationModel.ts
 delete mode 100644 src/client/northstar/core/attribute/CalculatedAttributeModel.ts
 delete mode 100644 src/client/northstar/core/brusher/IBaseBrushable.ts
 delete mode 100644 src/client/northstar/core/brusher/IBaseBrusher.ts
 delete mode 100644 src/client/northstar/core/filter/FilterModel.ts
 delete mode 100644 src/client/northstar/core/filter/FilterOperand.ts
 delete mode 100644 src/client/northstar/core/filter/FilterType.ts
 delete mode 100644 src/client/northstar/core/filter/IBaseFilterConsumer.ts
 delete mode 100644 src/client/northstar/core/filter/IBaseFilterProvider.ts
 delete mode 100644 src/client/northstar/core/filter/ValueComparision.ts
 delete mode 100644 src/client/northstar/dash-fields/HistogramField.ts
 delete mode 100644 src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts
 delete mode 100644 src/client/northstar/dash-nodes/HistogramBox.scss
 delete mode 100644 src/client/northstar/dash-nodes/HistogramBox.tsx
 delete mode 100644 src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
 delete mode 100644 src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
 delete mode 100644 src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
 delete mode 100644 src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
 delete mode 100644 src/client/northstar/manager/Gateway.ts
 delete mode 100644 src/client/northstar/model/ModelExtensions.ts
 delete mode 100644 src/client/northstar/model/ModelHelpers.ts
 delete mode 100644 src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
 delete mode 100644 src/client/northstar/model/binRanges/DateTimeVisualBinRange.ts
 delete mode 100644 src/client/northstar/model/binRanges/NominalVisualBinRange.ts
 delete mode 100644 src/client/northstar/model/binRanges/QuantitativeVisualBinRange.ts
 delete mode 100644 src/client/northstar/model/binRanges/VisualBinRange.ts
 delete mode 100644 src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
 delete mode 100644 src/client/northstar/model/idea/MetricTypeMapping.ts
 delete mode 100644 src/client/northstar/model/idea/idea.ts
 delete mode 100644 src/client/northstar/operations/BaseOperation.ts
 delete mode 100644 src/client/northstar/operations/HistogramOperation.ts
 delete mode 100644 src/client/northstar/utils/ArrayUtil.ts
 delete mode 100644 src/client/northstar/utils/Extensions.ts
 delete mode 100644 src/client/northstar/utils/GeometryUtil.ts
 delete mode 100644 src/client/northstar/utils/IDisposable.ts
 delete mode 100644 src/client/northstar/utils/IEquatable.ts
 delete mode 100644 src/client/northstar/utils/KeyCodes.ts
 delete mode 100644 src/client/northstar/utils/LABColor.ts
 delete mode 100644 src/client/northstar/utils/MathUtil.ts
 delete mode 100644 src/client/northstar/utils/PartialClass.ts
 delete mode 100644 src/client/northstar/utils/SizeConverter.ts
 delete mode 100644 src/client/northstar/utils/StyleContants.ts
 delete mode 100644 src/client/northstar/utils/Utils.ts
 create mode 100644 src/client/util/KeyCodes.ts
 delete mode 100644 src/client/views/nodes/ButtonBox.scss
 delete mode 100644 src/client/views/nodes/ButtonBox.tsx
 delete mode 100644 src/client/views/nodes/DocuLinkBox.scss
 delete mode 100644 src/client/views/nodes/DocuLinkBox.tsx
 create mode 100644 src/client/views/nodes/LabelBox.scss
 create mode 100644 src/client/views/nodes/LabelBox.tsx
 create mode 100644 src/client/views/nodes/LinkAnchorBox.scss
 create mode 100644 src/client/views/nodes/LinkAnchorBox.tsx
 create mode 100644 src/client/views/nodes/ScriptingBox.scss
 create mode 100644 src/client/views/nodes/ScriptingBox.tsx

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/package-lock.json b/package-lock.json
index 2cd3c0b82..1949a8a5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -750,7 +750,7 @@
         },
         "@types/passport": {
             "version": "1.0.2",
-            "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.2.tgz",
+            "resolved": "https://registry.npmjs.org/@types/passport/-/passport-1.0.0.tgz",
             "integrity": "sha512-Pf39AYKf8q+YoONym3150cEwfUD66dtwHJWvbeOzKxnA0GZZ/vAXhNWv9vMhKyRQBQZiQyWQnhYBEBlKW6G8wg==",
             "requires": {
                 "@types/express": "*"
@@ -14376,7 +14376,7 @@
         },
         "readable-stream": {
             "version": "2.3.6",
-            "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
+            "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
             "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
             "requires": {
                 "core-util-is": "~1.0.0",
@@ -15990,7 +15990,7 @@
         },
         "strip-ansi": {
             "version": "3.0.1",
-            "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
+            "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz",
             "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=",
             "requires": {
                 "ansi-regex": "^2.0.0"
@@ -18303,7 +18303,7 @@
         },
         "wrap-ansi": {
             "version": "2.1.0",
-            "resolved": "http://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
+            "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",
             "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=",
             "requires": {
                 "string-width": "^1.0.1",
diff --git a/src/client/apis/google_docs/GoogleApiClientUtils.ts b/src/client/apis/google_docs/GoogleApiClientUtils.ts
index 0d44ee8e0..fa67ddbef 100644
--- a/src/client/apis/google_docs/GoogleApiClientUtils.ts
+++ b/src/client/apis/google_docs/GoogleApiClientUtils.ts
@@ -97,7 +97,7 @@ export namespace GoogleApiClientUtils {
                 const paragraphs = extractParagraphs(document);
                 let text = paragraphs.map(paragraph => paragraph.contents.filter(content => !("inlineObjectId" in content)).map(run => run as docs_v1.Schema$TextRun).join("")).join("");
                 text = text.substring(0, text.length - 1);
-                removeNewlines && text.ReplaceAll("\n", "");
+                removeNewlines && text.replace(/\n/g, "");
                 return { text, paragraphs };
             };
 
diff --git a/src/client/apis/youtube/YoutubeBox.tsx b/src/client/apis/youtube/YoutubeBox.tsx
index c940bba43..4b4145fcc 100644
--- a/src/client/apis/youtube/YoutubeBox.tsx
+++ b/src/client/apis/youtube/YoutubeBox.tsx
@@ -171,9 +171,9 @@ export class YoutubeBox extends React.Component<FieldViewProps> {
      * in the title of the videos.
      */
     filterYoutubeTitleResult = (resultTitle: string) => {
-        let processedTitle: string = resultTitle.ReplaceAll("&amp;", "&");
-        processedTitle = processedTitle.ReplaceAll("&#39;", "'");
-        processedTitle = processedTitle.ReplaceAll("&quot;", "\"");
+        let processedTitle: string = resultTitle.replace(/&amp;/g, "&");//.ReplaceAll("&amp;", "&");
+        processedTitle = processedTitle.replace(/"&#39;/g, "'");
+        processedTitle = processedTitle.replace(/&quot;/g, "\"");
         return processedTitle;
     }
 
diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index b6a6cc75a..ab32d7301 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -1,31 +1,36 @@
 export enum DocumentType {
     NONE = "none",
-    TEXT = "text",
-    HIST = "histogram",
-    IMG = "image",
-    WEB = "web",
-    COL = "collection",
-    KVP = "kvp",
-    VID = "video",
-    AUDIO = "audio",
-    PDF = "pdf",
-    IMPORT = "import",
-    LINK = "link",
-    LINKDB = "linkdb",
-    BUTTON = "button",
-    SLIDER = "slider",
-    YOUTUBE = "youtube",
-    WEBCAM = "webcam",
-    FONTICON = "fonticonbox",
-    PRES = "presentation",
-    RECOMMENDATION = "recommendation",
-    LINKFOLLOW = "linkfollow",
-    PRESELEMENT = "preselement",
-    QUERY = "query",
-    COLOR = "color",
-    DOCULINK = "doculink",
-    PDFANNO = "pdfanno",
-    INK = "ink",
-    DOCUMENT = "document",
-    SCREENSHOT = "screenshot",
+
+    // core data types
+    RTF = "rtf",      // rich text
+    IMG = "image",      // image box
+    WEB = "web",        // web page or html clipping
+    COL = "collection", // collection
+    KVP = "kvp",        // key value pane
+    VID = "video",      // video
+    AUDIO = "audio",    // audio
+    PDF = "pdf",        // pdf
+    INK = "ink",        // ink stroke
+    SCREENSHOT = "screenshot",  // view of a desktop application
+    FONTICON = "fonticonbox",   // font icon
+    QUERY = "query",            // search query
+    LABEL = "label",            // simple text label
+    WEBCAM = "webcam",          // webcam
+    PDFANNO = "pdfanno",        // pdf text selection (could be just a collection?)
+    DATE = "date",              // calendar view of a date
+    SCRIPTING = "script",       // script editor
+
+    // special purpose wrappers that either take no data or are compositions of lower level types
+    LINK = "link",              // link  (view of a document that acts as a link)
+    LINKANCHOR = "linkanchor",  // blue dot link anchor  (view of a link document's anchor)
+    IMPORT = "import",          // directory import box  (file system directory)
+    SLIDER = "slider",          // number slider  (view of a number)
+    PRES = "presentation",      // presentation   (view of a collection) --- shouldn't this be a view type?  technically requires a special view in which documents must have their aliasOf fields filled in
+    PRESELEMENT = "preselement",// presentation item (view of a document in a collection)
+    COLOR = "color",            // color picker (view of a color picker for a color string)
+    YOUTUBE = "youtube",        // youtube directory (view of you tube search results)
+    DOCHOLDER = "docholder",    // nested document (view of a document)
+
+    LINKDB = "linkdb",          // database of links  ??? why do we have this
+    RECOMMENDATION = "recommendation", // view of a recommendation
 }
\ No newline at end of file
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index cca0e7bc6..b71205001 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1,6 +1,3 @@
-import { HistogramField } from "../northstar/dash-fields/HistogramField";
-import { HistogramBox } from "../northstar/dash-nodes/HistogramBox";
-import { HistogramOperation } from "../northstar/operations/HistogramOperation";
 import { CollectionView } from "../views/collections/CollectionView";
 import { CollectionViewType } from "../views/collections/CollectionView";
 import { AudioBox } from "../views/nodes/AudioBox";
@@ -8,21 +5,16 @@ import { FormattedTextBox } from "../views/nodes/FormattedTextBox";
 import { ImageBox } from "../views/nodes/ImageBox";
 import { KeyValueBox } from "../views/nodes/KeyValueBox";
 import { PDFBox } from "../views/nodes/PDFBox";
+import { ScriptingBox } from "../views/nodes/ScriptingBox";
 import { VideoBox } from "../views/nodes/VideoBox";
 import { WebBox } from "../views/nodes/WebBox";
-import { Gateway } from "../northstar/manager/Gateway";
 import { CurrentUserUtils } from "../../server/authentication/models/current_user_utils";
-import { action } from "mobx";
-import { ColumnAttributeModel } from "../northstar/core/attribute/AttributeModel";
-import { AttributeTransformationModel } from "../northstar/core/attribute/AttributeTransformationModel";
-import { AggregateFunction } from "../northstar/model/idea/idea";
 import { OmitKeys, JSONUtils, Utils } from "../../Utils";
 import { Field, Doc, Opt, DocListCastAsync, FieldResult, DocListCast } from "../../new_fields/Doc";
 import { ImageField, VideoField, AudioField, PdfField, WebField, YoutubeField } from "../../new_fields/URLField";
 import { HtmlField } from "../../new_fields/HtmlField";
 import { List } from "../../new_fields/List";
 import { Cast, NumCast, StrCast } from "../../new_fields/Types";
-import { listSpec } from "../../new_fields/Schema";
 import { DocServer } from "../DocServer";
 import { dropActionType } from "../util/DragManager";
 import { DateField } from "../../new_fields/DateField";
@@ -32,7 +24,7 @@ import { LinkManager } from "../util/LinkManager";
 import { DocumentManager } from "../util/DocumentManager";
 import DirectoryImportBox from "../util/Import & Export/DirectoryImportBox";
 import { Scripting } from "../util/Scripting";
-import { ButtonBox } from "../views/nodes/ButtonBox";
+import { LabelBox } from "../views/nodes/LabelBox";
 import { SliderBox } from "../views/nodes/SliderBox";
 import { FontIconBox } from "../views/nodes/FontIconBox";
 import { SchemaHeaderField } from "../../new_fields/SchemaHeaderField";
@@ -41,16 +33,12 @@ import { ComputedField, ScriptField } from "../../new_fields/ScriptField";
 import { ProxyField } from "../../new_fields/Proxy";
 import { DocumentType } from "./DocumentTypes";
 import { RecommendationsBox } from "../views/RecommendationsBox";
-import { SearchBox } from "../views/search/SearchBox";
-
-//import { PresBox } from "../views/nodes/PresBox";
-//import { PresField } from "../../new_fields/PresField";
 import { PresElementBox } from "../views/presentationview/PresElementBox";
 import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo";
 import { QueryBox } from "../views/nodes/QueryBox";
 import { ColorBox } from "../views/nodes/ColorBox";
-import { DocuLinkBox } from "../views/nodes/DocuLinkBox";
-import { DocumentBox } from "../views/nodes/DocumentBox";
+import { LinkAnchorBox } from "../views/nodes/LinkAnchorBox";
+import { DocHolderBox } from "../views/nodes/DocumentBox";
 import { InkingStroke } from "../views/InkingStroke";
 import { InkField } from "../../new_fields/InkField";
 import { InkingControl } from "../views/InkingControl";
@@ -80,7 +68,7 @@ export interface DocumentOptions {
     _showCaption?: string; // which field to display in the caption area.  leave empty to have no caption
     _scrollTop?: number; // scroll location for pdfs
     _chromeStatus?: string;
-    _viewType?: number;
+    _viewType?: string; // sub type of a collection
     _gridGap?: number; // gap between items in masonry view
     _xMargin?: number; // gap between left edge of document and start of masonry/stacking layouts
     _yMargin?: number; // gap between top edge of dcoument and start of masonry/stacking layouts
@@ -156,6 +144,7 @@ export interface DocumentOptions {
     treeViewChecked?: ScriptField; // script to call when a tree view checkbox is checked
     isFacetFilter?: boolean; // whether document functions as a facet filter in a tree view
     limitHeight?: number; // maximum height for newly created (eg, from pasting) text documents
+    editScriptOnClick?: string; // script field key to edit when document is clicked (e.g., "onClick", "onChecked")
     // [key: string]: Opt<Field>;
     pointerHack?: boolean; // for buttons, allows onClick handler to fire onPointerDown
     textTransform?: string; // is linear view expanded
@@ -192,14 +181,10 @@ export namespace Docs {
         const data = "data";
 
         const TemplateMap: TemplateMap = new Map([
-            [DocumentType.TEXT, {
+            [DocumentType.RTF, {
                 layout: { view: FormattedTextBox, dataField: "text" },
                 options: { _height: 150, _xMargin: 10, _yMargin: 10 }
             }],
-            [DocumentType.HIST, {
-                layout: { view: HistogramBox, dataField: data },
-                options: { _height: 300, backgroundColor: "black" }
-            }],
             [DocumentType.QUERY, {
                 layout: { view: QueryBox, dataField: data },
                 options: { _width: 400 }
@@ -224,8 +209,8 @@ export namespace Docs {
                 layout: { view: KeyValueBox, dataField: data },
                 options: { _height: 150 }
             }],
-            [DocumentType.DOCUMENT, {
-                layout: { view: DocumentBox, dataField: data },
+            [DocumentType.DOCHOLDER, {
+                layout: { view: DocHolderBox, dataField: data },
                 options: { _height: 250 }
             }],
             [DocumentType.VID, {
@@ -253,11 +238,14 @@ export namespace Docs {
                 layout: { view: EmptyBox, dataField: data },
                 options: { childDropAction: "alias", title: "LINK DB" }
             }],
+            [DocumentType.SCRIPTING, {
+                layout: { view: ScriptingBox, dataField: data }
+            }],
             [DocumentType.YOUTUBE, {
                 layout: { view: YoutubeBox, dataField: data }
             }],
-            [DocumentType.BUTTON, {
-                layout: { view: ButtonBox, dataField: data },
+            [DocumentType.LABEL, {
+                layout: { view: LabelBox, dataField: data },
             }],
             [DocumentType.SLIDER, {
                 layout: { view: SliderBox, dataField: data },
@@ -521,6 +509,10 @@ export namespace Docs {
             return InstanceFromProto(Prototypes.get(DocumentType.PRES), initial, options);
         }
 
+        export function ScriptingDocument(url: string, options: DocumentOptions = {}) {
+            return InstanceFromProto(Prototypes.get(DocumentType.SCRIPTING), new YoutubeField(new URL(url)), options);
+        }
+
         export function VideoDocument(url: string, options: DocumentOptions = {}) {
             return InstanceFromProto(Prototypes.get(DocumentType.VID), new VideoField(new URL(url)), options);
         }
@@ -543,10 +535,6 @@ export namespace Docs {
             return instance;
         }
 
-        export function HistogramDocument(histoOp: HistogramOperation, options: DocumentOptions = {}) {
-            return InstanceFromProto(Prototypes.get(DocumentType.HIST), new HistogramField(histoOp), options);
-        }
-
         export function QueryDocument(options: DocumentOptions = {}) {
             return InstanceFromProto(Prototypes.get(DocumentType.QUERY), "", options);
         }
@@ -556,7 +544,7 @@ export namespace Docs {
         }
 
         export function TextDocument(text: string, options: DocumentOptions = {}) {
-            return InstanceFromProto(Prototypes.get(DocumentType.TEXT), text, options, undefined, "text");
+            return InstanceFromProto(Prototypes.get(DocumentType.RTF), text, options, undefined, "text");
         }
 
         export function LinkDocument(source: { doc: Doc, ctx?: Doc }, target: { doc: Doc, ctx?: Doc }, options: DocumentOptions = {}, id?: string) {
@@ -566,8 +554,8 @@ export namespace Docs {
             linkDocProto.anchor2 = target.doc;
 
             if (linkDocProto.layout_key1 === undefined) {
-                Cast(linkDocProto.proto, Doc, null).layout_key1 = DocuLinkBox.LayoutString("anchor1");
-                Cast(linkDocProto.proto, Doc, null).layout_key2 = DocuLinkBox.LayoutString("anchor2");
+                Cast(linkDocProto.proto, Doc, null).layout_key1 = LinkAnchorBox.LayoutString("anchor1");
+                Cast(linkDocProto.proto, Doc, null).layout_key2 = LinkAnchorBox.LayoutString("anchor2");
                 Cast(linkDocProto.proto, Doc, null).linkBoxExcludedKeys = new List(["treeViewExpandedView", "treeViewHideTitle", "removeDropProperties", "linkBoxExcludedKeys", "treeViewOpen", "aliasNumber", "isPrototype", "lastOpened", "creationDate", "author"]);
                 Cast(linkDocProto.proto, Doc, null).layoutKey = undefined;
             }
@@ -605,37 +593,6 @@ export namespace Docs {
             return InstanceFromProto(Prototypes.get(DocumentType.PDF), new PdfField(new URL(url)), options);
         }
 
-        export async function DBDocument(url: string, options: DocumentOptions = {}, columnOptions: DocumentOptions = {}) {
-            const schemaName = options.title ? options.title : "-no schema-";
-            const ctlog = await Gateway.Instance.GetSchema(url, schemaName);
-            if (ctlog && ctlog.schemas) {
-                const schema = ctlog.schemas[0];
-                const schemaDoc = Docs.Create.TreeDocument([], { ...options, _nativeWidth: undefined, _nativeHeight: undefined, _width: 150, _height: 100, title: schema.displayName! });
-                const schemaDocuments = Cast(schemaDoc.data, listSpec(Doc), []);
-                if (!schemaDocuments) {
-                    return;
-                }
-                CurrentUserUtils.AddNorthstarSchema(schema, schemaDoc);
-                const docs = schemaDocuments;
-                CurrentUserUtils.GetAllNorthstarColumnAttributes(schema).map(attr => {
-                    DocServer.GetRefField(attr.displayName! + ".alias").then(action((field: Opt<Field>) => {
-                        if (field instanceof Doc) {
-                            docs.push(field);
-                        } else {
-                            const atmod = new ColumnAttributeModel(attr);
-                            const histoOp = new HistogramOperation(schema.displayName!,
-                                new AttributeTransformationModel(atmod, AggregateFunction.None),
-                                new AttributeTransformationModel(atmod, AggregateFunction.Count),
-                                new AttributeTransformationModel(atmod, AggregateFunction.Count));
-                            docs.push(Docs.Create.HistogramDocument(histoOp, { ...columnOptions, _width: 200, _height: 200, title: attr.displayName! }));
-                        }
-                    }));
-                });
-                return schemaDoc;
-            }
-            return Docs.Create.TreeDocument([], { _width: 50, _height: 100, title: schemaName });
-        }
-
         export function WebDocument(url: string, options: DocumentOptions = {}) {
             return InstanceFromProto(Prototypes.get(DocumentType.WEB), new WebField(new URL(url)), options);
         }
@@ -649,7 +606,7 @@ export namespace Docs {
         }
 
         export function DocumentDocument(document?: Doc, options: DocumentOptions = {}) {
-            return InstanceFromProto(Prototypes.get(DocumentType.DOCUMENT), document, { title: document ? document.title + "" : "container", ...options });
+            return InstanceFromProto(Prototypes.get(DocumentType.DOCHOLDER), document, { title: document ? document.title + "" : "container", ...options });
         }
 
         export function FreeformDocument(documents: Array<Doc>, options: DocumentOptions, id?: string) {
@@ -688,8 +645,12 @@ export namespace Docs {
             return InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { _chromeStatus: "collapsed", schemaColumns: new List([new SchemaHeaderField("title", "#f1efeb")]), ...options, _viewType: CollectionViewType.Masonry });
         }
 
+        export function LabelDocument(options?: DocumentOptions) {
+            return InstanceFromProto(Prototypes.get(DocumentType.LABEL), undefined, { ...(options || {}) });
+        }
+
         export function ButtonDocument(options?: DocumentOptions) {
-            return InstanceFromProto(Prototypes.get(DocumentType.BUTTON), undefined, { ...(options || {}) });
+            return InstanceFromProto(Prototypes.get(DocumentType.LABEL), undefined, { ...(options || {}), editScriptOnClick: "onClick" });
         }
 
         export function SliderDocument(options?: DocumentOptions) {
@@ -842,9 +803,6 @@ export namespace Docs {
             } else if (field instanceof AudioField) {
                 created = Docs.Create.AudioDocument((field).url.href, resolved);
                 layout = AudioBox.LayoutString;
-            } else if (field instanceof HistogramField) {
-                created = Docs.Create.HistogramDocument((field).HistoOp, resolved);
-                layout = HistogramBox.LayoutString;
             } else if (field instanceof InkField) {
                 const { selectedColor, selectedWidth, selectedTool } = InkingControl.Instance;
                 created = Docs.Create.InkDocument(selectedColor, selectedTool, Number(selectedWidth), (field).inkData, resolved);
@@ -856,9 +814,11 @@ export namespace Docs {
                 created = Docs.Create.TextDocument("", { ...{ _width: 200, _height: 25, _autoHeight: true }, ...resolved });
                 layout = FormattedTextBox.LayoutString;
             }
-            created.layout = layout?.(fieldKey);
-            created.title = fieldKey;
-            proto && (created.proto = Doc.GetProto(proto));
+            if (created) {
+                created.layout = layout?.(fieldKey);
+                created.title = fieldKey;
+                proto && created.proto && (created.proto = Doc.GetProto(proto));
+            }
             return created;
         }
 
@@ -881,10 +841,6 @@ export namespace Docs {
                 if (!options._width) options._width = 400;
                 if (!options._height) options._height = options._width * 1200 / 927;
             }
-            if (type.indexOf("excel") !== -1) {
-                ctor = Docs.Create.DBDocument;
-                options.dropAction = "copy";
-            }
             if (type.indexOf("html") !== -1) {
                 if (path.includes(window.location.hostname)) {
                     const s = path.split('/');
diff --git a/src/client/northstar/core/BaseObject.ts b/src/client/northstar/core/BaseObject.ts
deleted file mode 100644
index ed3818071..000000000
--- a/src/client/northstar/core/BaseObject.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { IEquatable } from '../utils/IEquatable';
-import { IDisposable } from '../utils/IDisposable';
-
-export class BaseObject implements IEquatable, IDisposable {
-
-    public Equals(other: Object): boolean {
-        return this === other;
-    }
-
-    public Dispose(): void {
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/attribute/AttributeModel.ts b/src/client/northstar/core/attribute/AttributeModel.ts
deleted file mode 100644
index c89b1617c..000000000
--- a/src/client/northstar/core/attribute/AttributeModel.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import { Attribute, DataType, VisualizationHint } from '../../model/idea/idea';
-import { BaseObject } from '../BaseObject';
-import { observable } from "mobx";
-
-export abstract class AttributeModel extends BaseObject {
-    public abstract get DisplayName(): string;
-    public abstract get CodeName(): string;
-    public abstract get DataType(): DataType;
-    public abstract get VisualizationHints(): VisualizationHint[];
-}
-
-export class ColumnAttributeModel extends AttributeModel {
-    public Attribute: Attribute;
-
-    constructor(attribute: Attribute) {
-        super();
-        this.Attribute = attribute;
-    }
-
-    public get DataType(): DataType {
-        return this.Attribute.dataType ? this.Attribute.dataType : DataType.Undefined;
-    }
-
-    public get DisplayName(): string {
-        return this.Attribute.displayName ? this.Attribute.displayName.ReplaceAll("_", " ") : "";
-    }
-
-    public get CodeName(): string {
-        return this.Attribute.rawName ? this.Attribute.rawName : "";
-    }
-
-    public get VisualizationHints(): VisualizationHint[] {
-        return this.Attribute.visualizationHints ? this.Attribute.visualizationHints : [];
-    }
-
-    public Equals(other: ColumnAttributeModel): boolean {
-        return this.Attribute.rawName === other.Attribute.rawName;
-    }
-}
-
-export class CodeAttributeModel extends AttributeModel {
-    private _visualizationHints: VisualizationHint[];
-
-    public CodeName: string;
-
-    @observable
-    public Code: string;
-
-    constructor(code: string, codeName: string, displayName: string, visualizationHints: VisualizationHint[]) {
-        super();
-        this.Code = code;
-        this.CodeName = codeName;
-        this.DisplayName = displayName;
-        this._visualizationHints = visualizationHints;
-    }
-
-    public get DataType(): DataType {
-        return DataType.Undefined;
-    }
-
-    @observable
-    public DisplayName: string;
-
-    public get VisualizationHints(): VisualizationHint[] {
-        return this._visualizationHints;
-    }
-
-    public Equals(other: CodeAttributeModel): boolean {
-        return this.CodeName === other.CodeName;
-    }
-
-}
-
-export class BackendAttributeModel extends AttributeModel {
-    private _dataType: DataType;
-    private _displayName: string;
-    private _codeName: string;
-    private _visualizationHints: VisualizationHint[];
-
-    public Id: string;
-
-    constructor(id: string, dataType: DataType, displayName: string, codeName: string, visualizationHints: VisualizationHint[]) {
-        super();
-        this.Id = id;
-        this._dataType = dataType;
-        this._displayName = displayName;
-        this._codeName = codeName;
-        this._visualizationHints = visualizationHints;
-    }
-
-    public get DataType(): DataType {
-        return this._dataType;
-    }
-
-    public get DisplayName(): string {
-        return this._displayName.ReplaceAll("_", " ");
-    }
-
-    public get CodeName(): string {
-        return this._codeName;
-    }
-
-    public get VisualizationHints(): VisualizationHint[] {
-        return this._visualizationHints;
-    }
-
-    public Equals(other: BackendAttributeModel): boolean {
-        return this.Id === other.Id;
-    }
-
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/attribute/AttributeTransformationModel.ts b/src/client/northstar/core/attribute/AttributeTransformationModel.ts
deleted file mode 100644
index 66485183b..000000000
--- a/src/client/northstar/core/attribute/AttributeTransformationModel.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-
-import { computed, observable } from "mobx";
-import { AggregateFunction } from "../../model/idea/idea";
-import { AttributeModel } from "./AttributeModel";
-import { IEquatable } from "../../utils/IEquatable";
-
-export class AttributeTransformationModel implements IEquatable {
-
-    @observable public AggregateFunction: AggregateFunction;
-    @observable public AttributeModel: AttributeModel;
-
-    constructor(attributeModel: AttributeModel, aggregateFunction: AggregateFunction = AggregateFunction.None) {
-        this.AttributeModel = attributeModel;
-        this.AggregateFunction = aggregateFunction;
-    }
-
-    @computed
-    public get PresentedName(): string {
-        var displayName = this.AttributeModel.DisplayName;
-        if (this.AggregateFunction === AggregateFunction.Count) {
-            return "count";
-        }
-        if (this.AggregateFunction === AggregateFunction.Avg) {
-            displayName = "avg(" + displayName + ")";
-        }
-        else if (this.AggregateFunction === AggregateFunction.Max) {
-            displayName = "max(" + displayName + ")";
- }
-        else if (this.AggregateFunction === AggregateFunction.Min) {
-            displayName = "min(" + displayName + ")";
- }
-        else if (this.AggregateFunction === AggregateFunction.Sum) {
-            displayName = "sum(" + displayName + ")";
- }
-        else if (this.AggregateFunction === AggregateFunction.SumE) {
-            displayName = "sumE(" + displayName + ")";
- }
-
-        return displayName;
-    }
-
-    public clone(): AttributeTransformationModel {
-        var clone = new AttributeTransformationModel(this.AttributeModel);
-        clone.AggregateFunction = this.AggregateFunction;
-        return clone;
-    }
-
-    public Equals(other: AttributeTransformationModel): boolean {
-        return this.AggregateFunction === other.AggregateFunction &&
-            this.AttributeModel.Equals(other.AttributeModel);
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/attribute/CalculatedAttributeModel.ts b/src/client/northstar/core/attribute/CalculatedAttributeModel.ts
deleted file mode 100644
index a197c1305..000000000
--- a/src/client/northstar/core/attribute/CalculatedAttributeModel.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { BackendAttributeModel, AttributeModel, CodeAttributeModel } from "./AttributeModel";
-import { DataType, VisualizationHint } from '../../model/idea/idea';
-
-export class CalculatedAttributeManager {
-    public static AllCalculatedAttributes: Array<AttributeModel> = new Array<AttributeModel>();
-
-    public static Clear() {
-        this.AllCalculatedAttributes = new Array<AttributeModel>();
-    }
-
-    public static CreateBackendAttributeModel(id: string, dataType: DataType, displayName: string, codeName: string, visualizationHints: VisualizationHint[]): BackendAttributeModel {
-        var filtered = this.AllCalculatedAttributes.filter(am => {
-            if (am instanceof BackendAttributeModel &&
-                am.Id === id) {
-                return true;
-            }
-            return false;
-        });
-        if (filtered.length > 0) {
-            return filtered[0] as BackendAttributeModel;
-        }
-        var newAttr = new BackendAttributeModel(id, dataType, displayName, codeName, visualizationHints);
-        this.AllCalculatedAttributes.push(newAttr);
-        return newAttr;
-    }
-
-    public static CreateCodeAttributeModel(code: string, codeName: string, visualizationHints: VisualizationHint[]): CodeAttributeModel {
-        var filtered = this.AllCalculatedAttributes.filter(am => {
-            if (am instanceof CodeAttributeModel &&
-                am.CodeName === codeName) {
-                return true;
-            }
-            return false;
-        });
-        if (filtered.length > 0) {
-            return filtered[0] as CodeAttributeModel;
-        }
-        var newAttr = new CodeAttributeModel(code, codeName, codeName.ReplaceAll("_", " "), visualizationHints);
-        this.AllCalculatedAttributes.push(newAttr);
-        return newAttr;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/brusher/IBaseBrushable.ts b/src/client/northstar/core/brusher/IBaseBrushable.ts
deleted file mode 100644
index 87f4ba413..000000000
--- a/src/client/northstar/core/brusher/IBaseBrushable.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { PIXIPoint } from '../../utils/MathUtil';
-import { IEquatable } from '../../utils/IEquatable';
-import { Doc } from '../../../../new_fields/Doc';
-
-export interface IBaseBrushable<T> extends IEquatable {
-    BrusherModels: Array<Doc>;
-    BrushColors: Array<number>;
-    Position: PIXIPoint;
-    Size: PIXIPoint;
-}
-export function instanceOfIBaseBrushable<T>(object: any): object is IBaseBrushable<T> {
-    return 'BrusherModels' in object;
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/brusher/IBaseBrusher.ts b/src/client/northstar/core/brusher/IBaseBrusher.ts
deleted file mode 100644
index d2de6ed62..000000000
--- a/src/client/northstar/core/brusher/IBaseBrusher.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { PIXIPoint } from '../../utils/MathUtil';
-import { IEquatable } from '../../utils/IEquatable';
-
-
-export interface IBaseBrusher<T> extends IEquatable {
-    Position: PIXIPoint;
-    Size: PIXIPoint;
-}
-export function instanceOfIBaseBrusher<T>(object: any): object is IBaseBrusher<T> {
-    return 'BrushableModels' in object;
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/FilterModel.ts b/src/client/northstar/core/filter/FilterModel.ts
deleted file mode 100644
index 6ab96b33d..000000000
--- a/src/client/northstar/core/filter/FilterModel.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { ValueComparison } from "./ValueComparision";
-import { Utils } from "../../utils/Utils";
-import { IBaseFilterProvider } from "./IBaseFilterProvider";
-import { FilterOperand } from "./FilterOperand";
-import { HistogramField } from "../../dash-fields/HistogramField";
-import { Cast, FieldValue } from "../../../../new_fields/Types";
-import { Doc } from "../../../../new_fields/Doc";
-
-export class FilterModel {
-    public ValueComparisons: ValueComparison[];
-    constructor() {
-        this.ValueComparisons = new Array<ValueComparison>();
-    }
-
-    public Equals(other: FilterModel): boolean {
-        if (!Utils.EqualityHelper(this, other)) return false;
-        if (!this.isSame(this.ValueComparisons, (other).ValueComparisons)) return false;
-        return true;
-    }
-
-    private isSame(a: ValueComparison[], b: ValueComparison[]): boolean {
-        if (a.length !== b.length) {
-            return false;
-        }
-        for (let i = 0; i < a.length; i++) {
-            let valueComp = a[i];
-            if (!valueComp.Equals(b[i])) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    public ToPythonString(): string {
-        return "(" + this.ValueComparisons.map(vc => vc.ToPythonString()).join("&&") + ")";
-    }
-
-    public static And(filters: string[]): string {
-        let ret = filters.filter(f => f !== "").join(" && ");
-        return ret;
-    }
-    public static GetFilterModelsRecursive(baseOperation: IBaseFilterProvider, visitedFilterProviders: Set<IBaseFilterProvider>, filterModels: FilterModel[], isFirst: boolean): string {
-        let ret = "";
-        visitedFilterProviders.add(baseOperation);
-        let filtered = baseOperation.FilterModels.filter(fm => fm && fm.ValueComparisons.length > 0);
-        if (!isFirst && filtered.length > 0) {
-            filterModels.push(...filtered);
-            ret = "(" + baseOperation.FilterModels.filter(fm => fm !== null).map(fm => fm.ToPythonString()).join(" || ") + ")";
-        }
-        if (Utils.isBaseFilterConsumer(baseOperation) && baseOperation.Links) {
-            let children = new Array<string>();
-            let linkedGraphNodes = baseOperation.Links;
-            linkedGraphNodes.map(linkVm => {
-                let filterDoc = FieldValue(Cast(linkVm.linkedFrom, Doc));
-                if (filterDoc) {
-                    let filterHistogram = Cast(filterDoc.data, HistogramField);
-                    if (filterHistogram) {
-                        if (!visitedFilterProviders.has(filterHistogram.HistoOp)) {
-                            let child = FilterModel.GetFilterModelsRecursive(filterHistogram.HistoOp, visitedFilterProviders, filterModels, false);
-                            if (child !== "") {
-                                // if (linkVm.IsInverted) {
-                                //     child = "! " + child;
-                                // }
-                                children.push(child);
-                            }
-                        }
-                    }
-                }
-            });
-
-            let childrenJoined = children.join(baseOperation.FilterOperand === FilterOperand.AND ? " && " : " || ");
-            if (children.length > 0) {
-                if (ret !== "") {
-                    ret = "(" + ret + " &&  (" + childrenJoined + "))";
-                }
-                else {
-                    ret = "(" + childrenJoined + ")";
-                }
-            }
-        }
-        return ret;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/FilterOperand.ts b/src/client/northstar/core/filter/FilterOperand.ts
deleted file mode 100644
index 2e8e8d6a0..000000000
--- a/src/client/northstar/core/filter/FilterOperand.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-export enum FilterOperand
-{
-    AND,
-    OR
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/FilterType.ts b/src/client/northstar/core/filter/FilterType.ts
deleted file mode 100644
index 9adbc087f..000000000
--- a/src/client/northstar/core/filter/FilterType.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-export enum FilterType
-{
-    Filter,
-    Brush,
-    Slice
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/IBaseFilterConsumer.ts b/src/client/northstar/core/filter/IBaseFilterConsumer.ts
deleted file mode 100644
index e7549d113..000000000
--- a/src/client/northstar/core/filter/IBaseFilterConsumer.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { FilterOperand } from '../filter/FilterOperand';
-import { IEquatable } from '../../utils/IEquatable';
-import { Doc } from '../../../../new_fields/Doc';
-
-export interface IBaseFilterConsumer extends IEquatable {
-    FilterOperand: FilterOperand;
-    Links: Doc[];
-}
-
-export function instanceOfIBaseFilterConsumer(object: any): object is IBaseFilterConsumer {
-    return 'FilterOperand' in object;
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/IBaseFilterProvider.ts b/src/client/northstar/core/filter/IBaseFilterProvider.ts
deleted file mode 100644
index fc3301b11..000000000
--- a/src/client/northstar/core/filter/IBaseFilterProvider.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { FilterModel } from '../filter/FilterModel';
-
-export interface IBaseFilterProvider {
-    FilterModels: Array<FilterModel>;
-}
-export function instanceOfIBaseFilterProvider(object: any): object is IBaseFilterProvider {
-    return 'FilterModels' in object;
-}
\ No newline at end of file
diff --git a/src/client/northstar/core/filter/ValueComparision.ts b/src/client/northstar/core/filter/ValueComparision.ts
deleted file mode 100644
index 65687a82b..000000000
--- a/src/client/northstar/core/filter/ValueComparision.ts
+++ /dev/null
@@ -1,78 +0,0 @@
-import { Predicate } from '../../model/idea/idea';
-import { Utils } from '../../utils/Utils';
-import { AttributeModel } from '../attribute/AttributeModel';
-
-export class ValueComparison {
-
-    public attributeModel: AttributeModel;
-    public Value: any;
-    public Predicate: Predicate;
-
-    public constructor(attributeModel: AttributeModel, predicate: Predicate, value: any) {
-        this.attributeModel = attributeModel;
-        this.Value = value;
-        this.Predicate = predicate;
-    }
-
-    public Equals(other: Object): boolean {
-        if (!Utils.EqualityHelper(this, other)) {
-            return false;
-        }
-        if (this.Predicate !== (other as ValueComparison).Predicate) {
-            return false;
-        }
-        let isComplex = (typeof this.Value === "object");
-        if (!isComplex && this.Value !== (other as ValueComparison).Value) {
-            return false;
-        }
-        if (isComplex && !this.Value.Equals((other as ValueComparison).Value)) {
-            return false;
-        }
-        return true;
-    }
-
-    public ToPythonString(): string {
-        var op = "";
-        switch (this.Predicate) {
-            case Predicate.EQUALS:
-                op = "==";
-                break;
-            case Predicate.GREATER_THAN:
-                op = ">";
-                break;
-            case Predicate.GREATER_THAN_EQUAL:
-                op = ">=";
-                break;
-            case Predicate.LESS_THAN:
-                op = "<";
-                break;
-            case Predicate.LESS_THAN_EQUAL:
-                op = "<=";
-                break;
-            default:
-                op = "==";
-                break;
-        }
-
-        var val = this.Value.toString();
-        if (typeof this.Value === 'string' || this.Value instanceof String) {
-            val = "\"" + val + "\"";
-        }
-        var ret = " ";
-        var rawName = this.attributeModel.CodeName;
-        switch (this.Predicate) {
-            case Predicate.STARTS_WITH:
-                ret += rawName + " != null && " + rawName + ".StartsWith(" + val + ") ";
-                return ret;
-            case Predicate.ENDS_WITH:
-                ret += rawName + " != null && " + rawName + ".EndsWith(" + val + ") ";
-                return ret;
-            case Predicate.CONTAINS:
-                ret += rawName + " != null && " + rawName + ".Contains(" + val + ") ";
-                return ret;
-            default:
-                ret += rawName + " " + op + " " + val + " ";
-                return ret;
-        }
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/dash-fields/HistogramField.ts b/src/client/northstar/dash-fields/HistogramField.ts
deleted file mode 100644
index 076516977..000000000
--- a/src/client/northstar/dash-fields/HistogramField.ts
+++ /dev/null
@@ -1,66 +0,0 @@
-import { observable } from "mobx";
-import { custom, serializable } from "serializr";
-import { ColumnAttributeModel } from "../../../client/northstar/core/attribute/AttributeModel";
-import { AttributeTransformationModel } from "../../../client/northstar/core/attribute/AttributeTransformationModel";
-import { HistogramOperation } from "../../../client/northstar/operations/HistogramOperation";
-import { ObjectField } from "../../../new_fields/ObjectField";
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import { OmitKeys } from "../../../Utils";
-import { Deserializable } from "../../util/SerializationHelper";
-import { Copy, ToScriptString, ToString } from "../../../new_fields/FieldSymbols";
-
-function serialize(field: HistogramField) {
-    const obj = OmitKeys(field, ['Links', 'BrushLinks', 'Result', 'BrushColors', 'FilterModels', 'FilterOperand']).omit;
-    return obj;
-}
-
-function deserialize(jp: any) {
-    let X: AttributeTransformationModel | undefined;
-    let Y: AttributeTransformationModel | undefined;
-    let V: AttributeTransformationModel | undefined;
-
-    const schema = CurrentUserUtils.GetNorthstarSchema(jp.SchemaName);
-    if (schema) {
-        CurrentUserUtils.GetAllNorthstarColumnAttributes(schema).map(attr => {
-            if (attr.displayName === jp.X.AttributeModel.Attribute.DisplayName) {
-                X = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.X.AggregateFunction);
-            }
-            if (attr.displayName === jp.Y.AttributeModel.Attribute.DisplayName) {
-                Y = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.Y.AggregateFunction);
-            }
-            if (attr.displayName === jp.V.AttributeModel.Attribute.DisplayName) {
-                V = new AttributeTransformationModel(new ColumnAttributeModel(attr), jp.V.AggregateFunction);
-            }
-        });
-        if (X && Y && V) {
-            return new HistogramOperation(jp.SchemaName, X, Y, V, jp.Normalization);
-        }
-    }
-    return HistogramOperation.Empty;
-}
-
-@Deserializable("histogramField")
-export class HistogramField extends ObjectField {
-    @serializable(custom(serialize, deserialize)) @observable public readonly HistoOp: HistogramOperation;
-    constructor(data?: HistogramOperation) {
-        super();
-        this.HistoOp = data ? data : HistogramOperation.Empty;
-    }
-
-    toString(): string {
-        return JSON.stringify(OmitKeys(this.HistoOp, ['Links', 'BrushLinks', 'Result', 'BrushColors', 'FilterModels', 'FilterOperand']).omit);
-    }
-
-    [Copy]() {
-        // const y = this.HistoOp;
-        // const z = this.HistoOp.Copy;
-        return new HistogramField(HistogramOperation.Duplicate(this.HistoOp));
-    }
-
-    [ToScriptString]() {
-        return this.toString();
-    }
-    [ToString]() {
-        return this.toString();
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts b/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts
deleted file mode 100644
index 6b36ffc9e..000000000
--- a/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts
+++ /dev/null
@@ -1,240 +0,0 @@
-import React = require("react");
-import { AttributeTransformationModel } from "../../northstar/core/attribute/AttributeTransformationModel";
-import { ChartType } from '../../northstar/model/binRanges/VisualBinRange';
-import { AggregateFunction, Bin, Brush, DoubleValueAggregateResult, HistogramResult, MarginAggregateParameters, MarginAggregateResult } from "../../northstar/model/idea/idea";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { LABColor } from '../../northstar/utils/LABColor';
-import { PIXIRectangle } from "../../northstar/utils/MathUtil";
-import { StyleConstants } from "../../northstar/utils/StyleContants";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramBoxPrimitives.scss";
-
-export class HistogramBinPrimitive {
-    constructor(init?: Partial<HistogramBinPrimitive>) {
-        Object.assign(this, init);
-    }
-    public DataValue: number = 0;
-    public Rect: PIXIRectangle = PIXIRectangle.EMPTY;
-    public MarginRect: PIXIRectangle = PIXIRectangle.EMPTY;
-    public MarginPercentage: number = 0;
-    public Color: number = StyleConstants.WARNING_COLOR;
-    public Opacity: number = 1;
-    public BrushIndex: number = 0;
-    public BarAxis: number = -1;
-}
-
-export class HistogramBinPrimitiveCollection {
-    private static TOLERANCE: number = 0.0001;
-
-    private _histoBox: HistogramBox;
-    private get histoOp() { return this._histoBox.HistoOp; }
-    private get histoResult() { return this.histoOp.Result as HistogramResult; }
-    private get sizeConverter() { return this._histoBox.SizeConverter; }
-    public BinPrimitives: Array<HistogramBinPrimitive> = new Array<HistogramBinPrimitive>();
-    public HitGeom: PIXIRectangle = PIXIRectangle.EMPTY;
-
-    constructor(bin: Bin, histoBox: HistogramBox) {
-        this._histoBox = histoBox;
-        let brushing = this.setupBrushing(bin, this.histoOp.Normalization); // X= 0, Y = 1, V = 2
-
-        brushing.orderedBrushes.reduce((brushFactorSum, brush) => {
-            switch (histoBox.ChartType) {
-                case ChartType.VerticalBar: return this.createVerticalBarChartBinPrimitives(bin, brush, brushing.maxAxis, this.histoOp.Normalization);
-                case ChartType.HorizontalBar: return this.createHorizontalBarChartBinPrimitives(bin, brush, brushing.maxAxis, this.histoOp.Normalization);
-                case ChartType.SinglePoint: return this.createSinglePointChartBinPrimitives(bin, brush);
-                case ChartType.HeatMap: return this.createHeatmapBinPrimitives(bin, brush, brushFactorSum);
-            }
-        }, 0);
-
-        // adjust brush rects (stacking or not)
-        var allBrushIndex = ModelHelpers.AllBrushIndex(this.histoResult);
-        var filteredBinPrims = this.BinPrimitives.filter(b => b.BrushIndex !== allBrushIndex && b.DataValue !== 0.0);
-        filteredBinPrims.reduce((sum, fbp) => {
-            if (histoBox.ChartType === ChartType.VerticalBar) {
-                if (this.histoOp.Y.AggregateFunction === AggregateFunction.Count) {
-                    fbp.Rect = new PIXIRectangle(fbp.Rect.x, fbp.Rect.y - sum, fbp.Rect.width, fbp.Rect.height);
-                    fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x, fbp.MarginRect.y - sum, fbp.MarginRect.width, fbp.MarginRect.height);
-                    return sum + fbp.Rect.height;
-                }
-                if (this.histoOp.Y.AggregateFunction === AggregateFunction.Avg) {
-                    var w = fbp.Rect.width / 2.0;
-                    fbp.Rect = new PIXIRectangle(fbp.Rect.x + sum, fbp.Rect.y, fbp.Rect.width / filteredBinPrims.length, fbp.Rect.height);
-                    fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x - w + sum + (fbp.Rect.width / 2.0), fbp.MarginRect.y, fbp.MarginRect.width, fbp.MarginRect.height);
-                    return sum + fbp.Rect.width;
-                }
-            }
-            else if (histoBox.ChartType === ChartType.HorizontalBar) {
-                if (this.histoOp.X.AggregateFunction === AggregateFunction.Count) {
-                    fbp.Rect = new PIXIRectangle(fbp.Rect.x + sum, fbp.Rect.y, fbp.Rect.width, fbp.Rect.height);
-                    fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x + sum, fbp.MarginRect.y, fbp.MarginRect.width, fbp.MarginRect.height);
-                    return sum + fbp.Rect.width;
-                }
-                if (this.histoOp.X.AggregateFunction === AggregateFunction.Avg) {
-                    var h = fbp.Rect.height / 2.0;
-                    fbp.Rect = new PIXIRectangle(fbp.Rect.x, fbp.Rect.y + sum, fbp.Rect.width, fbp.Rect.height / filteredBinPrims.length);
-                    fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x, fbp.MarginRect.y - h + sum + (fbp.Rect.height / 2.0), fbp.MarginRect.width, fbp.MarginRect.height);
-                    return sum + fbp.Rect.height;
-                }
-            }
-            return 0;
-        }, 0);
-        this.BinPrimitives = this.BinPrimitives.reverse();
-        var f = this.BinPrimitives.filter(b => b.BrushIndex === allBrushIndex);
-        this.HitGeom = f.length > 0 ? f[0].Rect : PIXIRectangle.EMPTY;
-    }
-
-    private setupBrushing(bin: Bin, normalization: number) {
-        var overlapBrushIndex = ModelHelpers.OverlapBrushIndex(this.histoResult);
-        var orderedBrushes = [this.histoResult.brushes![0], this.histoResult.brushes![overlapBrushIndex]];
-        this.histoResult.brushes!.map(brush => brush.brushIndex !== 0 && brush.brushIndex !== overlapBrushIndex && orderedBrushes.push(brush));
-        return {
-            orderedBrushes,
-            maxAxis: orderedBrushes.reduce((prev, Brush) => {
-                let aggResult = this.getBinValue(normalization, bin, Brush.brushIndex!);
-                return aggResult !== undefined && aggResult > prev ? aggResult : prev;
-            }, Number.MIN_VALUE)
-        };
-    }
-
-    private createHeatmapBinPrimitives(bin: Bin, brush: Brush, brushFactorSum: number): number {
-
-        let unNormalizedValue = this.getBinValue(2, bin, brush.brushIndex!);
-        if (unNormalizedValue === undefined) {
-            return brushFactorSum;
-        }
-
-        var normalizedValue = (unNormalizedValue - this._histoBox.ValueRange[0]) / (Math.abs((this._histoBox.ValueRange[1] - this._histoBox.ValueRange[0])) < HistogramBinPrimitiveCollection.TOLERANCE ?
-            unNormalizedValue : this._histoBox.ValueRange[1] - this._histoBox.ValueRange[0]);
-
-        let allUnNormalizedValue = this.getBinValue(2, bin, ModelHelpers.AllBrushIndex(this.histoResult));
-
-        // bcz: are these calls needed?  
-        let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
-        let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
-
-        var returnBrushFactorSum = brushFactorSum;
-        if (allUnNormalizedValue !== undefined) {
-            var brushFactor = (unNormalizedValue / allUnNormalizedValue);
-            returnBrushFactorSum += brushFactor;
-            returnBrushFactorSum = Math.min(returnBrushFactorSum, 1.0);
-
-            var tempRect = new PIXIRectangle(xFrom, yTo, xTo - xFrom, yFrom - yTo);
-            var ratio = (tempRect.width / tempRect.height);
-            var newHeight = Math.sqrt((1.0 / ratio) * ((tempRect.width * tempRect.height) * returnBrushFactorSum));
-            var newWidth = newHeight * ratio;
-
-            xFrom = (tempRect.x + (tempRect.width - newWidth) / 2.0);
-            yTo = (tempRect.y + (tempRect.height - newHeight) / 2.0);
-            xTo = (xFrom + newWidth);
-            yFrom = (yTo + newHeight);
-        }
-        var alpha = 0.0;
-        var color = this.baseColorFromBrush(brush);
-        var lerpColor = LABColor.Lerp(
-            LABColor.FromColor(StyleConstants.MIN_VALUE_COLOR),
-            LABColor.FromColor(color),
-            (alpha + Math.pow(normalizedValue, 1.0 / 3.0) * (1.0 - alpha)));
-        var dataColor = LABColor.ToColor(lerpColor);
-
-        this.createBinPrimitive(-1, brush, PIXIRectangle.EMPTY, 0, xFrom, xTo, yFrom, yTo, dataColor, 1, unNormalizedValue);
-        return returnBrushFactorSum;
-    }
-
-    private createSinglePointChartBinPrimitives(bin: Bin, brush: Brush): number {
-        let unNormalizedValue = this.getBinValue(2, bin, brush.brushIndex!);
-        if (unNormalizedValue !== undefined) {
-            let [xFrom, xTo] = this.sizeConverter.DataToScreenPointRange(0, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.X, this.histoResult, brush.brushIndex!));
-            let [yFrom, yTo] = this.sizeConverter.DataToScreenPointRange(1, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.Y, this.histoResult, brush.brushIndex!));
-
-            if (xFrom !== undefined && yFrom !== undefined && xTo !== undefined && yTo !== undefined) {
-                this.createBinPrimitive(-1, brush, PIXIRectangle.EMPTY, 0, xFrom, xTo, yFrom, yTo, this.baseColorFromBrush(brush), 1, unNormalizedValue);
-            }
-        }
-        return 0;
-    }
-
-    private createVerticalBarChartBinPrimitives(bin: Bin, brush: Brush, binBrushMaxAxis: number, normalization: number): number {
-        let dataValue = this.getBinValue(1, bin, brush.brushIndex!);
-        if (dataValue !== undefined) {
-            let [yFrom, yValue, yTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 1, binBrushMaxAxis);
-            let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
-
-            var yMarginAbsolute = this.getMargin(bin, brush, this.histoOp.Y);
-            var marginRect = new PIXIRectangle(xFrom + (xTo - xFrom) / 2.0 - 1,
-                this.sizeConverter.DataToScreenY(yValue + yMarginAbsolute), 2,
-                this.sizeConverter.DataToScreenY(yValue - yMarginAbsolute) - this.sizeConverter.DataToScreenY(yValue + yMarginAbsolute));
-
-            this.createBinPrimitive(1, brush, marginRect, 0, xFrom, xTo, yFrom, yTo,
-                this.baseColorFromBrush(brush), normalization !== 0 ? 1 : 0.6 * binBrushMaxAxis / this.sizeConverter.DataRanges[1] + 0.4, dataValue);
-        }
-        return 0;
-    }
-
-    private createHorizontalBarChartBinPrimitives(bin: Bin, brush: Brush, binBrushMaxAxis: number, normalization: number): number {
-        let dataValue = this.getBinValue(0, bin, brush.brushIndex!);
-        if (dataValue !== undefined) {
-            let [xFrom, xValue, xTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 0, binBrushMaxAxis);
-            let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
-
-            var xMarginAbsolute = this.sizeConverter.IsSmall ? 0 : this.getMargin(bin, brush, this.histoOp.X);
-            var marginRect = new PIXIRectangle(this.sizeConverter.DataToScreenX(xValue - xMarginAbsolute),
-                yTo + (yFrom - yTo) / 2.0 - 1,
-                this.sizeConverter.DataToScreenX(xValue + xMarginAbsolute) - this.sizeConverter.DataToScreenX(xValue - xMarginAbsolute),
-                2.0);
-
-            this.createBinPrimitive(0, brush, marginRect, 0, xFrom, xTo, yFrom, yTo,
-                this.baseColorFromBrush(brush), normalization !== 1 ? 1 : 0.6 * binBrushMaxAxis / this.sizeConverter.DataRanges[0] + 0.4, dataValue);
-        }
-        return 0;
-    }
-
-    public getBinValue(axis: number, bin: Bin, brushIndex: number) {
-        var aggregateKey = ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, axis === 0 ? this.histoOp.X : axis === 1 ? this.histoOp.Y : this.histoOp.V, this.histoResult, brushIndex);
-        let dataValue = ModelHelpers.GetAggregateResult(bin, aggregateKey) as DoubleValueAggregateResult;
-        return dataValue !== null && dataValue.hasResult ? dataValue.result : undefined;
-    }
-
-    private getMargin(bin: Bin, brush: Brush, axis: AttributeTransformationModel) {
-        var marginParams = new MarginAggregateParameters();
-        marginParams.aggregateFunction = axis.AggregateFunction;
-        var marginAggregateKey = ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, axis, this.histoResult, brush.brushIndex!, marginParams);
-        let aggResult = ModelHelpers.GetAggregateResult(bin, marginAggregateKey);
-        return aggResult instanceof MarginAggregateResult && aggResult.absolutMargin ? aggResult.absolutMargin : 0;
-    }
-
-    private createBinPrimitive(barAxis: number, brush: Brush, marginRect: PIXIRectangle,
-        marginPercentage: number, xFrom: number, xTo: number, yFrom: number, yTo: number, color: number, opacity: number, dataValue: number) {
-        var binPrimitive = new HistogramBinPrimitive(
-            {
-                Rect: new PIXIRectangle(xFrom, yTo, xTo - xFrom, yFrom - yTo),
-                MarginRect: marginRect,
-                MarginPercentage: marginPercentage,
-                BrushIndex: brush.brushIndex,
-                Color: color,
-                Opacity: opacity,
-                DataValue: dataValue,
-                BarAxis: barAxis
-            });
-        this.BinPrimitives.push(binPrimitive);
-    }
-
-    private baseColorFromBrush(brush: Brush): number {
-        let bc = StyleConstants.BRUSH_COLORS;
-        if (brush.brushIndex === ModelHelpers.RestBrushIndex(this.histoResult)) {
-            return StyleConstants.HIGHLIGHT_COLOR;
-        }
-        else if (brush.brushIndex === ModelHelpers.OverlapBrushIndex(this.histoResult)) {
-            return StyleConstants.OVERLAP_COLOR;
-        }
-        else if (brush.brushIndex === ModelHelpers.AllBrushIndex(this.histoResult)) {
-            return 0x00ff00;
-        }
-        else if (bc.length > 0) {
-            return bc[brush.brushIndex! % bc.length];
-        }
-        // else if (this.histoOp.BrushColors.length > 0) {
-        //     return this.histoOp.BrushColors[brush.brushIndex! % this.histoOp.BrushColors.length];
-        // }
-        return StyleConstants.HIGHLIGHT_COLOR;
-    }
-}
diff --git a/src/client/northstar/dash-nodes/HistogramBox.scss b/src/client/northstar/dash-nodes/HistogramBox.scss
deleted file mode 100644
index 06d781263..000000000
--- a/src/client/northstar/dash-nodes/HistogramBox.scss
+++ /dev/null
@@ -1,40 +0,0 @@
-.histogrambox-container {
-    padding: 0vw;
-    position: absolute;
-    top: -50%;
-    left:-50%;
-    text-align: center;
-    width: 100%;
-    height: 100%;
-    background: black; 
-  }
-  .histogrambox-xaxislabel {
-    position:absolute;
-    left:0;
-    width:100%;
-    text-align: center;
-    bottom:0;
-    background: lightgray;
-    font-size: 14;
-    font-weight: bold;
-  }
-  .histogrambox-yaxislabel {
-    position:absolute;
-    height:100%;
-    width: 25px;
-    left:0;
-    bottom:0;
-    background: lightgray;
-  }
-  .histogrambox-yaxislabel-text {
-    position:absolute;
-    left:0;
-    width: 1000px;
-    transform-origin: 10px 10px;
-    transform: rotate(-90deg);
-    text-align: left;
-    font-size: 14;
-    font-weight: bold;
-    bottom: calc(50% - 25px);
-  }
-  
\ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBox.tsx b/src/client/northstar/dash-nodes/HistogramBox.tsx
deleted file mode 100644
index 8fee53fb9..000000000
--- a/src/client/northstar/dash-nodes/HistogramBox.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import React = require("react");
-import { action, computed, observable, reaction, runInAction, trace } from "mobx";
-import { observer } from "mobx-react";
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import { ChartType, VisualBinRange } from '../../northstar/model/binRanges/VisualBinRange';
-import { VisualBinRangeHelper } from "../../northstar/model/binRanges/VisualBinRangeHelper";
-import { AggregateBinRange, AggregateFunction, BinRange, Catalog, DoubleValueAggregateResult, HistogramResult } from "../../northstar/model/idea/idea";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { HistogramOperation } from "../../northstar/operations/HistogramOperation";
-import { SizeConverter } from "../../northstar/utils/SizeConverter";
-import { DragManager } from "../../util/DragManager";
-import { FieldView, FieldViewProps } from "../../views/nodes/FieldView";
-import { AttributeTransformationModel } from "../core/attribute/AttributeTransformationModel";
-import { HistogramField } from "../dash-fields/HistogramField";
-import "../utils/Extensions";
-import "./HistogramBox.scss";
-import { HistogramBoxPrimitives } from './HistogramBoxPrimitives';
-import { HistogramLabelPrimitives } from "./HistogramLabelPrimitives";
-import { StyleConstants } from "../utils/StyleContants";
-import { Cast } from "../../../new_fields/Types";
-import { Doc, DocListCast, DocListCastAsync } from "../../../new_fields/Doc";
-import { Id } from "../../../new_fields/FieldSymbols";
-
-
-@observer
-export class HistogramBox extends React.Component<FieldViewProps> {
-    public static LayoutString(fieldStr: string) { return FieldView.LayoutString(HistogramBox, fieldStr); }
-    private _dropXRef = React.createRef<HTMLDivElement>();
-    private _dropYRef = React.createRef<HTMLDivElement>();
-    private _dropXDisposer?: DragManager.DragDropDisposer;
-    private _dropYDisposer?: DragManager.DragDropDisposer;
-
-    @observable public HistoOp: HistogramOperation = HistogramOperation.Empty;
-    @observable public VisualBinRanges: VisualBinRange[] = [];
-    @observable public ValueRange: number[] = [];
-    @computed public get HistogramResult(): HistogramResult { return this.HistoOp.Result as HistogramResult; }
-    @observable public SizeConverter: SizeConverter = new SizeConverter();
-
-    @computed get createOperationParamsCache() { return this.HistoOp.CreateOperationParameters(); }
-    @computed get BinRanges() { return this.HistogramResult ? this.HistogramResult.binRanges : undefined; }
-    @computed get ChartType() {
-        return !this.BinRanges ? ChartType.SinglePoint : this.BinRanges[0] instanceof AggregateBinRange ?
-            (this.BinRanges[1] instanceof AggregateBinRange ? ChartType.SinglePoint : ChartType.HorizontalBar) :
-            this.BinRanges[1] instanceof AggregateBinRange ? ChartType.VerticalBar : ChartType.HeatMap;
-    }
-
-    @action
-    dropX = (e: Event, de: DragManager.DropEvent) => {
-        if (de.complete.docDragData) {
-            let h = Cast(de.complete.docDragData.draggedDocuments[0].data, HistogramField);
-            if (h) {
-                this.HistoOp.X = h.HistoOp.X;
-            }
-            e.stopPropagation();
-            e.preventDefault();
-        }
-    }
-    @action
-    dropY = (e: Event, de: DragManager.DropEvent) => {
-        if (de.complete.docDragData) {
-            let h = Cast(de.complete.docDragData.draggedDocuments[0].data, HistogramField);
-            if (h) {
-                this.HistoOp.Y = h.HistoOp.X;
-            }
-            e.stopPropagation();
-            e.preventDefault();
-        }
-    }
-
-    @action
-    xLabelPointerDown = (e: React.PointerEvent) => {
-        this.HistoOp.X = new AttributeTransformationModel(this.HistoOp.X.AttributeModel, this.HistoOp.X.AggregateFunction === AggregateFunction.None ? AggregateFunction.Count : AggregateFunction.None);
-    }
-    @action
-    yLabelPointerDown = (e: React.PointerEvent) => {
-        this.HistoOp.Y = new AttributeTransformationModel(this.HistoOp.Y.AttributeModel, this.HistoOp.Y.AggregateFunction === AggregateFunction.None ? AggregateFunction.Count : AggregateFunction.None);
-    }
-
-    componentDidMount() {
-        if (this._dropXRef.current) {
-            this._dropXDisposer = DragManager.MakeDropTarget(this._dropXRef.current, this.dropX.bind(this));
-        }
-        if (this._dropYRef.current) {
-            this._dropYDisposer = DragManager.MakeDropTarget(this._dropYRef.current, this.dropY.bind(this));
-        }
-        reaction(() => CurrentUserUtils.NorthstarDBCatalog, (catalog?: Catalog) => this.activateHistogramOperation(catalog), { fireImmediately: true });
-        reaction(() => [this.VisualBinRanges && this.VisualBinRanges.slice()], () => this.SizeConverter.SetVisualBinRanges(this.VisualBinRanges));
-        reaction(() => [this.props.PanelWidth(), this.props.PanelHeight()], (size: number[]) => this.SizeConverter.SetIsSmall(size[0] < 40 && size[1] < 40));
-        reaction(() => this.HistogramResult ? this.HistogramResult.binRanges : undefined,
-            (binRanges: BinRange[] | undefined) => {
-                if (binRanges) {
-                    this.VisualBinRanges.splice(0, this.VisualBinRanges.length, ...binRanges.map((br, ind) =>
-                        VisualBinRangeHelper.GetVisualBinRange(this.HistoOp.Schema!.distinctAttributeParameters, br, this.HistogramResult, ind ? this.HistoOp.Y : this.HistoOp.X, this.ChartType)));
-
-                    let valueAggregateKey = ModelHelpers.CreateAggregateKey(this.HistoOp.Schema!.distinctAttributeParameters, this.HistoOp.V, this.HistogramResult, ModelHelpers.AllBrushIndex(this.HistogramResult));
-                    this.ValueRange = Object.values(this.HistogramResult.bins!).reduce((prev, cur) => {
-                        let value = ModelHelpers.GetAggregateResult(cur, valueAggregateKey) as DoubleValueAggregateResult;
-                        return value && value.hasResult ? [Math.min(prev[0], value.result!), Math.max(prev[1], value.result!)] : prev;
-                    }, [Number.MAX_VALUE, Number.MIN_VALUE]);
-                }
-            });
-    }
-
-    componentWillUnmount() {
-        if (this._dropXDisposer) {
-            this._dropXDisposer();
-        }
-        if (this._dropYDisposer) {
-            this._dropYDisposer();
-        }
-    }
-
-    async activateHistogramOperation(catalog?: Catalog) {
-        if (catalog) {
-            let histoOp = await Cast(this.props.Document[this.props.fieldKey], HistogramField);
-            runInAction(() => {
-                this.HistoOp = histoOp ? histoOp.HistoOp : HistogramOperation.Empty;
-                if (this.HistoOp !== HistogramOperation.Empty) {
-                    reaction(() => DocListCast(this.props.Document.linkedFromDocs), (docs) => this.HistoOp.Links.splice(0, this.HistoOp.Links.length, ...docs), { fireImmediately: true });
-                    reaction(() => DocListCast(this.props.Document.brushingDocs).length,
-                        async () => {
-                            let brushingDocs = await DocListCastAsync(this.props.Document.brushingDocs);
-                            const proto = this.props.Document.proto;
-                            if (proto && brushingDocs) {
-                                let mapped = brushingDocs.map((brush, i) => {
-                                    brush.backgroundColor = StyleConstants.BRUSH_COLORS[i % StyleConstants.BRUSH_COLORS.length];
-                                    let brushed = DocListCast(brush.brushingDocs);
-                                    if (!brushed.length) return null;
-                                    return { l: brush, b: brushed[0][Id] === proto[Id] ? brushed[1] : brushed[0] };
-                                });
-                                runInAction(() => this.HistoOp.BrushLinks.splice(0, this.HistoOp.BrushLinks.length, ...mapped.filter(m => m) as { l: Doc, b: Doc }[]));
-                            }
-                        }, { fireImmediately: true });
-                    reaction(() => this.createOperationParamsCache, () => this.HistoOp.Update(), { fireImmediately: true });
-                }
-            });
-        }
-    }
-
-    @action
-    private onScrollWheel = (e: React.WheelEvent) => {
-        this.HistoOp.DrillDown(e.deltaY > 0);
-        e.stopPropagation();
-    }
-
-    render() {
-        let labelY = this.HistoOp && this.HistoOp.Y ? this.HistoOp.Y.PresentedName : "<...>";
-        let labelX = this.HistoOp && this.HistoOp.X ? this.HistoOp.X.PresentedName : "<...>";
-        let loff = this.SizeConverter.LeftOffset;
-        let toff = this.SizeConverter.TopOffset;
-        let roff = this.SizeConverter.RightOffset;
-        let boff = this.SizeConverter.BottomOffset;
-        return (
-            <div className="histogrambox-container" onWheel={this.onScrollWheel}>
-                <div className="histogrambox-yaxislabel" onPointerDown={this.yLabelPointerDown} ref={this._dropYRef} >
-                    <span className="histogrambox-yaxislabel-text">
-                        {labelY}
-                    </span>
-                </div>
-                <div className="histogrambox-primitives" style={{
-                    transform: `translate(${loff + 25}px, ${toff}px)`,
-                    width: `calc(100% - ${loff + roff + 25}px)`,
-                    height: `calc(100% - ${toff + boff}px)`,
-                }}>
-                    <HistogramLabelPrimitives HistoBox={this} />
-                    <HistogramBoxPrimitives HistoBox={this} />
-                </div>
-                <div className="histogrambox-xaxislabel" onPointerDown={this.xLabelPointerDown} ref={this._dropXRef} >
-                    {labelX}
-                </div>
-            </div>
-        );
-    }
-}
-
diff --git a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
deleted file mode 100644
index 26203612a..000000000
--- a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
+++ /dev/null
@@ -1,42 +0,0 @@
-.histogramboxprimitives-container {
-    width: 100%;
-    height: 100%;
-}
-.histogramboxprimitives-border {
-    border: 3px;
-    pointer-events: none;
-    position: absolute;
-    fill:"transparent";
-    stroke: white;
-    stroke-width: 1px;
-}
-.histogramboxprimitives-bar {
-    position: absolute;
-    border: 1px;
-    border-style: solid;
-    border-color: #282828;
-    pointer-events: all;
-}
-
-.histogramboxprimitives-placer {
-    position: absolute;
-    pointer-events: none;
-    width: 100%;
-    height: 100%;
-}
-.histogramboxprimitives-svgContainer {
-    position: absolute;
-    top:0;
-    left:0;
-    width:100%;
-    height: 100%;
-}
-.histogramboxprimitives-line {
-    position: absolute;
-    background: darkGray;
-    stroke: darkGray;
-    stroke-width: 1px;
-    width:100%;
-    height:100%;
-    opacity: 0.4;
-}
\ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
deleted file mode 100644
index 66d91cc1d..000000000
--- a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import React = require("react");
-import { computed, observable, reaction, runInAction, trace, action } from "mobx";
-import { observer } from "mobx-react";
-import { Utils as DashUtils, emptyFunction } from '../../../Utils';
-import { FilterModel } from "../../northstar/core/filter/FilterModel";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { ArrayUtil } from "../../northstar/utils/ArrayUtil";
-import { LABColor } from '../../northstar/utils/LABColor';
-import { PIXIRectangle } from "../../northstar/utils/MathUtil";
-import { StyleConstants } from "../../northstar/utils/StyleContants";
-import { HistogramBinPrimitiveCollection, HistogramBinPrimitive } from "./HistogramBinPrimitiveCollection";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramBoxPrimitives.scss";
-
-export interface HistogramPrimitivesProps {
-    HistoBox: HistogramBox;
-}
-@observer
-export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesProps> {
-    private get histoOp() { return this.props.HistoBox.HistoOp; }
-    private get renderDimension() { return this.props.HistoBox.SizeConverter.RenderDimension; }
-    @observable _selectedPrims: HistogramBinPrimitive[] = [];
-    @computed get xaxislines() { return this.renderGridLinesAndLabels(0); }
-    @computed get yaxislines() { return this.renderGridLinesAndLabels(1); }
-    @computed get selectedPrimitives() { return this._selectedPrims.map(bp => this.drawRect(bp.Rect, bp.BarAxis, undefined, "border")); }
-    @computed get barPrimitives() {
-        let histoResult = this.props.HistoBox.HistogramResult;
-        if (!histoResult || !histoResult.bins || !this.props.HistoBox.VisualBinRanges.length) {
-            return (null);
-        }
-        let allBrushIndex = ModelHelpers.AllBrushIndex(histoResult);
-        return Object.keys(histoResult.bins).reduce((prims: JSX.Element[], key: string) => {
-            let drawPrims = new HistogramBinPrimitiveCollection(histoResult.bins![key], this.props.HistoBox);
-            let toggle = this.getSelectionToggle(drawPrims.BinPrimitives, allBrushIndex,
-                ModelHelpers.GetBinFilterModel(histoResult.bins![key], allBrushIndex, histoResult, this.histoOp.X, this.histoOp.Y));
-            drawPrims.BinPrimitives.filter(bp => bp.DataValue && bp.BrushIndex !== allBrushIndex).map(bp =>
-                prims.push(...[{ r: bp.Rect, c: bp.Color }, { r: bp.MarginRect, c: StyleConstants.MARGIN_BARS_COLOR }].map(pair => this.drawRect(pair.r, bp.BarAxis, pair.c, "bar", toggle))));
-            return prims;
-        }, [] as JSX.Element[]);
-    }
-
-    componentDidMount() {
-        reaction(() => this.props.HistoBox.HistoOp.FilterString, () => this._selectedPrims.length = this.histoOp.FilterModels.length = 0);
-    }
-
-    private getSelectionToggle(binPrimitives: HistogramBinPrimitive[], allBrushIndex: number, filterModel: FilterModel) {
-        let rawAllBrushPrim = ArrayUtil.FirstOrDefault(binPrimitives, bp => bp.BrushIndex === allBrushIndex);
-        if (!rawAllBrushPrim) {
-            return emptyFunction;
-        }
-        let allBrushPrim = rawAllBrushPrim;
-        return () => runInAction(() => {
-            if (ArrayUtil.Contains(this.histoOp.FilterModels, filterModel)) {
-                this._selectedPrims.splice(this._selectedPrims.indexOf(allBrushPrim), 1);
-                this.histoOp.RemoveFilterModels([filterModel]);
-            }
-            else {
-                this._selectedPrims.push(allBrushPrim);
-                this.histoOp.AddFilterModels([filterModel]);
-            }
-        });
-    }
-
-    private renderGridLinesAndLabels(axis: number) {
-        if (!this.props.HistoBox.SizeConverter.Initialized) {
-            return (null);
-        }
-        let labels = this.props.HistoBox.VisualBinRanges[axis].GetLabels();
-        return <svg className="histogramboxprimitives-svgContainer">
-            {labels.reduce((prims, binLabel, i) => {
-                let r = this.props.HistoBox.SizeConverter.DataToScreenRange(binLabel.minValue!, binLabel.maxValue!, axis);
-                prims.push(this.drawLine(r.xFrom, r.yFrom, axis === 0 ? 0 : r.xTo - r.xFrom, axis === 0 ? r.yTo - r.yFrom : 0));
-                if (i === labels.length - 1) {
-                    prims.push(this.drawLine(axis === 0 ? r.xTo : r.xFrom, axis === 0 ? r.yFrom : r.yTo, axis === 0 ? 0 : r.xTo - r.xFrom, axis === 0 ? r.yTo - r.yFrom : 0));
-                }
-                return prims;
-            }, [] as JSX.Element[])}
-        </svg>;
-    }
-
-    drawLine(xFrom: number, yFrom: number, width: number, height: number) {
-        if (height < 0) {
-            yFrom += height;
-            height = -height;
-        }
-        if (width < 0) {
-            xFrom += width;
-            width = -width;
-        }
-        let trans2Xpercent = `${(xFrom + width) / this.renderDimension * 100}%`;
-        let trans2Ypercent = `${(yFrom + height) / this.renderDimension * 100}%`;
-        let trans1Xpercent = `${xFrom / this.renderDimension * 100}%`;
-        let trans1Ypercent = `${yFrom / this.renderDimension * 100}%`;
-        return <line className="histogramboxprimitives-line" key={DashUtils.GenerateGuid()} x1={trans1Xpercent} x2={`${trans2Xpercent}`} y1={trans1Ypercent} y2={`${trans2Ypercent}`} />;
-    }
-    drawRect(r: PIXIRectangle, barAxis: number, color: number | undefined, classExt: string, tapHandler: () => void = emptyFunction) {
-        if (r.height < 0) {
-            r.y += r.height;
-            r.height = -r.height;
-        }
-        if (r.width < 0) {
-            r.x += r.width;
-            r.width = -r.width;
-        }
-        let transXpercent = `${r.x / this.renderDimension * 100}%`;
-        let transYpercent = `${r.y / this.renderDimension * 100}%`;
-        let widthXpercent = `${r.width / this.renderDimension * 100}%`;
-        let heightYpercent = `${r.height / this.renderDimension * 100}%`;
-        return (<rect className={`histogramboxprimitives-${classExt}`} key={DashUtils.GenerateGuid()} onPointerDown={(e: React.PointerEvent) => { if (e.button === 0) tapHandler(); }}
-            x={transXpercent} width={`${widthXpercent}`} y={transYpercent} height={`${heightYpercent}`} fill={color ? `${LABColor.RGBtoHexString(color)}` : "transparent"} />);
-    }
-    render() {
-        return <div className="histogramboxprimitives-container">
-            {this.xaxislines}
-            {this.yaxislines}
-            <svg className="histogramboxprimitives-svgContainer">
-                {this.barPrimitives}
-                {this.selectedPrimitives}
-            </svg>
-        </div>;
-    }
-}
diff --git a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
deleted file mode 100644
index 304d33771..000000000
--- a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
+++ /dev/null
@@ -1,13 +0,0 @@
-
-  .histogramLabelPrimitives-gridlabel {
-    position:absolute;
-    transform-origin: left top;
-    font-size: 11;
-    color:white;
-  }
-  .histogramLabelPrimitives-placer {
-    position:absolute;
-    width:100%;
-    height:100%;
-    pointer-events: none;
-  }
\ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
deleted file mode 100644
index 62aebd3c6..000000000
--- a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import React = require("react");
-import { action, computed, reaction } from "mobx";
-import { observer } from "mobx-react";
-import { Utils as DashUtils } from '../../../Utils';
-import { NominalVisualBinRange } from "../model/binRanges/NominalVisualBinRange";
-import "../utils/Extensions";
-import { StyleConstants } from "../utils/StyleContants";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramLabelPrimitives.scss";
-import { HistogramPrimitivesProps } from "./HistogramBoxPrimitives";
-
-@observer
-export class HistogramLabelPrimitives extends React.Component<HistogramPrimitivesProps> {
-    componentDidMount() {
-        reaction(() => [this.props.HistoBox.props.PanelWidth(), this.props.HistoBox.SizeConverter.LeftOffset, this.props.HistoBox.VisualBinRanges.length],
-            (fields) => HistogramLabelPrimitives.computeLabelAngle(fields[0], fields[1], this.props.HistoBox), { fireImmediately: true });
-    }
-
-    @action
-    static computeLabelAngle(panelWidth: number, leftOffset: number, histoBox: HistogramBox) {
-        const textWidth = 30;
-        if (panelWidth > 0 && histoBox.VisualBinRanges.length && histoBox.VisualBinRanges[0] instanceof NominalVisualBinRange) {
-            let space = (panelWidth - leftOffset * 2) / histoBox.VisualBinRanges[0].GetBins().length;
-            histoBox.SizeConverter.SetLabelAngle(Math.min(Math.PI / 2, Math.max(Math.PI / 6, textWidth / space * Math.PI / 2)));
-        } else if (histoBox.SizeConverter.LabelAngle) {
-            histoBox.SizeConverter.SetLabelAngle(0);
-        }
-    }
-    @computed get xaxislines() { return this.renderGridLinesAndLabels(0); }
-    @computed get yaxislines() { return this.renderGridLinesAndLabels(1); }
-
-    private renderGridLinesAndLabels(axis: number) {
-        let sc = this.props.HistoBox.SizeConverter;
-        let vb = this.props.HistoBox.VisualBinRanges;
-        if (!vb.length || !sc.Initialized) {
-            return (null);
-        }
-        let dim = (axis === 0 ? this.props.HistoBox.props.PanelWidth() : this.props.HistoBox.props.PanelHeight()) / ((axis === 0 && vb[axis] instanceof NominalVisualBinRange) ?
-            (12 + 5) : //  (<number>FontStyles.AxisLabel.fontSize + 5)));
-            sc.MaxLabelSizes[axis].coords[axis] + 5);
-
-        let labels = vb[axis].GetLabels();
-        return labels.reduce((prims, binLabel, i) => {
-            let r = sc.DataToScreenRange(binLabel.minValue!, binLabel.maxValue!, axis);
-            if (i % Math.ceil(labels.length / dim) === 0 && binLabel.label) {
-                const label = binLabel.label.Truncate(StyleConstants.MAX_CHAR_FOR_HISTOGRAM_LABELS, "...");
-                const textHeight = 14; const textWidth = 30;
-                let xStart = (axis === 0 ? r.xFrom + (r.xTo - r.xFrom) / 2.0 : r.xFrom - 10 - textWidth);
-                let yStart = (axis === 1 ? r.yFrom - textHeight / 2 : r.yFrom);
-
-                if (axis === 0 && vb[axis] instanceof NominalVisualBinRange) {
-                    let space = (r.xTo - r.xFrom) / sc.RenderDimension * this.props.HistoBox.props.PanelWidth();
-                    xStart += Math.max(textWidth / 2, (1 - textWidth / space) * textWidth / 2) - textHeight / 2;
-                }
-
-                let xPercent = axis === 1 ? `${xStart}px` : `${xStart / sc.RenderDimension * 100}%`;
-                let yPercent = axis === 0 ? `${this.props.HistoBox.props.PanelHeight() - sc.BottomOffset - textHeight}px` : `${yStart / sc.RenderDimension * 100}%`;
-
-                prims.push(
-                    <div className="histogramLabelPrimitives-placer" key={DashUtils.GenerateGuid()} style={{ transform: `translate(${xPercent}, ${yPercent})` }}>
-                        <div className="histogramLabelPrimitives-gridlabel" style={{ transform: `rotate(${axis === 0 ? sc.LabelAngle : 0}rad)` }}>
-                            {label}
-                        </div>
-                    </div>
-                );
-            }
-            return prims;
-        }, [] as JSX.Element[]);
-    }
-
-    render() {
-        let xaxislines = this.xaxislines;
-        let yaxislines = this.yaxislines;
-        return <div className="histogramLabelPrimitives-container">
-            {xaxislines}
-            {yaxislines}
-        </div>;
-    }
-
-}
\ No newline at end of file
diff --git a/src/client/northstar/manager/Gateway.ts b/src/client/northstar/manager/Gateway.ts
deleted file mode 100644
index c541cce6a..000000000
--- a/src/client/northstar/manager/Gateway.ts
+++ /dev/null
@@ -1,299 +0,0 @@
-import { Catalog, OperationReference, Result, CompileResults } from "../model/idea/idea";
-import { computed, observable, action } from "mobx";
-
-export class Gateway {
-
-    private static _instance: Gateway;
-
-    private constructor() {
-    }
-
-    public static get Instance() {
-        return this._instance || (this._instance = new this());
-    }
-
-    public async GetCatalog(): Promise<Catalog> {
-        try {
-            const json = await this.MakeGetRequest("catalog");
-            const cat = Catalog.fromJS(json);
-            return cat;
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async PostSchema(csvdata: string, schemaname: string): Promise<string> {
-        try {
-            const json = await this.MakePostJsonRequest("postSchema", { csv: csvdata, schema: schemaname });
-            // const cat = Catalog.fromJS(json);
-            // return cat;
-            return json;
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async GetSchema(pathname: string, schemaname: string): Promise<Catalog> {
-        try {
-            const json = await this.MakeGetRequest("schema", undefined, { path: pathname, schema: schemaname });
-            const cat = Catalog.fromJS(json);
-            return cat;
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async ClearCatalog(): Promise<void> {
-        try {
-            await this.MakePostJsonRequest("Datamart/ClearAllAugmentations", {});
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async TerminateServer(): Promise<void> {
-        try {
-            const url = Gateway.ConstructUrl("terminateServer");
-            const response = await fetch(url,
-                {
-                    redirect: "follow",
-                    method: "POST",
-                    credentials: "include"
-                });
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async Compile(data: any): Promise<CompileResults | undefined> {
-        const json = await this.MakePostJsonRequest("compile", data);
-        if (json !== null) {
-            const cr = CompileResults.fromJS(json);
-            return cr;
-        }
-    }
-
-    public async SubmitResult(data: any): Promise<void> {
-        try {
-            console.log(data);
-            const url = Gateway.ConstructUrl("submitProblem");
-            const response = await fetch(url,
-                {
-                    redirect: "follow",
-                    method: "POST",
-                    credentials: "include",
-                    body: JSON.stringify(data)
-                });
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async SpecifyProblem(data: any): Promise<void> {
-        try {
-            console.log(data);
-            const url = Gateway.ConstructUrl("specifyProblem");
-            const response = await fetch(url,
-                {
-                    redirect: "follow",
-                    method: "POST",
-                    credentials: "include",
-                    body: JSON.stringify(data)
-                });
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-    public async ExportToScript(solutionId: string): Promise<string> {
-        try {
-            const url = Gateway.ConstructUrl("exportsolution/script/" + solutionId);
-            const response = await fetch(url,
-                {
-                    redirect: "follow",
-                    method: "GET",
-                    credentials: "include"
-                });
-            return await response.text();
-        }
-        catch (error) {
-            throw new Error("can not reach northstar's backend");
-        }
-    }
-
-
-    public async StartOperation(data: any): Promise<OperationReference | undefined> {
-        const json = await this.MakePostJsonRequest("operation", data);
-        if (json !== null) {
-            const or = OperationReference.fromJS(json);
-            return or;
-        }
-    }
-
-    public async GetResult(data: any): Promise<Result | undefined> {
-        const json = await this.MakePostJsonRequest("result", data);
-        if (json !== null) {
-            const res = Result.fromJS(json);
-            return res;
-        }
-    }
-
-    public async PauseOperation(data: any): Promise<void> {
-        const url = Gateway.ConstructUrl("pause");
-        await fetch(url,
-            {
-                redirect: "follow",
-                method: "POST",
-                credentials: "include",
-                body: JSON.stringify(data)
-            });
-    }
-
-    public async MakeGetRequest(endpoint: string, signal?: AbortSignal, params?: any): Promise<any> {
-        let url = !params ? Gateway.ConstructUrl(endpoint) :
-            (() => {
-                let newUrl = new URL(Gateway.ConstructUrl(endpoint));
-                Object.getOwnPropertyNames(params).map(prop =>
-                    newUrl.searchParams.append(prop, params[prop]));
-                return Gateway.ConstructUrl(endpoint) + newUrl.search;
-            })();
-
-        const response = await fetch(url,
-            {
-                redirect: "follow",
-                method: "GET",
-                credentials: "include",
-                signal
-            });
-        const json = await response.json();
-        return json;
-    }
-
-    public async MakePostJsonRequest(endpoint: string, data: any, signal?: AbortSignal): Promise<any> {
-        const url = Gateway.ConstructUrl(endpoint);
-        const response = await fetch(url,
-            {
-                redirect: "follow",
-                method: "POST",
-                credentials: "include",
-                body: JSON.stringify(data),
-                signal
-            });
-        const json = await response.json();
-        return json;
-    }
-
-
-    public static ConstructUrl(appendix: string): string {
-        let base = NorthstarSettings.Instance.ServerUrl;
-        if (base.slice(-1) === "/") {
-            base = base.slice(0, -1);
-        }
-        let url = base + "/" + NorthstarSettings.Instance.ServerApiPath + "/" + appendix;
-        return url;
-    }
-}
-
-declare var ENV: any;
-
-export class NorthstarSettings {
-    private _environment: any;
-
-    @observable
-    public ServerUrl: string = document.URL;
-
-    @observable
-    public ServerApiPath?: string;
-
-    @observable
-    public SampleSize?: number;
-
-    @observable
-    public XBins?: number;
-
-    @observable
-    public YBins?: number;
-
-    @observable
-    public SplashTimeInMS?: number;
-
-    @observable
-    public ShowFpsCounter?: boolean;
-
-    @observable
-    public IsMenuFixed?: boolean;
-
-    @observable
-    public ShowShutdownButton?: boolean;
-
-    @observable
-    public IsDarpa?: boolean;
-
-    @observable
-    public IsIGT?: boolean;
-
-    @observable
-    public DegreeOfParallelism?: number;
-
-    @observable
-    public ShowWarnings?: boolean;
-
-    @computed
-    public get IsDev(): boolean {
-        return ENV.IsDev;
-    }
-
-    @computed
-    public get TestDataFolderPath(): string {
-        return this.Origin + "testdata/";
-    }
-
-    @computed
-    public get Origin(): string {
-        return window.location.origin + "/";
-    }
-
-    private static _instance: NorthstarSettings;
-
-    @action
-    public UpdateEnvironment(environment: any): void {
-        /*let serverParam = new URL(document.URL).searchParams.get("serverUrl");
-        if (serverParam) {
-            if (serverParam === "debug") {
-                this.ServerUrl = `http://${window.location.hostname}:1234`;
-            }
-            else {
-                this.ServerUrl = serverParam;
-            }
-        }
-        else {
-            this.ServerUrl = environment["SERVER_URL"] ? environment["SERVER_URL"] : document.URL;
-        }*/
-        this.ServerUrl = environment.SERVER_URL ? environment.SERVER_URL : document.URL;
-        this.ServerApiPath = environment.SERVER_API_PATH;
-        this.SampleSize = environment.SAMPLE_SIZE;
-        this.XBins = environment.X_BINS;
-        this.YBins = environment.Y_BINS;
-        this.SplashTimeInMS = environment.SPLASH_TIME_IN_MS;
-        this.ShowFpsCounter = environment.SHOW_FPS_COUNTER;
-        this.ShowShutdownButton = environment.SHOW_SHUTDOWN_BUTTON;
-        this.IsMenuFixed = environment.IS_MENU_FIXED;
-        this.IsDarpa = environment.IS_DARPA;
-        this.IsIGT = environment.IS_IGT;
-        this.DegreeOfParallelism = environment.DEGREE_OF_PARALLISM;
-    }
-
-    public static get Instance(): NorthstarSettings {
-        if (!this._instance) {
-            this._instance = new NorthstarSettings();
-        }
-        return this._instance;
-    }
-}
diff --git a/src/client/northstar/model/ModelExtensions.ts b/src/client/northstar/model/ModelExtensions.ts
deleted file mode 100644
index 29f80d2d1..000000000
--- a/src/client/northstar/model/ModelExtensions.ts
+++ /dev/null
@@ -1,48 +0,0 @@
-import { AttributeParameters, Brush, MarginAggregateParameters, SingleDimensionAggregateParameters, Solution } from '../model/idea/idea';
-import { Utils } from '../utils/Utils';
-
-import { FilterModel } from '../core/filter/FilterModel';
-
-(SingleDimensionAggregateParameters as any).prototype.Equals = function (other: Object) {
-    if (!Utils.EqualityHelper(this, other)) return false;
-    if (!Utils.EqualityHelper((this as SingleDimensionAggregateParameters).attributeParameters!,
-        (other as SingleDimensionAggregateParameters).attributeParameters!)) return false;
-    if (!((this as SingleDimensionAggregateParameters).attributeParameters! as any).Equals((other as SingleDimensionAggregateParameters).attributeParameters)) return false;
-    return true;
-};
-
-{
-    (AttributeParameters as any).prototype.Equals = function (other: AttributeParameters) {
-        return (this).constructor.name === (<any>other).constructor.name &&
-            this.rawName === other.rawName;
-    };
-}
-
-{
-    (Solution as any).prototype.Equals = function (other: Object) {
-        if (!Utils.EqualityHelper(this, other)) return false;
-        if ((this as Solution).solutionId !== (other as Solution).solutionId) return false;
-        return true;
-    };
-}
-
-{
-    (MarginAggregateParameters as any).prototype.Equals = function (other: Object) {
-        if (!Utils.EqualityHelper(this, other)) return false;
-        if (!Utils.EqualityHelper((this as SingleDimensionAggregateParameters).attributeParameters!,
-            (other as SingleDimensionAggregateParameters).attributeParameters!)) return false;
-        if (!((this as SingleDimensionAggregateParameters).attributeParameters! as any).Equals((other as SingleDimensionAggregateParameters).attributeParameters!)) return false;
-
-        if ((this as MarginAggregateParameters).aggregateFunction !== (other as MarginAggregateParameters).aggregateFunction) return false;
-        return true;
-    };
-}
-
-{
-    (Brush as any).prototype.Equals = function (other: Object) {
-        if (!Utils.EqualityHelper(this, other)) return false;
-        if ((this as Brush).brushEnum !== (other as Brush).brushEnum) return false;
-        if ((this as Brush).brushIndex !== (other as Brush).brushIndex) return false;
-        return true;
-    };
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/ModelHelpers.ts b/src/client/northstar/model/ModelHelpers.ts
deleted file mode 100644
index 88e6e72b8..000000000
--- a/src/client/northstar/model/ModelHelpers.ts
+++ /dev/null
@@ -1,220 +0,0 @@
-
-import { action } from "mobx";
-import { AggregateFunction, AggregateKey, AggregateParameters, AttributeColumnParameters, AttributeParameters, AverageAggregateParameters, Bin, BinningParameters, Brush, BrushEnum, CountAggregateParameters, DataType, EquiWidthBinningParameters, HistogramResult, MarginAggregateParameters, SingleBinBinningParameters, SingleDimensionAggregateParameters, SumAggregateParameters, AggregateBinRange, NominalBinRange, AlphabeticBinRange, Predicate, Schema, Attribute, AttributeGroup, Exception, AttributeBackendParameters, AttributeCodeParameters } from '../model/idea/idea';
-import { ValueComparison } from "../core/filter/ValueComparision";
-import { ArrayUtil } from "../utils/ArrayUtil";
-import { AttributeModel, ColumnAttributeModel, BackendAttributeModel, CodeAttributeModel } from "../core/attribute/AttributeModel";
-import { FilterModel } from "../core/filter/FilterModel";
-import { AlphabeticVisualBinRange } from "./binRanges/AlphabeticVisualBinRange";
-import { NominalVisualBinRange } from "./binRanges/NominalVisualBinRange";
-import { VisualBinRangeHelper } from "./binRanges/VisualBinRangeHelper";
-import { AttributeTransformationModel } from "../core/attribute/AttributeTransformationModel";
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-
-export class ModelHelpers {
-
-    public static CreateAggregateKey(distinctAttributeParameters: AttributeParameters | undefined, atm: AttributeTransformationModel, histogramResult: HistogramResult,
-        brushIndex: number, aggParameters?: SingleDimensionAggregateParameters): AggregateKey {
-        {
-            if (aggParameters === undefined) {
-                aggParameters = ModelHelpers.GetAggregateParameter(distinctAttributeParameters, atm);
-            }
-            else {
-                aggParameters.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
-            }
-            return new AggregateKey(
-                {
-                    aggregateParameterIndex: ModelHelpers.GetAggregateParametersIndex(histogramResult, aggParameters),
-                    brushIndex: brushIndex
-                });
-        }
-    }
-
-    public static GetAggregateParametersIndex(histogramResult: HistogramResult, aggParameters?: AggregateParameters): number {
-        return Array.from(histogramResult.aggregateParameters!).findIndex((value, i, set) => {
-            if (set[i] instanceof CountAggregateParameters && value instanceof CountAggregateParameters) return true;
-            if (set[i] instanceof MarginAggregateParameters && value instanceof MarginAggregateParameters) return true;
-            if (set[i] instanceof SumAggregateParameters && value instanceof SumAggregateParameters) return true;
-            return false;
-        });
-    }
-
-    public static GetAggregateParameter(distinctAttributeParameters: AttributeParameters | undefined, atm: AttributeTransformationModel): AggregateParameters | undefined {
-        var aggParam: AggregateParameters | undefined;
-        if (atm.AggregateFunction === AggregateFunction.Avg) {
-            var avg = new AverageAggregateParameters();
-            avg.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
-            avg.distinctAttributeParameters = distinctAttributeParameters;
-            aggParam = avg;
-        }
-        else if (atm.AggregateFunction === AggregateFunction.Count) {
-            var cnt = new CountAggregateParameters();
-            cnt.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
-            cnt.distinctAttributeParameters = distinctAttributeParameters;
-            aggParam = cnt;
-        }
-        else if (atm.AggregateFunction === AggregateFunction.Sum) {
-            var sum = new SumAggregateParameters();
-            sum.attributeParameters = ModelHelpers.GetAttributeParameters(atm.AttributeModel);
-            sum.distinctAttributeParameters = distinctAttributeParameters;
-            aggParam = sum;
-        }
-        return aggParam;
-    }
-
-    public static GetAggregateParametersWithMargins(distinctAttributeParameters: AttributeParameters | undefined, atms: Array<AttributeTransformationModel>): Array<AggregateParameters> {
-        var aggregateParameters = new Array<AggregateParameters>();
-        atms.forEach(agg => {
-            var aggParams = ModelHelpers.GetAggregateParameter(distinctAttributeParameters, agg);
-            if (aggParams) {
-                aggregateParameters.push(aggParams);
-
-                var margin = new MarginAggregateParameters();
-                margin.aggregateFunction = agg.AggregateFunction;
-                margin.attributeParameters = ModelHelpers.GetAttributeParameters(agg.AttributeModel);
-                margin.distinctAttributeParameters = distinctAttributeParameters;
-                aggregateParameters.push(margin);
-            }
-        });
-
-        return aggregateParameters;
-    }
-
-    public static GetBinningParameters(attr: AttributeTransformationModel, nrOfBins: number, minvalue?: number, maxvalue?: number): BinningParameters {
-        if (attr.AggregateFunction === AggregateFunction.None) {
-            return new EquiWidthBinningParameters(
-                {
-                    attributeParameters: ModelHelpers.GetAttributeParameters(attr.AttributeModel),
-                    requestedNrOfBins: nrOfBins,
-                    minValue: minvalue,
-                    maxValue: maxvalue
-                });
-        }
-        else {
-            return new SingleBinBinningParameters(
-                {
-                    attributeParameters: ModelHelpers.GetAttributeParameters(attr.AttributeModel)
-                });
-        }
-    }
-
-    public static GetAttributeParametersFromAttributeModel(am: AttributeModel): AttributeParameters {
-        if (am instanceof ColumnAttributeModel) {
-            return new AttributeColumnParameters(
-                {
-                    rawName: am.CodeName,
-                    visualizationHints: am.VisualizationHints
-                });
-        }
-        else if (am instanceof BackendAttributeModel) {
-            return new AttributeBackendParameters(
-                {
-                    rawName: am.CodeName,
-                    visualizationHints: am.VisualizationHints,
-                    id: (am).Id
-                });
-        }
-        else if (am instanceof CodeAttributeModel) {
-            return new AttributeCodeParameters(
-                {
-                    rawName: am.CodeName,
-                    visualizationHints: am.VisualizationHints,
-                    code: (am).Code
-                });
-        }
-        else {
-            throw new Exception();
-        }
-    }
-
-    public static GetAttributeParameters(am: AttributeModel): AttributeParameters {
-        return this.GetAttributeParametersFromAttributeModel(am);
-    }
-
-    public static OverlapBrushIndex(histogramResult: HistogramResult): number {
-        var brush = ArrayUtil.First(histogramResult.brushes!, (b: any) => b.brushEnum === BrushEnum.Overlap);
-        return ModelHelpers.GetBrushIndex(histogramResult, brush);
-    }
-
-    public static AllBrushIndex(histogramResult: HistogramResult): number {
-        var brush = ArrayUtil.First(histogramResult.brushes!, (b: any) => b.brushEnum === BrushEnum.All);
-        return ModelHelpers.GetBrushIndex(histogramResult, brush);
-    }
-
-    public static RestBrushIndex(histogramResult: HistogramResult): number {
-        var brush = ArrayUtil.First(histogramResult.brushes!, (b: Brush) => b.brushEnum === BrushEnum.Rest);
-        return ModelHelpers.GetBrushIndex(histogramResult, brush);
-    }
-
-    public static GetBrushIndex(histogramResult: HistogramResult, brush: Brush): number {
-        return ArrayUtil.IndexOfWithEqual(histogramResult.brushes!, brush);
-    }
-
-    public static GetAggregateResult(bin: Bin, aggregateKey: AggregateKey) {
-        if (aggregateKey.aggregateParameterIndex === -1 || aggregateKey.brushIndex === -1) {
-            return null;
-        }
-        return bin.aggregateResults![aggregateKey.aggregateParameterIndex! * bin.ySize! + aggregateKey.brushIndex!];
-    }
-
-    @action
-    public static PossibleAggegationFunctions(atm: AttributeTransformationModel): Array<AggregateFunction> {
-        var ret = new Array<AggregateFunction>();
-        ret.push(AggregateFunction.None);
-        ret.push(AggregateFunction.Count);
-        if (atm.AttributeModel.DataType === DataType.Float ||
-            atm.AttributeModel.DataType === DataType.Double ||
-            atm.AttributeModel.DataType === DataType.Int) {
-            ret.push(AggregateFunction.Avg);
-            ret.push(AggregateFunction.Sum);
-        }
-        return ret;
-    }
-
-    public static GetBinFilterModel(
-        bin: Bin, brushIndex: number, histogramResult: HistogramResult,
-        xAom: AttributeTransformationModel, yAom: AttributeTransformationModel): FilterModel {
-        var dimensions: Array<AttributeTransformationModel> = [xAom, yAom];
-        var filterModel = new FilterModel();
-
-        for (var i = 0; i < histogramResult.binRanges!.length; i++) {
-            if (!(histogramResult.binRanges![i] instanceof AggregateBinRange)) {
-                var binRange = VisualBinRangeHelper.GetNonAggregateVisualBinRange(histogramResult.binRanges![i]);
-                var dataFrom = binRange.GetValueFromIndex(bin.binIndex!.indices![i]);
-                var dataTo = binRange.AddStep(dataFrom);
-
-                if (binRange instanceof NominalVisualBinRange) {
-                    var tt = binRange.GetLabel(dataFrom);
-                    filterModel.ValueComparisons.push(new ValueComparison(dimensions[i].AttributeModel, Predicate.EQUALS, tt));
-                }
-                else if (binRange instanceof AlphabeticVisualBinRange) {
-                    filterModel.ValueComparisons.push(new ValueComparison(dimensions[i].AttributeModel, Predicate.STARTS_WITH,
-                        binRange.GetLabel(dataFrom)));
-                }
-                else {
-                    filterModel.ValueComparisons.push(new ValueComparison(dimensions[i].AttributeModel, Predicate.GREATER_THAN_EQUAL, dataFrom));
-                    filterModel.ValueComparisons.push(new ValueComparison(dimensions[i].AttributeModel, Predicate.LESS_THAN, dataTo));
-                }
-            }
-        }
-
-        return filterModel;
-    }
-
-    public GetAllAttributes(schema: Schema) {
-        if (!schema || !schema.rootAttributeGroup) {
-            return [];
-        }
-        const recurs = (attrs: Attribute[], g: AttributeGroup) => {
-            if (g.attributes) {
-                attrs.push.apply(attrs, g.attributes);
-                if (g.attributeGroups) {
-                    g.attributeGroups.forEach(ng => recurs(attrs, ng));
-                }
-            }
-        };
-        const allAttributes: Attribute[] = new Array<Attribute>();
-        recurs(allAttributes, schema.rootAttributeGroup);
-        return allAttributes;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts b/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
deleted file mode 100644
index 120b034f2..000000000
--- a/src/client/northstar/model/binRanges/AlphabeticVisualBinRange.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { AlphabeticBinRange, BinLabel } from '../../model/idea/idea';
-import { VisualBinRange } from './VisualBinRange';
-
-export class AlphabeticVisualBinRange extends VisualBinRange {
-    public DataBinRange: AlphabeticBinRange;
-
-    constructor(dataBinRange: AlphabeticBinRange) {
-        super();
-        this.DataBinRange = dataBinRange;
-    }
-
-    public AddStep(value: number): number {
-        return value + 1;
-    }
-
-    public GetValueFromIndex(index: number): number {
-        return index;
-    }
-
-    public GetBins(): number[] {
-        var bins = new Array<number>();
-        var idx = 0;
-        for (var key in this.DataBinRange.labelsValue) {
-            if (this.DataBinRange.labelsValue.hasOwnProperty(key)) {
-                bins.push(idx);
-                idx++;
-            }
-        }
-        return bins;
-    }
-
-    public GetLabel(value: number): string {
-        return this.DataBinRange.prefix + this.DataBinRange.valuesLabel![value];
-    }
-
-    public GetLabels(): Array<BinLabel> {
-        var labels = new Array<BinLabel>();
-        var count = 0;
-        for (var key in this.DataBinRange.valuesLabel) {
-            if (this.DataBinRange.valuesLabel.hasOwnProperty(key)) {
-                var value = this.DataBinRange.valuesLabel[key];
-                labels.push(new BinLabel({
-                    value: parseFloat(key),
-                    minValue: count++,
-                    maxValue: count,
-                    label: this.DataBinRange.prefix + value
-                }));
-            }
-        }
-        return labels;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/DateTimeVisualBinRange.ts b/src/client/northstar/model/binRanges/DateTimeVisualBinRange.ts
deleted file mode 100644
index 776e643cd..000000000
--- a/src/client/northstar/model/binRanges/DateTimeVisualBinRange.ts
+++ /dev/null
@@ -1,105 +0,0 @@
-import { DateTimeBinRange, DateTimeStep, DateTimeStepGranularity } from '../idea/idea';
-import { VisualBinRange } from './VisualBinRange';
-
-export class DateTimeVisualBinRange extends VisualBinRange {
-    public DataBinRange: DateTimeBinRange;
-
-    constructor(dataBinRange: DateTimeBinRange) {
-        super();
-        this.DataBinRange = dataBinRange;
-    }
-
-    public AddStep(value: number): number {
-        return DateTimeVisualBinRange.AddToDateTimeTicks(value, this.DataBinRange.step!);
-    }
-
-    public GetValueFromIndex(index: number): number {
-        var v = this.DataBinRange.minValue!;
-        for (var i = 0; i < index; i++) {
-            v = this.AddStep(v);
-        }
-        return v;
-    }
-
-    public GetBins(): number[] {
-        var bins = new Array<number>();
-        for (var v: number = this.DataBinRange.minValue!;
-            v < this.DataBinRange.maxValue!;
-            v = DateTimeVisualBinRange.AddToDateTimeTicks(v, this.DataBinRange.step!)) {
-            bins.push(v);
-        }
-        return bins;
-    }
-
-    private pad(n: number, size: number) {
-        var sign = n < 0 ? '-' : '';
-        return sign + new Array(size).concat([Math.abs(n)]).join('0').slice(-size);
-    }
-
-
-    public GetLabel(value: number): string {
-        var dt = DateTimeVisualBinRange.TicksToDate(value);
-        if (this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Second ||
-            this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Minute) {
-            return ("" + this.pad(dt.getMinutes(), 2) + ":" + this.pad(dt.getSeconds(), 2));
-            //return dt.ToString("mm:ss");
-        }
-        else if (this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Hour) {
-            return (this.pad(dt.getHours(), 2) + ":" + this.pad(dt.getMinutes(), 2));
-            //return dt.ToString("HH:mm");
-        }
-        else if (this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Day) {
-            return ((dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear());
-            //return dt.ToString("MM/dd/yyyy");
-        }
-        else if (this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Month) {
-            //return dt.ToString("MM/yyyy");
-            return ((dt.getMonth() + 1) + "/" + dt.getFullYear());
-        }
-        else if (this.DataBinRange.step!.dateTimeStepGranularity === DateTimeStepGranularity.Year) {
-            return "" + dt.getFullYear();
-        }
-        return "n/a";
-    }
-
-    public static TicksToDate(ticks: number): Date {
-        var dd = new Date((ticks - 621355968000000000) / 10000);
-        dd.setMinutes(dd.getMinutes() + dd.getTimezoneOffset());
-        return dd;
-    }
-
-
-    public static DateToTicks(date: Date): number {
-        var copiedDate = new Date(date.getTime());
-        copiedDate.setMinutes(copiedDate.getMinutes() - copiedDate.getTimezoneOffset());
-        var t = copiedDate.getTime() * 10000 + 621355968000000000;
-        /*var dd = new Date((ticks - 621355968000000000) / 10000);
-        dd.setMinutes(dd.getMinutes() + dd.getTimezoneOffset());
-        return dd;*/
-        return t;
-    }
-
-    public static AddToDateTimeTicks(ticks: number, dateTimeStep: DateTimeStep): number {
-        var copiedDate = DateTimeVisualBinRange.TicksToDate(ticks);
-        var returnDate: Date = new Date(Date.now());
-        if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Second) {
-            returnDate = new Date(copiedDate.setSeconds(copiedDate.getSeconds() + dateTimeStep.dateTimeStepValue!));
-        }
-        else if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Minute) {
-            returnDate = new Date(copiedDate.setMinutes(copiedDate.getMinutes() + dateTimeStep.dateTimeStepValue!));
-        }
-        else if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Hour) {
-            returnDate = new Date(copiedDate.setHours(copiedDate.getHours() + dateTimeStep.dateTimeStepValue!));
-        }
-        else if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Day) {
-            returnDate = new Date(copiedDate.setDate(copiedDate.getDate() + dateTimeStep.dateTimeStepValue!));
-        }
-        else if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Month) {
-            returnDate = new Date(copiedDate.setMonth(copiedDate.getMonth() + dateTimeStep.dateTimeStepValue!));
-        }
-        else if (dateTimeStep.dateTimeStepGranularity === DateTimeStepGranularity.Year) {
-            returnDate = new Date(copiedDate.setFullYear(copiedDate.getFullYear() + dateTimeStep.dateTimeStepValue!));
-        }
-        return DateTimeVisualBinRange.DateToTicks(returnDate);
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/NominalVisualBinRange.ts b/src/client/northstar/model/binRanges/NominalVisualBinRange.ts
deleted file mode 100644
index 42509d797..000000000
--- a/src/client/northstar/model/binRanges/NominalVisualBinRange.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { NominalBinRange, BinLabel } from '../../model/idea/idea';
-import { VisualBinRange } from './VisualBinRange';
-
-export class NominalVisualBinRange extends VisualBinRange {
-    public DataBinRange: NominalBinRange;
-
-    constructor(dataBinRange: NominalBinRange) {
-        super();
-        this.DataBinRange = dataBinRange;
-    }
-
-    public AddStep(value: number): number {
-        return value + 1;
-    }
-
-    public GetValueFromIndex(index: number): number {
-        return index;
-    }
-
-    public GetBins(): number[] {
-        var bins = new Array<number>();
-        var idx = 0;
-        for (var key in this.DataBinRange.labelsValue) {
-            if (this.DataBinRange.labelsValue.hasOwnProperty(key)) {
-                bins.push(idx);
-                idx++;
-            }
-        }
-        return bins;
-    }
-
-    public GetLabel(value: number): string {
-        return this.DataBinRange.valuesLabel![value];
-    }
-
-    public GetLabels(): Array<BinLabel> {
-        var labels = new Array<BinLabel>();
-        var count = 0;
-        for (var key in this.DataBinRange.valuesLabel) {
-            if (this.DataBinRange.valuesLabel.hasOwnProperty(key)) {
-                var value = this.DataBinRange.valuesLabel[key];
-                labels.push(new BinLabel({
-                    value: parseFloat(key),
-                    minValue: count++,
-                    maxValue: count,
-                    label: value
-                }));
-            }
-        }
-        return labels;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/QuantitativeVisualBinRange.ts b/src/client/northstar/model/binRanges/QuantitativeVisualBinRange.ts
deleted file mode 100644
index 7bc097e1d..000000000
--- a/src/client/northstar/model/binRanges/QuantitativeVisualBinRange.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { QuantitativeBinRange } from '../idea/idea';
-import { VisualBinRange } from './VisualBinRange';
-import { format } from "d3-format";
-
-export class QuantitativeVisualBinRange extends VisualBinRange {
-
-    public DataBinRange: QuantitativeBinRange;
-
-    constructor(dataBinRange: QuantitativeBinRange) {
-        super();
-        this.DataBinRange = dataBinRange;
-    }
-
-    public AddStep(value: number): number {
-        return value + this.DataBinRange.step!;
-    }
-
-    public GetValueFromIndex(index: number): number {
-        return this.DataBinRange.minValue! + (index * this.DataBinRange.step!);
-    }
-
-    public GetLabel(value: number): string {
-        return QuantitativeVisualBinRange.NumberFormatter(value);
-    }
-
-    public static NumberFormatter(val: number): string {
-        if (val === 0) {
-            return "0";
-        }
-        if (val < 1) {
-            /*if (val < Math.abs(0.001))  {
-                return val.toExponential(2);
-            }*/
-            return format(".3")(val);
-        }
-        return format("~s")(val);
-    }
-
-    public GetBins(): number[] {
-        const bins = new Array<number>();
-
-        for (let v: number = this.DataBinRange.minValue!; v < this.DataBinRange.maxValue!; v += this.DataBinRange.step!) {
-            bins.push(v);
-        }
-        return bins;
-    }
-
-    public static Initialize(dataMinValue: number, dataMaxValue: number, targetBinNumber: number, isIntegerRange: boolean): QuantitativeVisualBinRange {
-        const extent = QuantitativeVisualBinRange.getExtent(dataMinValue, dataMaxValue, targetBinNumber, isIntegerRange);
-        const dataBinRange = new QuantitativeBinRange();
-        dataBinRange.minValue = extent[0];
-        dataBinRange.maxValue = extent[1];
-        dataBinRange.step = extent[2];
-
-        return new QuantitativeVisualBinRange(dataBinRange);
-    }
-
-    private static getExtent(dataMin: number, dataMax: number, m: number, isIntegerRange: boolean): number[] {
-        if (dataMin === dataMax) {
-            // dataMin -= 0.1;
-            dataMax += 0.1;
-        }
-        const span = dataMax - dataMin;
-
-        let step = Math.pow(10, Math.floor(Math.log10(span / m)));
-        const err = m / span * step;
-
-        if (err <= .15) {
-            step *= 10;
-        }
-        else if (err <= .35) {
-            step *= 5;
-        }
-        else if (err <= .75) {
-            step *= 2;
-        }
-
-        if (isIntegerRange) {
-            step = Math.ceil(step);
-        }
-        const ret: number[] = new Array<number>(3);
-        const minDivStep = Math.floor(dataMin / step);
-        const maxDivStep = Math.floor(dataMax / step);
-        ret[0] = minDivStep * step; // Math.floor(Math.Round(dataMin, 8)/step)*step;
-        ret[1] = maxDivStep * step + step; // Math.floor(Math.Round(dataMax, 8)/step)*step + step;
-        ret[2] = step;
-
-        return ret;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/VisualBinRange.ts b/src/client/northstar/model/binRanges/VisualBinRange.ts
deleted file mode 100644
index 449a22e91..000000000
--- a/src/client/northstar/model/binRanges/VisualBinRange.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { BinLabel } from '../../model/idea/idea';
-
-export abstract class VisualBinRange {
-
-    public abstract AddStep(value: number): number;
-
-    public abstract GetValueFromIndex(index: number): number;
-
-    public abstract GetBins(): Array<number>;
-
-    public GetLabel(value: number): string {
-        return value.toString();
-    }
-
-    public GetLabels(): Array<BinLabel> {
-        var labels = new Array<BinLabel>();
-        var bins = this.GetBins();
-        bins.forEach(b => {
-            labels.push(new BinLabel({
-                value: b,
-                minValue: b,
-                maxValue: this.AddStep(b),
-                label: this.GetLabel(b)
-            }));
-        });
-        return labels;
-    }
-}
-
-export enum ChartType {
-    HorizontalBar = 0, VerticalBar = 1, HeatMap = 2, SinglePoint = 3
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts b/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
deleted file mode 100644
index a92412686..000000000
--- a/src/client/northstar/model/binRanges/VisualBinRangeHelper.ts
+++ /dev/null
@@ -1,70 +0,0 @@
-import { BinRange, NominalBinRange, QuantitativeBinRange, Exception, AlphabeticBinRange, DateTimeBinRange, AggregateBinRange, DoubleValueAggregateResult, HistogramResult, AttributeParameters } from "../idea/idea";
-import { VisualBinRange, ChartType } from "./VisualBinRange";
-import { NominalVisualBinRange } from "./NominalVisualBinRange";
-import { QuantitativeVisualBinRange } from "./QuantitativeVisualBinRange";
-import { AlphabeticVisualBinRange } from "./AlphabeticVisualBinRange";
-import { DateTimeVisualBinRange } from "./DateTimeVisualBinRange";
-import { NorthstarSettings } from "../../manager/Gateway";
-import { ModelHelpers } from "../ModelHelpers";
-import { AttributeTransformationModel } from "../../core/attribute/AttributeTransformationModel";
-
-export const SETTINGS_X_BINS = 15;
-export const SETTINGS_Y_BINS = 15;
-export const SETTINGS_SAMPLE_SIZE = 100000;
-
-export class VisualBinRangeHelper {
-
-    public static GetNonAggregateVisualBinRange(dataBinRange: BinRange): VisualBinRange {
-        if (dataBinRange instanceof NominalBinRange) {
-            return new NominalVisualBinRange(dataBinRange);
-        }
-        else if (dataBinRange instanceof QuantitativeBinRange) {
-            return new QuantitativeVisualBinRange(dataBinRange);
-        }
-        else if (dataBinRange instanceof AlphabeticBinRange) {
-            return new AlphabeticVisualBinRange(dataBinRange);
-        }
-        else if (dataBinRange instanceof DateTimeBinRange) {
-            return new DateTimeVisualBinRange(dataBinRange);
-        }
-        throw new Exception();
-    }
-
-    public static GetVisualBinRange(distinctAttributeParameters: AttributeParameters | undefined, dataBinRange: BinRange, histoResult: HistogramResult, attr: AttributeTransformationModel, chartType: ChartType): VisualBinRange {
-
-        if (!(dataBinRange instanceof AggregateBinRange)) {
-            return VisualBinRangeHelper.GetNonAggregateVisualBinRange(dataBinRange);
-        }
-        else {
-            var aggregateKey = ModelHelpers.CreateAggregateKey(distinctAttributeParameters, attr, histoResult, ModelHelpers.AllBrushIndex(histoResult));
-            var minValue = Number.MAX_VALUE;
-            var maxValue = Number.MIN_VALUE;
-            for (const brush of histoResult.brushes!) {
-                aggregateKey.brushIndex = brush.brushIndex;
-                for (var key in histoResult.bins) {
-                    if (histoResult.bins.hasOwnProperty(key)) {
-                        var bin = histoResult.bins[key];
-                        var res = <DoubleValueAggregateResult>ModelHelpers.GetAggregateResult(bin, aggregateKey);
-                        if (res && res.hasResult && res.result) {
-                            minValue = Math.min(minValue, res.result);
-                            maxValue = Math.max(maxValue, res.result);
-                        }
-                    }
-                }
-            }
-
-            let visualBinRange = QuantitativeVisualBinRange.Initialize(minValue, maxValue, 10, false);
-
-            if (chartType === ChartType.HorizontalBar || chartType === ChartType.VerticalBar) {
-                visualBinRange = QuantitativeVisualBinRange.Initialize(Math.min(0, minValue),
-                    Math.max(0, (visualBinRange).DataBinRange.maxValue!),
-                    SETTINGS_X_BINS, false);
-            }
-            else if (chartType === ChartType.SinglePoint) {
-                visualBinRange = QuantitativeVisualBinRange.Initialize(Math.min(0, minValue), Math.max(0, maxValue),
-                    SETTINGS_X_BINS, false);
-            }
-            return visualBinRange;
-        }
-    }
-}
diff --git a/src/client/northstar/model/idea/MetricTypeMapping.ts b/src/client/northstar/model/idea/MetricTypeMapping.ts
deleted file mode 100644
index e9759cf16..000000000
--- a/src/client/northstar/model/idea/MetricTypeMapping.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import { MetricType } from "./Idea";
-import { Dictionary } from 'typescript-collections';
-
-
-export class MetricTypeMapping {
-
-    public static GetMetricInterpretation(metricType: MetricType): MetricInterpretation {
-        if (metricType === MetricType.Accuracy ||
-            metricType === MetricType.F1 ||
-            metricType === MetricType.F1Macro ||
-            metricType === MetricType.F1Micro ||
-            metricType === MetricType.JaccardSimilarityScore ||
-            metricType === MetricType.ObjectDetectionAveragePrecision ||
-            metricType === MetricType.Precision ||
-            metricType === MetricType.PrecisionAtTopK ||
-            metricType === MetricType.NormalizedMutualInformation ||
-            metricType === MetricType.Recall ||
-            metricType === MetricType.RocAucMacro ||
-            metricType === MetricType.RocAuc ||
-            metricType === MetricType.RocAucMicro ||
-            metricType === MetricType.RSquared) {
-            return MetricInterpretation.HigherIsBetter;
-        }
-        return MetricInterpretation.LowerIsBetter;
-    }
-}
-
-export enum MetricInterpretation {
-    HigherIsBetter, LowerIsBetter
-}
\ No newline at end of file
diff --git a/src/client/northstar/model/idea/idea.ts b/src/client/northstar/model/idea/idea.ts
deleted file mode 100644
index c73a822c7..000000000
--- a/src/client/northstar/model/idea/idea.ts
+++ /dev/null
@@ -1,8557 +0,0 @@
-/* tslint:disable */
-//----------------------
-// <auto-generated>
-//     Generated using the NSwag toolchain v11.19.2.0 (NJsonSchema v9.10.73.0 (Newtonsoft.Json v9.0.0.0)) (http://NSwag.org)
-// </auto-generated>
-//----------------------
-// ReSharper disable InconsistentNaming
-
-
-
-export enum AggregateFunction {
-    None = "None",
-    Sum = "Sum",
-    SumE = "SumE",
-    Count = "Count",
-    Min = "Min",
-    Max = "Max",
-    Avg = "Avg",
-}
-
-export abstract class AggregateParameters implements IAggregateParameters {
-
-    protected _discriminator: string;
-
-    public Equals(other: Object): boolean {
-        return this == other;
-    }
-    constructor(data?: IAggregateParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "AggregateParameters";
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): AggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "AverageAggregateParameters") {
-            let result = new AverageAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SingleDimensionAggregateParameters") {
-            throw new Error("The abstract class 'SingleDimensionAggregateParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "CountAggregateParameters") {
-            let result = new CountAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KDEAggregateParameters") {
-            let result = new KDEAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MarginAggregateParameters") {
-            let result = new MarginAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MaxAggregateParameters") {
-            let result = new MaxAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MinAggregateParameters") {
-            let result = new MinAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SumAggregateParameters") {
-            let result = new SumAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SumEstimationAggregateParameters") {
-            let result = new SumEstimationAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'AggregateParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        return data;
-    }
-}
-
-export interface IAggregateParameters {
-}
-
-export abstract class SingleDimensionAggregateParameters extends AggregateParameters implements ISingleDimensionAggregateParameters {
-    attributeParameters?: AttributeParameters | undefined;
-    distinctAttributeParameters?: AttributeParameters | undefined;
-
-    constructor(data?: ISingleDimensionAggregateParameters) {
-        super(data);
-        this._discriminator = "SingleDimensionAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.attributeParameters = data["AttributeParameters"] ? AttributeParameters.fromJS(data["AttributeParameters"]) : <any>undefined;
-            this.distinctAttributeParameters = data["DistinctAttributeParameters"] ? AttributeParameters.fromJS(data["DistinctAttributeParameters"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): SingleDimensionAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "AverageAggregateParameters") {
-            let result = new AverageAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CountAggregateParameters") {
-            let result = new CountAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KDEAggregateParameters") {
-            let result = new KDEAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MarginAggregateParameters") {
-            let result = new MarginAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MaxAggregateParameters") {
-            let result = new MaxAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "MinAggregateParameters") {
-            let result = new MinAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SumAggregateParameters") {
-            let result = new SumAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SumEstimationAggregateParameters") {
-            let result = new SumEstimationAggregateParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'SingleDimensionAggregateParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AttributeParameters"] = this.attributeParameters ? this.attributeParameters.toJSON() : <any>undefined;
-        data["DistinctAttributeParameters"] = this.distinctAttributeParameters ? this.distinctAttributeParameters.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISingleDimensionAggregateParameters extends IAggregateParameters {
-    attributeParameters?: AttributeParameters | undefined;
-    distinctAttributeParameters?: AttributeParameters | undefined;
-}
-
-export class AverageAggregateParameters extends SingleDimensionAggregateParameters implements IAverageAggregateParameters {
-
-    constructor(data?: IAverageAggregateParameters) {
-        super(data);
-        this._discriminator = "AverageAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): AverageAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new AverageAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAverageAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export abstract class AttributeParameters implements IAttributeParameters {
-    visualizationHints?: VisualizationHint[] | undefined;
-    rawName?: string | undefined;
-    public Equals(other: Object): boolean {
-        return this == other;
-    }
-
-    protected _discriminator: string;
-
-    constructor(data?: IAttributeParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "AttributeParameters";
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["VisualizationHints"] && data["VisualizationHints"].constructor === Array) {
-                this.visualizationHints = [];
-                for (let item of data["VisualizationHints"])
-                    this.visualizationHints.push(item);
-            }
-            this.rawName = data["RawName"];
-        }
-    }
-
-    static fromJS(data: any): AttributeParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "AttributeBackendParameters") {
-            let result = new AttributeBackendParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AttributeCaclculatedParameters") {
-            throw new Error("The abstract class 'AttributeCaclculatedParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "AttributeCodeParameters") {
-            let result = new AttributeCodeParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AttributeColumnParameters") {
-            let result = new AttributeColumnParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'AttributeParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        if (this.visualizationHints && this.visualizationHints.constructor === Array) {
-            data["VisualizationHints"] = [];
-            for (let item of this.visualizationHints)
-                data["VisualizationHints"].push(item);
-        }
-        data["RawName"] = this.rawName;
-        return data;
-    }
-}
-
-export interface IAttributeParameters {
-    visualizationHints?: VisualizationHint[] | undefined;
-    rawName?: string | undefined;
-}
-
-export enum VisualizationHint {
-    TreatAsEnumeration = "TreatAsEnumeration",
-    DefaultFlipAxis = "DefaultFlipAxis",
-    Image = "Image",
-}
-
-export abstract class AttributeCaclculatedParameters extends AttributeParameters implements IAttributeCaclculatedParameters {
-
-    constructor(data?: IAttributeCaclculatedParameters) {
-        super(data);
-        this._discriminator = "AttributeCaclculatedParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): AttributeCaclculatedParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "AttributeBackendParameters") {
-            let result = new AttributeBackendParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AttributeCodeParameters") {
-            let result = new AttributeCodeParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'AttributeCaclculatedParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAttributeCaclculatedParameters extends IAttributeParameters {
-}
-
-export class AttributeBackendParameters extends AttributeCaclculatedParameters implements IAttributeBackendParameters {
-    id?: string | undefined;
-
-    constructor(data?: IAttributeBackendParameters) {
-        super(data);
-        this._discriminator = "AttributeBackendParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.id = data["Id"];
-        }
-    }
-
-    static fromJS(data: any): AttributeBackendParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new AttributeBackendParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAttributeBackendParameters extends IAttributeCaclculatedParameters {
-    id?: string | undefined;
-}
-
-export class AttributeCodeParameters extends AttributeCaclculatedParameters implements IAttributeCodeParameters {
-    code?: string | undefined;
-
-    constructor(data?: IAttributeCodeParameters) {
-        super(data);
-        this._discriminator = "AttributeCodeParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.code = data["Code"];
-        }
-    }
-
-    static fromJS(data: any): AttributeCodeParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new AttributeCodeParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Code"] = this.code;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAttributeCodeParameters extends IAttributeCaclculatedParameters {
-    code?: string | undefined;
-}
-
-export class AttributeColumnParameters extends AttributeParameters implements IAttributeColumnParameters {
-
-    constructor(data?: IAttributeColumnParameters) {
-        super(data);
-        this._discriminator = "AttributeColumnParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): AttributeColumnParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new AttributeColumnParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAttributeColumnParameters extends IAttributeParameters {
-}
-
-export class CountAggregateParameters extends SingleDimensionAggregateParameters implements ICountAggregateParameters {
-
-    constructor(data?: ICountAggregateParameters) {
-        super(data);
-        this._discriminator = "CountAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): CountAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new CountAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICountAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export class KDEAggregateParameters extends SingleDimensionAggregateParameters implements IKDEAggregateParameters {
-    nrOfSamples?: number | undefined;
-
-    constructor(data?: IKDEAggregateParameters) {
-        super(data);
-        this._discriminator = "KDEAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.nrOfSamples = data["NrOfSamples"];
-        }
-    }
-
-    static fromJS(data: any): KDEAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new KDEAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["NrOfSamples"] = this.nrOfSamples;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IKDEAggregateParameters extends ISingleDimensionAggregateParameters {
-    nrOfSamples?: number | undefined;
-}
-
-export class MarginAggregateParameters extends SingleDimensionAggregateParameters implements IMarginAggregateParameters {
-    aggregateFunction?: AggregateFunction | undefined;
-
-    constructor(data?: IMarginAggregateParameters) {
-        super(data);
-        this._discriminator = "MarginAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.aggregateFunction = data["AggregateFunction"];
-        }
-    }
-
-    static fromJS(data: any): MarginAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new MarginAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AggregateFunction"] = this.aggregateFunction;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IMarginAggregateParameters extends ISingleDimensionAggregateParameters {
-    aggregateFunction?: AggregateFunction | undefined;
-}
-
-export class MaxAggregateParameters extends SingleDimensionAggregateParameters implements IMaxAggregateParameters {
-
-    constructor(data?: IMaxAggregateParameters) {
-        super(data);
-        this._discriminator = "MaxAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): MaxAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new MaxAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IMaxAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export class MinAggregateParameters extends SingleDimensionAggregateParameters implements IMinAggregateParameters {
-
-    constructor(data?: IMinAggregateParameters) {
-        super(data);
-        this._discriminator = "MinAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): MinAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new MinAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IMinAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export class SumAggregateParameters extends SingleDimensionAggregateParameters implements ISumAggregateParameters {
-
-    constructor(data?: ISumAggregateParameters) {
-        super(data);
-        this._discriminator = "SumAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): SumAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SumAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISumAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export class SumEstimationAggregateParameters extends SingleDimensionAggregateParameters implements ISumEstimationAggregateParameters {
-
-    constructor(data?: ISumEstimationAggregateParameters) {
-        super(data);
-        this._discriminator = "SumEstimationAggregateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): SumEstimationAggregateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SumEstimationAggregateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISumEstimationAggregateParameters extends ISingleDimensionAggregateParameters {
-}
-
-export enum OrderingFunction {
-    None = 0,
-    SortUp = 1,
-    SortDown = 2,
-}
-
-export abstract class BinningParameters implements IBinningParameters {
-    attributeParameters?: AttributeParameters | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IBinningParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "BinningParameters";
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.attributeParameters = data["AttributeParameters"] ? AttributeParameters.fromJS(data["AttributeParameters"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): BinningParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "EquiWidthBinningParameters") {
-            let result = new EquiWidthBinningParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SingleBinBinningParameters") {
-            let result = new SingleBinBinningParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'BinningParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["AttributeParameters"] = this.attributeParameters ? this.attributeParameters.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface IBinningParameters {
-    attributeParameters?: AttributeParameters | undefined;
-}
-
-export class EquiWidthBinningParameters extends BinningParameters implements IEquiWidthBinningParameters {
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    requestedNrOfBins?: number | undefined;
-    referenceValue?: number | undefined;
-    step?: number | undefined;
-
-    constructor(data?: IEquiWidthBinningParameters) {
-        super(data);
-        this._discriminator = "EquiWidthBinningParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.minValue = data["MinValue"];
-            this.maxValue = data["MaxValue"];
-            this.requestedNrOfBins = data["RequestedNrOfBins"];
-            this.referenceValue = data["ReferenceValue"];
-            this.step = data["Step"];
-        }
-    }
-
-    static fromJS(data: any): EquiWidthBinningParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new EquiWidthBinningParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["MinValue"] = this.minValue;
-        data["MaxValue"] = this.maxValue;
-        data["RequestedNrOfBins"] = this.requestedNrOfBins;
-        data["ReferenceValue"] = this.referenceValue;
-        data["Step"] = this.step;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IEquiWidthBinningParameters extends IBinningParameters {
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    requestedNrOfBins?: number | undefined;
-    referenceValue?: number | undefined;
-    step?: number | undefined;
-}
-
-export class SingleBinBinningParameters extends BinningParameters implements ISingleBinBinningParameters {
-
-    constructor(data?: ISingleBinBinningParameters) {
-        super(data);
-        this._discriminator = "SingleBinBinningParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): SingleBinBinningParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SingleBinBinningParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISingleBinBinningParameters extends IBinningParameters {
-}
-
-export class Attribute implements IAttribute {
-    displayName?: string | undefined;
-    rawName?: string | undefined;
-    description?: string | undefined;
-    dataType?: DataType | undefined;
-    visualizationHints?: VisualizationHint[] | undefined;
-    isTarget?: boolean | undefined;
-
-    constructor(data?: IAttribute) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.displayName = data["DisplayName"];
-            this.rawName = data["RawName"];
-            this.description = data["Description"];
-            this.dataType = data["DataType"];
-            if (data["VisualizationHints"] && data["VisualizationHints"].constructor === Array) {
-                this.visualizationHints = [];
-                for (let item of data["VisualizationHints"])
-                    this.visualizationHints.push(item);
-            }
-            this.isTarget = data["IsTarget"];
-        }
-    }
-
-    static fromJS(data: any): Attribute {
-        data = typeof data === 'object' ? data : {};
-        let result = new Attribute();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["DisplayName"] = this.displayName;
-        data["RawName"] = this.rawName;
-        data["Description"] = this.description;
-        data["DataType"] = this.dataType;
-        if (this.visualizationHints && this.visualizationHints.constructor === Array) {
-            data["VisualizationHints"] = [];
-            for (let item of this.visualizationHints)
-                data["VisualizationHints"].push(item);
-        }
-        data["IsTarget"] = this.isTarget;
-        return data;
-    }
-}
-
-export interface IAttribute {
-    displayName?: string | undefined;
-    rawName?: string | undefined;
-    description?: string | undefined;
-    dataType?: DataType | undefined;
-    visualizationHints?: VisualizationHint[] | undefined;
-    isTarget?: boolean | undefined;
-}
-
-export enum DataType {
-    Int = "Int",
-    String = "String",
-    Float = "Float",
-    Double = "Double",
-    DateTime = "DateTime",
-    Object = "Object",
-    Undefined = "Undefined",
-}
-
-export class AttributeGroup implements IAttributeGroup {
-    name?: string | undefined;
-    attributeGroups?: AttributeGroup[] | undefined;
-    attributes?: Attribute[] | undefined;
-
-    constructor(data?: IAttributeGroup) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.name = data["Name"];
-            if (data["AttributeGroups"] && data["AttributeGroups"].constructor === Array) {
-                this.attributeGroups = [];
-                for (let item of data["AttributeGroups"])
-                    this.attributeGroups.push(AttributeGroup.fromJS(item));
-            }
-            if (data["Attributes"] && data["Attributes"].constructor === Array) {
-                this.attributes = [];
-                for (let item of data["Attributes"])
-                    this.attributes.push(Attribute.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): AttributeGroup {
-        data = typeof data === 'object' ? data : {};
-        let result = new AttributeGroup();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Name"] = this.name;
-        if (this.attributeGroups && this.attributeGroups.constructor === Array) {
-            data["AttributeGroups"] = [];
-            for (let item of this.attributeGroups)
-                data["AttributeGroups"].push(item.toJSON());
-        }
-        if (this.attributes && this.attributes.constructor === Array) {
-            data["Attributes"] = [];
-            for (let item of this.attributes)
-                data["Attributes"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IAttributeGroup {
-    name?: string | undefined;
-    attributeGroups?: AttributeGroup[] | undefined;
-    attributes?: Attribute[] | undefined;
-}
-
-export class Catalog implements ICatalog {
-    supportedOperations?: string[] | undefined;
-    schemas?: Schema[] | undefined;
-
-    constructor(data?: ICatalog) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["SupportedOperations"] && data["SupportedOperations"].constructor === Array) {
-                this.supportedOperations = [];
-                for (let item of data["SupportedOperations"])
-                    this.supportedOperations.push(item);
-            }
-            if (data["Schemas"] && data["Schemas"].constructor === Array) {
-                this.schemas = [];
-                for (let item of data["Schemas"])
-                    this.schemas.push(Schema.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): Catalog {
-        data = typeof data === 'object' ? data : {};
-        let result = new Catalog();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.supportedOperations && this.supportedOperations.constructor === Array) {
-            data["SupportedOperations"] = [];
-            for (let item of this.supportedOperations)
-                data["SupportedOperations"].push(item);
-        }
-        if (this.schemas && this.schemas.constructor === Array) {
-            data["Schemas"] = [];
-            for (let item of this.schemas)
-                data["Schemas"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface ICatalog {
-    supportedOperations?: string[] | undefined;
-    schemas?: Schema[] | undefined;
-}
-
-export class Schema implements ISchema {
-    rootAttributeGroup?: AttributeGroup | undefined;
-    displayName?: string | undefined;
-    augmentedFrom?: string | undefined;
-    rawName?: string | undefined;
-    problemDescription?: string | undefined;
-    darpaProblemDoc?: DarpaProblemDoc | undefined;
-    distinctAttributeParameters?: AttributeParameters | undefined;
-    darpaDatasetDoc?: DarpaDatasetDoc | undefined;
-    darpaDatasetLocation?: string | undefined;
-    isMultiResourceData?: boolean | undefined;
-    problemFinderRows?: ProblemFinderRows[] | undefined;
-    correlationRows?: ProblemFinderRows[] | undefined;
-
-    constructor(data?: ISchema) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.rootAttributeGroup = data["RootAttributeGroup"] ? AttributeGroup.fromJS(data["RootAttributeGroup"]) : <any>undefined;
-            this.displayName = data["DisplayName"];
-            this.augmentedFrom = data["AugmentedFrom"];
-            this.rawName = data["RawName"];
-            this.problemDescription = data["ProblemDescription"];
-            this.darpaProblemDoc = data["DarpaProblemDoc"] ? DarpaProblemDoc.fromJS(data["DarpaProblemDoc"]) : <any>undefined;
-            this.distinctAttributeParameters = data["DistinctAttributeParameters"] ? AttributeParameters.fromJS(data["DistinctAttributeParameters"]) : <any>undefined;
-            this.darpaDatasetDoc = data["DarpaDatasetDoc"] ? DarpaDatasetDoc.fromJS(data["DarpaDatasetDoc"]) : <any>undefined;
-            this.darpaDatasetLocation = data["DarpaDatasetLocation"];
-            this.isMultiResourceData = data["IsMultiResourceData"];
-            if (data["ProblemFinderRows"] && data["ProblemFinderRows"].constructor === Array) {
-                this.problemFinderRows = [];
-                for (let item of data["ProblemFinderRows"])
-                    this.problemFinderRows.push(ProblemFinderRows.fromJS(item));
-            }
-            if (data["CorrelationRows"] && data["CorrelationRows"].constructor === Array) {
-                this.correlationRows = [];
-                for (let item of data["CorrelationRows"])
-                    this.correlationRows.push(ProblemFinderRows.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): Schema {
-        data = typeof data === 'object' ? data : {};
-        let result = new Schema();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["RootAttributeGroup"] = this.rootAttributeGroup ? this.rootAttributeGroup.toJSON() : <any>undefined;
-        data["DisplayName"] = this.displayName;
-        data["AugmentedFrom"] = this.augmentedFrom;
-        data["RawName"] = this.rawName;
-        data["ProblemDescription"] = this.problemDescription;
-        data["DarpaProblemDoc"] = this.darpaProblemDoc ? this.darpaProblemDoc.toJSON() : <any>undefined;
-        data["DistinctAttributeParameters"] = this.distinctAttributeParameters ? this.distinctAttributeParameters.toJSON() : <any>undefined;
-        data["DarpaDatasetDoc"] = this.darpaDatasetDoc ? this.darpaDatasetDoc.toJSON() : <any>undefined;
-        data["DarpaDatasetLocation"] = this.darpaDatasetLocation;
-        data["IsMultiResourceData"] = this.isMultiResourceData;
-        if (this.problemFinderRows && this.problemFinderRows.constructor === Array) {
-            data["ProblemFinderRows"] = [];
-            for (let item of this.problemFinderRows)
-                data["ProblemFinderRows"].push(item.toJSON());
-        }
-        if (this.correlationRows && this.correlationRows.constructor === Array) {
-            data["CorrelationRows"] = [];
-            for (let item of this.correlationRows)
-                data["CorrelationRows"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface ISchema {
-    rootAttributeGroup?: AttributeGroup | undefined;
-    displayName?: string | undefined;
-    augmentedFrom?: string | undefined;
-    rawName?: string | undefined;
-    problemDescription?: string | undefined;
-    darpaProblemDoc?: DarpaProblemDoc | undefined;
-    distinctAttributeParameters?: AttributeParameters | undefined;
-    darpaDatasetDoc?: DarpaDatasetDoc | undefined;
-    darpaDatasetLocation?: string | undefined;
-    isMultiResourceData?: boolean | undefined;
-    problemFinderRows?: ProblemFinderRows[] | undefined;
-    correlationRows?: ProblemFinderRows[] | undefined;
-}
-
-export class DarpaProblemDoc implements IDarpaProblemDoc {
-    about?: ProblemAbout | undefined;
-    inputs?: ProblemInputs | undefined;
-
-    constructor(data?: IDarpaProblemDoc) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.about = data["about"] ? ProblemAbout.fromJS(data["about"]) : <any>undefined;
-            this.inputs = data["inputs"] ? ProblemInputs.fromJS(data["inputs"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): DarpaProblemDoc {
-        data = typeof data === 'object' ? data : {};
-        let result = new DarpaProblemDoc();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["about"] = this.about ? this.about.toJSON() : <any>undefined;
-        data["inputs"] = this.inputs ? this.inputs.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface IDarpaProblemDoc {
-    about?: ProblemAbout | undefined;
-    inputs?: ProblemInputs | undefined;
-}
-
-export class ProblemAbout implements IProblemAbout {
-    problemID?: string | undefined;
-    problemName?: string | undefined;
-    problemDescription?: string | undefined;
-    taskType?: string | undefined;
-    taskSubType?: string | undefined;
-    problemSchemaVersion?: string | undefined;
-    problemVersion?: string | undefined;
-
-    constructor(data?: IProblemAbout) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.problemID = data["problemID"];
-            this.problemName = data["problemName"];
-            this.problemDescription = data["problemDescription"];
-            this.taskType = data["taskType"];
-            this.taskSubType = data["taskSubType"];
-            this.problemSchemaVersion = data["problemSchemaVersion"];
-            this.problemVersion = data["problemVersion"];
-        }
-    }
-
-    static fromJS(data: any): ProblemAbout {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemAbout();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["problemID"] = this.problemID;
-        data["problemName"] = this.problemName;
-        data["problemDescription"] = this.problemDescription;
-        data["taskType"] = this.taskType;
-        data["taskSubType"] = this.taskSubType;
-        data["problemSchemaVersion"] = this.problemSchemaVersion;
-        data["problemVersion"] = this.problemVersion;
-        return data;
-    }
-}
-
-export interface IProblemAbout {
-    problemID?: string | undefined;
-    problemName?: string | undefined;
-    problemDescription?: string | undefined;
-    taskType?: string | undefined;
-    taskSubType?: string | undefined;
-    problemSchemaVersion?: string | undefined;
-    problemVersion?: string | undefined;
-}
-
-export class ProblemInputs implements IProblemInputs {
-    data?: ProblemData[] | undefined;
-    performanceMetrics?: ProblemPerformanceMetric[] | undefined;
-
-    constructor(data?: IProblemInputs) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["data"] && data["data"].constructor === Array) {
-                this.data = [];
-                for (let item of data["data"])
-                    this.data.push(ProblemData.fromJS(item));
-            }
-            if (data["performanceMetrics"] && data["performanceMetrics"].constructor === Array) {
-                this.performanceMetrics = [];
-                for (let item of data["performanceMetrics"])
-                    this.performanceMetrics.push(ProblemPerformanceMetric.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): ProblemInputs {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemInputs();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.data && this.data.constructor === Array) {
-            data["data"] = [];
-            for (let item of this.data)
-                data["data"].push(item.toJSON());
-        }
-        if (this.performanceMetrics && this.performanceMetrics.constructor === Array) {
-            data["performanceMetrics"] = [];
-            for (let item of this.performanceMetrics)
-                data["performanceMetrics"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IProblemInputs {
-    data?: ProblemData[] | undefined;
-    performanceMetrics?: ProblemPerformanceMetric[] | undefined;
-}
-
-export class ProblemData implements IProblemData {
-    datasetID?: string | undefined;
-    targets?: ProblemTarget[] | undefined;
-
-    constructor(data?: IProblemData) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.datasetID = data["datasetID"];
-            if (data["targets"] && data["targets"].constructor === Array) {
-                this.targets = [];
-                for (let item of data["targets"])
-                    this.targets.push(ProblemTarget.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): ProblemData {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemData();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["datasetID"] = this.datasetID;
-        if (this.targets && this.targets.constructor === Array) {
-            data["targets"] = [];
-            for (let item of this.targets)
-                data["targets"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IProblemData {
-    datasetID?: string | undefined;
-    targets?: ProblemTarget[] | undefined;
-}
-
-export class ProblemTarget implements IProblemTarget {
-    targetIndex?: number | undefined;
-    resID?: string | undefined;
-    colIndex?: number | undefined;
-    colName?: string | undefined;
-
-    constructor(data?: IProblemTarget) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.targetIndex = data["targetIndex"];
-            this.resID = data["resID"];
-            this.colIndex = data["colIndex"];
-            this.colName = data["colName"];
-        }
-    }
-
-    static fromJS(data: any): ProblemTarget {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemTarget();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["targetIndex"] = this.targetIndex;
-        data["resID"] = this.resID;
-        data["colIndex"] = this.colIndex;
-        data["colName"] = this.colName;
-        return data;
-    }
-}
-
-export interface IProblemTarget {
-    targetIndex?: number | undefined;
-    resID?: string | undefined;
-    colIndex?: number | undefined;
-    colName?: string | undefined;
-}
-
-export class ProblemPerformanceMetric implements IProblemPerformanceMetric {
-    metric?: string | undefined;
-
-    constructor(data?: IProblemPerformanceMetric) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.metric = data["metric"];
-        }
-    }
-
-    static fromJS(data: any): ProblemPerformanceMetric {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemPerformanceMetric();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["metric"] = this.metric;
-        return data;
-    }
-}
-
-export interface IProblemPerformanceMetric {
-    metric?: string | undefined;
-}
-
-export class DarpaDatasetDoc implements IDarpaDatasetDoc {
-    about?: DatasetAbout | undefined;
-    dataResources?: Resource[] | undefined;
-
-    constructor(data?: IDarpaDatasetDoc) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.about = data["about"] ? DatasetAbout.fromJS(data["about"]) : <any>undefined;
-            if (data["dataResources"] && data["dataResources"].constructor === Array) {
-                this.dataResources = [];
-                for (let item of data["dataResources"])
-                    this.dataResources.push(Resource.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): DarpaDatasetDoc {
-        data = typeof data === 'object' ? data : {};
-        let result = new DarpaDatasetDoc();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["about"] = this.about ? this.about.toJSON() : <any>undefined;
-        if (this.dataResources && this.dataResources.constructor === Array) {
-            data["dataResources"] = [];
-            for (let item of this.dataResources)
-                data["dataResources"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IDarpaDatasetDoc {
-    about?: DatasetAbout | undefined;
-    dataResources?: Resource[] | undefined;
-}
-
-export class DatasetAbout implements IDatasetAbout {
-    datasetID?: string | undefined;
-    datasetName?: string | undefined;
-    description?: string | undefined;
-    citation?: string | undefined;
-    license?: string | undefined;
-    source?: string | undefined;
-    sourceURI?: string | undefined;
-    approximateSize?: string | undefined;
-    datasetSchemaVersion?: string | undefined;
-    redacted?: boolean | undefined;
-    datasetVersion?: string | undefined;
-
-    constructor(data?: IDatasetAbout) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.datasetID = data["datasetID"];
-            this.datasetName = data["datasetName"];
-            this.description = data["description"];
-            this.citation = data["citation"];
-            this.license = data["license"];
-            this.source = data["source"];
-            this.sourceURI = data["sourceURI"];
-            this.approximateSize = data["approximateSize"];
-            this.datasetSchemaVersion = data["datasetSchemaVersion"];
-            this.redacted = data["redacted"];
-            this.datasetVersion = data["datasetVersion"];
-        }
-    }
-
-    static fromJS(data: any): DatasetAbout {
-        data = typeof data === 'object' ? data : {};
-        let result = new DatasetAbout();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["datasetID"] = this.datasetID;
-        data["datasetName"] = this.datasetName;
-        data["description"] = this.description;
-        data["citation"] = this.citation;
-        data["license"] = this.license;
-        data["source"] = this.source;
-        data["sourceURI"] = this.sourceURI;
-        data["approximateSize"] = this.approximateSize;
-        data["datasetSchemaVersion"] = this.datasetSchemaVersion;
-        data["redacted"] = this.redacted;
-        data["datasetVersion"] = this.datasetVersion;
-        return data;
-    }
-}
-
-export interface IDatasetAbout {
-    datasetID?: string | undefined;
-    datasetName?: string | undefined;
-    description?: string | undefined;
-    citation?: string | undefined;
-    license?: string | undefined;
-    source?: string | undefined;
-    sourceURI?: string | undefined;
-    approximateSize?: string | undefined;
-    datasetSchemaVersion?: string | undefined;
-    redacted?: boolean | undefined;
-    datasetVersion?: string | undefined;
-}
-
-export class Resource implements IResource {
-    resID?: string | undefined;
-    resPath?: string | undefined;
-    resType?: string | undefined;
-    resFormat?: string[] | undefined;
-    columns?: Column[] | undefined;
-    isCollection?: boolean | undefined;
-
-    constructor(data?: IResource) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.resID = data["resID"];
-            this.resPath = data["resPath"];
-            this.resType = data["resType"];
-            if (data["resFormat"] && data["resFormat"].constructor === Array) {
-                this.resFormat = [];
-                for (let item of data["resFormat"])
-                    this.resFormat.push(item);
-            }
-            if (data["columns"] && data["columns"].constructor === Array) {
-                this.columns = [];
-                for (let item of data["columns"])
-                    this.columns.push(Column.fromJS(item));
-            }
-            this.isCollection = data["isCollection"];
-        }
-    }
-
-    static fromJS(data: any): Resource {
-        data = typeof data === 'object' ? data : {};
-        let result = new Resource();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["resID"] = this.resID;
-        data["resPath"] = this.resPath;
-        data["resType"] = this.resType;
-        if (this.resFormat && this.resFormat.constructor === Array) {
-            data["resFormat"] = [];
-            for (let item of this.resFormat)
-                data["resFormat"].push(item);
-        }
-        if (this.columns && this.columns.constructor === Array) {
-            data["columns"] = [];
-            for (let item of this.columns)
-                data["columns"].push(item.toJSON());
-        }
-        data["isCollection"] = this.isCollection;
-        return data;
-    }
-}
-
-export interface IResource {
-    resID?: string | undefined;
-    resPath?: string | undefined;
-    resType?: string | undefined;
-    resFormat?: string[] | undefined;
-    columns?: Column[] | undefined;
-    isCollection?: boolean | undefined;
-}
-
-export class Column implements IColumn {
-    colIndex?: number | undefined;
-    colDescription?: string | undefined;
-    colName?: string | undefined;
-    colType?: string | undefined;
-    role?: string[] | undefined;
-    refersTo?: Reference | undefined;
-
-    constructor(data?: IColumn) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.colIndex = data["colIndex"];
-            this.colDescription = data["colDescription"];
-            this.colName = data["colName"];
-            this.colType = data["colType"];
-            if (data["role"] && data["role"].constructor === Array) {
-                this.role = [];
-                for (let item of data["role"])
-                    this.role.push(item);
-            }
-            this.refersTo = data["refersTo"] ? Reference.fromJS(data["refersTo"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): Column {
-        data = typeof data === 'object' ? data : {};
-        let result = new Column();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["colIndex"] = this.colIndex;
-        data["colDescription"] = this.colDescription;
-        data["colName"] = this.colName;
-        data["colType"] = this.colType;
-        if (this.role && this.role.constructor === Array) {
-            data["role"] = [];
-            for (let item of this.role)
-                data["role"].push(item);
-        }
-        data["refersTo"] = this.refersTo ? this.refersTo.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface IColumn {
-    colIndex?: number | undefined;
-    colDescription?: string | undefined;
-    colName?: string | undefined;
-    colType?: string | undefined;
-    role?: string[] | undefined;
-    refersTo?: Reference | undefined;
-}
-
-export class Reference implements IReference {
-    resID?: string | undefined;
-
-    constructor(data?: IReference) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.resID = data["resID"];
-        }
-    }
-
-    static fromJS(data: any): Reference {
-        data = typeof data === 'object' ? data : {};
-        let result = new Reference();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["resID"] = this.resID;
-        return data;
-    }
-}
-
-export interface IReference {
-    resID?: string | undefined;
-}
-
-export class ProblemFinderRows implements IProblemFinderRows {
-    label?: string | undefined;
-    type?: string | undefined;
-    features?: Feature[] | undefined;
-
-    constructor(data?: IProblemFinderRows) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.label = data["label"];
-            this.type = data["type"];
-            if (data["features"] && data["features"].constructor === Array) {
-                this.features = [];
-                for (let item of data["features"])
-                    this.features.push(Feature.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): ProblemFinderRows {
-        data = typeof data === 'object' ? data : {};
-        let result = new ProblemFinderRows();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["label"] = this.label;
-        data["type"] = this.type;
-        if (this.features && this.features.constructor === Array) {
-            data["features"] = [];
-            for (let item of this.features)
-                data["features"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IProblemFinderRows {
-    label?: string | undefined;
-    type?: string | undefined;
-    features?: Feature[] | undefined;
-}
-
-export class Feature implements IFeature {
-    name?: string | undefined;
-    selected?: boolean | undefined;
-    value?: number | undefined;
-
-    constructor(data?: IFeature) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.name = data["name"];
-            this.selected = data["selected"];
-            this.value = data["value"];
-        }
-    }
-
-    static fromJS(data: any): Feature {
-        data = typeof data === 'object' ? data : {};
-        let result = new Feature();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["name"] = this.name;
-        data["selected"] = this.selected;
-        data["value"] = this.value;
-        return data;
-    }
-}
-
-export interface IFeature {
-    name?: string | undefined;
-    selected?: boolean | undefined;
-    value?: number | undefined;
-}
-
-export enum DataType2 {
-    Int = 0,
-    String = 1,
-    Float = 2,
-    Double = 3,
-    DateTime = 4,
-    Object = 5,
-    Undefined = 6,
-}
-
-export abstract class DataTypeExtensions implements IDataTypeExtensions {
-
-    constructor(data?: IDataTypeExtensions) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): DataTypeExtensions {
-        data = typeof data === 'object' ? data : {};
-        throw new Error("The abstract class 'DataTypeExtensions' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        return data;
-    }
-}
-
-export interface IDataTypeExtensions {
-}
-
-export class ResObject implements IResObject {
-    columnName?: string | undefined;
-
-    constructor(data?: IResObject) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.columnName = data["columnName"];
-        }
-    }
-
-    static fromJS(data: any): ResObject {
-        data = typeof data === 'object' ? data : {};
-        let result = new ResObject();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["columnName"] = this.columnName;
-        return data;
-    }
-}
-
-export interface IResObject {
-    columnName?: string | undefined;
-}
-
-export class Exception implements IException {
-    message?: string | undefined;
-    innerException?: Exception | undefined;
-    stackTrace?: string | undefined;
-    source?: string | undefined;
-
-    constructor(data?: IException) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.message = data["Message"];
-            this.innerException = data["InnerException"] ? Exception.fromJS(data["InnerException"]) : <any>undefined;
-            this.stackTrace = data["StackTrace"];
-            this.source = data["Source"];
-        }
-    }
-
-    static fromJS(data: any): Exception {
-        data = typeof data === 'object' ? data : {};
-        let result = new Exception();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Message"] = this.message;
-        data["InnerException"] = this.innerException ? this.innerException.toJSON() : <any>undefined;
-        data["StackTrace"] = this.stackTrace;
-        data["Source"] = this.source;
-        return data;
-    }
-}
-
-export interface IException {
-    message?: string | undefined;
-    innerException?: Exception | undefined;
-    stackTrace?: string | undefined;
-    source?: string | undefined;
-}
-
-export class IDEAException extends Exception implements IIDEAException {
-
-    constructor(data?: IIDEAException) {
-        super(data);
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): IDEAException {
-        data = typeof data === 'object' ? data : {};
-        let result = new IDEAException();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IIDEAException extends IException {
-}
-
-export class CodeParameters implements ICodeParameters {
-    attributeCodeParameters?: AttributeCodeParameters[] | undefined;
-    adapterName?: string | undefined;
-
-    constructor(data?: ICodeParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["AttributeCodeParameters"] && data["AttributeCodeParameters"].constructor === Array) {
-                this.attributeCodeParameters = [];
-                for (let item of data["AttributeCodeParameters"])
-                    this.attributeCodeParameters.push(AttributeCodeParameters.fromJS(item));
-            }
-            this.adapterName = data["AdapterName"];
-        }
-    }
-
-    static fromJS(data: any): CodeParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new CodeParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.attributeCodeParameters && this.attributeCodeParameters.constructor === Array) {
-            data["AttributeCodeParameters"] = [];
-            for (let item of this.attributeCodeParameters)
-                data["AttributeCodeParameters"].push(item.toJSON());
-        }
-        data["AdapterName"] = this.adapterName;
-        return data;
-    }
-}
-
-export interface ICodeParameters {
-    attributeCodeParameters?: AttributeCodeParameters[] | undefined;
-    adapterName?: string | undefined;
-}
-
-export class CompileResult implements ICompileResult {
-    compileSuccess?: boolean | undefined;
-    compileMessage?: string | undefined;
-    dataType?: DataType | undefined;
-    replaceAttributeParameters?: AttributeParameters[] | undefined;
-
-    constructor(data?: ICompileResult) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.compileSuccess = data["CompileSuccess"];
-            this.compileMessage = data["CompileMessage"];
-            this.dataType = data["DataType"];
-            if (data["ReplaceAttributeParameters"] && data["ReplaceAttributeParameters"].constructor === Array) {
-                this.replaceAttributeParameters = [];
-                for (let item of data["ReplaceAttributeParameters"])
-                    this.replaceAttributeParameters.push(AttributeParameters.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): CompileResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new CompileResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["CompileSuccess"] = this.compileSuccess;
-        data["CompileMessage"] = this.compileMessage;
-        data["DataType"] = this.dataType;
-        if (this.replaceAttributeParameters && this.replaceAttributeParameters.constructor === Array) {
-            data["ReplaceAttributeParameters"] = [];
-            for (let item of this.replaceAttributeParameters)
-                data["ReplaceAttributeParameters"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface ICompileResult {
-    compileSuccess?: boolean | undefined;
-    compileMessage?: string | undefined;
-    dataType?: DataType | undefined;
-    replaceAttributeParameters?: AttributeParameters[] | undefined;
-}
-
-export class CompileResults implements ICompileResults {
-    rawNameToCompileResult?: { [key: string]: CompileResult; } | undefined;
-
-    constructor(data?: ICompileResults) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["RawNameToCompileResult"]) {
-                this.rawNameToCompileResult = {};
-                for (let key in data["RawNameToCompileResult"]) {
-                    if (data["RawNameToCompileResult"].hasOwnProperty(key))
-                        this.rawNameToCompileResult[key] = data["RawNameToCompileResult"][key] ? CompileResult.fromJS(data["RawNameToCompileResult"][key]) : new CompileResult();
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): CompileResults {
-        data = typeof data === 'object' ? data : {};
-        let result = new CompileResults();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.rawNameToCompileResult) {
-            data["RawNameToCompileResult"] = {};
-            for (let key in this.rawNameToCompileResult) {
-                if (this.rawNameToCompileResult.hasOwnProperty(key))
-                    data["RawNameToCompileResult"][key] = this.rawNameToCompileResult[key];
-            }
-        }
-        return data;
-    }
-}
-
-export interface ICompileResults {
-    rawNameToCompileResult?: { [key: string]: CompileResult; } | undefined;
-}
-
-export abstract class UniqueJson implements IUniqueJson {
-
-    constructor(data?: IUniqueJson) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): UniqueJson {
-        data = typeof data === 'object' ? data : {};
-        throw new Error("The abstract class 'UniqueJson' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        return data;
-    }
-}
-
-export interface IUniqueJson {
-}
-
-export abstract class OperationParameters extends UniqueJson implements IOperationParameters {
-    isCachable?: boolean | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IOperationParameters) {
-        super(data);
-        this._discriminator = "OperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.isCachable = data["IsCachable"];
-        }
-    }
-
-    static fromJS(data: any): OperationParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "DataOperationParameters") {
-            throw new Error("The abstract class 'DataOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "ExampleOperationParameters") {
-            let result = new ExampleOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "HistogramOperationParameters") {
-            let result = new HistogramOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DistOperationParameters") {
-            throw new Error("The abstract class 'DistOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "OptimizerOperationParameters") {
-            let result = new OptimizerOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RawDataOperationParameters") {
-            let result = new RawDataOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RecommenderOperationParameters") {
-            let result = new RecommenderOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CDFOperationParameters") {
-            let result = new CDFOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TestDistOperationParameters") {
-            throw new Error("The abstract class 'TestDistOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "ChiSquaredTestOperationParameters") {
-            let result = new ChiSquaredTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "HypothesisTestParameters") {
-            throw new Error("The abstract class 'HypothesisTestParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "CorrelationTestOperationParameters") {
-            let result = new CorrelationTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "EmpiricalDistOperationParameters") {
-            let result = new EmpiricalDistOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KSTestOperationParameters") {
-            let result = new KSTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "NewModelOperationParameters") {
-            let result = new NewModelOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ModelOperationParameters") {
-            throw new Error("The abstract class 'ModelOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "RootMeanSquareTestOperationParameters") {
-            let result = new RootMeanSquareTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TTestOperationParameters") {
-            let result = new TTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FeatureImportanceOperationParameters") {
-            let result = new FeatureImportanceOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SampleOperationParameters") {
-            let result = new SampleOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AddComparisonParameters") {
-            let result = new AddComparisonParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "GetModelStateParameters") {
-            let result = new GetModelStateParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FrequentItemsetOperationParameters") {
-            let result = new FrequentItemsetOperationParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'OperationParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["IsCachable"] = this.isCachable;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IOperationParameters extends IUniqueJson {
-    isCachable?: boolean | undefined;
-}
-
-export abstract class DataOperationParameters extends OperationParameters implements IDataOperationParameters {
-    sampleStreamBlockSize?: number | undefined;
-    adapterName?: string | undefined;
-    isCachable?: boolean | undefined;
-
-    constructor(data?: IDataOperationParameters) {
-        super(data);
-        this._discriminator = "DataOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.sampleStreamBlockSize = data["SampleStreamBlockSize"];
-            this.adapterName = data["AdapterName"];
-            this.isCachable = data["IsCachable"];
-        }
-    }
-
-    static fromJS(data: any): DataOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ExampleOperationParameters") {
-            let result = new ExampleOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "HistogramOperationParameters") {
-            let result = new HistogramOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DistOperationParameters") {
-            throw new Error("The abstract class 'DistOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "OptimizerOperationParameters") {
-            let result = new OptimizerOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RawDataOperationParameters") {
-            let result = new RawDataOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RecommenderOperationParameters") {
-            let result = new RecommenderOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CDFOperationParameters") {
-            let result = new CDFOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TestDistOperationParameters") {
-            throw new Error("The abstract class 'TestDistOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "EmpiricalDistOperationParameters") {
-            let result = new EmpiricalDistOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FeatureImportanceOperationParameters") {
-            let result = new FeatureImportanceOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SampleOperationParameters") {
-            let result = new SampleOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FrequentItemsetOperationParameters") {
-            let result = new FrequentItemsetOperationParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'DataOperationParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SampleStreamBlockSize"] = this.sampleStreamBlockSize;
-        data["AdapterName"] = this.adapterName;
-        data["IsCachable"] = this.isCachable;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDataOperationParameters extends IOperationParameters {
-    sampleStreamBlockSize?: number | undefined;
-    adapterName?: string | undefined;
-    isCachable?: boolean | undefined;
-}
-
-export class ExampleOperationParameters extends DataOperationParameters implements IExampleOperationParameters {
-    filter?: string | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    attributeCodeParameters?: AttributeCaclculatedParameters[] | undefined;
-    dummyValue?: number | undefined;
-    exampleType?: string | undefined;
-
-    constructor(data?: IExampleOperationParameters) {
-        super(data);
-        this._discriminator = "ExampleOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.filter = data["Filter"];
-            if (data["AttributeParameters"] && data["AttributeParameters"].constructor === Array) {
-                this.attributeParameters = [];
-                for (let item of data["AttributeParameters"])
-                    this.attributeParameters.push(AttributeParameters.fromJS(item));
-            }
-            if (data["AttributeCodeParameters"] && data["AttributeCodeParameters"].constructor === Array) {
-                this.attributeCodeParameters = [];
-                for (let item of data["AttributeCodeParameters"])
-                    this.attributeCodeParameters.push(AttributeCaclculatedParameters.fromJS(item));
-            }
-            this.dummyValue = data["DummyValue"];
-            this.exampleType = data["ExampleType"];
-        }
-    }
-
-    static fromJS(data: any): ExampleOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new ExampleOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Filter"] = this.filter;
-        if (this.attributeParameters && this.attributeParameters.constructor === Array) {
-            data["AttributeParameters"] = [];
-            for (let item of this.attributeParameters)
-                data["AttributeParameters"].push(item.toJSON());
-        }
-        if (this.attributeCodeParameters && this.attributeCodeParameters.constructor === Array) {
-            data["AttributeCodeParameters"] = [];
-            for (let item of this.attributeCodeParameters)
-                data["AttributeCodeParameters"].push(item.toJSON());
-        }
-        data["DummyValue"] = this.dummyValue;
-        data["ExampleType"] = this.exampleType;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IExampleOperationParameters extends IDataOperationParameters {
-    filter?: string | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    attributeCodeParameters?: AttributeCaclculatedParameters[] | undefined;
-    dummyValue?: number | undefined;
-    exampleType?: string | undefined;
-}
-
-export abstract class DistOperationParameters extends DataOperationParameters implements IDistOperationParameters {
-    filter?: string | undefined;
-    attributeCalculatedParameters?: AttributeCaclculatedParameters[] | undefined;
-
-    constructor(data?: IDistOperationParameters) {
-        super(data);
-        this._discriminator = "DistOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.filter = data["Filter"];
-            if (data["AttributeCalculatedParameters"] && data["AttributeCalculatedParameters"].constructor === Array) {
-                this.attributeCalculatedParameters = [];
-                for (let item of data["AttributeCalculatedParameters"])
-                    this.attributeCalculatedParameters.push(AttributeCaclculatedParameters.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): DistOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "HistogramOperationParameters") {
-            let result = new HistogramOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "OptimizerOperationParameters") {
-            let result = new OptimizerOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RawDataOperationParameters") {
-            let result = new RawDataOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CDFOperationParameters") {
-            let result = new CDFOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TestDistOperationParameters") {
-            throw new Error("The abstract class 'TestDistOperationParameters' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "EmpiricalDistOperationParameters") {
-            let result = new EmpiricalDistOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FeatureImportanceOperationParameters") {
-            let result = new FeatureImportanceOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SampleOperationParameters") {
-            let result = new SampleOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FrequentItemsetOperationParameters") {
-            let result = new FrequentItemsetOperationParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'DistOperationParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Filter"] = this.filter;
-        if (this.attributeCalculatedParameters && this.attributeCalculatedParameters.constructor === Array) {
-            data["AttributeCalculatedParameters"] = [];
-            for (let item of this.attributeCalculatedParameters)
-                data["AttributeCalculatedParameters"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDistOperationParameters extends IDataOperationParameters {
-    filter?: string | undefined;
-    attributeCalculatedParameters?: AttributeCaclculatedParameters[] | undefined;
-}
-
-export class HistogramOperationParameters extends DistOperationParameters implements IHistogramOperationParameters {
-    sortPerBinAggregateParameter?: AggregateParameters | undefined;
-    binningParameters?: BinningParameters[] | undefined;
-    perBinAggregateParameters?: AggregateParameters[] | undefined;
-    globalAggregateParameters?: AggregateParameters[] | undefined;
-    brushes?: string[] | undefined;
-    enableBrushComputation?: boolean | undefined;
-    degreeOfParallism?: number | undefined;
-
-    constructor(data?: IHistogramOperationParameters) {
-        super(data);
-        this._discriminator = "HistogramOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.sortPerBinAggregateParameter = data["SortPerBinAggregateParameter"] ? AggregateParameters.fromJS(data["SortPerBinAggregateParameter"]) : <any>undefined;
-            if (data["BinningParameters"] && data["BinningParameters"].constructor === Array) {
-                this.binningParameters = [];
-                for (let item of data["BinningParameters"])
-                    this.binningParameters.push(BinningParameters.fromJS(item));
-            }
-            if (data["PerBinAggregateParameters"] && data["PerBinAggregateParameters"].constructor === Array) {
-                this.perBinAggregateParameters = [];
-                for (let item of data["PerBinAggregateParameters"])
-                    this.perBinAggregateParameters.push(AggregateParameters.fromJS(item));
-            }
-            if (data["GlobalAggregateParameters"] && data["GlobalAggregateParameters"].constructor === Array) {
-                this.globalAggregateParameters = [];
-                for (let item of data["GlobalAggregateParameters"])
-                    this.globalAggregateParameters.push(AggregateParameters.fromJS(item));
-            }
-            if (data["Brushes"] && data["Brushes"].constructor === Array) {
-                this.brushes = [];
-                for (let item of data["Brushes"])
-                    this.brushes.push(item);
-            }
-            this.enableBrushComputation = data["EnableBrushComputation"];
-            this.degreeOfParallism = data["DegreeOfParallism"];
-        }
-    }
-
-    static fromJS(data: any): HistogramOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new HistogramOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SortPerBinAggregateParameter"] = this.sortPerBinAggregateParameter ? this.sortPerBinAggregateParameter.toJSON() : <any>undefined;
-        if (this.binningParameters && this.binningParameters.constructor === Array) {
-            data["BinningParameters"] = [];
-            for (let item of this.binningParameters)
-                data["BinningParameters"].push(item.toJSON());
-        }
-        if (this.perBinAggregateParameters && this.perBinAggregateParameters.constructor === Array) {
-            data["PerBinAggregateParameters"] = [];
-            for (let item of this.perBinAggregateParameters)
-                data["PerBinAggregateParameters"].push(item.toJSON());
-        }
-        if (this.globalAggregateParameters && this.globalAggregateParameters.constructor === Array) {
-            data["GlobalAggregateParameters"] = [];
-            for (let item of this.globalAggregateParameters)
-                data["GlobalAggregateParameters"].push(item.toJSON());
-        }
-        if (this.brushes && this.brushes.constructor === Array) {
-            data["Brushes"] = [];
-            for (let item of this.brushes)
-                data["Brushes"].push(item);
-        }
-        data["EnableBrushComputation"] = this.enableBrushComputation;
-        data["DegreeOfParallism"] = this.degreeOfParallism;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IHistogramOperationParameters extends IDistOperationParameters {
-    sortPerBinAggregateParameter?: AggregateParameters | undefined;
-    binningParameters?: BinningParameters[] | undefined;
-    perBinAggregateParameters?: AggregateParameters[] | undefined;
-    globalAggregateParameters?: AggregateParameters[] | undefined;
-    brushes?: string[] | undefined;
-    enableBrushComputation?: boolean | undefined;
-    degreeOfParallism?: number | undefined;
-}
-
-export class OptimizerOperationParameters extends DistOperationParameters implements IOptimizerOperationParameters {
-    taskType?: TaskType | undefined;
-    taskSubType?: TaskSubType | undefined;
-    metricType?: MetricType | undefined;
-    labelAttribute?: AttributeParameters | undefined;
-    featureAttributes?: AttributeParameters[] | undefined;
-    requiredPrimitives?: string[] | undefined;
-    pythonFilter?: string | undefined;
-    trainFilter?: string | undefined;
-    pythonTrainFilter?: string | undefined;
-    testFilter?: string | undefined;
-    pythonTestFilter?: string | undefined;
-
-    constructor(data?: IOptimizerOperationParameters) {
-        super(data);
-        this._discriminator = "OptimizerOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.taskType = data["TaskType"];
-            this.taskSubType = data["TaskSubType"];
-            this.metricType = data["MetricType"];
-            this.labelAttribute = data["LabelAttribute"] ? AttributeParameters.fromJS(data["LabelAttribute"]) : <any>undefined;
-            if (data["FeatureAttributes"] && data["FeatureAttributes"].constructor === Array) {
-                this.featureAttributes = [];
-                for (let item of data["FeatureAttributes"])
-                    this.featureAttributes.push(AttributeParameters.fromJS(item));
-            }
-            if (data["RequiredPrimitives"] && data["RequiredPrimitives"].constructor === Array) {
-                this.requiredPrimitives = [];
-                for (let item of data["RequiredPrimitives"])
-                    this.requiredPrimitives.push(item);
-            }
-            this.pythonFilter = data["PythonFilter"];
-            this.trainFilter = data["TrainFilter"];
-            this.pythonTrainFilter = data["PythonTrainFilter"];
-            this.testFilter = data["TestFilter"];
-            this.pythonTestFilter = data["PythonTestFilter"];
-        }
-    }
-
-    static fromJS(data: any): OptimizerOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new OptimizerOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["TaskType"] = this.taskType;
-        data["TaskSubType"] = this.taskSubType;
-        data["MetricType"] = this.metricType;
-        data["LabelAttribute"] = this.labelAttribute ? this.labelAttribute.toJSON() : <any>undefined;
-        if (this.featureAttributes && this.featureAttributes.constructor === Array) {
-            data["FeatureAttributes"] = [];
-            for (let item of this.featureAttributes)
-                data["FeatureAttributes"].push(item.toJSON());
-        }
-        if (this.requiredPrimitives && this.requiredPrimitives.constructor === Array) {
-            data["RequiredPrimitives"] = [];
-            for (let item of this.requiredPrimitives)
-                data["RequiredPrimitives"].push(item);
-        }
-        data["PythonFilter"] = this.pythonFilter;
-        data["TrainFilter"] = this.trainFilter;
-        data["PythonTrainFilter"] = this.pythonTrainFilter;
-        data["TestFilter"] = this.testFilter;
-        data["PythonTestFilter"] = this.pythonTestFilter;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IOptimizerOperationParameters extends IDistOperationParameters {
-    taskType?: TaskType | undefined;
-    taskSubType?: TaskSubType | undefined;
-    metricType?: MetricType | undefined;
-    labelAttribute?: AttributeParameters | undefined;
-    featureAttributes?: AttributeParameters[] | undefined;
-    requiredPrimitives?: string[] | undefined;
-    pythonFilter?: string | undefined;
-    trainFilter?: string | undefined;
-    pythonTrainFilter?: string | undefined;
-    testFilter?: string | undefined;
-    pythonTestFilter?: string | undefined;
-}
-
-export enum TaskType {
-    Undefined = 0,
-    Classification = 1,
-    Regression = 2,
-    Clustering = 3,
-    LinkPrediction = 4,
-    VertexNomination = 5,
-    CommunityDetection = 6,
-    GraphClustering = 7,
-    GraphMatching = 8,
-    TimeSeriesForecasting = 9,
-    CollaborativeFiltering = 10,
-}
-
-export enum TaskSubType {
-    Undefined = 0,
-    None = 1,
-    Binary = 2,
-    Multiclass = 3,
-    Multilabel = 4,
-    Univariate = 5,
-    Multivariate = 6,
-    Overlapping = 7,
-    Nonoverlapping = 8,
-}
-
-export enum MetricType {
-    MetricUndefined = 0,
-    Accuracy = 1,
-    Precision = 2,
-    Recall = 3,
-    F1 = 4,
-    F1Micro = 5,
-    F1Macro = 6,
-    RocAuc = 7,
-    RocAucMicro = 8,
-    RocAucMacro = 9,
-    MeanSquaredError = 10,
-    RootMeanSquaredError = 11,
-    RootMeanSquaredErrorAvg = 12,
-    MeanAbsoluteError = 13,
-    RSquared = 14,
-    NormalizedMutualInformation = 15,
-    JaccardSimilarityScore = 16,
-    PrecisionAtTopK = 17,
-    ObjectDetectionAveragePrecision = 18,
-    Loss = 100,
-}
-
-export class RawDataOperationParameters extends DistOperationParameters implements IRawDataOperationParameters {
-    sortUpRawName?: string | undefined;
-    sortDownRawName?: string | undefined;
-    numRecords?: number | undefined;
-    binningParameters?: BinningParameters[] | undefined;
-    brushes?: string[] | undefined;
-    enableBrushComputation?: boolean | undefined;
-
-    constructor(data?: IRawDataOperationParameters) {
-        super(data);
-        this._discriminator = "RawDataOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.sortUpRawName = data["SortUpRawName"];
-            this.sortDownRawName = data["SortDownRawName"];
-            this.numRecords = data["NumRecords"];
-            if (data["BinningParameters"] && data["BinningParameters"].constructor === Array) {
-                this.binningParameters = [];
-                for (let item of data["BinningParameters"])
-                    this.binningParameters.push(BinningParameters.fromJS(item));
-            }
-            if (data["Brushes"] && data["Brushes"].constructor === Array) {
-                this.brushes = [];
-                for (let item of data["Brushes"])
-                    this.brushes.push(item);
-            }
-            this.enableBrushComputation = data["EnableBrushComputation"];
-        }
-    }
-
-    static fromJS(data: any): RawDataOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new RawDataOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SortUpRawName"] = this.sortUpRawName;
-        data["SortDownRawName"] = this.sortDownRawName;
-        data["NumRecords"] = this.numRecords;
-        if (this.binningParameters && this.binningParameters.constructor === Array) {
-            data["BinningParameters"] = [];
-            for (let item of this.binningParameters)
-                data["BinningParameters"].push(item.toJSON());
-        }
-        if (this.brushes && this.brushes.constructor === Array) {
-            data["Brushes"] = [];
-            for (let item of this.brushes)
-                data["Brushes"].push(item);
-        }
-        data["EnableBrushComputation"] = this.enableBrushComputation;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRawDataOperationParameters extends IDistOperationParameters {
-    sortUpRawName?: string | undefined;
-    sortDownRawName?: string | undefined;
-    numRecords?: number | undefined;
-    binningParameters?: BinningParameters[] | undefined;
-    brushes?: string[] | undefined;
-    enableBrushComputation?: boolean | undefined;
-}
-
-export class RecommenderOperationParameters extends DataOperationParameters implements IRecommenderOperationParameters {
-    target?: HistogramOperationParameters | undefined;
-    budget?: number | undefined;
-    modelId?: ModelId | undefined;
-    includeAttributeParameters?: AttributeParameters[] | undefined;
-    excludeAttributeParameters?: AttributeParameters[] | undefined;
-    riskControlType?: RiskControlType | undefined;
-
-    constructor(data?: IRecommenderOperationParameters) {
-        super(data);
-        this._discriminator = "RecommenderOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.target = data["Target"] ? HistogramOperationParameters.fromJS(data["Target"]) : <any>undefined;
-            this.budget = data["Budget"];
-            this.modelId = data["ModelId"] ? ModelId.fromJS(data["ModelId"]) : <any>undefined;
-            if (data["IncludeAttributeParameters"] && data["IncludeAttributeParameters"].constructor === Array) {
-                this.includeAttributeParameters = [];
-                for (let item of data["IncludeAttributeParameters"])
-                    this.includeAttributeParameters.push(AttributeParameters.fromJS(item));
-            }
-            if (data["ExcludeAttributeParameters"] && data["ExcludeAttributeParameters"].constructor === Array) {
-                this.excludeAttributeParameters = [];
-                for (let item of data["ExcludeAttributeParameters"])
-                    this.excludeAttributeParameters.push(AttributeParameters.fromJS(item));
-            }
-            this.riskControlType = data["RiskControlType"];
-        }
-    }
-
-    static fromJS(data: any): RecommenderOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new RecommenderOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Target"] = this.target ? this.target.toJSON() : <any>undefined;
-        data["Budget"] = this.budget;
-        data["ModelId"] = this.modelId ? this.modelId.toJSON() : <any>undefined;
-        if (this.includeAttributeParameters && this.includeAttributeParameters.constructor === Array) {
-            data["IncludeAttributeParameters"] = [];
-            for (let item of this.includeAttributeParameters)
-                data["IncludeAttributeParameters"].push(item.toJSON());
-        }
-        if (this.excludeAttributeParameters && this.excludeAttributeParameters.constructor === Array) {
-            data["ExcludeAttributeParameters"] = [];
-            for (let item of this.excludeAttributeParameters)
-                data["ExcludeAttributeParameters"].push(item.toJSON());
-        }
-        data["RiskControlType"] = this.riskControlType;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRecommenderOperationParameters extends IDataOperationParameters {
-    target?: HistogramOperationParameters | undefined;
-    budget?: number | undefined;
-    modelId?: ModelId | undefined;
-    includeAttributeParameters?: AttributeParameters[] | undefined;
-    excludeAttributeParameters?: AttributeParameters[] | undefined;
-    riskControlType?: RiskControlType | undefined;
-}
-
-export class ModelId implements IModelId {
-    value?: string | undefined;
-
-    constructor(data?: IModelId) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): ModelId {
-        data = typeof data === 'object' ? data : {};
-        let result = new ModelId();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        return data;
-    }
-}
-
-export interface IModelId {
-    value?: string | undefined;
-}
-
-export enum RiskControlType {
-    PCER = 0,
-    Bonferroni = 1,
-    AdaBonferroni = 2,
-    HolmBonferroni = 3,
-    BHFDR = 4,
-    SeqFDR = 5,
-    AlphaFDR = 6,
-    BestFootForward = 7,
-    BetaFarsighted = 8,
-    BetaFarsightedWithSupport = 9,
-    GammaFixed = 10,
-    DeltaHopeful = 11,
-    EpsilonHybrid = 12,
-    EpsilonHybridWithoutSupport = 13,
-    PsiSupport = 14,
-    ZetaDynamic = 15,
-    Unknown = 16,
-}
-
-export abstract class TestDistOperationParameters extends DistOperationParameters implements ITestDistOperationParameters {
-    attributeParameters?: AttributeParameters[] | undefined;
-
-    constructor(data?: ITestDistOperationParameters) {
-        super(data);
-        this._discriminator = "TestDistOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["AttributeParameters"] && data["AttributeParameters"].constructor === Array) {
-                this.attributeParameters = [];
-                for (let item of data["AttributeParameters"])
-                    this.attributeParameters.push(AttributeParameters.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): TestDistOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "CDFOperationParameters") {
-            let result = new CDFOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "EmpiricalDistOperationParameters") {
-            let result = new EmpiricalDistOperationParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'TestDistOperationParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.attributeParameters && this.attributeParameters.constructor === Array) {
-            data["AttributeParameters"] = [];
-            for (let item of this.attributeParameters)
-                data["AttributeParameters"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ITestDistOperationParameters extends IDistOperationParameters {
-    attributeParameters?: AttributeParameters[] | undefined;
-}
-
-export class CDFOperationParameters extends TestDistOperationParameters implements ICDFOperationParameters {
-
-    constructor(data?: ICDFOperationParameters) {
-        super(data);
-        this._discriminator = "CDFOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): CDFOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new CDFOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICDFOperationParameters extends ITestDistOperationParameters {
-}
-
-export abstract class HypothesisTestParameters extends OperationParameters implements IHypothesisTestParameters {
-    childOperationParameters?: OperationParameters[] | undefined;
-    isCachable?: boolean | undefined;
-
-    constructor(data?: IHypothesisTestParameters) {
-        super(data);
-        this._discriminator = "HypothesisTestParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["ChildOperationParameters"] && data["ChildOperationParameters"].constructor === Array) {
-                this.childOperationParameters = [];
-                for (let item of data["ChildOperationParameters"])
-                    this.childOperationParameters.push(OperationParameters.fromJS(item));
-            }
-            this.isCachable = data["IsCachable"];
-        }
-    }
-
-    static fromJS(data: any): HypothesisTestParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ChiSquaredTestOperationParameters") {
-            let result = new ChiSquaredTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CorrelationTestOperationParameters") {
-            let result = new CorrelationTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KSTestOperationParameters") {
-            let result = new KSTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RootMeanSquareTestOperationParameters") {
-            let result = new RootMeanSquareTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TTestOperationParameters") {
-            let result = new TTestOperationParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'HypothesisTestParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.childOperationParameters && this.childOperationParameters.constructor === Array) {
-            data["ChildOperationParameters"] = [];
-            for (let item of this.childOperationParameters)
-                data["ChildOperationParameters"].push(item.toJSON());
-        }
-        data["IsCachable"] = this.isCachable;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IHypothesisTestParameters extends IOperationParameters {
-    childOperationParameters?: OperationParameters[] | undefined;
-    isCachable?: boolean | undefined;
-}
-
-export class ChiSquaredTestOperationParameters extends HypothesisTestParameters implements IChiSquaredTestOperationParameters {
-
-    constructor(data?: IChiSquaredTestOperationParameters) {
-        super(data);
-        this._discriminator = "ChiSquaredTestOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): ChiSquaredTestOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new ChiSquaredTestOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IChiSquaredTestOperationParameters extends IHypothesisTestParameters {
-}
-
-export class CorrelationTestOperationParameters extends HypothesisTestParameters implements ICorrelationTestOperationParameters {
-
-    constructor(data?: ICorrelationTestOperationParameters) {
-        super(data);
-        this._discriminator = "CorrelationTestOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): CorrelationTestOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new CorrelationTestOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICorrelationTestOperationParameters extends IHypothesisTestParameters {
-}
-
-export class SubmitProblemParameters implements ISubmitProblemParameters {
-    id?: string | undefined;
-
-    constructor(data?: ISubmitProblemParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-        }
-    }
-
-    static fromJS(data: any): SubmitProblemParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SubmitProblemParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        return data;
-    }
-}
-
-export interface ISubmitProblemParameters {
-    id?: string | undefined;
-}
-
-export class SpecifyProblemParameters implements ISpecifyProblemParameters {
-    id?: string | undefined;
-    userComment?: string | undefined;
-    optimizerOperationParameters?: OptimizerOperationParameters | undefined;
-
-    constructor(data?: ISpecifyProblemParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-            this.userComment = data["UserComment"];
-            this.optimizerOperationParameters = data["OptimizerOperationParameters"] ? OptimizerOperationParameters.fromJS(data["OptimizerOperationParameters"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): SpecifyProblemParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SpecifyProblemParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        data["UserComment"] = this.userComment;
-        data["OptimizerOperationParameters"] = this.optimizerOperationParameters ? this.optimizerOperationParameters.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface ISpecifyProblemParameters {
-    id?: string | undefined;
-    userComment?: string | undefined;
-    optimizerOperationParameters?: OptimizerOperationParameters | undefined;
-}
-
-export class EmpiricalDistOperationParameters extends TestDistOperationParameters implements IEmpiricalDistOperationParameters {
-    keepSamples?: boolean | undefined;
-
-    constructor(data?: IEmpiricalDistOperationParameters) {
-        super(data);
-        this._discriminator = "EmpiricalDistOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.keepSamples = data["KeepSamples"];
-        }
-    }
-
-    static fromJS(data: any): EmpiricalDistOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new EmpiricalDistOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["KeepSamples"] = this.keepSamples;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IEmpiricalDistOperationParameters extends ITestDistOperationParameters {
-    keepSamples?: boolean | undefined;
-}
-
-export class KSTestOperationParameters extends HypothesisTestParameters implements IKSTestOperationParameters {
-
-    constructor(data?: IKSTestOperationParameters) {
-        super(data);
-        this._discriminator = "KSTestOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): KSTestOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new KSTestOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IKSTestOperationParameters extends IHypothesisTestParameters {
-}
-
-export abstract class ModelOperationParameters extends OperationParameters implements IModelOperationParameters {
-
-    constructor(data?: IModelOperationParameters) {
-        super(data);
-        this._discriminator = "ModelOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): ModelOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "NewModelOperationParameters") {
-            let result = new NewModelOperationParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AddComparisonParameters") {
-            let result = new AddComparisonParameters();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "GetModelStateParameters") {
-            let result = new GetModelStateParameters();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'ModelOperationParameters' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IModelOperationParameters extends IOperationParameters {
-}
-
-export class NewModelOperationParameters extends ModelOperationParameters implements INewModelOperationParameters {
-    riskControlTypes?: RiskControlType[] | undefined;
-    alpha?: number | undefined;
-    alphaInvestParameter?: AlphaInvestParameter | undefined;
-
-    constructor(data?: INewModelOperationParameters) {
-        super(data);
-        this._discriminator = "NewModelOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["RiskControlTypes"] && data["RiskControlTypes"].constructor === Array) {
-                this.riskControlTypes = [];
-                for (let item of data["RiskControlTypes"])
-                    this.riskControlTypes.push(item);
-            }
-            this.alpha = data["Alpha"];
-            this.alphaInvestParameter = data["AlphaInvestParameter"] ? AlphaInvestParameter.fromJS(data["AlphaInvestParameter"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): NewModelOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new NewModelOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.riskControlTypes && this.riskControlTypes.constructor === Array) {
-            data["RiskControlTypes"] = [];
-            for (let item of this.riskControlTypes)
-                data["RiskControlTypes"].push(item);
-        }
-        data["Alpha"] = this.alpha;
-        data["AlphaInvestParameter"] = this.alphaInvestParameter ? this.alphaInvestParameter.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface INewModelOperationParameters extends IModelOperationParameters {
-    riskControlTypes?: RiskControlType[] | undefined;
-    alpha?: number | undefined;
-    alphaInvestParameter?: AlphaInvestParameter | undefined;
-}
-
-export class AlphaInvestParameter extends UniqueJson implements IAlphaInvestParameter {
-    beta?: number | undefined;
-    gamma?: number | undefined;
-    delta?: number | undefined;
-    epsilon?: number | undefined;
-    windowSize?: number | undefined;
-    psi?: number | undefined;
-
-    constructor(data?: IAlphaInvestParameter) {
-        super(data);
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.beta = data["Beta"];
-            this.gamma = data["Gamma"];
-            this.delta = data["Delta"];
-            this.epsilon = data["Epsilon"];
-            this.windowSize = data["WindowSize"];
-            this.psi = data["Psi"];
-        }
-    }
-
-    static fromJS(data: any): AlphaInvestParameter {
-        data = typeof data === 'object' ? data : {};
-        let result = new AlphaInvestParameter();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Beta"] = this.beta;
-        data["Gamma"] = this.gamma;
-        data["Delta"] = this.delta;
-        data["Epsilon"] = this.epsilon;
-        data["WindowSize"] = this.windowSize;
-        data["Psi"] = this.psi;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAlphaInvestParameter extends IUniqueJson {
-    beta?: number | undefined;
-    gamma?: number | undefined;
-    delta?: number | undefined;
-    epsilon?: number | undefined;
-    windowSize?: number | undefined;
-    psi?: number | undefined;
-}
-
-export class RootMeanSquareTestOperationParameters extends HypothesisTestParameters implements IRootMeanSquareTestOperationParameters {
-    seeded?: boolean | undefined;
-    pValueConvergenceThreshold?: number | undefined;
-    maxSimulationBatchCount?: number | undefined;
-    perBatchSimulationCount?: number | undefined;
-
-    constructor(data?: IRootMeanSquareTestOperationParameters) {
-        super(data);
-        this._discriminator = "RootMeanSquareTestOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.seeded = data["Seeded"];
-            this.pValueConvergenceThreshold = data["PValueConvergenceThreshold"];
-            this.maxSimulationBatchCount = data["MaxSimulationBatchCount"];
-            this.perBatchSimulationCount = data["PerBatchSimulationCount"];
-        }
-    }
-
-    static fromJS(data: any): RootMeanSquareTestOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new RootMeanSquareTestOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Seeded"] = this.seeded;
-        data["PValueConvergenceThreshold"] = this.pValueConvergenceThreshold;
-        data["MaxSimulationBatchCount"] = this.maxSimulationBatchCount;
-        data["PerBatchSimulationCount"] = this.perBatchSimulationCount;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRootMeanSquareTestOperationParameters extends IHypothesisTestParameters {
-    seeded?: boolean | undefined;
-    pValueConvergenceThreshold?: number | undefined;
-    maxSimulationBatchCount?: number | undefined;
-    perBatchSimulationCount?: number | undefined;
-}
-
-export class TTestOperationParameters extends HypothesisTestParameters implements ITTestOperationParameters {
-
-    constructor(data?: ITTestOperationParameters) {
-        super(data);
-        this._discriminator = "TTestOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): TTestOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new TTestOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ITTestOperationParameters extends IHypothesisTestParameters {
-}
-
-export enum EffectSize {
-    Small = 1,
-    Meduim = 2,
-    Large = 4,
-}
-
-export abstract class Result extends UniqueJson implements IResult {
-    progress?: number | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IResult) {
-        super(data);
-        this._discriminator = "Result";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.progress = data["Progress"];
-        }
-    }
-
-    static fromJS(data: any): Result {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ErrorResult") {
-            let result = new ErrorResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "HistogramResult") {
-            let result = new HistogramResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DistResult") {
-            throw new Error("The abstract class 'DistResult' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "ModelWealthResult") {
-            let result = new ModelWealthResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "HypothesisTestResult") {
-            throw new Error("The abstract class 'HypothesisTestResult' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "ModelOperationResult") {
-            throw new Error("The abstract class 'ModelOperationResult' cannot be instantiated.");
-        }
-        if (data["discriminator"] === "RecommenderResult") {
-            let result = new RecommenderResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "Decision") {
-            let result = new Decision();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "OptimizerResult") {
-            let result = new OptimizerResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ExampleResult") {
-            let result = new ExampleResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "NewModelOperationResult") {
-            let result = new NewModelOperationResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AddComparisonResult") {
-            let result = new AddComparisonResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "GetModelStateResult") {
-            let result = new GetModelStateResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FeatureImportanceResult") {
-            let result = new FeatureImportanceResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RawDataResult") {
-            let result = new RawDataResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SampleResult") {
-            let result = new SampleResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CDFResult") {
-            let result = new CDFResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ChiSquaredTestResult") {
-            let result = new ChiSquaredTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CorrelationTestResult") {
-            let result = new CorrelationTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "EmpiricalDistResult") {
-            let result = new EmpiricalDistResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KSTestResult") {
-            let result = new KSTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RootMeanSquareTestResult") {
-            let result = new RootMeanSquareTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TTestResult") {
-            let result = new TTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "FrequentItemsetResult") {
-            let result = new FrequentItemsetResult();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'Result' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["Progress"] = this.progress;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IResult extends IUniqueJson {
-    progress?: number | undefined;
-}
-
-export class ErrorResult extends Result implements IErrorResult {
-    message?: string | undefined;
-
-    constructor(data?: IErrorResult) {
-        super(data);
-        this._discriminator = "ErrorResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.message = data["Message"];
-        }
-    }
-
-    static fromJS(data: any): ErrorResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new ErrorResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Message"] = this.message;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IErrorResult extends IResult {
-    message?: string | undefined;
-}
-
-export abstract class DistResult extends Result implements IDistResult {
-    sampleSize?: number | undefined;
-    populationSize?: number | undefined;
-
-    constructor(data?: IDistResult) {
-        super(data);
-        this._discriminator = "DistResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.sampleSize = data["SampleSize"];
-            this.populationSize = data["PopulationSize"];
-        }
-    }
-
-    static fromJS(data: any): DistResult {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "HistogramResult") {
-            let result = new HistogramResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RawDataResult") {
-            let result = new RawDataResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SampleResult") {
-            let result = new SampleResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CDFResult") {
-            let result = new CDFResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "EmpiricalDistResult") {
-            let result = new EmpiricalDistResult();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'DistResult' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SampleSize"] = this.sampleSize;
-        data["PopulationSize"] = this.populationSize;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDistResult extends IResult {
-    sampleSize?: number | undefined;
-    populationSize?: number | undefined;
-}
-
-export class HistogramResult extends DistResult implements IHistogramResult {
-    aggregateResults?: AggregateResult[][] | undefined;
-    isEmpty?: boolean | undefined;
-    brushes?: Brush[] | undefined;
-    binRanges?: BinRange[] | undefined;
-    aggregateParameters?: AggregateParameters[] | undefined;
-    nullValueCount?: number | undefined;
-    bins?: { [key: string]: Bin; } | undefined;
-
-    constructor(data?: IHistogramResult) {
-        super(data);
-        this._discriminator = "HistogramResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["AggregateResults"] && data["AggregateResults"].constructor === Array) {
-                this.aggregateResults = [];
-                for (let item of data["AggregateResults"])
-                    this.aggregateResults.push(item);
-            }
-            this.isEmpty = data["IsEmpty"];
-            if (data["Brushes"] && data["Brushes"].constructor === Array) {
-                this.brushes = [];
-                for (let item of data["Brushes"])
-                    this.brushes.push(Brush.fromJS(item));
-            }
-            if (data["BinRanges"] && data["BinRanges"].constructor === Array) {
-                this.binRanges = [];
-                for (let item of data["BinRanges"])
-                    this.binRanges.push(BinRange.fromJS(item));
-            }
-            if (data["AggregateParameters"] && data["AggregateParameters"].constructor === Array) {
-                this.aggregateParameters = [];
-                for (let item of data["AggregateParameters"])
-                    this.aggregateParameters.push(AggregateParameters.fromJS(item));
-            }
-            this.nullValueCount = data["NullValueCount"];
-            if (data["Bins"]) {
-                this.bins = {};
-                for (let key in data["Bins"]) {
-                    if (data["Bins"].hasOwnProperty(key))
-                        this.bins[key] = data["Bins"][key] ? Bin.fromJS(data["Bins"][key]) : new Bin();
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): HistogramResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new HistogramResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.aggregateResults && this.aggregateResults.constructor === Array) {
-            data["AggregateResults"] = [];
-            for (let item of this.aggregateResults)
-                data["AggregateResults"].push(item);
-        }
-        data["IsEmpty"] = this.isEmpty;
-        if (this.brushes && this.brushes.constructor === Array) {
-            data["Brushes"] = [];
-            for (let item of this.brushes)
-                data["Brushes"].push(item.toJSON());
-        }
-        if (this.binRanges && this.binRanges.constructor === Array) {
-            data["BinRanges"] = [];
-            for (let item of this.binRanges)
-                data["BinRanges"].push(item.toJSON());
-        }
-        if (this.aggregateParameters && this.aggregateParameters.constructor === Array) {
-            data["AggregateParameters"] = [];
-            for (let item of this.aggregateParameters)
-                data["AggregateParameters"].push(item.toJSON());
-        }
-        data["NullValueCount"] = this.nullValueCount;
-        if (this.bins) {
-            data["Bins"] = {};
-            for (let key in this.bins) {
-                if (this.bins.hasOwnProperty(key))
-                    data["Bins"][key] = this.bins[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IHistogramResult extends IDistResult {
-    aggregateResults?: AggregateResult[][] | undefined;
-    isEmpty?: boolean | undefined;
-    brushes?: Brush[] | undefined;
-    binRanges?: BinRange[] | undefined;
-    aggregateParameters?: AggregateParameters[] | undefined;
-    nullValueCount?: number | undefined;
-    bins?: { [key: string]: Bin; } | undefined;
-}
-
-export abstract class AggregateResult implements IAggregateResult {
-    hasResult?: boolean | undefined;
-    n?: number | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IAggregateResult) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "AggregateResult";
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.hasResult = data["HasResult"];
-            this.n = data["N"];
-        }
-    }
-
-    static fromJS(data: any): AggregateResult | undefined {
-        if (data === null || data === undefined) {
-            return undefined;
-        }
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "MarginAggregateResult") {
-            let result = new MarginAggregateResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DoubleValueAggregateResult") {
-            let result = new DoubleValueAggregateResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PointsAggregateResult") {
-            let result = new PointsAggregateResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SumEstimationAggregateResult") {
-            let result = new SumEstimationAggregateResult();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'AggregateResult' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["HasResult"] = this.hasResult;
-        data["N"] = this.n;
-        return data;
-    }
-}
-
-export interface IAggregateResult {
-    hasResult?: boolean | undefined;
-    n?: number | undefined;
-}
-
-export class MarginAggregateResult extends AggregateResult implements IMarginAggregateResult {
-    margin?: number | undefined;
-    absolutMargin?: number | undefined;
-    sumOfSquare?: number | undefined;
-    sampleStandardDeviation?: number | undefined;
-    mean?: number | undefined;
-    ex?: number | undefined;
-    ex2?: number | undefined;
-    variance?: number | undefined;
-
-    constructor(data?: IMarginAggregateResult) {
-        super(data);
-        this._discriminator = "MarginAggregateResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.margin = data["Margin"];
-            this.absolutMargin = data["AbsolutMargin"];
-            this.sumOfSquare = data["SumOfSquare"];
-            this.sampleStandardDeviation = data["SampleStandardDeviation"];
-            this.mean = data["Mean"];
-            this.ex = data["Ex"];
-            this.ex2 = data["Ex2"];
-            this.variance = data["Variance"];
-        }
-    }
-
-    static fromJS(data: any): MarginAggregateResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new MarginAggregateResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Margin"] = this.margin;
-        data["AbsolutMargin"] = this.absolutMargin;
-        data["SumOfSquare"] = this.sumOfSquare;
-        data["SampleStandardDeviation"] = this.sampleStandardDeviation;
-        data["Mean"] = this.mean;
-        data["Ex"] = this.ex;
-        data["Ex2"] = this.ex2;
-        data["Variance"] = this.variance;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IMarginAggregateResult extends IAggregateResult {
-    margin?: number | undefined;
-    absolutMargin?: number | undefined;
-    sumOfSquare?: number | undefined;
-    sampleStandardDeviation?: number | undefined;
-    mean?: number | undefined;
-    ex?: number | undefined;
-    ex2?: number | undefined;
-    variance?: number | undefined;
-}
-
-export class DoubleValueAggregateResult extends AggregateResult implements IDoubleValueAggregateResult {
-    result?: number | undefined;
-    temporaryResult?: number | undefined;
-
-    constructor(data?: IDoubleValueAggregateResult) {
-        super(data);
-        this._discriminator = "DoubleValueAggregateResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.result = data["Result"];
-            this.temporaryResult = data["TemporaryResult"];
-        }
-    }
-
-    static fromJS(data: any): DoubleValueAggregateResult {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "SumEstimationAggregateResult") {
-            let result = new SumEstimationAggregateResult();
-            result.init(data);
-            return result;
-        }
-        let result = new DoubleValueAggregateResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Result"] = this.result;
-        data["TemporaryResult"] = this.temporaryResult;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDoubleValueAggregateResult extends IAggregateResult {
-    result?: number | undefined;
-    temporaryResult?: number | undefined;
-}
-
-export class PointsAggregateResult extends AggregateResult implements IPointsAggregateResult {
-    points?: Point[] | undefined;
-
-    constructor(data?: IPointsAggregateResult) {
-        super(data);
-        this._discriminator = "PointsAggregateResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Points"] && data["Points"].constructor === Array) {
-                this.points = [];
-                for (let item of data["Points"])
-                    this.points.push(Point.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): PointsAggregateResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new PointsAggregateResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.points && this.points.constructor === Array) {
-            data["Points"] = [];
-            for (let item of this.points)
-                data["Points"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPointsAggregateResult extends IAggregateResult {
-    points?: Point[] | undefined;
-}
-
-export class Point implements IPoint {
-    x?: number | undefined;
-    y?: number | undefined;
-
-    constructor(data?: IPoint) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.x = data["X"];
-            this.y = data["Y"];
-        }
-    }
-
-    static fromJS(data: any): Point {
-        data = typeof data === 'object' ? data : {};
-        let result = new Point();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["X"] = this.x;
-        data["Y"] = this.y;
-        return data;
-    }
-}
-
-export interface IPoint {
-    x?: number | undefined;
-    y?: number | undefined;
-}
-
-export class SumEstimationAggregateResult extends DoubleValueAggregateResult implements ISumEstimationAggregateResult {
-    sum?: number | undefined;
-    sumEstimation?: number | undefined;
-
-    constructor(data?: ISumEstimationAggregateResult) {
-        super(data);
-        this._discriminator = "SumEstimationAggregateResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.sum = data["Sum"];
-            this.sumEstimation = data["SumEstimation"];
-        }
-    }
-
-    static fromJS(data: any): SumEstimationAggregateResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new SumEstimationAggregateResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Sum"] = this.sum;
-        data["SumEstimation"] = this.sumEstimation;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISumEstimationAggregateResult extends IDoubleValueAggregateResult {
-    sum?: number | undefined;
-    sumEstimation?: number | undefined;
-}
-
-export class Brush implements IBrush {
-    brushIndex?: number | undefined;
-    brushEnum?: BrushEnum | undefined;
-
-    constructor(data?: IBrush) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.brushIndex = data["BrushIndex"];
-            this.brushEnum = data["BrushEnum"];
-        }
-    }
-
-    static fromJS(data: any): Brush {
-        data = typeof data === 'object' ? data : {};
-        let result = new Brush();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["BrushIndex"] = this.brushIndex;
-        data["BrushEnum"] = this.brushEnum;
-        return data;
-    }
-}
-
-export interface IBrush {
-    brushIndex?: number | undefined;
-    brushEnum?: BrushEnum | undefined;
-}
-
-export enum BrushEnum {
-    Overlap = 0,
-    Rest = 1,
-    All = 2,
-    UserSpecified = 3,
-}
-
-export abstract class BinRange implements IBinRange {
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    targetBinNumber?: number | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IBinRange) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "BinRange";
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.minValue = data["MinValue"];
-            this.maxValue = data["MaxValue"];
-            this.targetBinNumber = data["TargetBinNumber"];
-        }
-    }
-
-    static fromJS(data: any): BinRange {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "NominalBinRange") {
-            let result = new NominalBinRange();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "QuantitativeBinRange") {
-            let result = new QuantitativeBinRange();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AggregateBinRange") {
-            let result = new AggregateBinRange();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AlphabeticBinRange") {
-            let result = new AlphabeticBinRange();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DateTimeBinRange") {
-            let result = new DateTimeBinRange();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'BinRange' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["MinValue"] = this.minValue;
-        data["MaxValue"] = this.maxValue;
-        data["TargetBinNumber"] = this.targetBinNumber;
-        return data;
-    }
-}
-
-export interface IBinRange {
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    targetBinNumber?: number | undefined;
-}
-
-export class NominalBinRange extends BinRange implements INominalBinRange {
-    labelsValue?: { [key: string]: number; } | undefined;
-    valuesLabel?: { [key: string]: string; } | undefined;
-
-    constructor(data?: INominalBinRange) {
-        super(data);
-        this._discriminator = "NominalBinRange";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["LabelsValue"]) {
-                this.labelsValue = {};
-                for (let key in data["LabelsValue"]) {
-                    if (data["LabelsValue"].hasOwnProperty(key))
-                        this.labelsValue[key] = data["LabelsValue"][key];
-                }
-            }
-            if (data["ValuesLabel"]) {
-                this.valuesLabel = {};
-                for (let key in data["ValuesLabel"]) {
-                    if (data["ValuesLabel"].hasOwnProperty(key))
-                        this.valuesLabel[key] = data["ValuesLabel"][key];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): NominalBinRange {
-        data = typeof data === 'object' ? data : {};
-        let result = new NominalBinRange();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.labelsValue) {
-            data["LabelsValue"] = {};
-            for (let key in this.labelsValue) {
-                if (this.labelsValue.hasOwnProperty(key))
-                    data["LabelsValue"][key] = this.labelsValue[key];
-            }
-        }
-        if (this.valuesLabel) {
-            data["ValuesLabel"] = {};
-            for (let key in this.valuesLabel) {
-                if (this.valuesLabel.hasOwnProperty(key))
-                    data["ValuesLabel"][key] = this.valuesLabel[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface INominalBinRange extends IBinRange {
-    labelsValue?: { [key: string]: number; } | undefined;
-    valuesLabel?: { [key: string]: string; } | undefined;
-}
-
-export class QuantitativeBinRange extends BinRange implements IQuantitativeBinRange {
-    isIntegerRange?: boolean | undefined;
-    step?: number | undefined;
-
-    constructor(data?: IQuantitativeBinRange) {
-        super(data);
-        this._discriminator = "QuantitativeBinRange";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.isIntegerRange = data["IsIntegerRange"];
-            this.step = data["Step"];
-        }
-    }
-
-    static fromJS(data: any): QuantitativeBinRange {
-        data = typeof data === 'object' ? data : {};
-        let result = new QuantitativeBinRange();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["IsIntegerRange"] = this.isIntegerRange;
-        data["Step"] = this.step;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IQuantitativeBinRange extends IBinRange {
-    isIntegerRange?: boolean | undefined;
-    step?: number | undefined;
-}
-
-export class AggregateBinRange extends BinRange implements IAggregateBinRange {
-
-    constructor(data?: IAggregateBinRange) {
-        super(data);
-        this._discriminator = "AggregateBinRange";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): AggregateBinRange {
-        data = typeof data === 'object' ? data : {};
-        let result = new AggregateBinRange();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAggregateBinRange extends IBinRange {
-}
-
-export class AlphabeticBinRange extends BinRange implements IAlphabeticBinRange {
-    prefix?: string | undefined;
-    labelsValue?: { [key: string]: number; } | undefined;
-    valuesLabel?: { [key: string]: string; } | undefined;
-
-    constructor(data?: IAlphabeticBinRange) {
-        super(data);
-        this._discriminator = "AlphabeticBinRange";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.prefix = data["Prefix"];
-            if (data["LabelsValue"]) {
-                this.labelsValue = {};
-                for (let key in data["LabelsValue"]) {
-                    if (data["LabelsValue"].hasOwnProperty(key))
-                        this.labelsValue[key] = data["LabelsValue"][key];
-                }
-            }
-            if (data["ValuesLabel"]) {
-                this.valuesLabel = {};
-                for (let key in data["ValuesLabel"]) {
-                    if (data["ValuesLabel"].hasOwnProperty(key))
-                        this.valuesLabel[key] = data["ValuesLabel"][key];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): AlphabeticBinRange {
-        data = typeof data === 'object' ? data : {};
-        let result = new AlphabeticBinRange();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Prefix"] = this.prefix;
-        if (this.labelsValue) {
-            data["LabelsValue"] = {};
-            for (let key in this.labelsValue) {
-                if (this.labelsValue.hasOwnProperty(key))
-                    data["LabelsValue"][key] = this.labelsValue[key];
-            }
-        }
-        if (this.valuesLabel) {
-            data["ValuesLabel"] = {};
-            for (let key in this.valuesLabel) {
-                if (this.valuesLabel.hasOwnProperty(key))
-                    data["ValuesLabel"][key] = this.valuesLabel[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAlphabeticBinRange extends IBinRange {
-    prefix?: string | undefined;
-    labelsValue?: { [key: string]: number; } | undefined;
-    valuesLabel?: { [key: string]: string; } | undefined;
-}
-
-export class DateTimeBinRange extends BinRange implements IDateTimeBinRange {
-    step?: DateTimeStep | undefined;
-
-    constructor(data?: IDateTimeBinRange) {
-        super(data);
-        this._discriminator = "DateTimeBinRange";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.step = data["Step"] ? DateTimeStep.fromJS(data["Step"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): DateTimeBinRange {
-        data = typeof data === 'object' ? data : {};
-        let result = new DateTimeBinRange();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Step"] = this.step ? this.step.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDateTimeBinRange extends IBinRange {
-    step?: DateTimeStep | undefined;
-}
-
-export class DateTimeStep implements IDateTimeStep {
-    dateTimeStepGranularity?: DateTimeStepGranularity | undefined;
-    dateTimeStepValue?: number | undefined;
-    dateTimeStepMaxValue?: number | undefined;
-
-    constructor(data?: IDateTimeStep) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.dateTimeStepGranularity = data["DateTimeStepGranularity"];
-            this.dateTimeStepValue = data["DateTimeStepValue"];
-            this.dateTimeStepMaxValue = data["DateTimeStepMaxValue"];
-        }
-    }
-
-    static fromJS(data: any): DateTimeStep {
-        data = typeof data === 'object' ? data : {};
-        let result = new DateTimeStep();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["DateTimeStepGranularity"] = this.dateTimeStepGranularity;
-        data["DateTimeStepValue"] = this.dateTimeStepValue;
-        data["DateTimeStepMaxValue"] = this.dateTimeStepMaxValue;
-        return data;
-    }
-}
-
-export interface IDateTimeStep {
-    dateTimeStepGranularity?: DateTimeStepGranularity | undefined;
-    dateTimeStepValue?: number | undefined;
-    dateTimeStepMaxValue?: number | undefined;
-}
-
-export enum DateTimeStepGranularity {
-    Second = 0,
-    Minute = 1,
-    Hour = 2,
-    Day = 3,
-    Month = 4,
-    Year = 5,
-}
-
-export class Bin implements IBin {
-    aggregateResults?: AggregateResult[] | undefined;
-    count?: number | undefined;
-    binIndex?: BinIndex | undefined;
-    spans?: Span[] | undefined;
-    xSize?: number | undefined;
-    ySize?: number | undefined;
-
-    constructor(data?: IBin) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["AggregateResults"] && data["AggregateResults"].constructor === Array) {
-                this.aggregateResults = [];
-                for (let item of data["AggregateResults"]) {
-                    let fromJs = AggregateResult.fromJS(item);
-                    if (fromJs)
-                        this.aggregateResults.push(fromJs);
-                }
-            }
-            this.count = data["Count"];
-            this.binIndex = data["BinIndex"] ? BinIndex.fromJS(data["BinIndex"]) : <any>undefined;
-            if (data["Spans"] && data["Spans"].constructor === Array) {
-                this.spans = [];
-                for (let item of data["Spans"])
-                    this.spans.push(Span.fromJS(item));
-            }
-            this.xSize = data["XSize"];
-            this.ySize = data["YSize"];
-        }
-    }
-
-    static fromJS(data: any): Bin {
-        data = typeof data === 'object' ? data : {};
-        let result = new Bin();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.aggregateResults && this.aggregateResults.constructor === Array) {
-            data["AggregateResults"] = [];
-            for (let item of this.aggregateResults)
-                data["AggregateResults"].push(item.toJSON());
-        }
-        data["Count"] = this.count;
-        data["BinIndex"] = this.binIndex ? this.binIndex.toJSON() : <any>undefined;
-        if (this.spans && this.spans.constructor === Array) {
-            data["Spans"] = [];
-            for (let item of this.spans)
-                data["Spans"].push(item.toJSON());
-        }
-        data["XSize"] = this.xSize;
-        data["YSize"] = this.ySize;
-        return data;
-    }
-}
-
-export interface IBin {
-    aggregateResults?: AggregateResult[] | undefined;
-    count?: number | undefined;
-    binIndex?: BinIndex | undefined;
-    spans?: Span[] | undefined;
-    xSize?: number | undefined;
-    ySize?: number | undefined;
-}
-
-export class BinIndex implements IBinIndex {
-    indices?: number[] | undefined;
-    flatIndex?: number | undefined;
-
-    constructor(data?: IBinIndex) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["Indices"] && data["Indices"].constructor === Array) {
-                this.indices = [];
-                for (let item of data["Indices"])
-                    this.indices.push(item);
-            }
-            this.flatIndex = data["FlatIndex"];
-        }
-    }
-
-    static fromJS(data: any): BinIndex {
-        data = typeof data === 'object' ? data : {};
-        let result = new BinIndex();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.indices && this.indices.constructor === Array) {
-            data["Indices"] = [];
-            for (let item of this.indices)
-                data["Indices"].push(item);
-        }
-        data["FlatIndex"] = this.flatIndex;
-        return data;
-    }
-}
-
-export interface IBinIndex {
-    indices?: number[] | undefined;
-    flatIndex?: number | undefined;
-}
-
-export class Span implements ISpan {
-    min?: number | undefined;
-    max?: number | undefined;
-    index?: number | undefined;
-
-    constructor(data?: ISpan) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.min = data["Min"];
-            this.max = data["Max"];
-            this.index = data["Index"];
-        }
-    }
-
-    static fromJS(data: any): Span {
-        data = typeof data === 'object' ? data : {};
-        let result = new Span();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Min"] = this.min;
-        data["Max"] = this.max;
-        data["Index"] = this.index;
-        return data;
-    }
-}
-
-export interface ISpan {
-    min?: number | undefined;
-    max?: number | undefined;
-    index?: number | undefined;
-}
-
-export class ModelWealthResult extends Result implements IModelWealthResult {
-    wealth?: number | undefined;
-    startWealth?: number | undefined;
-
-    constructor(data?: IModelWealthResult) {
-        super(data);
-        this._discriminator = "ModelWealthResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.wealth = data["Wealth"];
-            this.startWealth = data["StartWealth"];
-        }
-    }
-
-    static fromJS(data: any): ModelWealthResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new ModelWealthResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Wealth"] = this.wealth;
-        data["StartWealth"] = this.startWealth;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IModelWealthResult extends IResult {
-    wealth?: number | undefined;
-    startWealth?: number | undefined;
-}
-
-export abstract class HypothesisTestResult extends Result implements IHypothesisTestResult {
-    pValue?: number | undefined;
-    statistic?: number | undefined;
-    support?: number | undefined;
-    sampleSizes?: number[] | undefined;
-    errorMessage?: string | undefined;
-
-    constructor(data?: IHypothesisTestResult) {
-        super(data);
-        this._discriminator = "HypothesisTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.pValue = data["PValue"];
-            this.statistic = data["Statistic"];
-            this.support = data["Support"];
-            if (data["SampleSizes"] && data["SampleSizes"].constructor === Array) {
-                this.sampleSizes = [];
-                for (let item of data["SampleSizes"])
-                    this.sampleSizes.push(item);
-            }
-            this.errorMessage = data["ErrorMessage"];
-        }
-    }
-
-    static fromJS(data: any): HypothesisTestResult {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ChiSquaredTestResult") {
-            let result = new ChiSquaredTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CorrelationTestResult") {
-            let result = new CorrelationTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "KSTestResult") {
-            let result = new KSTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "RootMeanSquareTestResult") {
-            let result = new RootMeanSquareTestResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "TTestResult") {
-            let result = new TTestResult();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'HypothesisTestResult' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["PValue"] = this.pValue;
-        data["Statistic"] = this.statistic;
-        data["Support"] = this.support;
-        if (this.sampleSizes && this.sampleSizes.constructor === Array) {
-            data["SampleSizes"] = [];
-            for (let item of this.sampleSizes)
-                data["SampleSizes"].push(item);
-        }
-        data["ErrorMessage"] = this.errorMessage;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IHypothesisTestResult extends IResult {
-    pValue?: number | undefined;
-    statistic?: number | undefined;
-    support?: number | undefined;
-    sampleSizes?: number[] | undefined;
-    errorMessage?: string | undefined;
-}
-
-export abstract class ModelOperationResult extends Result implements IModelOperationResult {
-    modelId?: ModelId | undefined;
-
-    constructor(data?: IModelOperationResult) {
-        super(data);
-        this._discriminator = "ModelOperationResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.modelId = data["ModelId"] ? ModelId.fromJS(data["ModelId"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): ModelOperationResult {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "NewModelOperationResult") {
-            let result = new NewModelOperationResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "AddComparisonResult") {
-            let result = new AddComparisonResult();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "GetModelStateResult") {
-            let result = new GetModelStateResult();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'ModelOperationResult' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ModelId"] = this.modelId ? this.modelId.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IModelOperationResult extends IResult {
-    modelId?: ModelId | undefined;
-}
-
-export class RecommenderResult extends Result implements IRecommenderResult {
-    recommendedHistograms?: RecommendedHistogram[] | undefined;
-    totalCount?: number | undefined;
-
-    constructor(data?: IRecommenderResult) {
-        super(data);
-        this._discriminator = "RecommenderResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["RecommendedHistograms"] && data["RecommendedHistograms"].constructor === Array) {
-                this.recommendedHistograms = [];
-                for (let item of data["RecommendedHistograms"])
-                    this.recommendedHistograms.push(RecommendedHistogram.fromJS(item));
-            }
-            this.totalCount = data["TotalCount"];
-        }
-    }
-
-    static fromJS(data: any): RecommenderResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new RecommenderResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.recommendedHistograms && this.recommendedHistograms.constructor === Array) {
-            data["RecommendedHistograms"] = [];
-            for (let item of this.recommendedHistograms)
-                data["RecommendedHistograms"].push(item.toJSON());
-        }
-        data["TotalCount"] = this.totalCount;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRecommenderResult extends IResult {
-    recommendedHistograms?: RecommendedHistogram[] | undefined;
-    totalCount?: number | undefined;
-}
-
-export class RecommendedHistogram implements IRecommendedHistogram {
-    histogramResult?: HistogramResult | undefined;
-    selectedBinIndices?: BinIndex[] | undefined;
-    selections?: Selection[] | undefined;
-    pValue?: number | undefined;
-    significance?: boolean | undefined;
-    decision?: Decision | undefined;
-    effectSize?: number | undefined;
-    hypothesisTestResult?: HypothesisTestResult | undefined;
-    id?: string | undefined;
-    xAttribute?: Attribute | undefined;
-    yAttribute?: Attribute | undefined;
-
-    constructor(data?: IRecommendedHistogram) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.histogramResult = data["HistogramResult"] ? HistogramResult.fromJS(data["HistogramResult"]) : <any>undefined;
-            if (data["SelectedBinIndices"] && data["SelectedBinIndices"].constructor === Array) {
-                this.selectedBinIndices = [];
-                for (let item of data["SelectedBinIndices"])
-                    this.selectedBinIndices.push(BinIndex.fromJS(item));
-            }
-            if (data["Selections"] && data["Selections"].constructor === Array) {
-                this.selections = [];
-                for (let item of data["Selections"])
-                    this.selections.push(Selection.fromJS(item));
-            }
-            this.pValue = data["PValue"];
-            this.significance = data["Significance"];
-            this.decision = data["Decision"] ? Decision.fromJS(data["Decision"]) : <any>undefined;
-            this.effectSize = data["EffectSize"];
-            this.hypothesisTestResult = data["HypothesisTestResult"] ? HypothesisTestResult.fromJS(data["HypothesisTestResult"]) : <any>undefined;
-            this.id = data["Id"];
-            this.xAttribute = data["XAttribute"] ? Attribute.fromJS(data["XAttribute"]) : <any>undefined;
-            this.yAttribute = data["YAttribute"] ? Attribute.fromJS(data["YAttribute"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): RecommendedHistogram {
-        data = typeof data === 'object' ? data : {};
-        let result = new RecommendedHistogram();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["HistogramResult"] = this.histogramResult ? this.histogramResult.toJSON() : <any>undefined;
-        if (this.selectedBinIndices && this.selectedBinIndices.constructor === Array) {
-            data["SelectedBinIndices"] = [];
-            for (let item of this.selectedBinIndices)
-                data["SelectedBinIndices"].push(item.toJSON());
-        }
-        if (this.selections && this.selections.constructor === Array) {
-            data["Selections"] = [];
-            for (let item of this.selections)
-                data["Selections"].push(item.toJSON());
-        }
-        data["PValue"] = this.pValue;
-        data["Significance"] = this.significance;
-        data["Decision"] = this.decision ? this.decision.toJSON() : <any>undefined;
-        data["EffectSize"] = this.effectSize;
-        data["HypothesisTestResult"] = this.hypothesisTestResult ? this.hypothesisTestResult.toJSON() : <any>undefined;
-        data["Id"] = this.id;
-        data["XAttribute"] = this.xAttribute ? this.xAttribute.toJSON() : <any>undefined;
-        data["YAttribute"] = this.yAttribute ? this.yAttribute.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface IRecommendedHistogram {
-    histogramResult?: HistogramResult | undefined;
-    selectedBinIndices?: BinIndex[] | undefined;
-    selections?: Selection[] | undefined;
-    pValue?: number | undefined;
-    significance?: boolean | undefined;
-    decision?: Decision | undefined;
-    effectSize?: number | undefined;
-    hypothesisTestResult?: HypothesisTestResult | undefined;
-    id?: string | undefined;
-    xAttribute?: Attribute | undefined;
-    yAttribute?: Attribute | undefined;
-}
-
-export class Selection implements ISelection {
-    statements?: Statement[] | undefined;
-    filterHistogramOperationReference?: IOperationReference | undefined;
-
-    constructor(data?: ISelection) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["Statements"] && data["Statements"].constructor === Array) {
-                this.statements = [];
-                for (let item of data["Statements"])
-                    this.statements.push(Statement.fromJS(item));
-            }
-            this.filterHistogramOperationReference = data["FilterHistogramOperationReference"] ? IOperationReference.fromJS(data["FilterHistogramOperationReference"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): Selection {
-        data = typeof data === 'object' ? data : {};
-        let result = new Selection();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.statements && this.statements.constructor === Array) {
-            data["Statements"] = [];
-            for (let item of this.statements)
-                data["Statements"].push(item.toJSON());
-        }
-        data["FilterHistogramOperationReference"] = this.filterHistogramOperationReference ? this.filterHistogramOperationReference.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface ISelection {
-    statements?: Statement[] | undefined;
-    filterHistogramOperationReference?: IOperationReference | undefined;
-}
-
-export class Statement implements IStatement {
-    attribute?: Attribute | undefined;
-    predicate?: Predicate | undefined;
-    value?: any | undefined;
-
-    constructor(data?: IStatement) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.attribute = data["Attribute"] ? Attribute.fromJS(data["Attribute"]) : <any>undefined;
-            this.predicate = data["Predicate"];
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): Statement {
-        data = typeof data === 'object' ? data : {};
-        let result = new Statement();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Attribute"] = this.attribute ? this.attribute.toJSON() : <any>undefined;
-        data["Predicate"] = this.predicate;
-        data["Value"] = this.value;
-        return data;
-    }
-}
-
-export interface IStatement {
-    attribute?: Attribute | undefined;
-    predicate?: Predicate | undefined;
-    value?: any | undefined;
-}
-
-export enum Predicate {
-    EQUALS = 0,
-    LIKE = 1,
-    GREATER_THAN = 2,
-    LESS_THAN = 3,
-    GREATER_THAN_EQUAL = 4,
-    LESS_THAN_EQUAL = 5,
-    STARTS_WITH = 6,
-    ENDS_WITH = 7,
-    CONTAINS = 8,
-}
-
-export abstract class IOperationReference implements IIOperationReference {
-    id?: string | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IIOperationReference) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "IOperationReference";
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-        }
-    }
-
-    static fromJS(data: any): IOperationReference {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "OperationReference") {
-            let result = new OperationReference();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'IOperationReference' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["Id"] = this.id;
-        return data;
-    }
-}
-
-export interface IIOperationReference {
-    id?: string | undefined;
-}
-
-export class OperationReference extends IOperationReference implements IOperationReference {
-    id?: string | undefined;
-
-    constructor(data?: IOperationReference) {
-        super(data);
-        this._discriminator = "OperationReference";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.id = data["Id"];
-        }
-    }
-
-    static fromJS(data: any): OperationReference {
-        data = typeof data === 'object' ? data : {};
-        let result = new OperationReference();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IOperationReference extends IIOperationReference {
-    id?: string | undefined;
-}
-
-export class Decision extends Result implements IDecision {
-    comparisonId?: ComparisonId | undefined;
-    riskControlType?: RiskControlType | undefined;
-    significance?: boolean | undefined;
-    pValue?: number | undefined;
-    lhs?: number | undefined;
-    significanceLevel?: number | undefined;
-    sampleSizeEstimate?: number | undefined;
-
-    constructor(data?: IDecision) {
-        super(data);
-        this._discriminator = "Decision";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.comparisonId = data["ComparisonId"] ? ComparisonId.fromJS(data["ComparisonId"]) : <any>undefined;
-            this.riskControlType = data["RiskControlType"];
-            this.significance = data["Significance"];
-            this.pValue = data["PValue"];
-            this.lhs = data["Lhs"];
-            this.significanceLevel = data["SignificanceLevel"];
-            this.sampleSizeEstimate = data["SampleSizeEstimate"];
-        }
-    }
-
-    static fromJS(data: any): Decision {
-        data = typeof data === 'object' ? data : {};
-        let result = new Decision();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ComparisonId"] = this.comparisonId ? this.comparisonId.toJSON() : <any>undefined;
-        data["RiskControlType"] = this.riskControlType;
-        data["Significance"] = this.significance;
-        data["PValue"] = this.pValue;
-        data["Lhs"] = this.lhs;
-        data["SignificanceLevel"] = this.significanceLevel;
-        data["SampleSizeEstimate"] = this.sampleSizeEstimate;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDecision extends IResult {
-    comparisonId?: ComparisonId | undefined;
-    riskControlType?: RiskControlType | undefined;
-    significance?: boolean | undefined;
-    pValue?: number | undefined;
-    lhs?: number | undefined;
-    significanceLevel?: number | undefined;
-    sampleSizeEstimate?: number | undefined;
-}
-
-export class ComparisonId implements IComparisonId {
-    value?: string | undefined;
-
-    constructor(data?: IComparisonId) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): ComparisonId {
-        data = typeof data === 'object' ? data : {};
-        let result = new ComparisonId();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        return data;
-    }
-}
-
-export interface IComparisonId {
-    value?: string | undefined;
-}
-
-export class OptimizerResult extends Result implements IOptimizerResult {
-    topKSolutions?: Solution[] | undefined;
-
-    constructor(data?: IOptimizerResult) {
-        super(data);
-        this._discriminator = "OptimizerResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["TopKSolutions"] && data["TopKSolutions"].constructor === Array) {
-                this.topKSolutions = [];
-                for (let item of data["TopKSolutions"])
-                    this.topKSolutions.push(Solution.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): OptimizerResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new OptimizerResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.topKSolutions && this.topKSolutions.constructor === Array) {
-            data["TopKSolutions"] = [];
-            for (let item of this.topKSolutions)
-                data["TopKSolutions"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IOptimizerResult extends IResult {
-    topKSolutions?: Solution[] | undefined;
-}
-
-export class Solution implements ISolution {
-    solutionId?: string | undefined;
-    stepDescriptions?: StepDescription[] | undefined;
-    pipelineDescription?: PipelineDescription | undefined;
-    score?: Score | undefined;
-    naiveScore?: Score | undefined;
-
-    constructor(data?: ISolution) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.solutionId = data["SolutionId"];
-            if (data["StepDescriptions"] && data["StepDescriptions"].constructor === Array) {
-                this.stepDescriptions = [];
-                for (let item of data["StepDescriptions"])
-                    this.stepDescriptions.push(StepDescription.fromJS(item));
-            }
-            this.pipelineDescription = data["PipelineDescription"] ? PipelineDescription.fromJS(data["PipelineDescription"]) : <any>undefined;
-            this.score = data["Score"] ? Score.fromJS(data["Score"]) : <any>undefined;
-            this.naiveScore = data["NaiveScore"] ? Score.fromJS(data["NaiveScore"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): Solution {
-        data = typeof data === 'object' ? data : {};
-        let result = new Solution();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SolutionId"] = this.solutionId;
-        if (this.stepDescriptions && this.stepDescriptions.constructor === Array) {
-            data["StepDescriptions"] = [];
-            for (let item of this.stepDescriptions)
-                data["StepDescriptions"].push(item.toJSON());
-        }
-        data["PipelineDescription"] = this.pipelineDescription ? this.pipelineDescription.toJSON() : <any>undefined;
-        data["Score"] = this.score ? this.score.toJSON() : <any>undefined;
-        data["NaiveScore"] = this.naiveScore ? this.naiveScore.toJSON() : <any>undefined;
-        return data;
-    }
-}
-
-export interface ISolution {
-    solutionId?: string | undefined;
-    stepDescriptions?: StepDescription[] | undefined;
-    pipelineDescription?: PipelineDescription | undefined;
-    score?: Score | undefined;
-    naiveScore?: Score | undefined;
-}
-
-export class StepDescription implements IStepDescription {
-
-    protected _discriminator: string;
-
-    constructor(data?: IStepDescription) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "StepDescription";
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): StepDescription {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "SubpipelineStepDescription") {
-            let result = new SubpipelineStepDescription();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PrimitiveStepDescription") {
-            let result = new PrimitiveStepDescription();
-            result.init(data);
-            return result;
-        }
-        let result = new StepDescription();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        return data;
-    }
-}
-
-export interface IStepDescription {
-}
-
-export class SubpipelineStepDescription extends StepDescription implements ISubpipelineStepDescription {
-    steps?: StepDescription[] | undefined;
-
-    constructor(data?: ISubpipelineStepDescription) {
-        super(data);
-        this._discriminator = "SubpipelineStepDescription";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Steps"] && data["Steps"].constructor === Array) {
-                this.steps = [];
-                for (let item of data["Steps"])
-                    this.steps.push(StepDescription.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): SubpipelineStepDescription {
-        data = typeof data === 'object' ? data : {};
-        let result = new SubpipelineStepDescription();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.steps && this.steps.constructor === Array) {
-            data["Steps"] = [];
-            for (let item of this.steps)
-                data["Steps"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISubpipelineStepDescription extends IStepDescription {
-    steps?: StepDescription[] | undefined;
-}
-
-export class PipelineDescription implements IPipelineDescription {
-    id?: string | undefined;
-    name?: string | undefined;
-    description?: string | undefined;
-    inputs?: PipelineDescriptionInput[] | undefined;
-    outputs?: PipelineDescriptionOutput[] | undefined;
-    steps?: PipelineDescriptionStep[] | undefined;
-
-    constructor(data?: IPipelineDescription) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-            this.name = data["Name"];
-            this.description = data["Description"];
-            if (data["Inputs"] && data["Inputs"].constructor === Array) {
-                this.inputs = [];
-                for (let item of data["Inputs"])
-                    this.inputs.push(PipelineDescriptionInput.fromJS(item));
-            }
-            if (data["Outputs"] && data["Outputs"].constructor === Array) {
-                this.outputs = [];
-                for (let item of data["Outputs"])
-                    this.outputs.push(PipelineDescriptionOutput.fromJS(item));
-            }
-            if (data["Steps"] && data["Steps"].constructor === Array) {
-                this.steps = [];
-                for (let item of data["Steps"])
-                    this.steps.push(PipelineDescriptionStep.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): PipelineDescription {
-        data = typeof data === 'object' ? data : {};
-        let result = new PipelineDescription();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        data["Name"] = this.name;
-        data["Description"] = this.description;
-        if (this.inputs && this.inputs.constructor === Array) {
-            data["Inputs"] = [];
-            for (let item of this.inputs)
-                data["Inputs"].push(item.toJSON());
-        }
-        if (this.outputs && this.outputs.constructor === Array) {
-            data["Outputs"] = [];
-            for (let item of this.outputs)
-                data["Outputs"].push(item.toJSON());
-        }
-        if (this.steps && this.steps.constructor === Array) {
-            data["Steps"] = [];
-            for (let item of this.steps)
-                data["Steps"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IPipelineDescription {
-    id?: string | undefined;
-    name?: string | undefined;
-    description?: string | undefined;
-    inputs?: PipelineDescriptionInput[] | undefined;
-    outputs?: PipelineDescriptionOutput[] | undefined;
-    steps?: PipelineDescriptionStep[] | undefined;
-}
-
-export class PipelineDescriptionInput implements IPipelineDescriptionInput {
-    name?: string | undefined;
-
-    constructor(data?: IPipelineDescriptionInput) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.name = data["Name"];
-        }
-    }
-
-    static fromJS(data: any): PipelineDescriptionInput {
-        data = typeof data === 'object' ? data : {};
-        let result = new PipelineDescriptionInput();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Name"] = this.name;
-        return data;
-    }
-}
-
-export interface IPipelineDescriptionInput {
-    name?: string | undefined;
-}
-
-export class PipelineDescriptionOutput implements IPipelineDescriptionOutput {
-    name?: string | undefined;
-    data?: string | undefined;
-
-    constructor(data?: IPipelineDescriptionOutput) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.name = data["Name"];
-            this.data = data["Data"];
-        }
-    }
-
-    static fromJS(data: any): PipelineDescriptionOutput {
-        data = typeof data === 'object' ? data : {};
-        let result = new PipelineDescriptionOutput();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Name"] = this.name;
-        data["Data"] = this.data;
-        return data;
-    }
-}
-
-export interface IPipelineDescriptionOutput {
-    name?: string | undefined;
-    data?: string | undefined;
-}
-
-export class PipelineDescriptionStep implements IPipelineDescriptionStep {
-    outputs?: StepOutput[] | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IPipelineDescriptionStep) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "PipelineDescriptionStep";
-    }
-
-    init(data?: any) {
-        if (data) {
-            if (data["Outputs"] && data["Outputs"].constructor === Array) {
-                this.outputs = [];
-                for (let item of data["Outputs"])
-                    this.outputs.push(StepOutput.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): PipelineDescriptionStep {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "PlaceholderPipelineDescriptionStep") {
-            let result = new PlaceholderPipelineDescriptionStep();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "SubpipelinePipelineDescriptionStep") {
-            let result = new SubpipelinePipelineDescriptionStep();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PrimitivePipelineDescriptionStep") {
-            let result = new PrimitivePipelineDescriptionStep();
-            result.init(data);
-            return result;
-        }
-        let result = new PipelineDescriptionStep();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        if (this.outputs && this.outputs.constructor === Array) {
-            data["Outputs"] = [];
-            for (let item of this.outputs)
-                data["Outputs"].push(item.toJSON());
-        }
-        return data;
-    }
-}
-
-export interface IPipelineDescriptionStep {
-    outputs?: StepOutput[] | undefined;
-}
-
-export class StepOutput implements IStepOutput {
-    id?: string | undefined;
-
-    constructor(data?: IStepOutput) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-        }
-    }
-
-    static fromJS(data: any): StepOutput {
-        data = typeof data === 'object' ? data : {};
-        let result = new StepOutput();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        return data;
-    }
-}
-
-export interface IStepOutput {
-    id?: string | undefined;
-}
-
-export class PlaceholderPipelineDescriptionStep extends PipelineDescriptionStep implements IPlaceholderPipelineDescriptionStep {
-    inputs?: StepInput[] | undefined;
-
-    constructor(data?: IPlaceholderPipelineDescriptionStep) {
-        super(data);
-        this._discriminator = "PlaceholderPipelineDescriptionStep";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Inputs"] && data["Inputs"].constructor === Array) {
-                this.inputs = [];
-                for (let item of data["Inputs"])
-                    this.inputs.push(StepInput.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): PlaceholderPipelineDescriptionStep {
-        data = typeof data === 'object' ? data : {};
-        let result = new PlaceholderPipelineDescriptionStep();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.inputs && this.inputs.constructor === Array) {
-            data["Inputs"] = [];
-            for (let item of this.inputs)
-                data["Inputs"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPlaceholderPipelineDescriptionStep extends IPipelineDescriptionStep {
-    inputs?: StepInput[] | undefined;
-}
-
-export class StepInput implements IStepInput {
-    data?: string | undefined;
-
-    constructor(data?: IStepInput) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.data = data["Data"];
-        }
-    }
-
-    static fromJS(data: any): StepInput {
-        data = typeof data === 'object' ? data : {};
-        let result = new StepInput();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Data"] = this.data;
-        return data;
-    }
-}
-
-export interface IStepInput {
-    data?: string | undefined;
-}
-
-export class SubpipelinePipelineDescriptionStep extends PipelineDescriptionStep implements ISubpipelinePipelineDescriptionStep {
-    pipelineDescription?: PipelineDescription | undefined;
-    inputs?: StepInput[] | undefined;
-
-    constructor(data?: ISubpipelinePipelineDescriptionStep) {
-        super(data);
-        this._discriminator = "SubpipelinePipelineDescriptionStep";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.pipelineDescription = data["PipelineDescription"] ? PipelineDescription.fromJS(data["PipelineDescription"]) : <any>undefined;
-            if (data["Inputs"] && data["Inputs"].constructor === Array) {
-                this.inputs = [];
-                for (let item of data["Inputs"])
-                    this.inputs.push(StepInput.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): SubpipelinePipelineDescriptionStep {
-        data = typeof data === 'object' ? data : {};
-        let result = new SubpipelinePipelineDescriptionStep();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["PipelineDescription"] = this.pipelineDescription ? this.pipelineDescription.toJSON() : <any>undefined;
-        if (this.inputs && this.inputs.constructor === Array) {
-            data["Inputs"] = [];
-            for (let item of this.inputs)
-                data["Inputs"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISubpipelinePipelineDescriptionStep extends IPipelineDescriptionStep {
-    pipelineDescription?: PipelineDescription | undefined;
-    inputs?: StepInput[] | undefined;
-}
-
-export class PrimitivePipelineDescriptionStep extends PipelineDescriptionStep implements IPrimitivePipelineDescriptionStep {
-    primitive?: Primitive | undefined;
-    arguments?: { [key: string]: PrimitiveStepArgument; } | undefined;
-    hyperparams?: { [key: string]: PrimitiveStepHyperparameter; } | undefined;
-
-    constructor(data?: IPrimitivePipelineDescriptionStep) {
-        super(data);
-        this._discriminator = "PrimitivePipelineDescriptionStep";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.primitive = data["Primitive"] ? Primitive.fromJS(data["Primitive"]) : <any>undefined;
-            if (data["Arguments"]) {
-                this.arguments = {};
-                for (let key in data["Arguments"]) {
-                    if (data["Arguments"].hasOwnProperty(key))
-                        this.arguments[key] = data["Arguments"][key] ? PrimitiveStepArgument.fromJS(data["Arguments"][key]) : new PrimitiveStepArgument();
-                }
-            }
-            if (data["Hyperparams"]) {
-                this.hyperparams = {};
-                for (let key in data["Hyperparams"]) {
-                    if (data["Hyperparams"].hasOwnProperty(key))
-                        this.hyperparams[key] = data["Hyperparams"][key] ? PrimitiveStepHyperparameter.fromJS(data["Hyperparams"][key]) : new PrimitiveStepHyperparameter();
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): PrimitivePipelineDescriptionStep {
-        data = typeof data === 'object' ? data : {};
-        let result = new PrimitivePipelineDescriptionStep();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Primitive"] = this.primitive ? this.primitive.toJSON() : <any>undefined;
-        if (this.arguments) {
-            data["Arguments"] = {};
-            for (let key in this.arguments) {
-                if (this.arguments.hasOwnProperty(key))
-                    data["Arguments"][key] = this.arguments[key];
-            }
-        }
-        if (this.hyperparams) {
-            data["Hyperparams"] = {};
-            for (let key in this.hyperparams) {
-                if (this.hyperparams.hasOwnProperty(key))
-                    data["Hyperparams"][key] = this.hyperparams[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPrimitivePipelineDescriptionStep extends IPipelineDescriptionStep {
-    primitive?: Primitive | undefined;
-    arguments?: { [key: string]: PrimitiveStepArgument; } | undefined;
-    hyperparams?: { [key: string]: PrimitiveStepHyperparameter; } | undefined;
-}
-
-export class Primitive implements IPrimitive {
-    id?: string | undefined;
-    version?: string | undefined;
-    pythonPath?: string | undefined;
-    name?: string | undefined;
-    digest?: string | undefined;
-
-    constructor(data?: IPrimitive) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.id = data["Id"];
-            this.version = data["Version"];
-            this.pythonPath = data["PythonPath"];
-            this.name = data["Name"];
-            this.digest = data["Digest"];
-        }
-    }
-
-    static fromJS(data: any): Primitive {
-        data = typeof data === 'object' ? data : {};
-        let result = new Primitive();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Id"] = this.id;
-        data["Version"] = this.version;
-        data["PythonPath"] = this.pythonPath;
-        data["Name"] = this.name;
-        data["Digest"] = this.digest;
-        return data;
-    }
-}
-
-export interface IPrimitive {
-    id?: string | undefined;
-    version?: string | undefined;
-    pythonPath?: string | undefined;
-    name?: string | undefined;
-    digest?: string | undefined;
-}
-
-export class PrimitiveStepHyperparameter implements IPrimitiveStepHyperparameter {
-
-    protected _discriminator: string;
-
-    constructor(data?: IPrimitiveStepHyperparameter) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "PrimitiveStepHyperparameter";
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): PrimitiveStepHyperparameter {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "PrimitiveStepArgument") {
-            let result = new PrimitiveStepArgument();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DataArguments") {
-            let result = new DataArguments();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PrimitiveArgument") {
-            let result = new PrimitiveArgument();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PrimitiveArguments") {
-            let result = new PrimitiveArguments();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ValueArgument") {
-            let result = new ValueArgument();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ContainerArgument") {
-            let result = new ContainerArgument();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DataArgument") {
-            let result = new DataArgument();
-            result.init(data);
-            return result;
-        }
-        let result = new PrimitiveStepHyperparameter();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        return data;
-    }
-}
-
-export interface IPrimitiveStepHyperparameter {
-}
-
-export class PrimitiveStepArgument extends PrimitiveStepHyperparameter implements IPrimitiveStepArgument {
-
-    protected _discriminator: string;
-
-    constructor(data?: IPrimitiveStepArgument) {
-        super(data);
-        this._discriminator = "PrimitiveStepArgument";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): PrimitiveStepArgument {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ContainerArgument") {
-            let result = new ContainerArgument();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DataArgument") {
-            let result = new DataArgument();
-            result.init(data);
-            return result;
-        }
-        let result = new PrimitiveStepArgument();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPrimitiveStepArgument extends IPrimitiveStepHyperparameter {
-}
-
-export class DataArguments extends PrimitiveStepHyperparameter implements IDataArguments {
-    data?: string[] | undefined;
-
-    constructor(data?: IDataArguments) {
-        super(data);
-        this._discriminator = "DataArguments";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Data"] && data["Data"].constructor === Array) {
-                this.data = [];
-                for (let item of data["Data"])
-                    this.data.push(item);
-            }
-        }
-    }
-
-    static fromJS(data: any): DataArguments {
-        data = typeof data === 'object' ? data : {};
-        let result = new DataArguments();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.data && this.data.constructor === Array) {
-            data["Data"] = [];
-            for (let item of this.data)
-                data["Data"].push(item);
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDataArguments extends IPrimitiveStepHyperparameter {
-    data?: string[] | undefined;
-}
-
-export class PrimitiveArgument extends PrimitiveStepHyperparameter implements IPrimitiveArgument {
-    data?: number | undefined;
-
-    constructor(data?: IPrimitiveArgument) {
-        super(data);
-        this._discriminator = "PrimitiveArgument";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.data = data["Data"];
-        }
-    }
-
-    static fromJS(data: any): PrimitiveArgument {
-        data = typeof data === 'object' ? data : {};
-        let result = new PrimitiveArgument();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Data"] = this.data;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPrimitiveArgument extends IPrimitiveStepHyperparameter {
-    data?: number | undefined;
-}
-
-export class PrimitiveArguments extends PrimitiveStepHyperparameter implements IPrimitiveArguments {
-    data?: number[] | undefined;
-
-    constructor(data?: IPrimitiveArguments) {
-        super(data);
-        this._discriminator = "PrimitiveArguments";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Data"] && data["Data"].constructor === Array) {
-                this.data = [];
-                for (let item of data["Data"])
-                    this.data.push(item);
-            }
-        }
-    }
-
-    static fromJS(data: any): PrimitiveArguments {
-        data = typeof data === 'object' ? data : {};
-        let result = new PrimitiveArguments();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.data && this.data.constructor === Array) {
-            data["Data"] = [];
-            for (let item of this.data)
-                data["Data"].push(item);
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPrimitiveArguments extends IPrimitiveStepHyperparameter {
-    data?: number[] | undefined;
-}
-
-export class ValueArgument extends PrimitiveStepHyperparameter implements IValueArgument {
-    data?: Value | undefined;
-
-    constructor(data?: IValueArgument) {
-        super(data);
-        this._discriminator = "ValueArgument";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.data = data["Data"] ? Value.fromJS(data["Data"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): ValueArgument {
-        data = typeof data === 'object' ? data : {};
-        let result = new ValueArgument();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Data"] = this.data ? this.data.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IValueArgument extends IPrimitiveStepHyperparameter {
-    data?: Value | undefined;
-}
-
-export abstract class Value implements IValue {
-
-    protected _discriminator: string;
-
-    constructor(data?: IValue) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-        this._discriminator = "Value";
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): Value {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "ErrorValue") {
-            let result = new ErrorValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DoubleValue") {
-            let result = new DoubleValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "LongValue") {
-            let result = new LongValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "BoolValue") {
-            let result = new BoolValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "StringValue") {
-            let result = new StringValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "DatasetUriValue") {
-            let result = new DatasetUriValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "CsvUriValue") {
-            let result = new CsvUriValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PickleUriValue") {
-            let result = new PickleUriValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PickleBlobValue") {
-            let result = new PickleBlobValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "PlasmaIdValue") {
-            let result = new PlasmaIdValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "BytesValue") {
-            let result = new BytesValue();
-            result.init(data);
-            return result;
-        }
-        if (data["discriminator"] === "ListValue") {
-            let result = new ListValue();
-            result.init(data);
-            return result;
-        }
-        throw new Error("The abstract class 'Value' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        return data;
-    }
-}
-
-export interface IValue {
-}
-
-export class ErrorValue extends Value implements IErrorValue {
-    message?: string | undefined;
-
-    constructor(data?: IErrorValue) {
-        super(data);
-        this._discriminator = "ErrorValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.message = data["Message"];
-        }
-    }
-
-    static fromJS(data: any): ErrorValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new ErrorValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Message"] = this.message;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IErrorValue extends IValue {
-    message?: string | undefined;
-}
-
-export class DoubleValue extends Value implements IDoubleValue {
-    value?: number | undefined;
-
-    constructor(data?: IDoubleValue) {
-        super(data);
-        this._discriminator = "DoubleValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): DoubleValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new DoubleValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDoubleValue extends IValue {
-    value?: number | undefined;
-}
-
-export class LongValue extends Value implements ILongValue {
-    value?: number | undefined;
-
-    constructor(data?: ILongValue) {
-        super(data);
-        this._discriminator = "LongValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): LongValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new LongValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ILongValue extends IValue {
-    value?: number | undefined;
-}
-
-export class BoolValue extends Value implements IBoolValue {
-    value?: boolean | undefined;
-
-    constructor(data?: IBoolValue) {
-        super(data);
-        this._discriminator = "BoolValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): BoolValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new BoolValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IBoolValue extends IValue {
-    value?: boolean | undefined;
-}
-
-export class StringValue extends Value implements IStringValue {
-    value?: string | undefined;
-
-    constructor(data?: IStringValue) {
-        super(data);
-        this._discriminator = "StringValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): StringValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new StringValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IStringValue extends IValue {
-    value?: string | undefined;
-}
-
-export class DatasetUriValue extends Value implements IDatasetUriValue {
-    value?: string | undefined;
-
-    constructor(data?: IDatasetUriValue) {
-        super(data);
-        this._discriminator = "DatasetUriValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): DatasetUriValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new DatasetUriValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDatasetUriValue extends IValue {
-    value?: string | undefined;
-}
-
-export class CsvUriValue extends Value implements ICsvUriValue {
-    value?: string | undefined;
-
-    constructor(data?: ICsvUriValue) {
-        super(data);
-        this._discriminator = "CsvUriValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): CsvUriValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new CsvUriValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICsvUriValue extends IValue {
-    value?: string | undefined;
-}
-
-export class PickleUriValue extends Value implements IPickleUriValue {
-    value?: string | undefined;
-
-    constructor(data?: IPickleUriValue) {
-        super(data);
-        this._discriminator = "PickleUriValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): PickleUriValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new PickleUriValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPickleUriValue extends IValue {
-    value?: string | undefined;
-}
-
-export class PickleBlobValue extends Value implements IPickleBlobValue {
-    value?: string | undefined;
-
-    constructor(data?: IPickleBlobValue) {
-        super(data);
-        this._discriminator = "PickleBlobValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): PickleBlobValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new PickleBlobValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPickleBlobValue extends IValue {
-    value?: string | undefined;
-}
-
-export class PlasmaIdValue extends Value implements IPlasmaIdValue {
-    value?: string | undefined;
-
-    constructor(data?: IPlasmaIdValue) {
-        super(data);
-        this._discriminator = "PlasmaIdValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): PlasmaIdValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new PlasmaIdValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPlasmaIdValue extends IValue {
-    value?: string | undefined;
-}
-
-export class BytesValue extends Value implements IBytesValue {
-    value?: string | undefined;
-
-    constructor(data?: IBytesValue) {
-        super(data);
-        this._discriminator = "BytesValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): BytesValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new BytesValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IBytesValue extends IValue {
-    value?: string | undefined;
-}
-
-export class ContainerArgument extends PrimitiveStepArgument implements IContainerArgument {
-    data?: string | undefined;
-
-    constructor(data?: IContainerArgument) {
-        super(data);
-        this._discriminator = "ContainerArgument";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.data = data["Data"];
-        }
-    }
-
-    static fromJS(data: any): ContainerArgument {
-        data = typeof data === 'object' ? data : {};
-        let result = new ContainerArgument();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Data"] = this.data;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IContainerArgument extends IPrimitiveStepArgument {
-    data?: string | undefined;
-}
-
-export class Score implements IScore {
-    metricType?: MetricType | undefined;
-    value?: number | undefined;
-
-    constructor(data?: IScore) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.metricType = data["MetricType"];
-            this.value = data["Value"];
-        }
-    }
-
-    static fromJS(data: any): Score {
-        data = typeof data === 'object' ? data : {};
-        let result = new Score();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["MetricType"] = this.metricType;
-        data["Value"] = this.value;
-        return data;
-    }
-}
-
-export interface IScore {
-    metricType?: MetricType | undefined;
-    value?: number | undefined;
-}
-
-export class ExampleResult extends Result implements IExampleResult {
-    resultValues?: { [key: string]: string; } | undefined;
-    message?: string | undefined;
-
-    constructor(data?: IExampleResult) {
-        super(data);
-        this._discriminator = "ExampleResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["ResultValues"]) {
-                this.resultValues = {};
-                for (let key in data["ResultValues"]) {
-                    if (data["ResultValues"].hasOwnProperty(key))
-                        this.resultValues[key] = data["ResultValues"][key];
-                }
-            }
-            this.message = data["Message"];
-        }
-    }
-
-    static fromJS(data: any): ExampleResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new ExampleResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.resultValues) {
-            data["ResultValues"] = {};
-            for (let key in this.resultValues) {
-                if (this.resultValues.hasOwnProperty(key))
-                    data["ResultValues"][key] = this.resultValues[key];
-            }
-        }
-        data["Message"] = this.message;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IExampleResult extends IResult {
-    resultValues?: { [key: string]: string; } | undefined;
-    message?: string | undefined;
-}
-
-export class NewModelOperationResult extends ModelOperationResult implements INewModelOperationResult {
-
-    constructor(data?: INewModelOperationResult) {
-        super(data);
-        this._discriminator = "NewModelOperationResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): NewModelOperationResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new NewModelOperationResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface INewModelOperationResult extends IModelOperationResult {
-}
-
-export class AddComparisonResult extends ModelOperationResult implements IAddComparisonResult {
-    comparisonId?: ComparisonId | undefined;
-
-    constructor(data?: IAddComparisonResult) {
-        super(data);
-        this._discriminator = "AddComparisonResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.comparisonId = data["ComparisonId"] ? ComparisonId.fromJS(data["ComparisonId"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): AddComparisonResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new AddComparisonResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ComparisonId"] = this.comparisonId ? this.comparisonId.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAddComparisonResult extends IModelOperationResult {
-    comparisonId?: ComparisonId | undefined;
-}
-
-export class GetModelStateResult extends ModelOperationResult implements IGetModelStateResult {
-    decisions?: Decision[] | undefined;
-    startingWealth?: number | undefined;
-    currentWealth?: number | undefined;
-
-    constructor(data?: IGetModelStateResult) {
-        super(data);
-        this._discriminator = "GetModelStateResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Decisions"] && data["Decisions"].constructor === Array) {
-                this.decisions = [];
-                for (let item of data["Decisions"])
-                    this.decisions.push(Decision.fromJS(item));
-            }
-            this.startingWealth = data["StartingWealth"];
-            this.currentWealth = data["CurrentWealth"];
-        }
-    }
-
-    static fromJS(data: any): GetModelStateResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new GetModelStateResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.decisions && this.decisions.constructor === Array) {
-            data["Decisions"] = [];
-            for (let item of this.decisions)
-                data["Decisions"].push(item.toJSON());
-        }
-        data["StartingWealth"] = this.startingWealth;
-        data["CurrentWealth"] = this.currentWealth;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IGetModelStateResult extends IModelOperationResult {
-    decisions?: Decision[] | undefined;
-    startingWealth?: number | undefined;
-    currentWealth?: number | undefined;
-}
-
-export class AggregateKey implements IAggregateKey {
-    aggregateParameterIndex?: number | undefined;
-    brushIndex?: number | undefined;
-
-    constructor(data?: IAggregateKey) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.aggregateParameterIndex = data["AggregateParameterIndex"];
-            this.brushIndex = data["BrushIndex"];
-        }
-    }
-
-    static fromJS(data: any): AggregateKey {
-        data = typeof data === 'object' ? data : {};
-        let result = new AggregateKey();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AggregateParameterIndex"] = this.aggregateParameterIndex;
-        data["BrushIndex"] = this.brushIndex;
-        return data;
-    }
-}
-
-export interface IAggregateKey {
-    aggregateParameterIndex?: number | undefined;
-    brushIndex?: number | undefined;
-}
-
-export abstract class IResult implements IIResult {
-
-    constructor(data?: IIResult) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): IResult {
-        data = typeof data === 'object' ? data : {};
-        throw new Error("The abstract class 'IResult' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        return data;
-    }
-}
-
-export interface IIResult {
-}
-
-export class DataArgument extends PrimitiveStepArgument implements IDataArgument {
-    data?: string | undefined;
-
-    constructor(data?: IDataArgument) {
-        super(data);
-        this._discriminator = "DataArgument";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.data = data["Data"];
-        }
-    }
-
-    static fromJS(data: any): DataArgument {
-        data = typeof data === 'object' ? data : {};
-        let result = new DataArgument();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Data"] = this.data;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IDataArgument extends IPrimitiveStepArgument {
-    data?: string | undefined;
-}
-
-export class ListValue extends Value implements IListValue {
-    items?: Value[] | undefined;
-
-    constructor(data?: IListValue) {
-        super(data);
-        this._discriminator = "ListValue";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Items"] && data["Items"].constructor === Array) {
-                this.items = [];
-                for (let item of data["Items"])
-                    this.items.push(Value.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): ListValue {
-        data = typeof data === 'object' ? data : {};
-        let result = new ListValue();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.items && this.items.constructor === Array) {
-            data["Items"] = [];
-            for (let item of this.items)
-                data["Items"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IListValue extends IValue {
-    items?: Value[] | undefined;
-}
-
-export class Metrics implements IMetrics {
-    averageAccuracy?: number | undefined;
-    averageRSquared?: number | undefined;
-    f1Macro?: number | undefined;
-
-    constructor(data?: IMetrics) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.averageAccuracy = data["AverageAccuracy"];
-            this.averageRSquared = data["AverageRSquared"];
-            this.f1Macro = data["F1Macro"];
-        }
-    }
-
-    static fromJS(data: any): Metrics {
-        data = typeof data === 'object' ? data : {};
-        let result = new Metrics();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AverageAccuracy"] = this.averageAccuracy;
-        data["AverageRSquared"] = this.averageRSquared;
-        data["F1Macro"] = this.f1Macro;
-        return data;
-    }
-}
-
-export interface IMetrics {
-    averageAccuracy?: number | undefined;
-    averageRSquared?: number | undefined;
-    f1Macro?: number | undefined;
-}
-
-export class FeatureImportanceOperationParameters extends DistOperationParameters implements IFeatureImportanceOperationParameters {
-    solutionId?: string | undefined;
-
-    constructor(data?: IFeatureImportanceOperationParameters) {
-        super(data);
-        this._discriminator = "FeatureImportanceOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.solutionId = data["SolutionId"];
-        }
-    }
-
-    static fromJS(data: any): FeatureImportanceOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new FeatureImportanceOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SolutionId"] = this.solutionId;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IFeatureImportanceOperationParameters extends IDistOperationParameters {
-    solutionId?: string | undefined;
-}
-
-export class FeatureImportanceResult extends Result implements IFeatureImportanceResult {
-    featureImportances?: { [key: string]: TupleOfDoubleAndDouble; } | undefined;
-
-    constructor(data?: IFeatureImportanceResult) {
-        super(data);
-        this._discriminator = "FeatureImportanceResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["FeatureImportances"]) {
-                this.featureImportances = {};
-                for (let key in data["FeatureImportances"]) {
-                    if (data["FeatureImportances"].hasOwnProperty(key))
-                        this.featureImportances[key] = data["FeatureImportances"][key] ? TupleOfDoubleAndDouble.fromJS(data["FeatureImportances"][key]) : new TupleOfDoubleAndDouble();
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): FeatureImportanceResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new FeatureImportanceResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.featureImportances) {
-            data["FeatureImportances"] = {};
-            for (let key in this.featureImportances) {
-                if (this.featureImportances.hasOwnProperty(key))
-                    data["FeatureImportances"][key] = this.featureImportances[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IFeatureImportanceResult extends IResult {
-    featureImportances?: { [key: string]: TupleOfDoubleAndDouble; } | undefined;
-}
-
-export class TupleOfDoubleAndDouble implements ITupleOfDoubleAndDouble {
-    item1?: number | undefined;
-    item2?: number | undefined;
-
-    constructor(data?: ITupleOfDoubleAndDouble) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.item1 = data["Item1"];
-            this.item2 = data["Item2"];
-        }
-    }
-
-    static fromJS(data: any): TupleOfDoubleAndDouble {
-        data = typeof data === 'object' ? data : {};
-        let result = new TupleOfDoubleAndDouble();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Item1"] = this.item1;
-        data["Item2"] = this.item2;
-        return data;
-    }
-}
-
-export interface ITupleOfDoubleAndDouble {
-    item1?: number | undefined;
-    item2?: number | undefined;
-}
-
-export class PrimitiveStepDescription extends StepDescription implements IPrimitiveStepDescription {
-    hyperparams?: { [key: string]: Value; } | undefined;
-
-    constructor(data?: IPrimitiveStepDescription) {
-        super(data);
-        this._discriminator = "PrimitiveStepDescription";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Hyperparams"]) {
-                this.hyperparams = {};
-                for (let key in data["Hyperparams"]) {
-                    if (data["Hyperparams"].hasOwnProperty(key))
-                        this.hyperparams[key] = data["Hyperparams"][key] ? Value.fromJS(data["Hyperparams"][key]) : <any>undefined;
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): PrimitiveStepDescription {
-        data = typeof data === 'object' ? data : {};
-        let result = new PrimitiveStepDescription();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.hyperparams) {
-            data["Hyperparams"] = {};
-            for (let key in this.hyperparams) {
-                if (this.hyperparams.hasOwnProperty(key))
-                    data["Hyperparams"][key] = this.hyperparams[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IPrimitiveStepDescription extends IStepDescription {
-    hyperparams?: { [key: string]: Value; } | undefined;
-}
-
-export enum ValueType {
-    VALUE_TYPE_UNDEFINED = 0,
-    RAW = 1,
-    DATASET_URI = 2,
-    CSV_URI = 3,
-    PICKLE_URI = 4,
-    PICKLE_BLOB = 5,
-    PLASMA_ID = 6,
-}
-
-export class DatamartSearchParameters implements IDatamartSearchParameters {
-    adapterName?: string | undefined;
-    queryJson?: string | undefined;
-
-    constructor(data?: IDatamartSearchParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.adapterName = data["AdapterName"];
-            this.queryJson = data["QueryJson"];
-        }
-    }
-
-    static fromJS(data: any): DatamartSearchParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new DatamartSearchParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AdapterName"] = this.adapterName;
-        data["QueryJson"] = this.queryJson;
-        return data;
-    }
-}
-
-export interface IDatamartSearchParameters {
-    adapterName?: string | undefined;
-    queryJson?: string | undefined;
-}
-
-export class DatamartAugmentParameters implements IDatamartAugmentParameters {
-    adapterName?: string | undefined;
-    augmentationJson?: string | undefined;
-    numberOfSamples?: number | undefined;
-    augmentedAdapterName?: string | undefined;
-
-    constructor(data?: IDatamartAugmentParameters) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.adapterName = data["AdapterName"];
-            this.augmentationJson = data["AugmentationJson"];
-            this.numberOfSamples = data["NumberOfSamples"];
-            this.augmentedAdapterName = data["AugmentedAdapterName"];
-        }
-    }
-
-    static fromJS(data: any): DatamartAugmentParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new DatamartAugmentParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["AdapterName"] = this.adapterName;
-        data["AugmentationJson"] = this.augmentationJson;
-        data["NumberOfSamples"] = this.numberOfSamples;
-        data["AugmentedAdapterName"] = this.augmentedAdapterName;
-        return data;
-    }
-}
-
-export interface IDatamartAugmentParameters {
-    adapterName?: string | undefined;
-    augmentationJson?: string | undefined;
-    numberOfSamples?: number | undefined;
-    augmentedAdapterName?: string | undefined;
-}
-
-export class RawDataResult extends DistResult implements IRawDataResult {
-    samples?: { [key: string]: any[]; } | undefined;
-    weightedWords?: { [key: string]: Word[]; } | undefined;
-
-    constructor(data?: IRawDataResult) {
-        super(data);
-        this._discriminator = "RawDataResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Samples"]) {
-                this.samples = {};
-                for (let key in data["Samples"]) {
-                    if (data["Samples"].hasOwnProperty(key))
-                        this.samples[key] = data["Samples"][key] !== undefined ? data["Samples"][key] : [];
-                }
-            }
-            if (data["WeightedWords"]) {
-                this.weightedWords = {};
-                for (let key in data["WeightedWords"]) {
-                    if (data["WeightedWords"].hasOwnProperty(key))
-                        this.weightedWords[key] = data["WeightedWords"][key] ? data["WeightedWords"][key].map((i: any) => Word.fromJS(i)) : [];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): RawDataResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new RawDataResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.samples) {
-            data["Samples"] = {};
-            for (let key in this.samples) {
-                if (this.samples.hasOwnProperty(key))
-                    data["Samples"][key] = this.samples[key];
-            }
-        }
-        if (this.weightedWords) {
-            data["WeightedWords"] = {};
-            for (let key in this.weightedWords) {
-                if (this.weightedWords.hasOwnProperty(key))
-                    data["WeightedWords"][key] = this.weightedWords[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRawDataResult extends IDistResult {
-    samples?: { [key: string]: any[]; } | undefined;
-    weightedWords?: { [key: string]: Word[]; } | undefined;
-}
-
-export class Word implements IWord {
-    text?: string | undefined;
-    occurrences?: number | undefined;
-    stem?: string | undefined;
-    isWordGroup?: boolean | undefined;
-
-    constructor(data?: IWord) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.text = data["Text"];
-            this.occurrences = data["Occurrences"];
-            this.stem = data["Stem"];
-            this.isWordGroup = data["IsWordGroup"];
-        }
-    }
-
-    static fromJS(data: any): Word {
-        data = typeof data === 'object' ? data : {};
-        let result = new Word();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Text"] = this.text;
-        data["Occurrences"] = this.occurrences;
-        data["Stem"] = this.stem;
-        data["IsWordGroup"] = this.isWordGroup;
-        return data;
-    }
-}
-
-export interface IWord {
-    text?: string | undefined;
-    occurrences?: number | undefined;
-    stem?: string | undefined;
-    isWordGroup?: boolean | undefined;
-}
-
-export class SampleOperationParameters extends DistOperationParameters implements ISampleOperationParameters {
-    numSamples?: number | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    brushes?: string[] | undefined;
-
-    constructor(data?: ISampleOperationParameters) {
-        super(data);
-        this._discriminator = "SampleOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.numSamples = data["NumSamples"];
-            if (data["AttributeParameters"] && data["AttributeParameters"].constructor === Array) {
-                this.attributeParameters = [];
-                for (let item of data["AttributeParameters"])
-                    this.attributeParameters.push(AttributeParameters.fromJS(item));
-            }
-            if (data["Brushes"] && data["Brushes"].constructor === Array) {
-                this.brushes = [];
-                for (let item of data["Brushes"])
-                    this.brushes.push(item);
-            }
-        }
-    }
-
-    static fromJS(data: any): SampleOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new SampleOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["NumSamples"] = this.numSamples;
-        if (this.attributeParameters && this.attributeParameters.constructor === Array) {
-            data["AttributeParameters"] = [];
-            for (let item of this.attributeParameters)
-                data["AttributeParameters"].push(item.toJSON());
-        }
-        if (this.brushes && this.brushes.constructor === Array) {
-            data["Brushes"] = [];
-            for (let item of this.brushes)
-                data["Brushes"].push(item);
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISampleOperationParameters extends IDistOperationParameters {
-    numSamples?: number | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    brushes?: string[] | undefined;
-}
-
-export class SampleResult extends DistResult implements ISampleResult {
-    samples?: { [key: string]: { [key: string]: number; }; } | undefined;
-    isTruncated?: boolean | undefined;
-
-    constructor(data?: ISampleResult) {
-        super(data);
-        this._discriminator = "SampleResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Samples"]) {
-                this.samples = {};
-                for (let key in data["Samples"]) {
-                    if (data["Samples"].hasOwnProperty(key))
-                        this.samples[key] = data["Samples"][key] !== undefined ? data["Samples"][key] : {};
-                }
-            }
-            this.isTruncated = data["IsTruncated"];
-        }
-    }
-
-    static fromJS(data: any): SampleResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new SampleResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.samples) {
-            data["Samples"] = {};
-            for (let key in this.samples) {
-                if (this.samples.hasOwnProperty(key))
-                    data["Samples"][key] = this.samples[key];
-            }
-        }
-        data["IsTruncated"] = this.isTruncated;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ISampleResult extends IDistResult {
-    samples?: { [key: string]: { [key: string]: number; }; } | undefined;
-    isTruncated?: boolean | undefined;
-}
-
-export class ResultParameters extends UniqueJson implements IResultParameters {
-    operationReference?: IOperationReference | undefined;
-    stopOperation?: boolean | undefined;
-
-    protected _discriminator: string;
-
-    constructor(data?: IResultParameters) {
-        super(data);
-        this._discriminator = "ResultParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.operationReference = data["OperationReference"] ? IOperationReference.fromJS(data["OperationReference"]) : <any>undefined;
-            this.stopOperation = data["StopOperation"];
-        }
-    }
-
-    static fromJS(data: any): ResultParameters {
-        data = typeof data === 'object' ? data : {};
-        if (data["discriminator"] === "RecommenderResultParameters") {
-            let result = new RecommenderResultParameters();
-            result.init(data);
-            return result;
-        }
-        let result = new ResultParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["discriminator"] = this._discriminator;
-        data["OperationReference"] = this.operationReference ? this.operationReference.toJSON() : <any>undefined;
-        data["StopOperation"] = this.stopOperation;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IResultParameters extends IUniqueJson {
-    operationReference?: IOperationReference | undefined;
-    stopOperation?: boolean | undefined;
-}
-
-export class RecommenderResultParameters extends ResultParameters implements IRecommenderResultParameters {
-    from?: number | undefined;
-    to?: number | undefined;
-    pValueSorting?: Sorting | undefined;
-    effectSizeFilter?: EffectSize | undefined;
-
-    constructor(data?: IRecommenderResultParameters) {
-        super(data);
-        this._discriminator = "RecommenderResultParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.from = data["From"];
-            this.to = data["To"];
-            this.pValueSorting = data["PValueSorting"];
-            this.effectSizeFilter = data["EffectSizeFilter"];
-        }
-    }
-
-    static fromJS(data: any): RecommenderResultParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new RecommenderResultParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["From"] = this.from;
-        data["To"] = this.to;
-        data["PValueSorting"] = this.pValueSorting;
-        data["EffectSizeFilter"] = this.effectSizeFilter;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRecommenderResultParameters extends IResultParameters {
-    from?: number | undefined;
-    to?: number | undefined;
-    pValueSorting?: Sorting | undefined;
-    effectSizeFilter?: EffectSize | undefined;
-}
-
-export enum Sorting {
-    Ascending = "Ascending",
-    Descending = "Descending",
-}
-
-export class AddComparisonParameters extends ModelOperationParameters implements IAddComparisonParameters {
-    modelId?: ModelId | undefined;
-    comparisonOrder?: number | undefined;
-    childOperationParameters?: OperationParameters[] | undefined;
-    isCachable?: boolean | undefined;
-
-    constructor(data?: IAddComparisonParameters) {
-        super(data);
-        this._discriminator = "AddComparisonParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.modelId = data["ModelId"] ? ModelId.fromJS(data["ModelId"]) : <any>undefined;
-            this.comparisonOrder = data["ComparisonOrder"];
-            if (data["ChildOperationParameters"] && data["ChildOperationParameters"].constructor === Array) {
-                this.childOperationParameters = [];
-                for (let item of data["ChildOperationParameters"])
-                    this.childOperationParameters.push(OperationParameters.fromJS(item));
-            }
-            this.isCachable = data["IsCachable"];
-        }
-    }
-
-    static fromJS(data: any): AddComparisonParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new AddComparisonParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ModelId"] = this.modelId ? this.modelId.toJSON() : <any>undefined;
-        data["ComparisonOrder"] = this.comparisonOrder;
-        if (this.childOperationParameters && this.childOperationParameters.constructor === Array) {
-            data["ChildOperationParameters"] = [];
-            for (let item of this.childOperationParameters)
-                data["ChildOperationParameters"].push(item.toJSON());
-        }
-        data["IsCachable"] = this.isCachable;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IAddComparisonParameters extends IModelOperationParameters {
-    modelId?: ModelId | undefined;
-    comparisonOrder?: number | undefined;
-    childOperationParameters?: OperationParameters[] | undefined;
-    isCachable?: boolean | undefined;
-}
-
-export class CDFResult extends DistResult implements ICDFResult {
-    cDF?: { [key: string]: number; } | undefined;
-
-    constructor(data?: ICDFResult) {
-        super(data);
-        this._discriminator = "CDFResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["CDF"]) {
-                this.cDF = {};
-                for (let key in data["CDF"]) {
-                    if (data["CDF"].hasOwnProperty(key))
-                        this.cDF[key] = data["CDF"][key];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): CDFResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new CDFResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.cDF) {
-            data["CDF"] = {};
-            for (let key in this.cDF) {
-                if (this.cDF.hasOwnProperty(key))
-                    data["CDF"][key] = this.cDF[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICDFResult extends IDistResult {
-    cDF?: { [key: string]: number; } | undefined;
-}
-
-export class ChiSquaredTestResult extends HypothesisTestResult implements IChiSquaredTestResult {
-    hs_aligned?: TupleOfDoubleAndDouble[] | undefined;
-
-    constructor(data?: IChiSquaredTestResult) {
-        super(data);
-        this._discriminator = "ChiSquaredTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["hs_aligned"] && data["hs_aligned"].constructor === Array) {
-                this.hs_aligned = [];
-                for (let item of data["hs_aligned"])
-                    this.hs_aligned.push(TupleOfDoubleAndDouble.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): ChiSquaredTestResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new ChiSquaredTestResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.hs_aligned && this.hs_aligned.constructor === Array) {
-            data["hs_aligned"] = [];
-            for (let item of this.hs_aligned)
-                data["hs_aligned"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IChiSquaredTestResult extends IHypothesisTestResult {
-    hs_aligned?: TupleOfDoubleAndDouble[] | undefined;
-}
-
-export class CorrelationTestResult extends HypothesisTestResult implements ICorrelationTestResult {
-    degreeOfFreedom?: number | undefined;
-    sampleCorrelationCoefficient?: number | undefined;
-    distResult?: EmpiricalDistResult | undefined;
-
-    constructor(data?: ICorrelationTestResult) {
-        super(data);
-        this._discriminator = "CorrelationTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.degreeOfFreedom = data["DegreeOfFreedom"];
-            this.sampleCorrelationCoefficient = data["SampleCorrelationCoefficient"];
-            this.distResult = data["DistResult"] ? EmpiricalDistResult.fromJS(data["DistResult"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): CorrelationTestResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new CorrelationTestResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["DegreeOfFreedom"] = this.degreeOfFreedom;
-        data["SampleCorrelationCoefficient"] = this.sampleCorrelationCoefficient;
-        data["DistResult"] = this.distResult ? this.distResult.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ICorrelationTestResult extends IHypothesisTestResult {
-    degreeOfFreedom?: number | undefined;
-    sampleCorrelationCoefficient?: number | undefined;
-    distResult?: EmpiricalDistResult | undefined;
-}
-
-export class EmpiricalDistResult extends DistResult implements IEmpiricalDistResult {
-    marginals?: AttributeParameters[] | undefined;
-    marginalDistParameters?: { [key: string]: DistParameter; } | undefined;
-    jointDistParameter?: JointDistParameter | undefined;
-
-    constructor(data?: IEmpiricalDistResult) {
-        super(data);
-        this._discriminator = "EmpiricalDistResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["Marginals"] && data["Marginals"].constructor === Array) {
-                this.marginals = [];
-                for (let item of data["Marginals"])
-                    this.marginals.push(AttributeParameters.fromJS(item));
-            }
-            if (data["MarginalDistParameters"]) {
-                this.marginalDistParameters = {};
-                for (let key in data["MarginalDistParameters"]) {
-                    if (data["MarginalDistParameters"].hasOwnProperty(key))
-                        this.marginalDistParameters[key] = data["MarginalDistParameters"][key] ? DistParameter.fromJS(data["MarginalDistParameters"][key]) : new DistParameter();
-                }
-            }
-            this.jointDistParameter = data["JointDistParameter"] ? JointDistParameter.fromJS(data["JointDistParameter"]) : <any>undefined;
-        }
-    }
-
-    static fromJS(data: any): EmpiricalDistResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new EmpiricalDistResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.marginals && this.marginals.constructor === Array) {
-            data["Marginals"] = [];
-            for (let item of this.marginals)
-                data["Marginals"].push(item.toJSON());
-        }
-        if (this.marginalDistParameters) {
-            data["MarginalDistParameters"] = {};
-            for (let key in this.marginalDistParameters) {
-                if (this.marginalDistParameters.hasOwnProperty(key))
-                    data["MarginalDistParameters"][key] = this.marginalDistParameters[key];
-            }
-        }
-        data["JointDistParameter"] = this.jointDistParameter ? this.jointDistParameter.toJSON() : <any>undefined;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IEmpiricalDistResult extends IDistResult {
-    marginals?: AttributeParameters[] | undefined;
-    marginalDistParameters?: { [key: string]: DistParameter; } | undefined;
-    jointDistParameter?: JointDistParameter | undefined;
-}
-
-export class DistParameter implements IDistParameter {
-    mean?: number | undefined;
-    moment2?: number | undefined;
-    variance?: number | undefined;
-    varianceEstimate?: number | undefined;
-    min?: number | undefined;
-    max?: number | undefined;
-
-    constructor(data?: IDistParameter) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.mean = data["Mean"];
-            this.moment2 = data["Moment2"];
-            this.variance = data["Variance"];
-            this.varianceEstimate = data["VarianceEstimate"];
-            this.min = data["Min"];
-            this.max = data["Max"];
-        }
-    }
-
-    static fromJS(data: any): DistParameter {
-        data = typeof data === 'object' ? data : {};
-        let result = new DistParameter();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Mean"] = this.mean;
-        data["Moment2"] = this.moment2;
-        data["Variance"] = this.variance;
-        data["VarianceEstimate"] = this.varianceEstimate;
-        data["Min"] = this.min;
-        data["Max"] = this.max;
-        return data;
-    }
-}
-
-export interface IDistParameter {
-    mean?: number | undefined;
-    moment2?: number | undefined;
-    variance?: number | undefined;
-    varianceEstimate?: number | undefined;
-    min?: number | undefined;
-    max?: number | undefined;
-}
-
-export class JointDistParameter implements IJointDistParameter {
-    jointDist?: DistParameter | undefined;
-    covariance?: number | undefined;
-
-    constructor(data?: IJointDistParameter) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.jointDist = data["JointDist"] ? DistParameter.fromJS(data["JointDist"]) : <any>undefined;
-            this.covariance = data["Covariance"];
-        }
-    }
-
-    static fromJS(data: any): JointDistParameter {
-        data = typeof data === 'object' ? data : {};
-        let result = new JointDistParameter();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["JointDist"] = this.jointDist ? this.jointDist.toJSON() : <any>undefined;
-        data["Covariance"] = this.covariance;
-        return data;
-    }
-}
-
-export interface IJointDistParameter {
-    jointDist?: DistParameter | undefined;
-    covariance?: number | undefined;
-}
-
-export enum DistributionType {
-    Continuous = 0,
-    Discrete = 1,
-}
-
-export abstract class DistributionTypeExtension implements IDistributionTypeExtension {
-
-    constructor(data?: IDistributionTypeExtension) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): DistributionTypeExtension {
-        data = typeof data === 'object' ? data : {};
-        throw new Error("The abstract class 'DistributionTypeExtension' cannot be instantiated.");
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        return data;
-    }
-}
-
-export interface IDistributionTypeExtension {
-}
-
-export class GetModelStateParameters extends ModelOperationParameters implements IGetModelStateParameters {
-    modelId?: ModelId | undefined;
-    comparisonIds?: ComparisonId[] | undefined;
-    riskControlType?: RiskControlType | undefined;
-
-    constructor(data?: IGetModelStateParameters) {
-        super(data);
-        this._discriminator = "GetModelStateParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.modelId = data["ModelId"] ? ModelId.fromJS(data["ModelId"]) : <any>undefined;
-            if (data["ComparisonIds"] && data["ComparisonIds"].constructor === Array) {
-                this.comparisonIds = [];
-                for (let item of data["ComparisonIds"])
-                    this.comparisonIds.push(ComparisonId.fromJS(item));
-            }
-            this.riskControlType = data["RiskControlType"];
-        }
-    }
-
-    static fromJS(data: any): GetModelStateParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new GetModelStateParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ModelId"] = this.modelId ? this.modelId.toJSON() : <any>undefined;
-        if (this.comparisonIds && this.comparisonIds.constructor === Array) {
-            data["ComparisonIds"] = [];
-            for (let item of this.comparisonIds)
-                data["ComparisonIds"].push(item.toJSON());
-        }
-        data["RiskControlType"] = this.riskControlType;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IGetModelStateParameters extends IModelOperationParameters {
-    modelId?: ModelId | undefined;
-    comparisonIds?: ComparisonId[] | undefined;
-    riskControlType?: RiskControlType | undefined;
-}
-
-export class KSTestResult extends HypothesisTestResult implements IKSTestResult {
-
-    constructor(data?: IKSTestResult) {
-        super(data);
-        this._discriminator = "KSTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): KSTestResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new KSTestResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IKSTestResult extends IHypothesisTestResult {
-}
-
-export class ModelWealthParameters extends UniqueJson implements IModelWealthParameters {
-    modelId?: ModelId | undefined;
-    riskControlType?: RiskControlType | undefined;
-
-    constructor(data?: IModelWealthParameters) {
-        super(data);
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.modelId = data["ModelId"] ? ModelId.fromJS(data["ModelId"]) : <any>undefined;
-            this.riskControlType = data["RiskControlType"];
-        }
-    }
-
-    static fromJS(data: any): ModelWealthParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new ModelWealthParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["ModelId"] = this.modelId ? this.modelId.toJSON() : <any>undefined;
-        data["RiskControlType"] = this.riskControlType;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IModelWealthParameters extends IUniqueJson {
-    modelId?: ModelId | undefined;
-    riskControlType?: RiskControlType | undefined;
-}
-
-export class RootMeanSquareTestResult extends HypothesisTestResult implements IRootMeanSquareTestResult {
-    simulationCount?: number | undefined;
-    extremeSimulationCount?: number | undefined;
-
-    constructor(data?: IRootMeanSquareTestResult) {
-        super(data);
-        this._discriminator = "RootMeanSquareTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.simulationCount = data["SimulationCount"];
-            this.extremeSimulationCount = data["ExtremeSimulationCount"];
-        }
-    }
-
-    static fromJS(data: any): RootMeanSquareTestResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new RootMeanSquareTestResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["SimulationCount"] = this.simulationCount;
-        data["ExtremeSimulationCount"] = this.extremeSimulationCount;
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IRootMeanSquareTestResult extends IHypothesisTestResult {
-    simulationCount?: number | undefined;
-    extremeSimulationCount?: number | undefined;
-}
-
-export class TTestResult extends HypothesisTestResult implements ITTestResult {
-    degreeOfFreedom?: number | undefined;
-    distResults?: EmpiricalDistResult[] | undefined;
-
-    constructor(data?: ITTestResult) {
-        super(data);
-        this._discriminator = "TTestResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.degreeOfFreedom = data["DegreeOfFreedom"];
-            if (data["DistResults"] && data["DistResults"].constructor === Array) {
-                this.distResults = [];
-                for (let item of data["DistResults"])
-                    this.distResults.push(EmpiricalDistResult.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): TTestResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new TTestResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["DegreeOfFreedom"] = this.degreeOfFreedom;
-        if (this.distResults && this.distResults.constructor === Array) {
-            data["DistResults"] = [];
-            for (let item of this.distResults)
-                data["DistResults"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface ITTestResult extends IHypothesisTestResult {
-    degreeOfFreedom?: number | undefined;
-    distResults?: EmpiricalDistResult[] | undefined;
-}
-
-export enum Sorting2 {
-    Ascending = 0,
-    Descending = 1,
-}
-
-export class BinLabel implements IBinLabel {
-    value?: number | undefined;
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    label?: string | undefined;
-
-    constructor(data?: IBinLabel) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.value = data["Value"];
-            this.minValue = data["MinValue"];
-            this.maxValue = data["MaxValue"];
-            this.label = data["Label"];
-        }
-    }
-
-    static fromJS(data: any): BinLabel {
-        data = typeof data === 'object' ? data : {};
-        let result = new BinLabel();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        data["MinValue"] = this.minValue;
-        data["MaxValue"] = this.maxValue;
-        data["Label"] = this.label;
-        return data;
-    }
-}
-
-export interface IBinLabel {
-    value?: number | undefined;
-    minValue?: number | undefined;
-    maxValue?: number | undefined;
-    label?: string | undefined;
-}
-
-export class PreProcessedString implements IPreProcessedString {
-    value?: string | undefined;
-    id?: number | undefined;
-    stringLookup?: { [key: string]: number; } | undefined;
-    indexLookup?: { [key: string]: string; } | undefined;
-
-    constructor(data?: IPreProcessedString) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.value = data["Value"];
-            this.id = data["Id"];
-            if (data["StringLookup"]) {
-                this.stringLookup = {};
-                for (let key in data["StringLookup"]) {
-                    if (data["StringLookup"].hasOwnProperty(key))
-                        this.stringLookup[key] = data["StringLookup"][key];
-                }
-            }
-            if (data["IndexLookup"]) {
-                this.indexLookup = {};
-                for (let key in data["IndexLookup"]) {
-                    if (data["IndexLookup"].hasOwnProperty(key))
-                        this.indexLookup[key] = data["IndexLookup"][key];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): PreProcessedString {
-        data = typeof data === 'object' ? data : {};
-        let result = new PreProcessedString();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Value"] = this.value;
-        data["Id"] = this.id;
-        if (this.stringLookup) {
-            data["StringLookup"] = {};
-            for (let key in this.stringLookup) {
-                if (this.stringLookup.hasOwnProperty(key))
-                    data["StringLookup"][key] = this.stringLookup[key];
-            }
-        }
-        if (this.indexLookup) {
-            data["IndexLookup"] = {};
-            for (let key in this.indexLookup) {
-                if (this.indexLookup.hasOwnProperty(key))
-                    data["IndexLookup"][key] = this.indexLookup[key];
-            }
-        }
-        return data;
-    }
-}
-
-export interface IPreProcessedString {
-    value?: string | undefined;
-    id?: number | undefined;
-    stringLookup?: { [key: string]: number; } | undefined;
-    indexLookup?: { [key: string]: string; } | undefined;
-}
-
-export class BitSet implements IBitSet {
-    length?: number | undefined;
-    size?: number | undefined;
-
-    constructor(data?: IBitSet) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-            this.length = data["Length"];
-            this.size = data["Size"];
-        }
-    }
-
-    static fromJS(data: any): BitSet {
-        data = typeof data === 'object' ? data : {};
-        let result = new BitSet();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Length"] = this.length;
-        data["Size"] = this.size;
-        return data;
-    }
-}
-
-export interface IBitSet {
-    length?: number | undefined;
-    size?: number | undefined;
-}
-
-export class DateTimeUtil implements IDateTimeUtil {
-
-    constructor(data?: IDateTimeUtil) {
-        if (data) {
-            for (var property in data) {
-                if (data.hasOwnProperty(property))
-                    (<any>this)[property] = (<any>data)[property];
-            }
-        }
-    }
-
-    init(data?: any) {
-        if (data) {
-        }
-    }
-
-    static fromJS(data: any): DateTimeUtil {
-        data = typeof data === 'object' ? data : {};
-        let result = new DateTimeUtil();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        return data;
-    }
-}
-
-export interface IDateTimeUtil {
-}
-
-export class FrequentItemsetOperationParameters extends DistOperationParameters implements IFrequentItemsetOperationParameters {
-    filter?: string | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    attributeCodeParameters?: AttributeCaclculatedParameters[] | undefined;
-
-    constructor(data?: IFrequentItemsetOperationParameters) {
-        super(data);
-        this._discriminator = "FrequentItemsetOperationParameters";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            this.filter = data["Filter"];
-            if (data["AttributeParameters"] && data["AttributeParameters"].constructor === Array) {
-                this.attributeParameters = [];
-                for (let item of data["AttributeParameters"])
-                    this.attributeParameters.push(AttributeParameters.fromJS(item));
-            }
-            if (data["AttributeCodeParameters"] && data["AttributeCodeParameters"].constructor === Array) {
-                this.attributeCodeParameters = [];
-                for (let item of data["AttributeCodeParameters"])
-                    this.attributeCodeParameters.push(AttributeCaclculatedParameters.fromJS(item));
-            }
-        }
-    }
-
-    static fromJS(data: any): FrequentItemsetOperationParameters {
-        data = typeof data === 'object' ? data : {};
-        let result = new FrequentItemsetOperationParameters();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        data["Filter"] = this.filter;
-        if (this.attributeParameters && this.attributeParameters.constructor === Array) {
-            data["AttributeParameters"] = [];
-            for (let item of this.attributeParameters)
-                data["AttributeParameters"].push(item.toJSON());
-        }
-        if (this.attributeCodeParameters && this.attributeCodeParameters.constructor === Array) {
-            data["AttributeCodeParameters"] = [];
-            for (let item of this.attributeCodeParameters)
-                data["AttributeCodeParameters"].push(item.toJSON());
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IFrequentItemsetOperationParameters extends IDistOperationParameters {
-    filter?: string | undefined;
-    attributeParameters?: AttributeParameters[] | undefined;
-    attributeCodeParameters?: AttributeCaclculatedParameters[] | undefined;
-}
-
-export class FrequentItemsetResult extends Result implements IFrequentItemsetResult {
-    frequentItems?: { [key: string]: number; } | undefined;
-
-    constructor(data?: IFrequentItemsetResult) {
-        super(data);
-        this._discriminator = "FrequentItemsetResult";
-    }
-
-    init(data?: any) {
-        super.init(data);
-        if (data) {
-            if (data["FrequentItems"]) {
-                this.frequentItems = {};
-                for (let key in data["FrequentItems"]) {
-                    if (data["FrequentItems"].hasOwnProperty(key))
-                        this.frequentItems[key] = data["FrequentItems"][key];
-                }
-            }
-        }
-    }
-
-    static fromJS(data: any): FrequentItemsetResult {
-        data = typeof data === 'object' ? data : {};
-        let result = new FrequentItemsetResult();
-        result.init(data);
-        return result;
-    }
-
-    toJSON(data?: any) {
-        data = typeof data === 'object' ? data : {};
-        if (this.frequentItems) {
-            data["FrequentItems"] = {};
-            for (let key in this.frequentItems) {
-                if (this.frequentItems.hasOwnProperty(key))
-                    data["FrequentItems"][key] = this.frequentItems[key];
-            }
-        }
-        super.toJSON(data);
-        return data;
-    }
-}
-
-export interface IFrequentItemsetResult extends IResult {
-    frequentItems?: { [key: string]: number; } | undefined;
-}
-
diff --git a/src/client/northstar/operations/BaseOperation.ts b/src/client/northstar/operations/BaseOperation.ts
deleted file mode 100644
index 013f2244e..000000000
--- a/src/client/northstar/operations/BaseOperation.ts
+++ /dev/null
@@ -1,162 +0,0 @@
-import { FilterModel } from '../core/filter/FilterModel';
-import { ErrorResult, Exception, OperationParameters, OperationReference, Result, ResultParameters } from '../model/idea/idea';
-import { action, computed, observable } from "mobx";
-import { Gateway } from '../manager/Gateway';
-
-export abstract class BaseOperation {
-    private _interactionTimeoutId: number = 0;
-    private static _currentOperations: Map<number, PollPromise> = new Map<number, PollPromise>();
-    //public InteractionTimeout: EventDelegate<InteractionTimeoutEventArgs> = new EventDelegate<InteractionTimeoutEventArgs>();
-
-    @observable public Error: string = "";
-    @observable public OverridingFilters: FilterModel[] = [];
-    //@observable 
-    @observable public Result?: Result = undefined;
-    @observable public ComputationStarted: boolean = false;
-    public OperationReference?: OperationReference = undefined;
-
-    private static _nextId = 0;
-    public RequestSalt: string = "";
-    public Id: number;
-
-    constructor() {
-        this.Id = BaseOperation._nextId++;
-    }
-
-    @computed
-    public get FilterString(): string {
-        return "";
-    }
-
-
-    @action
-    public SetResult(result: Result): void {
-        this.Result = result;
-    }
-
-    public async Update(): Promise<void> {
-
-        try {
-            if (BaseOperation._currentOperations.has(this.Id)) {
-                BaseOperation._currentOperations.get(this.Id)!.Cancel();
-                if (this.OperationReference) {
-                    Gateway.Instance.PauseOperation(this.OperationReference.toJSON());
-                }
-            }
-
-            const operationParameters = this.CreateOperationParameters();
-            if (this.Result) {
-                this.Result.progress = 0;
-            } // bcz: used to set Result to undefined, but that causes the display to blink
-            this.Error = "";
-            const salt = Math.random().toString();
-            this.RequestSalt = salt;
-
-            if (!operationParameters) {
-                this.ComputationStarted = false;
-                return;
-            }
-
-            this.ComputationStarted = true;
-            //let start = performance.now();
-            const promise = Gateway.Instance.StartOperation(operationParameters.toJSON());
-            promise.catch(err => {
-                action(() => {
-                    this.Error = err;
-                    console.error(err);
-                });
-            });
-            const operationReference = await promise;
-
-
-            if (operationReference) {
-                this.OperationReference = operationReference;
-
-                const resultParameters = new ResultParameters();
-                resultParameters.operationReference = operationReference;
-
-                const pollPromise = new PollPromise(salt, operationReference);
-                BaseOperation._currentOperations.set(this.Id, pollPromise);
-
-                pollPromise.Start(async () => {
-                    const result = await Gateway.Instance.GetResult(resultParameters.toJSON());
-                    if (result instanceof ErrorResult) {
-                        throw new Error((result).message);
-                    }
-                    if (this.RequestSalt === pollPromise.RequestSalt) {
-                        if (result && (!this.Result || this.Result.progress !== result.progress)) {
-                            /*if (operationViewModel.Result !== null && operationViewModel.Result !== undefined) {
-                                let t1 = performance.now();
-                                console.log((t1 - start) + " milliseconds.");
-                                start = performance.now();
-                            }*/
-                            this.SetResult(result);
-                        }
-
-                        if (!result || result.progress! < 1) {
-                            return true;
-                        }
-                    }
-                    return false;
-                }, 100).catch((err: Error) => action(() => {
-                    this.Error = err.message;
-                    console.error(err.message);
-                })()
-                );
-            }
-        }
-        catch (err) {
-            console.error(err as Exception);
-            // ErrorDialog.Instance.HandleError(err, operationViewModel);
-        }
-    }
-
-    public CreateOperationParameters(): OperationParameters | undefined { return undefined; }
-
-    private interactionTimeout() {
-        // clearTimeout(this._interactionTimeoutId);
-        // this.InteractionTimeout.Fire(new InteractionTimeoutEventArgs(this.TypedViewModel, InteractionTimeoutType.Timeout));
-    }
-}
-
-export class PollPromise {
-    public RequestSalt: string;
-    public OperationReference: OperationReference;
-
-    private _notCanceled: boolean = true;
-    private _poll: undefined | (() => Promise<boolean>);
-    private _delay: number = 0;
-
-    public constructor(requestKey: string, operationReference: OperationReference) {
-        this.RequestSalt = requestKey;
-        this.OperationReference = operationReference;
-    }
-
-    public Cancel(): void {
-        this._notCanceled = false;
-    }
-
-    public Start(poll: () => Promise<boolean>, delay: number): Promise<void> {
-        this._poll = poll;
-        this._delay = delay;
-        return this.pollRecursive();
-    }
-
-    private pollRecursive = (): Promise<void> => {
-        return Promise.resolve().then(this._poll).then((flag) => {
-            this._notCanceled && flag && new Promise((res) => (setTimeout(res, this._delay)))
-                .then(this.pollRecursive);
-        });
-    }
-}
-
-
-export class InteractionTimeoutEventArgs {
-    constructor(public Sender: object, public Type: InteractionTimeoutType) {
-    }
-}
-
-export enum InteractionTimeoutType {
-    Reset = 0,
-    Timeout = 1
-}
diff --git a/src/client/northstar/operations/HistogramOperation.ts b/src/client/northstar/operations/HistogramOperation.ts
deleted file mode 100644
index 74e23ea48..000000000
--- a/src/client/northstar/operations/HistogramOperation.ts
+++ /dev/null
@@ -1,158 +0,0 @@
-import { action, computed, observable, trace } from "mobx";
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import { ColumnAttributeModel } from "../core/attribute/AttributeModel";
-import { AttributeTransformationModel } from "../core/attribute/AttributeTransformationModel";
-import { CalculatedAttributeManager } from "../core/attribute/CalculatedAttributeModel";
-import { FilterModel } from "../core/filter/FilterModel";
-import { FilterOperand } from "../core/filter/FilterOperand";
-import { IBaseFilterConsumer } from "../core/filter/IBaseFilterConsumer";
-import { IBaseFilterProvider } from "../core/filter/IBaseFilterProvider";
-import { HistogramField } from "../dash-fields/HistogramField";
-import { SETTINGS_SAMPLE_SIZE, SETTINGS_X_BINS, SETTINGS_Y_BINS } from "../model/binRanges/VisualBinRangeHelper";
-import { AggregateFunction, AggregateParameters, Attribute, AverageAggregateParameters, Bin, DataType, DoubleValueAggregateResult, HistogramOperationParameters, HistogramResult, QuantitativeBinRange } from "../model/idea/idea";
-import { ModelHelpers } from "../model/ModelHelpers";
-import { ArrayUtil } from "../utils/ArrayUtil";
-import { BaseOperation } from "./BaseOperation";
-import { Doc } from "../../../new_fields/Doc";
-import { Cast, NumCast } from "../../../new_fields/Types";
-
-export class HistogramOperation extends BaseOperation implements IBaseFilterConsumer, IBaseFilterProvider {
-    public static Empty = new HistogramOperation("-empty schema-", new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())), new AttributeTransformationModel(new ColumnAttributeModel(new Attribute())));
-    @observable public FilterOperand: FilterOperand = FilterOperand.AND;
-    @observable public Links: Doc[] = [];
-    @observable public BrushLinks: { l: Doc, b: Doc }[] = [];
-    @observable public BrushColors: number[] = [];
-    @observable public BarFilterModels: FilterModel[] = [];
-
-    @observable public Normalization: number = -1;
-    @observable public X: AttributeTransformationModel;
-    @observable public Y: AttributeTransformationModel;
-    @observable public V: AttributeTransformationModel;
-    @observable public SchemaName: string;
-    @observable public QRange: QuantitativeBinRange | undefined;
-    public get Schema() { return CurrentUserUtils.GetNorthstarSchema(this.SchemaName); }
-
-    constructor(schemaName: string, x: AttributeTransformationModel, y: AttributeTransformationModel, v: AttributeTransformationModel, normalized?: number) {
-        super();
-        this.X = x;
-        this.Y = y;
-        this.V = v;
-        this.Normalization = normalized ? normalized : -1;
-        this.SchemaName = schemaName;
-    }
-
-    public static Duplicate(op: HistogramOperation) {
-
-        return new HistogramOperation(op.SchemaName, op.X, op.Y, op.V, op.Normalization);
-    }
-    public Copy(): HistogramOperation {
-        return new HistogramOperation(this.SchemaName, this.X, this.Y, this.V, this.Normalization);
-    }
-
-    Equals(other: Object): boolean {
-        throw new Error("Method not implemented.");
-    }
-
-
-    public get FilterModels() {
-        return this.BarFilterModels;
-    }
-    @action
-    public AddFilterModels(filterModels: FilterModel[]): void {
-        filterModels.filter(f => f !== null).forEach(fm => this.BarFilterModels.push(fm));
-    }
-    @action
-    public RemoveFilterModels(filterModels: FilterModel[]): void {
-        ArrayUtil.RemoveMany(this.BarFilterModels, filterModels);
-    }
-
-    @computed
-    public get FilterString(): string {
-        if (this.OverridingFilters.length > 0) {
-            return "(" + this.OverridingFilters.filter(fm => fm !== null).map(fm => fm.ToPythonString()).join(" || ") + ")";
-        }
-        let filterModels: FilterModel[] = [];
-        return FilterModel.GetFilterModelsRecursive(this, new Set<IBaseFilterProvider>(), filterModels, true);
-    }
-
-    public get BrushString(): string[] {
-        let brushes: string[] = [];
-        this.BrushLinks.map(brushLink => {
-            let brushHistogram = Cast(brushLink.b.data, HistogramField);
-            if (brushHistogram) {
-                let filterModels: FilterModel[] = [];
-                brushes.push(FilterModel.GetFilterModelsRecursive(brushHistogram.HistoOp, new Set<IBaseFilterProvider>(), filterModels, false));
-            }
-        });
-        return brushes;
-    }
-
-    _stackedFilters: (FilterModel[])[] = [];
-    @action
-    public DrillDown(up: boolean) {
-        if (!up) {
-            if (!this.BarFilterModels.length) {
-                return;
-            }
-            this._stackedFilters.push(this.BarFilterModels.map(f => f));
-            this.OverridingFilters.length = 0;
-            this.OverridingFilters.push(...this._stackedFilters[this._stackedFilters.length - 1]);
-            this.BarFilterModels.map(fm => fm).map(fm => this.RemoveFilterModels([fm]));
-            //this.updateHistogram();
-        } else {
-            this.OverridingFilters.length = 0;
-            if (this._stackedFilters.length) {
-                this.OverridingFilters.push(...this._stackedFilters.pop()!);
-            }
-            // else 
-            //     this.updateHistogram();
-        }
-    }
-
-    private getAggregateParameters(histoX: AttributeTransformationModel, histoY: AttributeTransformationModel, histoValue: AttributeTransformationModel) {
-        let allAttributes = new Array<AttributeTransformationModel>(histoX, histoY, histoValue);
-        allAttributes = ArrayUtil.Distinct(allAttributes.filter(a => a.AggregateFunction !== AggregateFunction.None));
-
-        let numericDataTypes = [DataType.Int, DataType.Double, DataType.Float];
-        let perBinAggregateParameters: AggregateParameters[] = ModelHelpers.GetAggregateParametersWithMargins(this.Schema!.distinctAttributeParameters, allAttributes);
-        let globalAggregateParameters: AggregateParameters[] = [];
-        [histoX, histoY]
-            .filter(a => a.AggregateFunction === AggregateFunction.None && ArrayUtil.Contains(numericDataTypes, a.AttributeModel.DataType))
-            .forEach(a => {
-                let avg = new AverageAggregateParameters();
-                avg.attributeParameters = ModelHelpers.GetAttributeParameters(a.AttributeModel);
-                globalAggregateParameters.push(avg);
-            });
-        return [perBinAggregateParameters, globalAggregateParameters];
-    }
-
-    public CreateOperationParameters(): HistogramOperationParameters | undefined {
-        if (this.X && this.Y && this.V) {
-            let [perBinAggregateParameters, globalAggregateParameters] = this.getAggregateParameters(this.X, this.Y, this.V);
-            return new HistogramOperationParameters({
-                enableBrushComputation: true,
-                adapterName: this.SchemaName,
-                filter: this.FilterString,
-                brushes: this.BrushString,
-                binningParameters: [ModelHelpers.GetBinningParameters(this.X, SETTINGS_X_BINS, this.QRange ? this.QRange.minValue : undefined, this.QRange ? this.QRange.maxValue : undefined),
-                ModelHelpers.GetBinningParameters(this.Y, SETTINGS_Y_BINS)],
-                sampleStreamBlockSize: SETTINGS_SAMPLE_SIZE,
-                perBinAggregateParameters: perBinAggregateParameters,
-                globalAggregateParameters: globalAggregateParameters,
-                sortPerBinAggregateParameter: undefined,
-                attributeCalculatedParameters: CalculatedAttributeManager
-                    .AllCalculatedAttributes.map(a => ModelHelpers.GetAttributeParametersFromAttributeModel(a)),
-                degreeOfParallism: 1, // Settings.Instance.DegreeOfParallelism,
-                isCachable: false
-            });
-        }
-    }
-
-    @action
-    public async Update(): Promise<void> {
-        this.BrushColors = this.BrushLinks.map(e => NumCast(e.l.backgroundColor));
-        return super.Update();
-    }
-}
-
-
diff --git a/src/client/northstar/utils/ArrayUtil.ts b/src/client/northstar/utils/ArrayUtil.ts
deleted file mode 100644
index 12b8d8e77..000000000
--- a/src/client/northstar/utils/ArrayUtil.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { Exception } from "../model/idea/idea";
-
-export class ArrayUtil {
-
-    public static Contains(arr1: any[], arr2: any): boolean {
-        if (arr1.length === 0) {
-            return false;
-        }
-        let isComplex = typeof arr1[0] === "object";
-        for (const ele of arr1) {
-            if (isComplex && "Equals" in ele) {
-                if (ele.Equals(arr2)) {
-                    return true;
-                }
-            }
-            else {
-                if (ele === arr2) {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }
-
-
-    public static RemoveMany(arr: any[], elements: Object[]) {
-        elements.forEach(e => ArrayUtil.Remove(arr, e));
-    }
-
-    public static AddMany(arr: any[], others: Object[]) {
-        arr.push(...others);
-    }
-
-    public static Clear(arr: any[]) {
-        arr.splice(0, arr.length);
-    }
-
-
-    public static Remove(arr: any[], other: Object) {
-        const index = ArrayUtil.IndexOfWithEqual(arr, other);
-        if (index === -1) {
-            return;
-        }
-        arr.splice(index, 1);
-    }
-
-
-    public static First<T>(arr: T[], predicate: (x: any) => boolean): T {
-        let filtered = arr.filter(predicate);
-        if (filtered.length > 0) {
-            return filtered[0];
-        }
-        throw new Exception();
-    }
-
-    public static FirstOrDefault<T>(arr: T[], predicate: (x: any) => boolean): T | undefined {
-        let filtered = arr.filter(predicate);
-        if (filtered.length > 0) {
-            return filtered[0];
-        }
-        return undefined;
-    }
-
-    public static Distinct(arr: any[]): any[] {
-        let ret = [];
-        for (const ele of arr) {
-            if (!ArrayUtil.Contains(ret, ele)) {
-                ret.push(ele);
-            }
-        }
-        return ret;
-    }
-
-    public static IndexOfWithEqual(arr: any[], other: any): number {
-        for (let i = 0; i < arr.length; i++) {
-            let isComplex = typeof arr[0] === "object";
-            if (isComplex && "Equals" in arr[i]) {
-                if (arr[i].Equals(other)) {
-                    return i;
-                }
-            }
-            else {
-                if (arr[i] === other) {
-                    return i;
-                }
-            }
-        }
-        return -1;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/Extensions.ts b/src/client/northstar/utils/Extensions.ts
deleted file mode 100644
index df14d4da0..000000000
--- a/src/client/northstar/utils/Extensions.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-interface String {
-    ReplaceAll(toReplace: string, replacement: string): string;
-    Truncate(length: number, replacement: string): String;
-}
-
-String.prototype.ReplaceAll = function (toReplace: string, replacement: string): string {
-    var target = this;
-    return target.split(toReplace).join(replacement);
-};
-
-String.prototype.Truncate = function (length: number, replacement: string): String {
-    var target = this;
-    if (target.length >= length) {
-        target = target.slice(0, Math.max(0, length - replacement.length)) + replacement;
-    }
-    return target;
-};
-
-interface Math {
-    log10(val: number): number;
-}
-
-Math.log10 = function (val: number): number {
-    return Math.log(val) / Math.LN10;
-};
-
-declare interface ObjectConstructor {
-    assign(...objects: Object[]): Object;
-}
diff --git a/src/client/northstar/utils/GeometryUtil.ts b/src/client/northstar/utils/GeometryUtil.ts
deleted file mode 100644
index d5220c479..000000000
--- a/src/client/northstar/utils/GeometryUtil.ts
+++ /dev/null
@@ -1,133 +0,0 @@
-import { MathUtil, PIXIRectangle, PIXIPoint } from "./MathUtil";
-
-
-export class GeometryUtil {
-
-    public static ComputeBoundingBox(points: { x: number, y: number }[], scale = 1, padding: number = 0): PIXIRectangle {
-        let minX: number = Number.MAX_VALUE;
-        let minY: number = Number.MAX_VALUE;
-        let maxX: number = Number.MIN_VALUE;
-        let maxY: number = Number.MIN_VALUE;
-        for (const point of points) {
-            if (point.x < minX) {
-                minX = point.x;
-            }
-            if (point.y < minY) {
-                minY = point.y;
-            }
-            if (point.x > maxX) {
-                maxX = point.x;
-            }
-            if (point.y > maxY) {
-                maxY = point.y;
-            }
-        }
-        return new PIXIRectangle(minX * scale - padding, minY * scale - padding, (maxX - minX) * scale + padding * 2, (maxY - minY) * scale + padding * 2);
-    }
-
-    public static RectangleOverlap(rect1: PIXIRectangle, rect2: PIXIRectangle) {
-        let x_overlap = Math.max(0, Math.min(rect1.right, rect2.right) - Math.max(rect1.left, rect2.left));
-        let y_overlap = Math.max(0, Math.min(rect1.bottom, rect2.bottom) - Math.max(rect1.top, rect2.top));
-        return x_overlap * y_overlap;
-    }
-
-    public static RotatePoints(center: { x: number, y: number }, points: { x: number, y: number }[], angle: number): PIXIPoint[] {
-        const rotate = (cx: number, cy: number, x: number, y: number, angle: number) => {
-            const radians = angle,
-                cos = Math.cos(radians),
-                sin = Math.sin(radians),
-                nx = (cos * (x - cx)) + (sin * (y - cy)) + cx,
-                ny = (cos * (y - cy)) - (sin * (x - cx)) + cy;
-            return new PIXIPoint(nx, ny);
-        };
-        return points.map(p => rotate(center.x, center.y, p.x, p.y, angle));
-    }
-
-    public static LineByLeastSquares(points: { x: number, y: number }[]): PIXIPoint[] {
-        let sum_x: number = 0;
-        let sum_y: number = 0;
-        let sum_xy: number = 0;
-        let sum_xx: number = 0;
-        let count: number = 0;
-
-        let x: number = 0;
-        let y: number = 0;
-
-
-        if (points.length === 0) {
-            return [];
-        }
-
-        for (const point of points) {
-            x = point.x;
-            y = point.y;
-            sum_x += x;
-            sum_y += y;
-            sum_xx += x * x;
-            sum_xy += x * y;
-            count++;
-        }
-
-        let m = (count * sum_xy - sum_x * sum_y) / (count * sum_xx - sum_x * sum_x);
-        let b = (sum_y / count) - (m * sum_x) / count;
-        let result: PIXIPoint[] = new Array<PIXIPoint>();
-
-        for (const point of points) {
-            x = point.x;
-            y = x * m + b;
-            result.push(new PIXIPoint(x, y));
-        }
-        return result;
-    }
-
-    // public static PointInsidePolygon(vs:Point[], x:number, y:number):boolean {
-    //     // ray-casting algorithm based on
-    //     // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-
-    //     var inside = false;
-    //     for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
-    //         var xi = vs[i].x, yi = vs[i].y;
-    //         var xj = vs[j].x, yj = vs[j].y;
-
-    //         var intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
-    //         if (intersect) 
-    //            inside = !inside;
-    //     }
-
-    //     return inside;
-    // };
-
-    public static IntersectLines(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number): boolean {
-        let a1: number, a2: number, b1: number, b2: number, c1: number, c2: number;
-        let r1: number, r2: number, r3: number, r4: number;
-        let denom: number, offset: number, num: number;
-
-        a1 = y2 - y1;
-        b1 = x1 - x2;
-        c1 = (x2 * y1) - (x1 * y2);
-        r3 = ((a1 * x3) + (b1 * y3) + c1);
-        r4 = ((a1 * x4) + (b1 * y4) + c1);
-
-        if ((r3 !== 0) && (r4 !== 0) && (MathUtil.Sign(r3) === MathUtil.Sign(r4))) {
-            return false;
-        }
-
-        a2 = y4 - y3;
-        b2 = x3 - x4;
-        c2 = (x4 * y3) - (x3 * y4);
-
-        r1 = (a2 * x1) + (b2 * y1) + c2;
-        r2 = (a2 * x2) + (b2 * y2) + c2;
-
-        if ((r1 !== 0) && (r2 !== 0) && (MathUtil.Sign(r1) === MathUtil.Sign(r2))) {
-            return false;
-        }
-
-        denom = (a1 * b2) - (a2 * b1);
-
-        if (denom === 0) {
-            return false;
-        }
-        return true;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/IDisposable.ts b/src/client/northstar/utils/IDisposable.ts
deleted file mode 100644
index 5e9843326..000000000
--- a/src/client/northstar/utils/IDisposable.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export interface IDisposable {
-    Dispose(): void;
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/IEquatable.ts b/src/client/northstar/utils/IEquatable.ts
deleted file mode 100644
index 2f81c2478..000000000
--- a/src/client/northstar/utils/IEquatable.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-export interface IEquatable {
-    Equals(other: Object): boolean;
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/KeyCodes.ts b/src/client/northstar/utils/KeyCodes.ts
deleted file mode 100644
index 044569ffe..000000000
--- a/src/client/northstar/utils/KeyCodes.ts
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * Class contains the keycodes for keys on your keyboard.
- *
- * Useful for auto completion:
- *
- * ```
- * switch (event.key)
- * {
- *      case KeyCode.UP:
- *      {
- *      	// Up key pressed
- *       	break;
- *      }
- *      case KeyCode.DOWN:
- *      {
- *      	// Down key pressed
- *       	break;
- *      }
- *      case KeyCode.LEFT:
- *      {
- *      	// Left key pressed
- *       	break;
- *      }
- *      case KeyCode.RIGHT:
- *      {
- *      	// Right key pressed
- *       	break;
- *      }
- *      default:
- *      {
- *      	// ignore
- *      	break;
- *      }
- * }
- * ```
- */
-export class KeyCodes
-{
-	public static TAB:number = 9;
-	public static CAPS_LOCK:number = 20;
-	public static SHIFT:number = 16;
-	public static CONTROL:number = 17;
-	public static SPACE:number = 32;
-	public static DOWN:number = 40;
-	public static UP:number = 38;
-	public static LEFT:number = 37;
-	public static RIGHT:number = 39;
-	public static ESCAPE:number = 27;
-	public static F1:number = 112;
-	public static F2:number = 113;
-	public static F3:number = 114;
-	public static F4:number = 115;
-	public static F5:number = 116;
-	public static F6:number = 117;
-	public static F7:number = 118;
-	public static F8:number = 119;
-	public static F9:number = 120;
-	public static F10:number = 121;
-	public static F11:number = 122;
-	public static F12:number = 123;
-	public static INSERT:number = 45;
-	public static HOME:number = 36;
-	public static PAGE_UP:number = 33;
-	public static PAGE_DOWN:number = 34;
-	public static DELETE:number = 46;
-	public static END:number = 35;
-	public static ENTER:number = 13;
-	public static BACKSPACE:number = 8;
-	public static NUMPAD_0:number = 96;
-	public static NUMPAD_1:number = 97;
-	public static NUMPAD_2:number = 98;
-	public static NUMPAD_3:number = 99;
-	public static NUMPAD_4:number = 100;
-	public static NUMPAD_5:number = 101;
-	public static NUMPAD_6:number = 102;
-	public static NUMPAD_7:number = 103;
-	public static NUMPAD_8:number = 104;
-	public static NUMPAD_9:number = 105;
-	public static NUMPAD_DIVIDE:number = 111;
-	public static NUMPAD_ADD:number = 107;
-	public static NUMPAD_ENTER:number = 13;
-	public static NUMPAD_DECIMAL:number = 110;
-	public static NUMPAD_SUBTRACT:number = 109;
-	public static NUMPAD_MULTIPLY:number = 106;
-	public static SEMICOLON:number = 186;
-	public static EQUAL:number = 187;
-	public static COMMA:number = 188;
-	public static MINUS:number = 189;
-	public static PERIOD:number = 190;
-	public static SLASH:number = 191;
-	public static BACKQUOTE:number = 192;
-	public static LEFTBRACKET:number = 219;
-	public static BACKSLASH:number = 220;
-	public static RIGHTBRACKET:number = 221;
-	public static QUOTE:number = 222;
-	public static ALT:number = 18;
-	public static COMMAND:number = 15;
-	public static NUMPAD:number = 21;
-	public static A:number = 65;
-	public static B:number = 66;
-	public static C:number = 67;
-	public static D:number = 68;
-	public static E:number = 69;
-	public static F:number = 70;
-	public static G:number = 71;
-	public static H:number = 72;
-	public static I:number = 73;
-	public static J:number = 74;
-	public static K:number = 75;
-	public static L:number = 76;
-	public static M:number = 77;
-	public static N:number = 78;
-	public static O:number = 79;
-	public static P:number = 80;
-	public static Q:number = 81;
-	public static R:number = 82;
-	public static S:number = 83;
-	public static T:number = 84;
-	public static U:number = 85;
-	public static V:number = 86;
-	public static W:number = 87;
-	public static X:number = 88;
-	public static Y:number = 89;
-	public static Z:number = 90;
-	public static NUM_0:number = 48;
-	public static NUM_1:number = 49;
-	public static NUM_2:number = 50;
-	public static NUM_3:number = 51;
-	public static NUM_4:number = 52;
-	public static NUM_5:number = 53;
-	public static NUM_6:number = 54;
-	public static NUM_7:number = 55;
-	public static NUM_8:number = 56;
-	public static NUM_9:number = 57;
-	public static SUBSTRACT:number = 189;
-	public static ADD:number = 187;
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/LABColor.ts b/src/client/northstar/utils/LABColor.ts
deleted file mode 100644
index 72e46fb7f..000000000
--- a/src/client/northstar/utils/LABColor.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-
-export class LABColor {
-    public L: number;
-    public A: number;
-    public B: number;
-
-    // constructor - takes three floats for lightness and color-opponent dimensions
-    constructor(l: number, a: number, b: number) {
-        this.L = l;
-        this.A = a;
-        this.B = b;
-    }
-
-    // static function for linear interpolation between two LABColors
-    public static Lerp(a: LABColor, b: LABColor, t: number): LABColor {
-        return new LABColor(LABColor.LerpNumber(a.L, b.L, t), LABColor.LerpNumber(a.A, b.A, t), LABColor.LerpNumber(a.B, b.B, t));
-    }
-
-    public static LerpNumber(a: number, b: number, percent: number): number {
-        return a + percent * (b - a);
-    }
-
-    static hexToRGB(hex: number, alpha: number): number[] {
-        var r = (hex & (0xff << 16)) >> 16;
-        var g = (hex & (0xff << 8)) >> 8;
-        var b = (hex & (0xff << 0)) >> 0;
-        return [r, g, b];
-    }
-    static RGBtoHex(red: number, green: number, blue: number): number {
-        return blue | (green << 8) | (red << 16);
-    }
-
-    public static RGBtoHexString(rgb: number): string {
-        let str = "#" + this.hex((rgb & (0xff << 16)) >> 16) + this.hex((rgb & (0xff << 8)) >> 8) + this.hex((rgb & (0xff << 0)) >> 0);
-        return str;
-    }
-
-    static hex(x: number): string {
-        var hexDigits = new Array
-            ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f");
-        return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
-    }
-
-    public static FromColor(c: number): LABColor {
-        var rgb = LABColor.hexToRGB(c, 0);
-        var r = LABColor.d3_rgb_xyz(rgb[0] * 255);
-        var g = LABColor.d3_rgb_xyz(rgb[1] * 255);
-        var b = LABColor.d3_rgb_xyz(rgb[2] * 255);
-
-        var x = LABColor.d3_xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LABColor.d3_lab_X);
-        var y = LABColor.d3_xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LABColor.d3_lab_Y);
-        var z = LABColor.d3_xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LABColor.d3_lab_Z);
-        var lab = new LABColor(116 * y - 16, 500 * (x - y), 200 * (y - z));
-        return lab;
-    }
-
-    private static d3_lab_X: number = 0.950470;
-    private static d3_lab_Y: number = 1;
-    private static d3_lab_Z: number = 1.088830;
-
-    public static d3_lab_xyz(x: number): number {
-        return x > 0.206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
-    }
-
-    public static d3_xyz_rgb(r: number): number {
-        return Math.round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - 0.055));
-    }
-
-    public static d3_rgb_xyz(r: number): number {
-        return (r /= 255) <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
-    }
-
-    public static d3_xyz_lab(x: number): number {
-        return x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
-    }
-
-    public static ToColor(lab: LABColor): number {
-        var y = (lab.L + 16) / 116;
-        var x = y + lab.A / 500;
-        var z = y - lab.B / 200;
-        x = LABColor.d3_lab_xyz(x) * LABColor.d3_lab_X;
-        y = LABColor.d3_lab_xyz(y) * LABColor.d3_lab_Y;
-        z = LABColor.d3_lab_xyz(z) * LABColor.d3_lab_Z;
-
-        return LABColor.RGBtoHex(
-            LABColor.d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z) / 255,
-            LABColor.d3_xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z) / 255,
-            LABColor.d3_xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z) / 255);
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/MathUtil.ts b/src/client/northstar/utils/MathUtil.ts
deleted file mode 100644
index 5def5e704..000000000
--- a/src/client/northstar/utils/MathUtil.ts
+++ /dev/null
@@ -1,249 +0,0 @@
-
-
-export class PIXIPoint {
-    public get x() { return this.coords[0]; }
-    public get y() { return this.coords[1]; }
-    public set x(value: number) { this.coords[0] = value; }
-    public set y(value: number) { this.coords[1] = value; }
-    public coords: number[] = [0, 0];
-    constructor(x: number, y: number) {
-        this.coords[0] = x;
-        this.coords[1] = y;
-    }
-}
-
-export class PIXIRectangle {
-    public x: number;
-    public y: number;
-    public width: number;
-    public height: number;
-    public get left() { return this.x; }
-    public get right() { return this.x + this.width; }
-    public get top() { return this.y; }
-    public get bottom() { return this.top + this.height; }
-    public static get EMPTY() { return new PIXIRectangle(0, 0, -1, -1); }
-    constructor(x: number, y: number, width: number, height: number) {
-        this.x = x;
-        this.y = y;
-        this.width = width;
-        this.height = height;
-    }
-}
-
-export class MathUtil {
-
-    public static EPSILON: number = 0.001;
-
-    public static Sign(value: number): number {
-        return value >= 0 ? 1 : -1;
-    }
-
-    public static AddPoint(p1: PIXIPoint, p2: PIXIPoint, inline: boolean = false): PIXIPoint {
-        if (inline) {
-            p1.x += p2.x;
-            p1.y += p2.y;
-            return p1;
-        }
-        else {
-            return new PIXIPoint(p1.x + p2.x, p1.y + p2.y);
-        }
-    }
-
-    public static Perp(p1: PIXIPoint): PIXIPoint {
-        return new PIXIPoint(-p1.y, p1.x);
-    }
-
-    public static DividePoint(p1: PIXIPoint, by: number, inline: boolean = false): PIXIPoint {
-        if (inline) {
-            p1.x /= by;
-            p1.y /= by;
-            return p1;
-        }
-        else {
-            return new PIXIPoint(p1.x / by, p1.y / by);
-        }
-    }
-
-    public static MultiplyConstant(p1: PIXIPoint, by: number, inline: boolean = false) {
-        if (inline) {
-            p1.x *= by;
-            p1.y *= by;
-            return p1;
-        }
-        else {
-            return new PIXIPoint(p1.x * by, p1.y * by);
-        }
-    }
-
-    public static SubtractPoint(p1: PIXIPoint, p2: PIXIPoint, inline: boolean = false): PIXIPoint {
-        if (inline) {
-            p1.x -= p2.x;
-            p1.y -= p2.y;
-            return p1;
-        }
-        else {
-            return new PIXIPoint(p1.x - p2.x, p1.y - p2.y);
-        }
-    }
-
-    public static Area(rect: PIXIRectangle): number {
-        return rect.width * rect.height;
-    }
-
-    public static DistToLineSegment(v: PIXIPoint, w: PIXIPoint, p: PIXIPoint) {
-        // Return minimum distance between line segment vw and point p
-        const l2 = MathUtil.DistSquared(v, w);  // i.e. |w-v|^2 -  avoid a sqrt
-        if (l2 === 0.0) return MathUtil.Dist(p, v);   // v === w case
-        // Consider the line extending the segment, parameterized as v + t (w - v).
-        // We find projection of point p onto the line. 
-        // It falls where t = [(p-v) . (w-v)] / |w-v|^2
-        // We clamp t from [0,1] to handle points outside the segment vw.
-        const dot = MathUtil.Dot(
-            MathUtil.SubtractPoint(p, v),
-            MathUtil.SubtractPoint(w, v)) / l2;
-        const t = Math.max(0, Math.min(1, dot));
-        // Projection falls on the segment
-        const projection = MathUtil.AddPoint(v,
-            MathUtil.MultiplyConstant(
-                MathUtil.SubtractPoint(w, v), t));
-        return MathUtil.Dist(p, projection);
-    }
-
-    public static LineSegmentIntersection(ps1: PIXIPoint, pe1: PIXIPoint, ps2: PIXIPoint, pe2: PIXIPoint): PIXIPoint | undefined {
-        const a1 = pe1.y - ps1.y;
-        const b1 = ps1.x - pe1.x;
-
-        const a2 = pe2.y - ps2.y;
-        const b2 = ps2.x - pe2.x;
-
-        const delta = a1 * b2 - a2 * b1;
-        if (delta === 0) {
-            return undefined;
-        }
-        const c2 = a2 * ps2.x + b2 * ps2.y;
-        const c1 = a1 * ps1.x + b1 * ps1.y;
-        const invdelta = 1 / delta;
-        return new PIXIPoint((b2 * c1 - b1 * c2) * invdelta, (a1 * c2 - a2 * c1) * invdelta);
-    }
-
-    public static PointInPIXIRectangle(p: PIXIPoint, rect: PIXIRectangle): boolean {
-        if (p.x < rect.left - this.EPSILON) {
-            return false;
-        }
-        if (p.x > rect.right + this.EPSILON) {
-            return false;
-        }
-        if (p.y < rect.top - this.EPSILON) {
-            return false;
-        }
-        if (p.y > rect.bottom + this.EPSILON) {
-            return false;
-        }
-
-        return true;
-    }
-
-    public static LinePIXIRectangleIntersection(lineFrom: PIXIPoint, lineTo: PIXIPoint, rect: PIXIRectangle): Array<PIXIPoint> {
-        const r1 = new PIXIPoint(rect.left, rect.top);
-        const r2 = new PIXIPoint(rect.right, rect.top);
-        const r3 = new PIXIPoint(rect.right, rect.bottom);
-        const r4 = new PIXIPoint(rect.left, rect.bottom);
-        const ret = new Array<PIXIPoint>();
-        const dist = this.Dist(lineFrom, lineTo);
-        let inter = this.LineSegmentIntersection(lineFrom, lineTo, r1, r2);
-        if (inter && this.PointInPIXIRectangle(inter, rect) &&
-            this.Dist(inter, lineFrom) < dist && this.Dist(inter, lineTo) < dist) {
-            ret.push(inter);
-        }
-        inter = this.LineSegmentIntersection(lineFrom, lineTo, r2, r3);
-        if (inter && this.PointInPIXIRectangle(inter, rect) &&
-            this.Dist(inter, lineFrom) < dist && this.Dist(inter, lineTo) < dist) {
-            ret.push(inter);
-        }
-        inter = this.LineSegmentIntersection(lineFrom, lineTo, r3, r4);
-        if (inter && this.PointInPIXIRectangle(inter, rect) &&
-            this.Dist(inter, lineFrom) < dist && this.Dist(inter, lineTo) < dist) {
-            ret.push(inter);
-        }
-        inter = this.LineSegmentIntersection(lineFrom, lineTo, r4, r1);
-        if (inter && this.PointInPIXIRectangle(inter, rect) &&
-            this.Dist(inter, lineFrom) < dist && this.Dist(inter, lineTo) < dist) {
-            ret.push(inter);
-        }
-        return ret;
-    }
-
-    public static Intersection(rect1: PIXIRectangle, rect2: PIXIRectangle): PIXIRectangle {
-        const left = Math.max(rect1.x, rect2.x);
-        const right = Math.min(rect1.x + rect1.width, rect2.x + rect2.width);
-        const top = Math.max(rect1.y, rect2.y);
-        const bottom = Math.min(rect1.y + rect1.height, rect2.y + rect2.height);
-        return new PIXIRectangle(left, top, right - left, bottom - top);
-    }
-
-    public static Dist(p1: PIXIPoint, p2: PIXIPoint): number {
-        return Math.sqrt(MathUtil.DistSquared(p1, p2));
-    }
-
-    public static Dot(p1: PIXIPoint, p2: PIXIPoint): number {
-        return p1.x * p2.x + p1.y * p2.y;
-    }
-
-    public static Normalize(p1: PIXIPoint) {
-        const d = this.Length(p1);
-        return new PIXIPoint(p1.x / d, p1.y / d);
-    }
-
-    public static Length(p1: PIXIPoint): number {
-        return Math.sqrt(p1.x * p1.x + p1.y * p1.y);
-    }
-
-    public static DistSquared(p1: PIXIPoint, p2: PIXIPoint): number {
-        const a = p1.x - p2.x;
-        const b = p1.y - p2.y;
-        return (a * a + b * b);
-    }
-
-    public static RectIntersectsRect(r1: PIXIRectangle, r2: PIXIRectangle): boolean {
-        return !(r2.x > r1.x + r1.width ||
-            r2.x + r2.width < r1.x ||
-            r2.y > r1.y + r1.height ||
-            r2.y + r2.height < r1.y);
-    }
-
-    public static ArgMin(temp: number[]): number {
-        let index = 0;
-        let value = temp[0];
-        for (let i = 1; i < temp.length; i++) {
-            if (temp[i] < value) {
-                value = temp[i];
-                index = i;
-            }
-        }
-        return index;
-    }
-
-    public static ArgMax(temp: number[]): number {
-        let index = 0;
-        let value = temp[0];
-        for (let i = 1; i < temp.length; i++) {
-            if (temp[i] > value) {
-                value = temp[i];
-                index = i;
-            }
-        }
-        return index;
-    }
-
-    public static Combinations<T>(chars: T[]) {
-        const result = new Array<T>();
-        const f = (prefix: any, chars: any) => {
-            for (let i = 0; i < chars.length; i++) {
-                result.push(prefix.concat(chars[i]));
-                f(prefix.concat(chars[i]), chars.slice(i + 1));
-            }
-        };
-        f([], chars);
-        return result;
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/PartialClass.ts b/src/client/northstar/utils/PartialClass.ts
deleted file mode 100644
index 2f20de96f..000000000
--- a/src/client/northstar/utils/PartialClass.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-
-export class PartialClass<T> {
-
-    constructor(data?: Partial<T>) {
-        Object.assign(this, data);
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/SizeConverter.ts b/src/client/northstar/utils/SizeConverter.ts
deleted file mode 100644
index a52890ed9..000000000
--- a/src/client/northstar/utils/SizeConverter.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import { PIXIPoint } from "./MathUtil";
-import { VisualBinRange } from "../model/binRanges/VisualBinRange";
-import { Bin, DoubleValueAggregateResult, AggregateKey } from "../model/idea/idea";
-import { ModelHelpers } from "../model/ModelHelpers";
-import { observable, action, computed } from "mobx";
-
-export class SizeConverter {
-    public DataMins: Array<number> = new Array<number>(2);
-    public DataMaxs: Array<number> = new Array<number>(2);
-    public DataRanges: Array<number> = new Array<number>(2);
-    public MaxLabelSizes: Array<PIXIPoint> = new Array<PIXIPoint>(2);
-    public RenderDimension: number = 300;
-
-    @observable _leftOffset: number = 40;
-    @observable _rightOffset: number = 20;
-    @observable _topOffset: number = 20;
-    @observable _bottomOffset: number = 45;
-    @observable _labelAngle: number = 0;
-    @observable _isSmall: boolean = false;
-    @observable public Initialized = 0;
-
-    @action public SetIsSmall(isSmall: boolean) { this._isSmall = isSmall; }
-    @action public SetLabelAngle(angle: number) { this._labelAngle = angle; }
-    @computed public get IsSmall() { return this._isSmall; }
-    @computed public get LabelAngle() { return this._labelAngle; }
-    @computed public get LeftOffset() { return this.IsSmall ? 5 : this._leftOffset; }
-    @computed public get RightOffset() { return this.IsSmall ? 5 : !this._labelAngle ? this._bottomOffset : Math.max(this._rightOffset, Math.cos(this._labelAngle) * (this.MaxLabelSizes[0].x + 18)); }
-    @computed public get TopOffset() { return this.IsSmall ? 5 : this._topOffset; }
-    @computed public get BottomOffset() { return this.IsSmall ? 25 : !this._labelAngle ? this._bottomOffset : Math.max(this._bottomOffset, Math.sin(this._labelAngle) * (this.MaxLabelSizes[0].x + 18)) + 18; }
-
-    public SetVisualBinRanges(visualBinRanges: Array<VisualBinRange>) {
-        this.Initialized++;
-        var xLabels = visualBinRanges[0].GetLabels();
-        var yLabels = visualBinRanges[1].GetLabels();
-        var xLabelStrings = xLabels.map(l => l.label!).sort(function (a, b) { return b.length - a.length; });
-        var yLabelStrings = yLabels.map(l => l.label!).sort(function (a, b) { return b.length - a.length; });
-
-        var metricsX = { width: 75 }; // RenderUtils.MeasureText(FontStyles.Default.fontFamily.toString(), 12, // FontStyles.AxisLabel.fontSize as number,
-        //xLabelStrings[0]!.slice(0, 20)) // StyleConstants.MAX_CHAR_FOR_HISTOGRAM_LABELS));
-        var metricsY = { width: 22 }; // RenderUtils.MeasureText(FontStyles.Default.fontFamily.toString(), 12, // FontStyles.AxisLabel.fontSize as number,
-        // yLabelStrings[0]!.slice(0, 20)); // StyleConstants.MAX_CHAR_FOR_HISTOGRAM_LABELS));
-        this.MaxLabelSizes[0] = new PIXIPoint(metricsX.width, 12);// FontStyles.AxisLabel.fontSize as number);
-        this.MaxLabelSizes[1] = new PIXIPoint(metricsY.width, 12); // FontStyles.AxisLabel.fontSize as number);
-
-        this._leftOffset = Math.max(10, metricsY.width + 10 + 20);
-
-        this.DataMins[0] = xLabels.map(l => l.minValue!).reduce((m, c) => Math.min(m, c), Number.MAX_VALUE);
-        this.DataMins[1] = yLabels.map(l => l.minValue!).reduce((m, c) => Math.min(m, c), Number.MAX_VALUE);
-        this.DataMaxs[0] = xLabels.map(l => l.maxValue!).reduce((m, c) => Math.max(m, c), Number.MIN_VALUE);
-        this.DataMaxs[1] = yLabels.map(l => l.maxValue!).reduce((m, c) => Math.max(m, c), Number.MIN_VALUE);
-
-        this.DataRanges[0] = this.DataMaxs[0] - this.DataMins[0];
-        this.DataRanges[1] = this.DataMaxs[1] - this.DataMins[1];
-    }
-
-    public DataToScreenNormalizedRange(dataValue: number, normalization: number, axis: number, binBrushMaxAxis: number) {
-        var value = normalization !== 1 - axis || binBrushMaxAxis === 0 ? dataValue : (dataValue - 0) / (binBrushMaxAxis - 0) * this.DataRanges[axis];
-        var from = this.DataToScreenCoord(Math.min(0, value), axis);
-        var to = this.DataToScreenCoord(Math.max(0, value), axis);
-        return [from, value, to];
-    }
-
-    public DataToScreenPointRange(axis: number, bin: Bin, aggregateKey: AggregateKey) {
-        var value = ModelHelpers.GetAggregateResult(bin, aggregateKey) as DoubleValueAggregateResult;
-        if (value && value.hasResult) {
-            return [this.DataToScreenCoord(value.result!, axis) - 5,
-            this.DataToScreenCoord(value.result!, axis) + 5];
-        }
-        return [undefined, undefined];
-    }
-
-    public DataToScreenXAxisRange(visualBinRanges: VisualBinRange[], index: number, bin: Bin) {
-        var value = visualBinRanges[0].GetValueFromIndex(bin.binIndex!.indices![index]);
-        return [this.DataToScreenX(value), this.DataToScreenX(visualBinRanges[index].AddStep(value))];
-    }
-    public DataToScreenYAxisRange(visualBinRanges: VisualBinRange[], index: number, bin: Bin) {
-        var value = visualBinRanges[1].GetValueFromIndex(bin.binIndex!.indices![index]);
-        return [this.DataToScreenY(value), this.DataToScreenY(visualBinRanges[index].AddStep(value))];
-    }
-
-    public DataToScreenX(x: number): number {
-        return ((x - this.DataMins[0]) / this.DataRanges[0]) * this.RenderDimension;
-    }
-    public DataToScreenY(y: number, flip: boolean = true) {
-        var retY = ((y - this.DataMins[1]) / this.DataRanges[1]) * this.RenderDimension;
-        return flip ? (this.RenderDimension) - retY : retY;
-    }
-    public DataToScreenCoord(v: number, axis: number) {
-        if (axis === 0) {
-            return this.DataToScreenX(v);
-        }
-        return this.DataToScreenY(v);
-    }
-    public DataToScreenRange(minVal: number, maxVal: number, axis: number) {
-        let xFrom = this.DataToScreenX(axis === 0 ? minVal : this.DataMins[0]);
-        let xTo = this.DataToScreenX(axis === 0 ? maxVal : this.DataMaxs[0]);
-        let yFrom = this.DataToScreenY(axis === 1 ? minVal : this.DataMins[1]);
-        let yTo = this.DataToScreenY(axis === 1 ? maxVal : this.DataMaxs[1]);
-        return { xFrom, yFrom, xTo, yTo };
-    }
-}
\ No newline at end of file
diff --git a/src/client/northstar/utils/StyleContants.ts b/src/client/northstar/utils/StyleContants.ts
deleted file mode 100644
index e9b6e0297..000000000
--- a/src/client/northstar/utils/StyleContants.ts
+++ /dev/null
@@ -1,95 +0,0 @@
-import { PIXIPoint } from "./MathUtil";
-
-export class StyleConstants {
-
-    static DEFAULT_FONT: string = "Roboto Condensed";
-
-    static MENU_SUBMENU_WIDTH: number = 85;
-    static MENU_SUBMENU_HEIGHT: number = 400;
-    static MENU_BOX_SIZE: PIXIPoint = new PIXIPoint(80, 35);
-    static MENU_BOX_PADDING: number = 10;
-
-    static OPERATOR_MENU_LARGE: number = 35;
-    static OPERATOR_MENU_SMALL: number = 25;
-    static BRUSH_PALETTE: number[] = [0x42b43c, 0xfa217f, 0x6a9c75, 0xfb5de7, 0x25b8ea, 0x9b5bc4, 0xda9f63, 0xe23209, 0xfb899b, 0x94a6fd];
-    static GAP: number = 3;
-
-    static BACKGROUND_COLOR: number = 0xF3F3F3;
-    static TOOL_TIP_BACKGROUND_COLOR: number = 0xffffff;
-    static LIGHT_TEXT_COLOR: number = 0xffffff;
-    static LIGHT_TEXT_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.LIGHT_TEXT_COLOR);
-    static DARK_TEXT_COLOR: number = 0x282828;
-    static HIGHLIGHT_TEXT_COLOR: number = 0xffcc00;
-    static FPS_TEXT_COLOR: number = StyleConstants.DARK_TEXT_COLOR;
-    static CORRELATION_LABEL_TEXT_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.DARK_TEXT_COLOR);
-    static LOADING_SCREEN_TEXT_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.DARK_TEXT_COLOR);
-    static ERROR_COLOR: number = 0x540E25;
-    static WARNING_COLOR: number = 0xE58F24;
-    static LOWER_THAN_NAIVE_COLOR: number = 0xee0000;
-    static HIGHLIGHT_COLOR: number = 0x82A8D9;
-    static HIGHLIGHT_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.HIGHLIGHT_COLOR);
-    static OPERATOR_BACKGROUND_COLOR: number = 0x282828;
-    static LOADING_ANIMATION_COLOR: number = StyleConstants.OPERATOR_BACKGROUND_COLOR;
-    static MENU_COLOR: number = 0x282828;
-    static MENU_FONT_COLOR: number = StyleConstants.LIGHT_TEXT_COLOR;
-    static MENU_SELECTED_COLOR: number = StyleConstants.HIGHLIGHT_COLOR;
-    static MENU_SELECTED_FONT_COLOR: number = StyleConstants.LIGHT_TEXT_COLOR;
-    static BRUSH_COLOR: number = 0xff0000;
-    static DROP_ACCEPT_COLOR: number = StyleConstants.HIGHLIGHT_COLOR;
-    static SELECTED_COLOR: number = 0xffffff;
-    static SELECTED_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.SELECTED_COLOR);
-    static PROGRESS_BACKGROUND_COLOR: number = 0x595959;
-    static GRID_LINES_COLOR: number = 0x3D3D3D;
-    static GRID_LINES_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.GRID_LINES_COLOR);
-
-    static MAX_CHAR_FOR_HISTOGRAM_LABELS: number = 20;
-
-    static OVERLAP_COLOR: number = 0x0000ff;//0x540E25;
-    static BRUSH_COLORS: Array<number> = new Array<number>(
-        0xFFDA7E, 0xFE8F65, 0xDA5655, 0x8F2240
-    );
-
-    static MIN_VALUE_COLOR: number = 0x373d43; //32343d, 373d43,  3b4648
-    static MARGIN_BARS_COLOR: number = 0xffffff;
-    static MARGIN_BARS_COLOR_STR: string = StyleConstants.HexToHexString(StyleConstants.MARGIN_BARS_COLOR);
-
-    static HISTOGRAM_WIDTH: number = 200;
-    static HISTOGRAM_HEIGHT: number = 150;
-    static PREDICTOR_WIDTH: number = 150;
-    static PREDICTOR_HEIGHT: number = 100;
-    static RAWDATA_WIDTH: number = 150;
-    static RAWDATA_HEIGHT: number = 100;
-    static FREQUENT_ITEM_WIDTH: number = 180;
-    static FREQUENT_ITEM_HEIGHT: number = 100;
-    static CORRELATION_WIDTH: number = 555;
-    static CORRELATION_HEIGHT: number = 390;
-    static PROBLEM_FINDER_WIDTH: number = 450;
-    static PROBLEM_FINDER_HEIGHT: number = 150;
-    static PIPELINE_OPERATOR_WIDTH: number = 300;
-    static PIPELINE_OPERATOR_HEIGHT: number = 120;
-    static SLICE_WIDTH: number = 150;
-    static SLICE_HEIGHT: number = 45;
-    static BORDER_MENU_ITEM_WIDTH: number = 50;
-    static BORDER_MENU_ITEM_HEIGHT: number = 30;
-
-
-    static SLICE_BG_COLOR: string = StyleConstants.HexToHexString(StyleConstants.OPERATOR_BACKGROUND_COLOR);
-    static SLICE_EMPTY_COLOR: number = StyleConstants.OPERATOR_BACKGROUND_COLOR;
-    static SLICE_OCCUPIED_COLOR: number = 0xffffff;
-    static SLICE_OCCUPIED_BG_COLOR: string = StyleConstants.HexToHexString(StyleConstants.OPERATOR_BACKGROUND_COLOR);
-    static SLICE_HOVER_BG_COLOR: string = StyleConstants.HexToHexString(StyleConstants.HIGHLIGHT_COLOR);
-    static SLICE_HOVER_COLOR: number = 0xffffff;
-
-    static HexToHexString(hex: number): string {
-        if (hex === undefined) {
-            return "#000000";
-        }
-        var s = hex.toString(16);
-        while (s.length < 6) {
-            s = "0" + s;
-        }
-        return "#" + s;
-    }
-
-
-} 
diff --git a/src/client/northstar/utils/Utils.ts b/src/client/northstar/utils/Utils.ts
deleted file mode 100644
index d071dec62..000000000
--- a/src/client/northstar/utils/Utils.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-import { IBaseBrushable } from '../core/brusher/IBaseBrushable';
-import { IBaseFilterConsumer } from '../core/filter/IBaseFilterConsumer';
-import { IBaseFilterProvider } from '../core/filter/IBaseFilterProvider';
-import { AggregateFunction } from '../model/idea/idea';
-
-export class Utils {
-
-    public static EqualityHelper(a: Object, b: Object): boolean {
-        if (a === b) return true;
-        if (a === undefined && b !== undefined) return false;
-        if (a === null && b !== null) return false;
-        if (b === undefined && a !== undefined) return false;
-        if (b === null && a !== null) return false;
-        if ((<any>a).constructor.name !== (<any>b).constructor.name) return false;
-        return true;
-    }
-
-    public static LowercaseFirstLetter(str: string) {
-        return str.charAt(0).toUpperCase() + str.slice(1);
-    }
-
-    //
-    // this Type Guard tests if dropTarget is an IDropTarget.  If it is, it coerces the compiler
-    // to treat the dropTarget parameter as an IDropTarget *ouside* this function scope (ie, in
-    // the scope of where this function is called from).
-    //
-
-    public static isBaseBrushable<T>(obj: Object): obj is IBaseBrushable<T> {
-        let typed = <IBaseBrushable<T>>obj;
-        return typed !== null && typed.BrusherModels !== undefined;
-    }
-
-    public static isBaseFilterProvider(obj: Object): obj is IBaseFilterProvider {
-        let typed = <IBaseFilterProvider>obj;
-        return typed !== null && typed.FilterModels !== undefined;
-    }
-
-    public static isBaseFilterConsumer(obj: Object): obj is IBaseFilterConsumer {
-        let typed = <IBaseFilterConsumer>obj;
-        return typed !== null && typed.FilterOperand !== undefined;
-    }
-
-    public static EncodeQueryData(data: any): string {
-        const ret = [];
-        for (let d in data) {
-            ret.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d]));
-        }
-        return ret.join("&");
-    }
-
-    public static ToVegaAggregationString(agg: AggregateFunction): string {
-        if (agg === AggregateFunction.Avg) {
-            return "average";
-        }
-        else if (agg === AggregateFunction.Count) {
-            return "count";
-        }
-        else {
-            return "";
-        }
-    }
-
-    public static GetQueryVariable(variable: string) {
-        let query = window.location.search.substring(1);
-        let vars = query.split("&");
-        for (const variable of vars) {
-            let pair = variable.split("=");
-            if (decodeURIComponent(pair[0]) === variable) {
-                return decodeURIComponent(pair[1]);
-            }
-        }
-        return undefined;
-    }
-}
-
diff --git a/src/client/util/DictationManager.ts b/src/client/util/DictationManager.ts
index 569c1ef6d..b3295ece0 100644
--- a/src/client/util/DictationManager.ts
+++ b/src/client/util/DictationManager.ts
@@ -10,7 +10,6 @@ import { CollectionViewType } from "../views/collections/CollectionView";
 import { Cast, CastCtor } from "../../new_fields/Types";
 import { listSpec } from "../../new_fields/Schema";
 import { AudioField, ImageField } from "../../new_fields/URLField";
-import { HistogramField } from "../northstar/dash-fields/HistogramField";
 import { Utils } from "../../Utils";
 import { RichTextField } from "../../new_fields/RichTextField";
 import { DictationOverlay } from "../views/DictationOverlay";
@@ -282,9 +281,8 @@ export namespace DictationManager {
             [DocumentType.COL, listSpec(Doc)],
             [DocumentType.AUDIO, AudioField],
             [DocumentType.IMG, ImageField],
-            [DocumentType.HIST, HistogramField],
             [DocumentType.IMPORT, listSpec(Doc)],
-            [DocumentType.TEXT, "string"]
+            [DocumentType.RTF, "string"]
         ]);
 
         const tryCast = (view: DocumentView, type: DocumentType) => {
@@ -377,7 +375,7 @@ export namespace DictationManager {
             {
                 expression: /view as (freeform|stacking|masonry|schema|tree)/g,
                 action: (target: DocumentView, matches: RegExpExecArray) => {
-                    const mode = CollectionViewType.valueOf(matches[1]);
+                    const mode = matches[1];
                     mode && (target.props.Document._viewType = mode);
                 },
                 restrictTo: [DocumentType.COL]
diff --git a/src/client/util/DropConverter.ts b/src/client/util/DropConverter.ts
index d96257ca1..7b38fdac2 100644
--- a/src/client/util/DropConverter.ts
+++ b/src/client/util/DropConverter.ts
@@ -52,7 +52,7 @@ export function convertDropDataToButtons(data: DragManager.DocumentDragData) {
         // bcz: isButtonBar is intended to allow a collection of linear buttons to be dropped and nested into another collection of buttons... it's not being used yet, and isn't very elegant
         if (!doc.onDragStart && !doc.isButtonBar) {
             const layoutDoc = doc.layout instanceof Doc && doc.layout.isTemplateForField ? doc.layout : doc;
-            if (layoutDoc.type === DocumentType.COL || layoutDoc.type === DocumentType.TEXT || layoutDoc.type === DocumentType.IMG) {
+            if (layoutDoc.type === DocumentType.COL || layoutDoc.type === DocumentType.RTF || layoutDoc.type === DocumentType.IMG) {
                 !layoutDoc.isTemplateDoc && makeTemplate(layoutDoc);
             } else {
                 (layoutDoc.layout instanceof Doc) && !data.userDropAction;
diff --git a/src/client/util/KeyCodes.ts b/src/client/util/KeyCodes.ts
new file mode 100644
index 000000000..cacb72a57
--- /dev/null
+++ b/src/client/util/KeyCodes.ts
@@ -0,0 +1,136 @@
+/**
+ * Class contains the keycodes for keys on your keyboard.
+ *
+ * Useful for auto completion:
+ *
+ * ```
+ * switch (event.key)
+ * {
+ *      case KeyCode.UP:
+ *      {
+ *      	// Up key pressed
+ *       	break;
+ *      }
+ *      case KeyCode.DOWN:
+ *      {
+ *      	// Down key pressed
+ *       	break;
+ *      }
+ *      case KeyCode.LEFT:
+ *      {
+ *      	// Left key pressed
+ *       	break;
+ *      }
+ *      case KeyCode.RIGHT:
+ *      {
+ *      	// Right key pressed
+ *       	break;
+ *      }
+ *      default:
+ *      {
+ *      	// ignore
+ *      	break;
+ *      }
+ * }
+ * ```
+ */
+export class KeyCodes {
+    public static TAB: number = 9;
+    public static CAPS_LOCK: number = 20;
+    public static SHIFT: number = 16;
+    public static CONTROL: number = 17;
+    public static SPACE: number = 32;
+    public static DOWN: number = 40;
+    public static UP: number = 38;
+    public static LEFT: number = 37;
+    public static RIGHT: number = 39;
+    public static ESCAPE: number = 27;
+    public static F1: number = 112;
+    public static F2: number = 113;
+    public static F3: number = 114;
+    public static F4: number = 115;
+    public static F5: number = 116;
+    public static F6: number = 117;
+    public static F7: number = 118;
+    public static F8: number = 119;
+    public static F9: number = 120;
+    public static F10: number = 121;
+    public static F11: number = 122;
+    public static F12: number = 123;
+    public static INSERT: number = 45;
+    public static HOME: number = 36;
+    public static PAGE_UP: number = 33;
+    public static PAGE_DOWN: number = 34;
+    public static DELETE: number = 46;
+    public static END: number = 35;
+    public static ENTER: number = 13;
+    public static BACKSPACE: number = 8;
+    public static NUMPAD_0: number = 96;
+    public static NUMPAD_1: number = 97;
+    public static NUMPAD_2: number = 98;
+    public static NUMPAD_3: number = 99;
+    public static NUMPAD_4: number = 100;
+    public static NUMPAD_5: number = 101;
+    public static NUMPAD_6: number = 102;
+    public static NUMPAD_7: number = 103;
+    public static NUMPAD_8: number = 104;
+    public static NUMPAD_9: number = 105;
+    public static NUMPAD_DIVIDE: number = 111;
+    public static NUMPAD_ADD: number = 107;
+    public static NUMPAD_ENTER: number = 13;
+    public static NUMPAD_DECIMAL: number = 110;
+    public static NUMPAD_SUBTRACT: number = 109;
+    public static NUMPAD_MULTIPLY: number = 106;
+    public static SEMICOLON: number = 186;
+    public static EQUAL: number = 187;
+    public static COMMA: number = 188;
+    public static MINUS: number = 189;
+    public static PERIOD: number = 190;
+    public static SLASH: number = 191;
+    public static BACKQUOTE: number = 192;
+    public static LEFTBRACKET: number = 219;
+    public static BACKSLASH: number = 220;
+    public static RIGHTBRACKET: number = 221;
+    public static QUOTE: number = 222;
+    public static ALT: number = 18;
+    public static COMMAND: number = 15;
+    public static NUMPAD: number = 21;
+    public static A: number = 65;
+    public static B: number = 66;
+    public static C: number = 67;
+    public static D: number = 68;
+    public static E: number = 69;
+    public static F: number = 70;
+    public static G: number = 71;
+    public static H: number = 72;
+    public static I: number = 73;
+    public static J: number = 74;
+    public static K: number = 75;
+    public static L: number = 76;
+    public static M: number = 77;
+    public static N: number = 78;
+    public static O: number = 79;
+    public static P: number = 80;
+    public static Q: number = 81;
+    public static R: number = 82;
+    public static S: number = 83;
+    public static T: number = 84;
+    public static U: number = 85;
+    public static V: number = 86;
+    public static W: number = 87;
+    public static X: number = 88;
+    public static Y: number = 89;
+    public static Z: number = 90;
+    public static NUM_0: number = 48;
+    public static NUM_1: number = 49;
+    public static NUM_2: number = 50;
+    public static NUM_3: number = 51;
+    public static NUM_4: number = 52;
+    public static NUM_5: number = 53;
+    public static NUM_6: number = 54;
+    public static NUM_7: number = 55;
+    public static NUM_8: number = 56;
+    public static NUM_9: number = 57;
+    public static SUBSTRACT: number = 189;
+    public static ADD: number = 187;
+}
\ No newline at end of file
diff --git a/src/client/util/type_decls.d b/src/client/util/type_decls.d
index 97f6b79fb..08aec3724 100644
--- a/src/client/util/type_decls.d
+++ b/src/client/util/type_decls.d
@@ -195,7 +195,6 @@ interface DocumentOptions { }
 declare const Docs: {
     ImageDocument(url: string, options?: DocumentOptions): Doc;
     VideoDocument(url: string, options?: DocumentOptions): Doc;
-    // HistogramDocument(url:string, options?:DocumentOptions);
     TextDocument(options?: DocumentOptions): Doc;
     PdfDocument(url: string, options?: DocumentOptions): Doc;
     WebDocument(url: string, options?: DocumentOptions): Doc;
diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 21eec66be..0c8ce28c3 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -9,7 +9,7 @@ import { PositionDocument } from '../../new_fields/documentSchemas';
 import { InteractionUtils } from '../util/InteractionUtils';
 
 
-///  DocComponent returns a generic React base class used by views that don't have any data extensions (e.g.,CollectionFreeFormDocumentView, DocumentView, ButtonBox)
+///  DocComponent returns a generic React base class used by views that don't have any data extensions (e.g.,CollectionFreeFormDocumentView, DocumentView, LabelBox)
 interface DocComponentProps {
     Document: Doc;
     LayoutDoc?: () => Opt<Doc>;
diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index e313b117f..bd72385ef 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -76,7 +76,7 @@ export class DocumentDecorations extends React.Component<{}, { value: string }>
             var [sptX, sptY] = transform.transformPoint(0, 0);
             let [bptX, bptY] = transform.transformPoint(documentView.props.PanelWidth(), documentView.props.PanelHeight());
             if (documentView.props.Document.type === DocumentType.LINK) {
-                const docuBox = documentView.ContentDiv!.getElementsByClassName("docuLinkBox-cont");
+                const docuBox = documentView.ContentDiv!.getElementsByClassName("linkAnchorBox-cont");
                 if (docuBox.length) {
                     const rect = docuBox[0].getBoundingClientRect();
                     sptX = rect.left;
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index bef92f0fd..7c9f47fe4 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -275,7 +275,7 @@ export class MainView extends React.Component {
     defaultBackgroundColors = (doc: Doc) => {
         if (this.darkScheme) {
             switch (doc.type) {
-                case DocumentType.TEXT || DocumentType.BUTTON: return "#2d2d2d";
+                case DocumentType.RTF || DocumentType.LABEL: return "#2d2d2d";
                 case DocumentType.LINK:
                 case DocumentType.COL: {
                     if (doc._viewType !== CollectionViewType.Freeform && doc._viewType !== CollectionViewType.Time) return "rgb(62,62,62)";
@@ -284,8 +284,8 @@ export class MainView extends React.Component {
             }
         } else {
             switch (doc.type) {
-                case DocumentType.TEXT: return "#f1efeb";
-                case DocumentType.BUTTON: return "lightgray";
+                case DocumentType.RTF: return "#f1efeb";
+                case DocumentType.LABEL: return "lightgray";
                 case DocumentType.LINK:
                 case DocumentType.COL: {
                     if (doc._viewType !== CollectionViewType.Freeform && doc._viewType !== CollectionViewType.Time) return "lightgray";
diff --git a/src/client/views/ScriptBox.tsx b/src/client/views/ScriptBox.tsx
index 1e81bb80b..0352ddaca 100644
--- a/src/client/views/ScriptBox.tsx
+++ b/src/client/views/ScriptBox.tsx
@@ -50,7 +50,7 @@ export class ScriptBox extends React.Component<ScriptBoxProps> {
     }
 
     onBlur = () => {
-        this.overlayDisposer && this.overlayDisposer();
+        this.overlayDisposer?.();
     }
 
     render() {
diff --git a/src/client/views/SearchDocBox.tsx b/src/client/views/SearchDocBox.tsx
index 4790a2ad7..799fa9d85 100644
--- a/src/client/views/SearchDocBox.tsx
+++ b/src/client/views/SearchDocBox.tsx
@@ -394,7 +394,7 @@ export class SearchDocBox extends React.Component<FieldViewProps> {
 
     render() {
         const isEditing = this.editingMetadata;
-        return (
+        return !this.content ? (null) : (
             <div style={{ pointerEvents: "all" }}>
                 <ContentFittingDocumentView {...this.props}
                     Document={this.content}
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index ae71c54f7..82204ca7b 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -4,8 +4,9 @@ import { observer } from "mobx-react";
 import { CellInfo } from "react-table";
 import "react-table/react-table.css";
 import { emptyFunction, returnFalse, returnZero, returnOne } from "../../../Utils";
-import { Doc, DocListCast, DocListCastAsync, Field, Opt } from "../../../new_fields/Doc";
+import { Doc, DocListCast, Field, Opt } from "../../../new_fields/Doc";
 import { Id } from "../../../new_fields/FieldSymbols";
+import { KeyCodes } from "../../util/KeyCodes";
 import { SetupDrag, DragManager } from "../../util/DragManager";
 import { CompileScript } from "../../util/Scripting";
 import { Transform } from "../../util/Transform";
@@ -21,9 +22,7 @@ import { SelectionManager } from "../../util/SelectionManager";
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faExpand } from '@fortawesome/free-solid-svg-icons';
 import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
-import { KeyCodes } from "../../northstar/utils/KeyCodes";
 import { undoBatch } from "../../util/UndoManager";
-import { List } from "lodash";
 
 library.add(faExpand);
 
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index e835811c9..57be77fdd 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -14,7 +14,6 @@ import { SchemaHeaderField } from "../../../new_fields/SchemaHeaderField";
 import { ComputedField } from "../../../new_fields/ScriptField";
 import { Cast, FieldValue, NumCast, StrCast, BoolCast } from "../../../new_fields/Types";
 import { Docs, DocumentOptions } from "../../documents/Documents";
-import { Gateway } from "../../northstar/manager/Gateway";
 import { CompileScript, Transformer, ts } from "../../util/Scripting";
 import { Transform } from "../../util/Transform";
 import { undoBatch } from "../../util/UndoManager";
@@ -673,27 +672,6 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
         }
     }
 
-    @action
-    makeDB = async () => {
-        let csv: string = this.columns.reduce((val, col) => val + col + ",", "");
-        csv = csv.substr(0, csv.length - 1) + "\n";
-        const self = this;
-        this.childDocs.map(doc => {
-            csv += self.columns.reduce((val, col) => val + (doc[col.heading] ? doc[col.heading]!.toString() : "0") + ",", "");
-            csv = csv.substr(0, csv.length - 1) + "\n";
-        });
-        csv.substring(0, csv.length - 1);
-        const dbName = StrCast(this.props.Document.title);
-        const res = await Gateway.Instance.PostSchema(csv, dbName);
-        if (self.props.CollectionView && self.props.CollectionView.props.addDocument) {
-            const schemaDoc = await Docs.Create.DBDocument("https://www.cs.brown.edu/" + dbName, { title: dbName }, { dbDoc: self.props.Document });
-            if (schemaDoc) {
-                //self.props.CollectionView.props.addDocument(schemaDoc, false);
-                self.props.Document.schemaDoc = schemaDoc;
-            }
-        }
-    }
-
     getField = (row: number, col?: number) => {
         const docs = this.childDocs;
 
diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index b066f2be3..da53888fc 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -343,7 +343,7 @@ export class CollectionStackingView extends CollectionSubView(doc => doc) {
                     const doc = this.props.DataDoc && this.props.DataDoc.layout === this.layoutDoc ? this.props.DataDoc : this.layoutDoc;
                     this.observer = new _global.ResizeObserver(action((entries: any) => {
                         if (this.props.Document._autoHeight && ref && this.refList.length && !SelectionManager.GetIsDragging()) {
-                            Doc.Layout(doc)._height = this.refList.reduce((p, r) => p + Number(getComputedStyle(r).height.replace("px", "")), 0)
+                            Doc.Layout(doc)._height = this.refList.reduce((p, r) => p + Number(getComputedStyle(r).height.replace("px", "")), 0);
                         }
                     }));
                     this.observer.observe(ref);
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 746b2e174..41f4fb3f0 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -99,7 +99,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 this.props.Document.resolvedDataDoc ? this.props.Document : Doc.GetProto(this.props.Document)); // if the layout document has a resolvedDataDoc, then we don't want to get its parent which would be the unexpanded template
         }
 
-        rootSelected = (outsideReaction: boolean) => {
+        rootSelected = (outsideReaction?: boolean) => {
             return this.props.isSelected(outsideReaction) || (this.props.Document.rootDocument || this.props.Document.forceActive ? this.props.rootSelected(outsideReaction) : false);
         }
 
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index c7ab66c9f..5819c829f 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -52,39 +52,19 @@ const path = require('path');
 library.add(faTh, faTree, faSquare, faProjectDiagram, faSignature, faThList, faFingerprint, faColumns, faEllipsisV, faImage, faEye as any, faCopy);
 
 export enum CollectionViewType {
-    Invalid,
-    Freeform,
-    Schema,
-    Docking,
-    Tree,
-    Stacking,
-    Masonry,
-    Multicolumn,
-    Multirow,
-    Time,
-    Carousel,
-    Linear,
-    Staff
-}
-
-export namespace CollectionViewType {
-    const stringMapping = new Map<string, CollectionViewType>([
-        ["invalid", CollectionViewType.Invalid],
-        ["freeform", CollectionViewType.Freeform],
-        ["schema", CollectionViewType.Schema],
-        ["docking", CollectionViewType.Docking],
-        ["tree", CollectionViewType.Tree],
-        ["stacking", CollectionViewType.Stacking],
-        ["masonry", CollectionViewType.Masonry],
-        ["multicolumn", CollectionViewType.Multicolumn],
-        ["multirow", CollectionViewType.Multirow],
-        ["time", CollectionViewType.Time],
-        ["carousel", CollectionViewType.Carousel],
-        ["linear", CollectionViewType.Linear],
-    ]);
-
-    export const valueOf = (value: string) => stringMapping.get(value.toLowerCase());
-    export const stringFor = (value: number) => Array.from(stringMapping.entries()).find(entry => entry[1] === value)?.[0];
+    Invalid = "invalid",
+    Freeform = "freeform",
+    Schema = "schema",
+    Docking = "docking",
+    Tree = 'tree',
+    Stacking = "stacking",
+    Masonry = "masonry",
+    Multicolumn = "multicolumn",
+    Multirow = "multirow",
+    Time = "time",
+    Carousel = "carousel",
+    Linear = "linear",
+    Staff = "staff",
 }
 
 export interface CollectionRenderProps {
@@ -110,7 +90,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
     protected multiTouchDisposer?: InteractionUtils.MultiTouchEventDisposer;
 
     get collectionViewType(): CollectionViewType | undefined {
-        const viewField = NumCast(this.props.Document._viewType);
+        const viewField = StrCast(this.props.Document._viewType);
         if (CollectionView._safeMode) {
             if (viewField === CollectionViewType.Freeform) {
                 return CollectionViewType.Tree;
@@ -119,7 +99,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
                 return CollectionViewType.Freeform;
             }
         }
-        return viewField;
+        return viewField as any as CollectionViewType;
     }
 
     active = (outsideReaction?: boolean) => this.props.isSelected(outsideReaction) || (this.props.rootSelected(outsideReaction) && BoolCast(this.props.Document.forceActive)) || this._isChildActive || this.props.renderDepth === 0;
@@ -394,7 +374,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
                 const params = { layoutDoc: Doc.name, dataDoc: Doc.name, };
                 newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, dataDoc, "${this.props.fieldKey}", "${facetHeader}")`, params, capturedVariables);
             }
-            Doc.AddDocToList(facetCollection, this.props.fieldKey + "-filter", newFacet);
+            newFacet && Doc.AddDocToList(facetCollection, this.props.fieldKey + "-filter", newFacet);
         }
     }
 
diff --git a/src/client/views/collections/CollectionViewChromes.tsx b/src/client/views/collections/CollectionViewChromes.tsx
index 9bade1c82..7741f7d42 100644
--- a/src/client/views/collections/CollectionViewChromes.tsx
+++ b/src/client/views/collections/CollectionViewChromes.tsx
@@ -18,7 +18,6 @@ import { CollectionView } from "./CollectionView";
 import "./CollectionViewChromes.scss";
 import * as Autosuggest from 'react-autosuggest';
 import KeyRestrictionRow from "./KeyRestrictionRow";
-import { ObjectField } from "../../../new_fields/ObjectField";
 const datepicker = require('js-datepicker');
 
 interface CollectionViewChromeProps {
@@ -349,11 +348,11 @@ export class CollectionViewBaseChrome extends React.Component<CollectionViewChro
 
     dragViewDown = (e: React.PointerEvent) => {
         setupMoveUpEvents(this, e, (e, down, delta) => {
-            const vtype = NumCast(this.props.CollectionView.props.Document._viewType) as CollectionViewType;
+            const vtype = this.props.CollectionView.collectionViewType;
             const c = {
-                params: ["target"], title: CollectionViewType.stringFor(vtype),
+                params: ["target"], title: vtype,
                 script: `this.target._viewType = ${NumCast(this.props.CollectionView.props.Document._viewType)}`,
-                immediate: (source: Doc[]) => this.target = Doc.getTemplateDoc(source?.[0]),
+                immediate: (source: Doc[]) => this.props.CollectionView.props.Document._viewType = Doc.getDocTemplate(source?.[0]),
                 initialize: emptyFunction,
             };
             DragManager.StartButtonDrag([this._viewRef.current!], c.script, StrCast(c.title),
diff --git a/src/client/views/collections/ParentDocumentSelector.tsx b/src/client/views/collections/ParentDocumentSelector.tsx
index afe269ec3..2f0132fec 100644
--- a/src/client/views/collections/ParentDocumentSelector.tsx
+++ b/src/client/views/collections/ParentDocumentSelector.tsx
@@ -54,7 +54,7 @@ export class SelectorContextMenu extends React.Component<SelectorProps> {
     getOnClick({ col, target }: { col: Doc, target: Doc }) {
         return () => {
             col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
-            if (NumCast(col._viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
+            if (col._viewType === CollectionViewType.Freeform) {
                 const newPanX = NumCast(target.x) + NumCast(target._width) / 2;
                 const newPanY = NumCast(target.y) + NumCast(target._height) / 2;
                 col._panX = newPanX;
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
index a33146388..09fc5148e 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinkView.tsx
@@ -26,8 +26,8 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
             action(() => {
                 setTimeout(action(() => this._opacity = 1), 0); // since the render code depends on querying the Dom through getBoudndingClientRect, we need to delay triggering render()
                 setTimeout(action(() => this._opacity = 0.05), 750); // this will unhighlight the link line.
-                const acont = this.props.A.props.Document.type === DocumentType.LINK ? this.props.A.ContentDiv!.getElementsByClassName("docuLinkBox-cont") : [];
-                const bcont = this.props.B.props.Document.type === DocumentType.LINK ? this.props.B.ContentDiv!.getElementsByClassName("docuLinkBox-cont") : [];
+                const acont = this.props.A.props.Document.type === DocumentType.LINK ? this.props.A.ContentDiv!.getElementsByClassName("linkAnchorBox-cont") : [];
+                const bcont = this.props.B.props.Document.type === DocumentType.LINK ? this.props.B.ContentDiv!.getElementsByClassName("linkAnchorBox-cont") : [];
                 const adiv = (acont.length ? acont[0] : this.props.A.ContentDiv!);
                 const bdiv = (bcont.length ? bcont[0] : this.props.B.ContentDiv!);
                 const a = adiv.getBoundingClientRect();
@@ -43,7 +43,7 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
                 const afield = StrCast(this.props.A.props.Document[StrCast(this.props.A.props.layoutKey, "layout")]).indexOf("anchor1") === -1 ? "anchor2" : "anchor1";
                 const bfield = afield === "anchor1" ? "anchor2" : "anchor1";
 
-                // really hacky stuff to make the DocuLinkBox display where we want it to:
+                // really hacky stuff to make the LinkAnchorBox display where we want it to:
                 //   if there's an element in the DOM with the id of the opposite anchor, then that DOM element is a hyperlink source for the current anchor and we want to place our link box at it's top right
                 //   otherwise, we just use the computed nearest point on the document boundary to the target Document
                 const targetAhyperlink = window.document.getElementById(this.props.LinkDocs[0][Id] + (this.props.LinkDocs[0][afield] as Doc)[Id]);
@@ -81,8 +81,8 @@ export class CollectionFreeFormLinkView extends React.Component<CollectionFreeFo
     }
 
     render() {
-        const acont = this.props.A.props.Document.type === DocumentType.LINK ? this.props.A.ContentDiv!.getElementsByClassName("docuLinkBox-cont") : [];
-        const bcont = this.props.B.props.Document.type === DocumentType.LINK ? this.props.B.ContentDiv!.getElementsByClassName("docuLinkBox-cont") : [];
+        const acont = this.props.A.props.Document.type === DocumentType.LINK ? this.props.A.ContentDiv!.getElementsByClassName("linkAnchorBox-cont") : [];
+        const bcont = this.props.B.props.Document.type === DocumentType.LINK ? this.props.B.ContentDiv!.getElementsByClassName("linkAnchorBox-cont") : [];
         const a = (acont.length ? acont[0] : this.props.A.ContentDiv!).getBoundingClientRect();
         const b = (bcont.length ? bcont[0] : this.props.B.ContentDiv!).getBoundingClientRect();
         const apt = Utils.closestPtBetweenRectangles(a.left, a.top, a.width, a.height,
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
index 49ca024a2..d12f93f15 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLinksView.tsx
@@ -43,60 +43,4 @@ export class CollectionFreeFormLinksView extends React.Component {
             {this.props.children}
         </div>;
     }
-    // _brushReactionDisposer?: IReactionDisposer;
-    // componentDidMount() {
-    //     this._brushReactionDisposer = reaction(
-    //         () => {
-    //             let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-    //             return { doclist: doclist ? doclist : [], xs: doclist.map(d => d.x) };
-    //         },
-    //         () => {
-    //             let doclist = DocListCast(this.props.Document[this.props.fieldKey]);
-    //             let views = doclist ? doclist.filter(doc => StrCast(doc.backgroundLayout).indexOf("istogram") !== -1) : [];
-    //             views.forEach((dstDoc, i) => {
-    //                 views.forEach((srcDoc, j) => {
-    //                     let dstTarg = dstDoc;
-    //                     let srcTarg = srcDoc;
-    //                     let x1 = NumCast(srcDoc.x);
-    //                     let x2 = NumCast(dstDoc.x);
-    //                     let x1w = NumCast(srcDoc.width, -1);
-    //                     let x2w = NumCast(dstDoc.width, -1);
-    //                     if (x1w < 0 || x2w < 0 || i === j) { }
-    //                     else {
-    //                         let findBrush = (field: (Doc | Promise<Doc>)[]) => field.findIndex(brush => {
-    //                             let bdocs = brush instanceof Doc ? Cast(brush.brushingDocs, listSpec(Doc), []) : undefined;
-    //                             return bdocs && bdocs.length && ((bdocs[0] === dstTarg && bdocs[1] === srcTarg)) ? true : false;
-    //                         });
-    //                         let brushAction = (field: (Doc | Promise<Doc>)[]) => {
-    //                             let found = findBrush(field);
-    //                             if (found !== -1) {
-    //                                 field.splice(found, 1);
-    //                             }
-    //                         };
-    //                         if (Math.abs(x1 + x1w - x2) < 20) {
-    //                             let linkDoc: Doc = new Doc();
-    //                             linkDoc.title = "Histogram Brush";
-    //                             linkDoc.linkDescription = "Brush between " + StrCast(srcTarg.title) + " and " + StrCast(dstTarg.Title);
-    //                             linkDoc.brushingDocs = new List([dstTarg, srcTarg]);
-
-    //                             brushAction = (field: (Doc | Promise<Doc>)[]) => {
-    //                                 if (findBrush(field) === -1) {
-    //                                     field.push(linkDoc);
-    //                                 }
-    //                             };
-    //                         }
-    //                         if (dstTarg.brushingDocs === undefined) dstTarg.brushingDocs = new List<Doc>();
-    //                         if (srcTarg.brushingDocs === undefined) srcTarg.brushingDocs = new List<Doc>();
-    //                         let dstBrushDocs = Cast(dstTarg.brushingDocs, listSpec(Doc), []);
-    //                         let srcBrushDocs = Cast(srcTarg.brushingDocs, listSpec(Doc), []);
-    //                         brushAction(dstBrushDocs);
-    //                         brushAction(srcBrushDocs);
-    //                     }
-    //                 });
-    //             });
-    //         });
-    // }
-    // componentWillUnmount() {
-    //     this._brushReactionDisposer?.();
-    // }
 }
\ No newline at end of file
diff --git a/src/client/views/nodes/AudioBox.scss b/src/client/views/nodes/AudioBox.scss
index fb16b8365..53b54d7e4 100644
--- a/src/client/views/nodes/AudioBox.scss
+++ b/src/client/views/nodes/AudioBox.scss
@@ -88,7 +88,7 @@
                     opacity:0.9;
                     background-color: transparent;
                     box-shadow: black 2px 2px 1px;
-                    .docuLinkBox-cont {
+                    .linkAnchorBox-cont {
                         position: relative !important;
                         height: 100%  !important;
                         width: 100% !important;
@@ -103,7 +103,7 @@
                     box-shadow: black 1px 1px 1px;
                     margin-left: -1;
                     margin-top: -2;
-                    .docuLinkBox-cont {
+                    .linkAnchorBox-cont {
                         position: relative !important;
                         height: 100%  !important;
                         width: 100% !important;
diff --git a/src/client/views/nodes/ButtonBox.scss b/src/client/views/nodes/ButtonBox.scss
deleted file mode 100644
index 293af289d..000000000
--- a/src/client/views/nodes/ButtonBox.scss
+++ /dev/null
@@ -1,38 +0,0 @@
-.buttonBox-outerDiv {
-    width: 100%;
-    height: 100%;
-    pointer-events: all;
-    border-radius: inherit;
-    display: flex;
-    flex-direction: column;
-}
-
-.buttonBox-mainButton {
-    width: 100%;
-    height: 100%;
-    border-radius: inherit;
-    letter-spacing: 2px;
-    text-transform: uppercase;
-    overflow: hidden;
-    display:flex;
-}
-
-.buttonBox-mainButtonCenter {
-    overflow: hidden;
-    text-overflow: ellipsis;
-    white-space: nowrap;
-    display: inline;
-    align-items: center;
-    margin: auto;
-}
-
-.buttonBox-params {
-    display: flex;
-    flex-direction: row;
-}
-
-.buttonBox-missingParam {
-    width: 100%;
-    background: lightgray;
-    border: dimGray solid 1px;
-}
\ No newline at end of file
diff --git a/src/client/views/nodes/ButtonBox.tsx b/src/client/views/nodes/ButtonBox.tsx
deleted file mode 100644
index 1b70ff824..000000000
--- a/src/client/views/nodes/ButtonBox.tsx
+++ /dev/null
@@ -1,97 +0,0 @@
-import { library } from '@fortawesome/fontawesome-svg-core';
-import { faEdit } from '@fortawesome/free-regular-svg-icons';
-import { action, computed } from 'mobx';
-import { observer } from 'mobx-react';
-import * as React from 'react';
-import { Doc, DocListCast } from '../../../new_fields/Doc';
-import { List } from '../../../new_fields/List';
-import { createSchema, makeInterface, listSpec } from '../../../new_fields/Schema';
-import { ScriptField } from '../../../new_fields/ScriptField';
-import { BoolCast, StrCast, Cast, FieldValue } from '../../../new_fields/Types';
-import { DragManager } from '../../util/DragManager';
-import { undoBatch } from '../../util/UndoManager';
-import { DocComponent } from '../DocComponent';
-import './ButtonBox.scss';
-import { FieldView, FieldViewProps } from './FieldView';
-import { ContextMenuProps } from '../ContextMenuItem';
-import { ContextMenu } from '../ContextMenu';
-import { documentSchema } from '../../../new_fields/documentSchemas';
-
-
-library.add(faEdit as any);
-
-const ButtonSchema = createSchema({
-    onClick: ScriptField,
-    buttonParams: listSpec("string"),
-    text: "string"
-});
-
-type ButtonDocument = makeInterface<[typeof ButtonSchema, typeof documentSchema]>;
-const ButtonDocument = makeInterface(ButtonSchema, documentSchema);
-
-@observer
-export class ButtonBox extends DocComponent<FieldViewProps, ButtonDocument>(ButtonDocument) {
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(ButtonBox, fieldKey); }
-    private dropDisposer?: DragManager.DragDropDisposer;
-
-    @computed get dataDoc() {
-        return this.props.DataDoc &&
-            (this.Document.isTemplateForField || BoolCast(this.props.DataDoc.isTemplateForField) ||
-                this.props.DataDoc.layout === this.props.Document) ? this.props.DataDoc : Doc.GetProto(this.props.Document);
-    }
-
-
-    protected createDropTarget = (ele: HTMLDivElement) => {
-        this.dropDisposer?.();
-        if (ele) {
-            this.dropDisposer = DragManager.MakeDropTarget(ele, this.drop.bind(this));
-        }
-    }
-
-    specificContextMenu = (e: React.MouseEvent): void => {
-        const funcs: ContextMenuProps[] = [];
-        funcs.push({
-            description: "Clear Script Params", event: () => {
-                const params = FieldValue(this.Document.buttonParams);
-                params?.map(p => this.props.Document[p] = undefined);
-            }, icon: "trash"
-        });
-
-        ContextMenu.Instance.addItem({ description: "OnClick...", subitems: funcs, icon: "asterisk" });
-    }
-
-    @undoBatch
-    @action
-    drop = (e: Event, de: DragManager.DropEvent) => {
-        const docDragData = de.complete.docDragData;
-        const params = this.Document.buttonParams;
-        const missingParams = params?.filter(p => this.props.Document[p] === undefined);
-        if (docDragData && missingParams?.includes((e.target as any).textContent)) {
-            this.props.Document[(e.target as any).textContent] = new List<Doc>(docDragData.droppedDocuments.map((d, i) =>
-                d.onDragStart ? docDragData.draggedDocuments[i] : d));
-            e.stopPropagation();
-        }
-    }
-    // (!missingParams || !missingParams.length ? "" : "(" + missingParams.map(m => m + ":").join(" ") + ")")
-    render() {
-        const params = this.Document.buttonParams;
-        const missingParams = params?.filter(p => this.props.Document[p] === undefined);
-        params?.map(p => DocListCast(this.props.Document[p])); // bcz: really hacky form of prefetching ... 
-        return (
-            <div className="buttonBox-outerDiv" ref={this.createDropTarget} onContextMenu={this.specificContextMenu}
-                style={{ boxShadow: this.Document.opacity === 0 ? undefined : StrCast(this.Document.boxShadow, "") }}>
-                <div className="buttonBox-mainButton" style={{
-                    background: this.Document.backgroundColor, color: this.Document.color || "inherit",
-                    fontSize: this.Document.fontSize, letterSpacing: this.Document.letterSpacing || "", textTransform: (this.Document.textTransform as any) || ""
-                }} >
-                    <div className="buttonBox-mainButtonCenter">
-                        {(this.Document.text || this.Document.title)}
-                    </div>
-                </div>
-                <div className="buttonBox-params" >
-                    {!missingParams || !missingParams.length ? (null) : missingParams.map(m => <div key={m} className="buttonBox-missingParam">{m}</div>)}
-                </div>
-            </div>
-        );
-    }
-}
\ No newline at end of file
diff --git a/src/client/views/nodes/DocuLinkBox.scss b/src/client/views/nodes/DocuLinkBox.scss
deleted file mode 100644
index f2c203548..000000000
--- a/src/client/views/nodes/DocuLinkBox.scss
+++ /dev/null
@@ -1,29 +0,0 @@
-.docuLinkBox-cont, .docuLinkBox-cont-small {
-    cursor: default;
-    position: absolute;
-    width: 15;
-    height: 15;
-    border-radius: 20px;
-    pointer-events: all;
-    user-select: none;
-
-    .docuLinkBox-linkCloser {
-        position: absolute;
-        width: 18;
-        height: 18;
-        background: rgb(219, 21, 21);
-        top: -1px;
-        left: -1px;
-        border-radius: 5px;
-        display: flex;
-        justify-content: center;
-        align-items: center;
-        padding-left: 2px;
-        padding-top: 1px;
-    }
-}
-
-.docuLinkBox-cont-small {
-    width:5px;
-    height:5px;
-}
\ No newline at end of file
diff --git a/src/client/views/nodes/DocuLinkBox.tsx b/src/client/views/nodes/DocuLinkBox.tsx
deleted file mode 100644
index 31ce58079..000000000
--- a/src/client/views/nodes/DocuLinkBox.tsx
+++ /dev/null
@@ -1,146 +0,0 @@
-import { action, observable } from "mobx";
-import { observer } from "mobx-react";
-import { Doc, DocListCast } from "../../../new_fields/Doc";
-import { documentSchema } from "../../../new_fields/documentSchemas";
-import { makeInterface } from "../../../new_fields/Schema";
-import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
-import { Utils, setupMoveUpEvents } from '../../../Utils';
-import { DocumentManager } from "../../util/DocumentManager";
-import { DragManager } from "../../util/DragManager";
-import { DocComponent } from "../DocComponent";
-import "./DocuLinkBox.scss";
-import { FieldView, FieldViewProps } from "./FieldView";
-import React = require("react");
-import { ContextMenuProps } from "../ContextMenuItem";
-import { ContextMenu } from "../ContextMenu";
-import { LinkEditor } from "../linking/LinkEditor";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { SelectionManager } from "../../util/SelectionManager";
-import { TraceMobx } from "../../../new_fields/util";
-const higflyout = require("@hig/flyout");
-export const { anchorPoints } = higflyout;
-export const Flyout = higflyout.default;
-
-type DocLinkSchema = makeInterface<[typeof documentSchema]>;
-const DocLinkDocument = makeInterface(documentSchema);
-
-@observer
-export class DocuLinkBox extends DocComponent<FieldViewProps, DocLinkSchema>(DocLinkDocument) {
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DocuLinkBox, fieldKey); }
-    _doubleTap = false;
-    _lastTap: number = 0;
-    _ref = React.createRef<HTMLDivElement>();
-    _isOpen = false;
-    _timeout: NodeJS.Timeout | undefined;
-    @observable _x = 0;
-    @observable _y = 0;
-    @observable _selected = false;
-    @observable _editing = false;
-    @observable _forceOpen = false;
-
-    onPointerDown = (e: React.PointerEvent) => {
-        setupMoveUpEvents(this, e, this.onPointerMove, () => { }, this.onClick);
-    }
-    onPointerMove = action((e: PointerEvent, down: number[], delta: number[]) => {
-        const cdiv = this._ref && this._ref.current && this._ref.current.parentElement;
-        if (!this._isOpen && cdiv) {
-            const bounds = cdiv.getBoundingClientRect();
-            const pt = Utils.getNearestPointInPerimeter(bounds.left, bounds.top, bounds.width, bounds.height, e.clientX, e.clientY);
-            const separation = Math.sqrt((pt[0] - e.clientX) * (pt[0] - e.clientX) + (pt[1] - e.clientY) * (pt[1] - e.clientY));
-            const dragdist = Math.sqrt((pt[0] - down[0]) * (pt[0] - down[0]) + (pt[1] - down[1]) * (pt[1] - down[1]));
-            if (separation > 100) {
-                const dragData = new DragManager.DocumentDragData([this.props.Document]);
-                dragData.dropAction = "alias";
-                dragData.removeDropProperties = ["anchor1_x", "anchor1_y", "anchor2_x", "anchor2_y", "isButton"];
-                DragManager.StartDocumentDrag([this._ref.current!], dragData, down[0], down[1]);
-                return true;
-            } else if (dragdist > separation) {
-                this.props.Document[this.props.fieldKey + "_x"] = (pt[0] - bounds.left) / bounds.width * 100;
-                this.props.Document[this.props.fieldKey + "_y"] = (pt[1] - bounds.top) / bounds.height * 100;
-            }
-        }
-        return false;
-    });
-    @action
-    onClick = (e: PointerEvent) => {
-        this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0);
-        this._lastTap = Date.now();
-        if ((e.button === 2 || e.ctrlKey || !this.props.Document.isButton)) {
-            this.props.select(false);
-        }
-        if (!this._doubleTap) {
-            const anchorContainerDoc = this.props.ContainingCollectionDoc; // bcz: hack!  need a better prop for passing the anchor's container 
-            this._editing = true;
-            anchorContainerDoc && this.props.bringToFront(anchorContainerDoc, false);
-            if (anchorContainerDoc && !this.props.Document.onClick && !this._isOpen) {
-                this._timeout = setTimeout(action(() => {
-                    DocumentManager.Instance.FollowLink(this.props.Document, anchorContainerDoc, document => this.props.addDocTab(document, StrCast(this.props.Document.linkOpenLocation, "inTab")), false);
-                    this._editing = false;
-                }), 300 - (Date.now() - this._lastTap));
-            }
-        } else {
-            this._timeout && clearTimeout(this._timeout);
-            this._timeout = undefined;
-        }
-    }
-
-    openLinkDocOnRight = (e: React.MouseEvent) => {
-        this.props.addDocTab(this.props.Document, "onRight");
-    }
-    openLinkTargetOnRight = (e: React.MouseEvent) => {
-        const alias = Doc.MakeAlias(Cast(this.props.Document[this.props.fieldKey], Doc, null));
-        alias.isButton = undefined;
-        alias.isBackground = undefined;
-        alias.layoutKey = "layout";
-        this.props.addDocTab(alias, "onRight");
-    }
-    @action
-    openLinkEditor = action((e: React.MouseEvent) => {
-        SelectionManager.DeselectAll();
-        this._editing = this._forceOpen = true;
-    });
-
-    specificContextMenu = (e: React.MouseEvent): void => {
-        const funcs: ContextMenuProps[] = [];
-        funcs.push({ description: "Open Link Target on Right", event: () => this.openLinkTargetOnRight(e), icon: "eye" });
-        funcs.push({ description: "Open Link on Right", event: () => this.openLinkDocOnRight(e), icon: "eye" });
-        funcs.push({ description: "Open Link Editor", event: () => this.openLinkEditor(e), icon: "eye" });
-
-        ContextMenu.Instance.addItem({ description: "Link Funcs...", subitems: funcs, icon: "asterisk" });
-    }
-
-    render() {
-        TraceMobx();
-        const x = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_x"], 100) : 0;
-        const y = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_y"], 100) : 0;
-        const c = StrCast(this.props.Document.backgroundColor, "lightblue");
-        const anchor = this.props.fieldKey === "anchor1" ? "anchor2" : "anchor1";
-        const anchorScale = (x === 0 || x === 100 || y === 0 || y === 100) ? 1 : .15;
-
-        const timecode = this.props.Document[anchor + "Timecode"];
-        const targetTitle = StrCast((this.props.Document[anchor]! as Doc).title) + (timecode !== undefined ? ":" + timecode : "");
-        const flyout = (
-            <div className="docuLinkBox-flyout" title=" " onPointerOver={() => Doc.UnBrushDoc(this.props.Document)}>
-                <LinkEditor sourceDoc={Cast(this.props.Document[this.props.fieldKey], Doc, null)} hideback={true} linkDoc={this.props.Document} showLinks={action(() => { })} />
-                {!this._forceOpen ? (null) : <div className="docuLinkBox-linkCloser" onPointerDown={action(() => this._isOpen = this._editing = this._forceOpen = false)}>
-                    <FontAwesomeIcon color="dimGray" icon={"times"} size={"sm"} />
-                </div>}
-            </div>
-        );
-        const small = this.props.PanelWidth() <= 1;
-        return <div className={`docuLinkBox-cont${small ? "-small" : ""}`} onPointerDown={this.onPointerDown} title={targetTitle} onContextMenu={this.specificContextMenu}
-            ref={this._ref} style={{
-                background: c,
-                left: !small ? `calc(${x}% - 7.5px)` : undefined,
-                top: !small ? `calc(${y}% - 7.5px)` : undefined,
-                transform: `scale(${anchorScale / this.props.ContentScaling()})`
-            }} >
-            {!this._editing && !this._forceOpen ? (null) :
-                <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout} open={this._forceOpen ? true : undefined} onOpen={() => this._isOpen = true} onClose={action(() => this._isOpen = this._forceOpen = this._editing = false)}>
-                    <span className="parentDocumentSelector-button" >
-                        <FontAwesomeIcon icon={"eye"} size={"lg"} />
-                    </span>
-                </Flyout>}
-        </div>;
-    }
-}
diff --git a/src/client/views/nodes/DocumentBox.tsx b/src/client/views/nodes/DocumentBox.tsx
index 0e2685d41..4f2b3b656 100644
--- a/src/client/views/nodes/DocumentBox.tsx
+++ b/src/client/views/nodes/DocumentBox.tsx
@@ -18,12 +18,12 @@ import { TraceMobx } from "../../../new_fields/util";
 import { DocumentView } from "./DocumentView";
 import { Docs } from "../../documents/Documents";
 
-type DocBoxSchema = makeInterface<[typeof documentSchema]>;
-const DocBoxDocument = makeInterface(documentSchema);
+type DocHolderBoxSchema = makeInterface<[typeof documentSchema]>;
+const DocHolderBoxDocument = makeInterface(documentSchema);
 
 @observer
-export class DocumentBox extends DocAnnotatableComponent<FieldViewProps, DocBoxSchema>(DocBoxDocument) {
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DocumentBox, fieldKey); }
+export class DocHolderBox extends DocAnnotatableComponent<FieldViewProps, DocHolderBoxSchema>(DocHolderBoxDocument) {
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(DocHolderBox, fieldKey); }
     _prevSelectionDisposer: IReactionDisposer | undefined;
     _selections: Doc[] = [];
     _curSelection = -1;
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index dc71ba280..7522af3a3 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -3,7 +3,6 @@ import { observer } from "mobx-react";
 import { Doc, Opt } from "../../../new_fields/Doc";
 import { Cast, StrCast } from "../../../new_fields/Types";
 import { OmitKeys, Without } from "../../../Utils";
-import { HistogramBox } from "../../northstar/dash-nodes/HistogramBox";
 import DirectoryImportBox from "../../util/Import & Export/DirectoryImportBox";
 import { CollectionDockingView } from "../collections/CollectionDockingView";
 import { CollectionFreeFormView } from "../collections/collectionFreeForm/CollectionFreeFormView";
@@ -11,10 +10,11 @@ import { CollectionSchemaView } from "../collections/CollectionSchemaView";
 import { CollectionView } from "../collections/CollectionView";
 import { YoutubeBox } from "./../../apis/youtube/YoutubeBox";
 import { AudioBox } from "./AudioBox";
-import { ButtonBox } from "./ButtonBox";
+import { LabelBox } from "./LabelBox";
 import { SliderBox } from "./SliderBox";
 import { LinkBox } from "./LinkBox";
-import { DocumentBox } from "./DocumentBox";
+import { ScriptingBox } from "./ScriptingBox";
+import { DocHolderBox } from "./DocumentBox";
 import { DocumentViewProps } from "./DocumentView";
 import "./DocumentView.scss";
 import { FontIconBox } from "./FontIconBox";
@@ -27,7 +27,7 @@ import { PresBox } from "./PresBox";
 import { QueryBox } from "./QueryBox";
 import { ColorBox } from "./ColorBox";
 import { DashWebRTCVideo } from "../webcam/DashWebRTCVideo";
-import { DocuLinkBox } from "./DocuLinkBox";
+import { LinkAnchorBox } from "./LinkAnchorBox";
 import { PresElementBox } from "../presentationview/PresElementBox";
 import { ScreenshotBox } from "./ScreenshotBox";
 import { VideoBox } from "./VideoBox";
@@ -109,10 +109,10 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
                 <ObserverJsxParser
                     blacklistedAttrs={[]}
                     components={{
-                        FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, ButtonBox, SliderBox, FieldView,
+                        FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, LabelBox, SliderBox, FieldView,
                         CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
-                        PDFBox, VideoBox, AudioBox, HistogramBox, PresBox, YoutubeBox, PresElementBox, QueryBox,
-                        ColorBox, DashWebRTCVideo, DocuLinkBox, InkingStroke, DocumentBox, LinkBox,
+                        PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, QueryBox,
+                        ColorBox, DashWebRTCVideo, LinkAnchorBox, InkingStroke, DocHolderBox, LinkBox, ScriptingBox,
                         RecommendationsBox, ScreenshotBox
                     }}
                     bindings={this.CreateBindings()}
diff --git a/src/client/views/nodes/DocumentView.scss b/src/client/views/nodes/DocumentView.scss
index ce7bcd206..fc9ee1201 100644
--- a/src/client/views/nodes/DocumentView.scss
+++ b/src/client/views/nodes/DocumentView.scss
@@ -34,11 +34,11 @@
         overflow-y: scroll;
         height: calc(100% - 20px);
     }
-    .documentView-docuLinkAnchor {
+    .documentView-linkAnchorBoxAnchor {
         display:flex;
         overflow: hidden;
     }
-    .documentView-docuLinkWrapper {
+    .documentView-linkAnchorBoxWrapper {
         pointer-events: none;
         position: absolute;
         transform-origin: top left;
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 2df5c9bbd..8ba61fb7e 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -296,13 +296,13 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                     this: this.props.Document,
                     self: Cast(this.props.Document.rootDocument, Doc, null) || this.props.Document,
                     thisContainer: this.props.ContainingCollectionDoc, shiftKey: e.shiftKey
-                }, console.log);// && !this.props.Document.isButton && this.select(false);
+                }, console.log);
                 if (this.props.Document !== Doc.UserDoc().undoBtn && this.props.Document !== Doc.UserDoc().redoBtn) {
                     UndoManager.RunInBatch(func, "on click");
                 } else func();
-            } else if (this.Document.type === DocumentType.BUTTON) {
-                UndoManager.RunInBatch(() => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", e.clientX, e.clientY), "on button click");
-            } else if (this.Document.isButton) {
+            } else if (this.Document.editScriptOnClick) {
+                UndoManager.RunInBatch(() => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, StrCast(this.Document.editScriptOnClick), e.clientX, e.clientY), "on button click");
+            } else if (this.Document.isLinkButton) {
                 DocListCast(this.props.Document.links).length && this.followLinkClick(e.altKey, e.ctrlKey, e.shiftKey);
             } else {
                 if (this.props.Document.isTemplateForField && !(e.ctrlKey || e.button > 0)) {
@@ -327,7 +327,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             const targetFocusAfterDocFocus = () => {
                 const where = StrCast(this.Document.followLinkLocation) || followLoc;
                 const hackToCallFinishAfterFocus = () => {
-                    setTimeout(() => finished?.(), 0); // finished() needs to be called right after hackToCallFinishAfterFocus(), but there's no callback for that so we use the hacky timeout.  
+                    finished && setTimeout(finished, 0); // finished() needs to be called right after hackToCallFinishAfterFocus(), but there's no callback for that so we use the hacky timeout.  
                     return false; // we must return false here so that the zoom to the document is not reversed.  If it weren't for needing to call finished(), we wouldn't need this function at all since not having it is equivalent to returning false
                 };
                 this.props.addDocTab(doc, where) && this.props.focus(doc, true, undefined, hackToCallFinishAfterFocus); //  add the target and focus on it.
@@ -577,23 +577,23 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     }
 
     @undoBatch
-    toggleButtonBehavior = (): void => {
-        if (this.Document.isButton || this.Document.onClick || this.Document.ignoreClick) {
-            this.Document.isButton = false;
+    toggleLinkButtonBehavior = (): void => {
+        if (this.Document.isLinkButton || this.Document.onClick || this.Document.ignoreClick) {
+            this.Document.isLinkButton = false;
             this.Document.ignoreClick = false;
             this.Document.onClick = undefined;
         } else {
-            this.Document.isButton = true;
+            this.Document.isLinkButton = true;
             this.Document.followLinkLocation = undefined;
         }
     }
 
     @undoBatch
     toggleFollowInPlace = (): void => {
-        if (this.Document.isButton) {
-            this.Document.isButton = false;
+        if (this.Document.isLinkButton) {
+            this.Document.isLinkButton = false;
         } else {
-            this.Document.isButton = true;
+            this.Document.isLinkButton = true;
             this.Document.followLinkLocation = "inPlace";
         }
     }
@@ -642,7 +642,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             const portal = Docs.Create.FreeformDocument([], { _width: (this.layoutDoc._width || 0) + 10, _height: this.layoutDoc._height || 0, title: StrCast(this.props.Document.title) + ".portal" });
             DocUtils.MakeLink({ doc: this.props.Document }, { doc: portal }, "portal to");
         }
-        this.Document.isButton = true;
+        this.Document.isLinkButton = true;
     }
 
     @undoBatch
@@ -727,8 +727,8 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         onClicks.push({ description: "Enter Portal", event: this.makeIntoPortal, icon: "window-restore" });
         onClicks.push({ description: "Toggle Detail", event: () => this.Document.onClick = ScriptField.MakeScript(`toggleDetail(this, "${this.props.Document.layoutKey}")`), icon: "window-restore" });
         onClicks.push({ description: this.Document.ignoreClick ? "Select" : "Do Nothing", event: () => this.Document.ignoreClick = !this.Document.ignoreClick, icon: this.Document.ignoreClick ? "unlock" : "lock" });
-        onClicks.push({ description: this.Document.isButton ? "Remove Follow Behavior" : "Follow Link in Place", event: this.toggleFollowInPlace, icon: "concierge-bell" });
-        onClicks.push({ description: this.Document.isButton || this.Document.onClick ? "Remove Click Behavior" : "Follow Link", event: this.toggleButtonBehavior, icon: "concierge-bell" });
+        onClicks.push({ description: this.Document.isLinkButton ? "Remove Follow Behavior" : "Follow Link in Place", event: this.toggleFollowInPlace, icon: "concierge-bell" });
+        onClicks.push({ description: this.Document.isLinkButton || this.Document.onClick ? "Remove Click Behavior" : "Follow Link", event: this.toggleLinkButtonBehavior, icon: "concierge-bell" });
         onClicks.push({ description: "Edit onClick Script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Button Clicked ...", this.props.Document, "onClick", obj.x, obj.y) });
         !existingOnClick && cm.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" });
 
@@ -861,7 +861,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         await Promise.all(allDocs.map((doc: Doc) => {
             let isMainDoc: boolean = false;
             const dataDoc = Doc.GetProto(doc);
-            if (doc.type === DocumentType.TEXT) {
+            if (doc.type === DocumentType.RTF) {
                 if (dataDoc === Doc.GetProto(this.props.Document)) {
                     isMainDoc = true;
                 }
@@ -964,7 +964,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         const fallback = Cast(this.props.Document.layoutKey, "string");
         return typeof fallback === "string" ? fallback : "layout";
     }
-    rootSelected = (outsideReaction: boolean) => {
+    rootSelected = (outsideReaction?: boolean) => {
         return this.isSelected(outsideReaction) || (this.props.Document.forceActive && this.props.rootSelected?.(outsideReaction) ? true : false);
     }
     childScaling = () => (this.layoutDoc._fitWidth ? this.props.PanelWidth() / this.nativeWidth : this.props.ContentScaling());
@@ -1026,10 +1026,10 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     @computed get anchors() {
         TraceMobx();
         return DocListCast(this.Document.links).filter(d => !d.hidden && this.isNonTemporalLink).map((d, i) =>
-            <div className="documentView-docuLinkWrapper" key={d[Id]}>
+            <div className="documentView-linkAnchorBoxWrapper" key={d[Id]}>
                 <DocumentView {...this.props}
                     Document={d}
-                    ContainingCollectionDoc={this.props.Document} // bcz: hack this.props.Document is not a collection  Need a better prop for passing the containing document to the DocuLinkBox
+                    ContainingCollectionDoc={this.props.Document} // bcz: hack this.props.Document is not a collection  Need a better prop for passing the containing document to the LinkAnchorBox
                     PanelWidth={this.anchorPanelWidth}
                     PanelHeight={this.anchorPanelHeight}
                     layoutKey={this.linkEndpoint(d)}
@@ -1041,7 +1041,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
     @computed get innards() {
         TraceMobx();
         if (!this.props.PanelWidth()) {  // this happens when the document is a tree view label
-            return <div className="documentView-docuLinkAnchor" >
+            return <div className="documentView-linkAnchorBoxAnchor" >
                 {StrCast(this.props.Document.title)}
                 {this.anchors}
             </div>;
diff --git a/src/client/views/nodes/FormattedTextBox.tsx b/src/client/views/nodes/FormattedTextBox.tsx
index 37770a2e1..836d95830 100644
--- a/src/client/views/nodes/FormattedTextBox.tsx
+++ b/src/client/views/nodes/FormattedTextBox.tsx
@@ -262,7 +262,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
         if (de.complete.docDragData) {
             const draggedDoc = de.complete.docDragData.draggedDocuments.length && de.complete.docDragData.draggedDocuments[0];
             // replace text contents whend dragging with Alt
-            if (draggedDoc && draggedDoc.type === DocumentType.TEXT && !Doc.AreProtosEqual(draggedDoc, this.props.Document) && de.altKey) {
+            if (draggedDoc && draggedDoc.type === DocumentType.RTF && !Doc.AreProtosEqual(draggedDoc, this.props.Document) && de.altKey) {
                 if (draggedDoc.data instanceof RichTextField) {
                     Doc.GetProto(this.dataDoc)[this.props.fieldKey] = new RichTextField(draggedDoc.data.Data, draggedDoc.data.Text);
                     e.stopPropagation();
@@ -1206,7 +1206,7 @@ export class FormattedTextBox extends DocAnnotatableComponent<(FieldViewProps &
                     <div className={`formattedTextBox-inner${rounded}`} ref={this.createDropTarget}
                         style={{
                             padding: `${NumCast(this.Document._xMargin, 0)}px  ${NumCast(this.Document._yMargin, 0)}px`,
-                            pointerEvents: ((this.Document.isButton || this.props.onClick) && !this.props.isSelected()) ? "none" : undefined
+                            pointerEvents: ((this.Document.isLinkButton || this.props.onClick) && !this.props.isSelected()) ? "none" : undefined
                         }} />
                 </div>
                 {!this.props.Document._showSidebar ? (null) : this.sidebarWidthPercent === "0%" ?
diff --git a/src/client/views/nodes/LabelBox.scss b/src/client/views/nodes/LabelBox.scss
new file mode 100644
index 000000000..ab5b2c6b3
--- /dev/null
+++ b/src/client/views/nodes/LabelBox.scss
@@ -0,0 +1,38 @@
+.labelBox-outerDiv {
+    width: 100%;
+    height: 100%;
+    pointer-events: all;
+    border-radius: inherit;
+    display: flex;
+    flex-direction: column;
+}
+
+.labelBox-mainButton {
+    width: 100%;
+    height: 100%;
+    border-radius: inherit;
+    letter-spacing: 2px;
+    text-transform: uppercase;
+    overflow: hidden;
+    display:flex;
+}
+
+.labelBox-mainButtonCenter {
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    display: inline;
+    align-items: center;
+    margin: auto;
+}
+
+.labelBox-params {
+    display: flex;
+    flex-direction: row;
+}
+
+.labelBox-missingParam {
+    width: 100%;
+    background: lightgray;
+    border: dimGray solid 1px;
+}
\ No newline at end of file
diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx
new file mode 100644
index 000000000..0ec6af93a
--- /dev/null
+++ b/src/client/views/nodes/LabelBox.tsx
@@ -0,0 +1,97 @@
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { faEdit } from '@fortawesome/free-regular-svg-icons';
+import { action, computed } from 'mobx';
+import { observer } from 'mobx-react';
+import * as React from 'react';
+import { Doc, DocListCast } from '../../../new_fields/Doc';
+import { List } from '../../../new_fields/List';
+import { createSchema, makeInterface, listSpec } from '../../../new_fields/Schema';
+import { ScriptField } from '../../../new_fields/ScriptField';
+import { BoolCast, StrCast, Cast, FieldValue } from '../../../new_fields/Types';
+import { DragManager } from '../../util/DragManager';
+import { undoBatch } from '../../util/UndoManager';
+import { DocComponent } from '../DocComponent';
+import './LabelBox.scss';
+import { FieldView, FieldViewProps } from './FieldView';
+import { ContextMenuProps } from '../ContextMenuItem';
+import { ContextMenu } from '../ContextMenu';
+import { documentSchema } from '../../../new_fields/documentSchemas';
+
+
+library.add(faEdit as any);
+
+const LabelSchema = createSchema({
+    onClick: ScriptField,
+    buttonParams: listSpec("string"),
+    text: "string"
+});
+
+type LabelDocument = makeInterface<[typeof LabelSchema, typeof documentSchema]>;
+const LabelDocument = makeInterface(LabelSchema, documentSchema);
+
+@observer
+export class LabelBox extends DocComponent<FieldViewProps, LabelDocument>(LabelDocument) {
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(LabelBox, fieldKey); }
+    private dropDisposer?: DragManager.DragDropDisposer;
+
+    @computed get dataDoc() {
+        return this.props.DataDoc &&
+            (this.Document.isTemplateForField || BoolCast(this.props.DataDoc.isTemplateForField) ||
+                this.props.DataDoc.layout === this.props.Document) ? this.props.DataDoc : Doc.GetProto(this.props.Document);
+    }
+
+
+    protected createDropTarget = (ele: HTMLDivElement) => {
+        this.dropDisposer?.();
+        if (ele) {
+            this.dropDisposer = DragManager.MakeDropTarget(ele, this.drop.bind(this));
+        }
+    }
+
+    specificContextMenu = (e: React.MouseEvent): void => {
+        const funcs: ContextMenuProps[] = [];
+        funcs.push({
+            description: "Clear Script Params", event: () => {
+                const params = FieldValue(this.Document.buttonParams);
+                params?.map(p => this.props.Document[p] = undefined);
+            }, icon: "trash"
+        });
+
+        ContextMenu.Instance.addItem({ description: "OnClick...", subitems: funcs, icon: "asterisk" });
+    }
+
+    @undoBatch
+    @action
+    drop = (e: Event, de: DragManager.DropEvent) => {
+        const docDragData = de.complete.docDragData;
+        const params = this.Document.buttonParams;
+        const missingParams = params?.filter(p => this.props.Document[p] === undefined);
+        if (docDragData && missingParams?.includes((e.target as any).textContent)) {
+            this.props.Document[(e.target as any).textContent] = new List<Doc>(docDragData.droppedDocuments.map((d, i) =>
+                d.onDragStart ? docDragData.draggedDocuments[i] : d));
+            e.stopPropagation();
+        }
+    }
+    // (!missingParams || !missingParams.length ? "" : "(" + missingParams.map(m => m + ":").join(" ") + ")")
+    render() {
+        const params = this.Document.buttonParams;
+        const missingParams = params?.filter(p => this.props.Document[p] === undefined);
+        params?.map(p => DocListCast(this.props.Document[p])); // bcz: really hacky form of prefetching ... 
+        return (
+            <div className="labelBox-outerDiv" ref={this.createDropTarget} onContextMenu={this.specificContextMenu}
+                style={{ boxShadow: this.Document.opacity === 0 ? undefined : StrCast(this.Document.boxShadow, "") }}>
+                <div className="labelBox-mainButton" style={{
+                    background: this.Document.backgroundColor, color: this.Document.color || "inherit",
+                    fontSize: this.Document.fontSize, letterSpacing: this.Document.letterSpacing || "", textTransform: (this.Document.textTransform as any) || ""
+                }} >
+                    <div className="labelBox-mainButtonCenter">
+                        {(this.Document.text || this.Document.title)}
+                    </div>
+                </div>
+                <div className="labelBox-params" >
+                    {!missingParams || !missingParams.length ? (null) : missingParams.map(m => <div key={m} className="labelBox-missingParam">{m}</div>)}
+                </div>
+            </div>
+        );
+    }
+}
\ No newline at end of file
diff --git a/src/client/views/nodes/LinkAnchorBox.scss b/src/client/views/nodes/LinkAnchorBox.scss
new file mode 100644
index 000000000..7b6093ebd
--- /dev/null
+++ b/src/client/views/nodes/LinkAnchorBox.scss
@@ -0,0 +1,29 @@
+.linkAnchorBox-cont, .linkAnchorBox-cont-small {
+    cursor: default;
+    position: absolute;
+    width: 15;
+    height: 15;
+    border-radius: 20px;
+    pointer-events: all;
+    user-select: none;
+
+    .linkAnchorBox-linkCloser {
+        position: absolute;
+        width: 18;
+        height: 18;
+        background: rgb(219, 21, 21);
+        top: -1px;
+        left: -1px;
+        border-radius: 5px;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        padding-left: 2px;
+        padding-top: 1px;
+    }
+}
+
+.linkAnchorBox-cont-small {
+    width:5px;
+    height:5px;
+}
\ No newline at end of file
diff --git a/src/client/views/nodes/LinkAnchorBox.tsx b/src/client/views/nodes/LinkAnchorBox.tsx
new file mode 100644
index 000000000..770a3d0d1
--- /dev/null
+++ b/src/client/views/nodes/LinkAnchorBox.tsx
@@ -0,0 +1,146 @@
+import { action, observable } from "mobx";
+import { observer } from "mobx-react";
+import { Doc, DocListCast } from "../../../new_fields/Doc";
+import { documentSchema } from "../../../new_fields/documentSchemas";
+import { makeInterface } from "../../../new_fields/Schema";
+import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
+import { Utils, setupMoveUpEvents } from '../../../Utils';
+import { DocumentManager } from "../../util/DocumentManager";
+import { DragManager } from "../../util/DragManager";
+import { DocComponent } from "../DocComponent";
+import "./LinkAnchorBox.scss";
+import { FieldView, FieldViewProps } from "./FieldView";
+import React = require("react");
+import { ContextMenuProps } from "../ContextMenuItem";
+import { ContextMenu } from "../ContextMenu";
+import { LinkEditor } from "../linking/LinkEditor";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { SelectionManager } from "../../util/SelectionManager";
+import { TraceMobx } from "../../../new_fields/util";
+const higflyout = require("@hig/flyout");
+export const { anchorPoints } = higflyout;
+export const Flyout = higflyout.default;
+
+type LinkAnchorSchema = makeInterface<[typeof documentSchema]>;
+const LinkAnchorDocument = makeInterface(documentSchema);
+
+@observer
+export class LinkAnchorBox extends DocComponent<FieldViewProps, LinkAnchorSchema>(LinkAnchorDocument) {
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(LinkAnchorBox, fieldKey); }
+    _doubleTap = false;
+    _lastTap: number = 0;
+    _ref = React.createRef<HTMLDivElement>();
+    _isOpen = false;
+    _timeout: NodeJS.Timeout | undefined;
+    @observable _x = 0;
+    @observable _y = 0;
+    @observable _selected = false;
+    @observable _editing = false;
+    @observable _forceOpen = false;
+
+    onPointerDown = (e: React.PointerEvent) => {
+        setupMoveUpEvents(this, e, this.onPointerMove, () => { }, this.onClick);
+    }
+    onPointerMove = action((e: PointerEvent, down: number[], delta: number[]) => {
+        const cdiv = this._ref && this._ref.current && this._ref.current.parentElement;
+        if (!this._isOpen && cdiv) {
+            const bounds = cdiv.getBoundingClientRect();
+            const pt = Utils.getNearestPointInPerimeter(bounds.left, bounds.top, bounds.width, bounds.height, e.clientX, e.clientY);
+            const separation = Math.sqrt((pt[0] - e.clientX) * (pt[0] - e.clientX) + (pt[1] - e.clientY) * (pt[1] - e.clientY));
+            const dragdist = Math.sqrt((pt[0] - down[0]) * (pt[0] - down[0]) + (pt[1] - down[1]) * (pt[1] - down[1]));
+            if (separation > 100) {
+                const dragData = new DragManager.DocumentDragData([this.props.Document]);
+                dragData.dropAction = "alias";
+                dragData.removeDropProperties = ["anchor1_x", "anchor1_y", "anchor2_x", "anchor2_y", "isButton"];
+                DragManager.StartDocumentDrag([this._ref.current!], dragData, down[0], down[1]);
+                return true;
+            } else if (dragdist > separation) {
+                this.props.Document[this.props.fieldKey + "_x"] = (pt[0] - bounds.left) / bounds.width * 100;
+                this.props.Document[this.props.fieldKey + "_y"] = (pt[1] - bounds.top) / bounds.height * 100;
+            }
+        }
+        return false;
+    });
+    @action
+    onClick = (e: PointerEvent) => {
+        this._doubleTap = (Date.now() - this._lastTap < 300 && e.button === 0);
+        this._lastTap = Date.now();
+        if ((e.button === 2 || e.ctrlKey || !this.props.Document.isLinkButton)) {
+            this.props.select(false);
+        }
+        if (!this._doubleTap) {
+            const anchorContainerDoc = this.props.ContainingCollectionDoc; // bcz: hack!  need a better prop for passing the anchor's container 
+            this._editing = true;
+            anchorContainerDoc && this.props.bringToFront(anchorContainerDoc, false);
+            if (anchorContainerDoc && !this.props.Document.onClick && !this._isOpen) {
+                this._timeout = setTimeout(action(() => {
+                    DocumentManager.Instance.FollowLink(this.props.Document, anchorContainerDoc, document => this.props.addDocTab(document, StrCast(this.props.Document.linkOpenLocation, "inTab")), false);
+                    this._editing = false;
+                }), 300 - (Date.now() - this._lastTap));
+            }
+        } else {
+            this._timeout && clearTimeout(this._timeout);
+            this._timeout = undefined;
+        }
+    }
+
+    openLinkDocOnRight = (e: React.MouseEvent) => {
+        this.props.addDocTab(this.props.Document, "onRight");
+    }
+    openLinkTargetOnRight = (e: React.MouseEvent) => {
+        const alias = Doc.MakeAlias(Cast(this.props.Document[this.props.fieldKey], Doc, null));
+        alias.isLinkButton = undefined;
+        alias.isBackground = undefined;
+        alias.layoutKey = "layout";
+        this.props.addDocTab(alias, "onRight");
+    }
+    @action
+    openLinkEditor = action((e: React.MouseEvent) => {
+        SelectionManager.DeselectAll();
+        this._editing = this._forceOpen = true;
+    });
+
+    specificContextMenu = (e: React.MouseEvent): void => {
+        const funcs: ContextMenuProps[] = [];
+        funcs.push({ description: "Open Link Target on Right", event: () => this.openLinkTargetOnRight(e), icon: "eye" });
+        funcs.push({ description: "Open Link on Right", event: () => this.openLinkDocOnRight(e), icon: "eye" });
+        funcs.push({ description: "Open Link Editor", event: () => this.openLinkEditor(e), icon: "eye" });
+
+        ContextMenu.Instance.addItem({ description: "Link Funcs...", subitems: funcs, icon: "asterisk" });
+    }
+
+    render() {
+        TraceMobx();
+        const x = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_x"], 100) : 0;
+        const y = this.props.PanelWidth() > 1 ? NumCast(this.props.Document[this.props.fieldKey + "_y"], 100) : 0;
+        const c = StrCast(this.props.Document.backgroundColor, "lightblue");
+        const anchor = this.props.fieldKey === "anchor1" ? "anchor2" : "anchor1";
+        const anchorScale = (x === 0 || x === 100 || y === 0 || y === 100) ? 1 : .15;
+
+        const timecode = this.props.Document[anchor + "Timecode"];
+        const targetTitle = StrCast((this.props.Document[anchor]! as Doc).title) + (timecode !== undefined ? ":" + timecode : "");
+        const flyout = (
+            <div className="linkAnchorBoxBox-flyout" title=" " onPointerOver={() => Doc.UnBrushDoc(this.props.Document)}>
+                <LinkEditor sourceDoc={Cast(this.props.Document[this.props.fieldKey], Doc, null)} hideback={true} linkDoc={this.props.Document} showLinks={action(() => { })} />
+                {!this._forceOpen ? (null) : <div className="linkAnchorBox-linkCloser" onPointerDown={action(() => this._isOpen = this._editing = this._forceOpen = false)}>
+                    <FontAwesomeIcon color="dimGray" icon={"times"} size={"sm"} />
+                </div>}
+            </div>
+        );
+        const small = this.props.PanelWidth() <= 1;
+        return <div className={`linkAnchorBox-cont${small ? "-small" : ""}`} onPointerDown={this.onPointerDown} title={targetTitle} onContextMenu={this.specificContextMenu}
+            ref={this._ref} style={{
+                background: c,
+                left: !small ? `calc(${x}% - 7.5px)` : undefined,
+                top: !small ? `calc(${y}% - 7.5px)` : undefined,
+                transform: `scale(${anchorScale / this.props.ContentScaling()})`
+            }} >
+            {!this._editing && !this._forceOpen ? (null) :
+                <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={flyout} open={this._forceOpen ? true : undefined} onOpen={() => this._isOpen = true} onClose={action(() => this._isOpen = this._forceOpen = this._editing = false)}>
+                    <span className="parentDocumentSelector-button" >
+                        <FontAwesomeIcon icon={"eye"} size={"lg"} />
+                    </span>
+                </Flyout>}
+        </div>;
+    }
+}
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index f8c008a2d..53ad547b6 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -9,7 +9,6 @@ import { ScriptField } from '../../../new_fields/ScriptField';
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
 import { PdfField, URLField } from "../../../new_fields/URLField";
 import { Utils } from '../../../Utils';
-import { KeyCodes } from '../../northstar/utils/KeyCodes';
 import { undoBatch } from '../../util/UndoManager';
 import { panZoomSchema } from '../collections/collectionFreeForm/CollectionFreeFormView';
 import { ContextMenu } from '../ContextMenu';
@@ -18,10 +17,10 @@ import { DocAnnotatableComponent } from "../DocComponent";
 import { PDFViewer } from "../pdf/PDFViewer";
 import { FieldView, FieldViewProps } from './FieldView';
 import { pageSchema } from "./ImageBox";
+import { KeyCodes } from '../../util/KeyCodes';
 import "./PDFBox.scss";
 import React = require("react");
 import { documentSchema } from '../../../new_fields/documentSchemas';
-import { url } from 'inspector';
 
 type PdfDocument = makeInterface<[typeof documentSchema, typeof panZoomSchema, typeof pageSchema]>;
 const PdfDocument = makeInterface(documentSchema, panZoomSchema, pageSchema);
diff --git a/src/client/views/nodes/PresBox.tsx b/src/client/views/nodes/PresBox.tsx
index 73d09b4e1..e7434feaa 100644
--- a/src/client/views/nodes/PresBox.tsx
+++ b/src/client/views/nodes/PresBox.tsx
@@ -6,7 +6,7 @@ import { action, computed, IReactionDisposer, observable, reaction, runInAction
 import { observer } from "mobx-react";
 import { Doc, DocListCast } from "../../../new_fields/Doc";
 import { InkTool } from "../../../new_fields/InkField";
-import { BoolCast, Cast, FieldValue, NumCast } from "../../../new_fields/Types";
+import { BoolCast, Cast, FieldValue, NumCast, StrCast } from "../../../new_fields/Types";
 import { returnFalse } from "../../../Utils";
 import { DocumentManager } from "../../util/DocumentManager";
 import { undoBatch } from "../../util/UndoManager";
@@ -246,7 +246,7 @@ export class PresBox extends React.Component<FieldViewProps> {
         });
     }
 
-    updateMinimize = undoBatch(action((e: React.ChangeEvent, mode: number) => {
+    updateMinimize = undoBatch(action((e: React.ChangeEvent, mode: CollectionViewType) => {
         if (BoolCast(this.props.Document.inOverlay) !== (mode === CollectionViewType.Invalid)) {
             if (this.props.Document.inOverlay) {
                 Doc.RemoveDocFromList((Doc.UserDoc().overlays as Doc), undefined, this.props.Document);
@@ -261,7 +261,7 @@ export class PresBox extends React.Component<FieldViewProps> {
         }
     }));
 
-    initializeViewAliases = (docList: Doc[], viewtype: number) => {
+    initializeViewAliases = (docList: Doc[], viewtype: CollectionViewType) => {
         const hgt = (viewtype === CollectionViewType.Tree) ? 50 : 46;
         docList.forEach(doc => {
             doc.presBox = this.props.Document; // give contained documents a reference to the presentation
@@ -283,14 +283,14 @@ export class PresBox extends React.Component<FieldViewProps> {
     @undoBatch
     viewChanged = action((e: React.ChangeEvent) => {
         //@ts-ignore
-        this.props.Document._viewType = Number(e.target.selectedOptions[0].value);
+        this.props.Document._viewType = e.target.selectedOptions[0].value;
         this.props.Document._viewType === CollectionViewType.Stacking && (this.props.Document._pivotField = undefined); // pivot field may be set by the user in timeline view (or some other way) -- need to reset it here
         this.updateMinimize(e, Number(this.props.Document._viewType));
     });
 
     childLayoutTemplate = () => this.props.Document._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().presentationTemplate, Doc, null) : undefined;
     render() {
-        const mode = NumCast(this.props.Document._viewType, CollectionViewType.Invalid);
+        const mode = StrCast(this.props.Document._viewType) as CollectionViewType;
         this.initializeViewAliases(this.childDocs, mode);
         return <div className="presBox-cont" style={{ minWidth: this.props.Document.inOverlay ? 240 : undefined, pointerEvents: this.active() || this.props.Document.inOverlay ? "all" : "none" }} >
             <div className="presBox-buttons" style={{ display: this.props.Document._chromeStatus === "disabled" ? "none" : undefined }}>
diff --git a/src/client/views/nodes/ScriptingBox.scss b/src/client/views/nodes/ScriptingBox.scss
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/client/views/nodes/ScriptingBox.tsx b/src/client/views/nodes/ScriptingBox.tsx
new file mode 100644
index 000000000..a2dd134ed
--- /dev/null
+++ b/src/client/views/nodes/ScriptingBox.tsx
@@ -0,0 +1,71 @@
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { faEdit } from '@fortawesome/free-regular-svg-icons';
+import { computed } from 'mobx';
+import { observer } from 'mobx-react';
+import * as React from 'react';
+import { Doc } from '../../../new_fields/Doc';
+import { documentSchema } from '../../../new_fields/documentSchemas';
+import { CompileScript } from "../../util/Scripting";
+import { ScriptBox } from '../ScriptBox';
+import { createSchema, listSpec, makeInterface } from '../../../new_fields/Schema';
+import { ScriptField } from '../../../new_fields/ScriptField';
+import { BoolCast, ScriptCast } from '../../../new_fields/Types';
+import { DocComponent } from '../DocComponent';
+import { FieldView, FieldViewProps } from './FieldView';
+import './ScriptingBox.scss';
+import { DocumentIconContainer } from './DocumentIcon';
+
+
+library.add(faEdit as any);
+
+const ScriptingSchema = createSchema({
+    onClick: ScriptField,
+    buttonParams: listSpec("string"),
+    text: "string"
+});
+
+type ScriptingDocument = makeInterface<[typeof ScriptingSchema, typeof documentSchema]>;
+const ScriptingDocument = makeInterface(ScriptingSchema, documentSchema);
+
+@observer
+export class ScriptingBox extends DocComponent<FieldViewProps, ScriptingDocument>(ScriptingDocument) {
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(ScriptingBox, fieldKey); }
+
+    @computed get dataDoc() {
+        return this.props.DataDoc &&
+            (this.Document.isTemplateForField || BoolCast(this.props.DataDoc.isTemplateForField) ||
+                this.props.DataDoc.layout === this.props.Document) ? this.props.DataDoc : Doc.GetProto(this.props.Document);
+    }
+
+    specificContextMenu = (e: React.MouseEvent): void => { }
+
+    render() {
+        const script = ScriptCast(this.props.Document[this.props.fieldKey]);
+        let originalText: string | undefined = undefined;
+        if (script) {
+            originalText = script.script.originalScript;
+        }
+        return !(this.props.Document instanceof Doc) ? (null) :
+            <ScriptBox initialText={originalText}
+                setParams={() => { }}
+                onCancel={() => { }}
+                onSave={(text, onError) => {
+                    if (!text) {
+                        this.dataDoc[this.props.fieldKey] = undefined;
+                    } else {
+                        const script = CompileScript(text, {
+                            params: { this: Doc.name },
+                            typecheck: false,
+                            editable: true,
+                            transformer: DocumentIconContainer.getTransformer()
+                        });
+                        if (!script.compiled) {
+                            onError(script.errors.map(error => error.messageText).join("\n"));
+                        }
+                        else {
+                            this.dataDoc[this.props.fieldKey] = new ScriptField(script);
+                        }
+                    }
+                }} showDocumentIcons />;
+    }
+}
\ No newline at end of file
diff --git a/src/client/views/nodes/VideoBox.tsx b/src/client/views/nodes/VideoBox.tsx
index d384ad12f..a4a330fe6 100644
--- a/src/client/views/nodes/VideoBox.tsx
+++ b/src/client/views/nodes/VideoBox.tsx
@@ -132,7 +132,7 @@ export class VideoBox extends DocAnnotatableComponent<FieldViewProps, VideoDocum
                         x: (this.Document.x || 0) + width, y: (this.Document.y || 0),
                         _width: 150, _height: height / width * 150, title: "--snapshot" + (this.Document.currentTimecode || 0) + " image-"
                     });
-                    imageSummary.isButton = true;
+                    imageSummary.isLinkButton = true;
                     this.props.addDocument && this.props.addDocument(imageSummary);
                     DocUtils.MakeLink({ doc: imageSummary }, { doc: this.props.Document }, "video snapshot");
                 }
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 720f09fe0..90cd64f3c 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -282,7 +282,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
             if (anno.style.height) annoDoc._height = parseInt(anno.style.height);
             if (anno.style.width) annoDoc._width = parseInt(anno.style.width);
             annoDoc.group = mainAnnoDoc;
-            annoDoc.isButton = true;
+            annoDoc.isLinkButton = true;
             annoDocs.push(annoDoc);
             anno.remove();
             mainAnnoDoc = annoDoc;
diff --git a/src/client/views/search/FilterBox.tsx b/src/client/views/search/FilterBox.tsx
index 1c05ff864..662b37d77 100644
--- a/src/client/views/search/FilterBox.tsx
+++ b/src/client/views/search/FilterBox.tsx
@@ -33,7 +33,7 @@ export enum Keys {
 export class FilterBox extends React.Component {
 
     static Instance: FilterBox;
-    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.TEXT, DocumentType.VID, DocumentType.WEB];
+    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.RTF, DocumentType.VID, DocumentType.WEB];
 
     //if true, any keywords can be used. if false, all keywords are required.
     //this also serves as an indicator if the word status filter is applied
diff --git a/src/client/views/search/IconBar.tsx b/src/client/views/search/IconBar.tsx
index 46c109934..ec942bf7c 100644
--- a/src/client/views/search/IconBar.tsx
+++ b/src/client/views/search/IconBar.tsx
@@ -26,7 +26,7 @@ library.add(faBan);
 
 @observer
 export class IconBar extends React.Component {
-    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.TEXT, DocumentType.VID, DocumentType.WEB];
+    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.RTF, DocumentType.VID, DocumentType.WEB];
 
     @observable private _icons: string[] = this._allIcons;
 
diff --git a/src/client/views/search/IconButton.tsx b/src/client/views/search/IconButton.tsx
index 4f94139d9..52641c543 100644
--- a/src/client/views/search/IconButton.tsx
+++ b/src/client/views/search/IconButton.tsx
@@ -86,15 +86,13 @@ export class IconButton extends React.Component<IconButtonProps>{
                 return faMusic;
             case (DocumentType.COL):
                 return faObjectGroup;
-            case (DocumentType.HIST):
-                return faChartBar;
             case (DocumentType.IMG):
                 return faImage;
             case (DocumentType.LINK):
                 return faLink;
             case (DocumentType.PDF):
                 return faFilePdf;
-            case (DocumentType.TEXT):
+            case (DocumentType.RTF):
                 return faStickyNote;
             case (DocumentType.VID):
                 return faVideo;
@@ -158,15 +156,13 @@ export class IconButton extends React.Component<IconButtonProps>{
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faMusic} />);
             case (DocumentType.COL):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faObjectGroup} />);
-            case (DocumentType.HIST):
-                return (<FontAwesomeIcon className="fontawesome-icon" icon={faChartBar} />);
             case (DocumentType.IMG):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faImage} />);
             case (DocumentType.LINK):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faLink} />);
             case (DocumentType.PDF):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faFilePdf} />);
-            case (DocumentType.TEXT):
+            case (DocumentType.RTF):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faStickyNote} />);
             case (DocumentType.VID):
                 return (<FontAwesomeIcon className="fontawesome-icon" icon={faVideo} />);
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 67af661c9..19a4d558e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -128,7 +128,7 @@ export class SearchBox extends React.Component<SearchProps> {
         }
     }
 
-    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.TEXT, DocumentType.VID, DocumentType.WEB];
+    public _allIcons: string[] = [DocumentType.AUDIO, DocumentType.COL, DocumentType.IMG, DocumentType.LINK, DocumentType.PDF, DocumentType.RTF, DocumentType.VID, DocumentType.WEB];
     //if true, any keywords can be used. if false, all keywords are required.
     //this also serves as an indicator if the word status filter is applied
     @observable private _filterOpen: boolean = false;
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 0d77026ad..fe2000700 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -68,7 +68,7 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
     getOnClick({ col, target }: { col: Doc, target: Doc }) {
         return () => {
             col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
-            if (NumCast(col._viewType, CollectionViewType.Invalid) === CollectionViewType.Freeform) {
+            if (col._viewType === CollectionViewType.Freeform) {
                 const newPanX = NumCast(target.x) + NumCast(target._width) / 2;
                 const newPanY = NumCast(target.y) + NumCast(target._height) / 2;
                 col._panX = newPanX;
@@ -178,14 +178,13 @@ export class SearchItem extends React.Component<SearchItemProps> {
         }
         const button = layoutresult.indexOf(DocumentType.PDF) !== -1 ? faFilePdf :
             layoutresult.indexOf(DocumentType.IMG) !== -1 ? faImage :
-                layoutresult.indexOf(DocumentType.TEXT) !== -1 ? faStickyNote :
+                layoutresult.indexOf(DocumentType.RTF) !== -1 ? faStickyNote :
                     layoutresult.indexOf(DocumentType.VID) !== -1 ? faFilm :
                         layoutresult.indexOf(DocumentType.COL) !== -1 ? faObjectGroup :
                             layoutresult.indexOf(DocumentType.AUDIO) !== -1 ? faMusic :
                                 layoutresult.indexOf(DocumentType.LINK) !== -1 ? faLink :
-                                    layoutresult.indexOf(DocumentType.HIST) !== -1 ? faChartBar :
-                                        layoutresult.indexOf(DocumentType.WEB) !== -1 ? faGlobeAsia :
-                                            faCaretUp;
+                                    layoutresult.indexOf(DocumentType.WEB) !== -1 ? faGlobeAsia :
+                                        faCaretUp;
         return <div onClick={action(() => { this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} >
             <FontAwesomeIcon icon={button} size="2x" />
         </div>;
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index d381447c5..4fc4dc1cf 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -80,7 +80,7 @@ export function DocListCastAsync(field: FieldResult, defaultValue?: Doc[]) {
 }
 
 export async function DocCastAsync(field: FieldResult): Promise<Opt<Doc>> {
-    return await Cast(field, Doc);
+    return Cast(field, Doc);
 }
 
 export function DocListCast(field: FieldResult): Doc[] {
@@ -713,7 +713,7 @@ export namespace Doc {
     export function SetUserDoc(doc: Doc) { manager._user_doc = doc; }
     export function IsBrushed(doc: Doc) {
         return computedFn(function IsBrushed(doc: Doc) {
-            return brushManager.BrushedDoc.has(doc) ||  brushManager.BrushedDoc.has(Doc.GetProto(doc));
+            return brushManager.BrushedDoc.has(doc) || brushManager.BrushedDoc.has(Doc.GetProto(doc));
         })(doc);
     }
     // don't bother memoizing (caching) the result if called from a non-reactive context. (plus this avoids a warning message)
@@ -919,7 +919,7 @@ Scripting.addGlobal(function curPresentationItem() {
 Scripting.addGlobal(function selectDoc(doc: any) { Doc.UserDoc().SelectedDocs = new List([doc]); });
 Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: boolean, prevValue: any) {
     const docs = DocListCast(Doc.UserDoc().SelectedDocs).
-        filter(d => !Doc.AreProtosEqual(d, container) && !d.annotationOn && d.type !== DocumentType.DOCUMENT && d.type !== DocumentType.KVP &&
+        filter(d => !Doc.AreProtosEqual(d, container) && !d.annotationOn && d.type !== DocumentType.DOCHOLDER && d.type !== DocumentType.KVP &&
             (!excludeCollections || d.type !== DocumentType.COL || !Cast(d.data, listSpec(Doc), null)));
     return docs.length ? new List(docs) : prevValue;
 });
diff --git a/src/new_fields/RichTextField.ts b/src/new_fields/RichTextField.ts
index ad4a5a252..a5a81f4a4 100644
--- a/src/new_fields/RichTextField.ts
+++ b/src/new_fields/RichTextField.ts
@@ -4,9 +4,6 @@ import { Deserializable } from "../client/util/SerializationHelper";
 import { Copy, ToScriptString, ToPlainText, ToString } from "./FieldSymbols";
 import { scriptingGlobal } from "../client/util/Scripting";
 
-const delimiter = "\n";
-const joiner = "";
-
 @scriptingGlobal
 @Deserializable("RichTextField")
 export class RichTextField extends ObjectField {
diff --git a/src/new_fields/ScriptField.ts b/src/new_fields/ScriptField.ts
index 4a3119aeb..8d0ddf94c 100644
--- a/src/new_fields/ScriptField.ts
+++ b/src/new_fields/ScriptField.ts
@@ -98,12 +98,15 @@ export class ScriptField extends ObjectField {
     [Copy](): ObjectField {
         return new ScriptField(this.script);
     }
+    toString() {
+        return `${this.script.originalScript}`;
+    }
 
     [ToScriptString]() {
         return "script field";
     }
     [ToString]() {
-        return "script field";
+        return this.script.originalScript;
     }
     public static CompileScript(script: string, params: object = {}, addReturn = false, capturedVariables?: { [name: string]: Field }) {
         const compiled = CompileScript(script, {
diff --git a/src/new_fields/documentSchemas.ts b/src/new_fields/documentSchemas.ts
index 03519cb94..216b63352 100644
--- a/src/new_fields/documentSchemas.ts
+++ b/src/new_fields/documentSchemas.ts
@@ -61,7 +61,7 @@ export const documentSchema = createSchema({
     fitToBox: "boolean",        // whether freeform view contents should be zoomed/panned to fill the area of the document view
     letterSpacing: "string",
     textTransform: "string",
-    childTemplateName: "string" // the name of a template to use to override the layoutKey when rendering a document in DocumentBox 
+    childTemplateName: "string" // the name of a template to use to override the layoutKey when rendering a document in DocHolderBox 
 });
 
 export const positionSchema = createSchema({
diff --git a/src/server/Message.ts b/src/server/Message.ts
index 81f63656b..01aae5de7 100644
--- a/src/server/Message.ts
+++ b/src/server/Message.ts
@@ -19,7 +19,7 @@ export class Message<T> {
 
 export enum Types {
     Number, List, Key, Image, Web, Document, Text, Icon, RichText, DocumentReference,
-    Html, Video, Audio, Ink, PDF, Tuple, HistogramOp, Boolean, Script, Templates
+    Html, Video, Audio, Ink, PDF, Tuple, Boolean, Script, Templates
 }
 
 export interface Transferable {
diff --git a/src/server/RouteManager.ts b/src/server/RouteManager.ts
index a8680c0c9..80e4a6741 100644
--- a/src/server/RouteManager.ts
+++ b/src/server/RouteManager.ts
@@ -2,7 +2,6 @@ import RouteSubscriber from "./RouteSubscriber";
 import { DashUserModel } from "./authentication/models/user_model";
 import { Request, Response, Express } from 'express';
 import { cyan, red, green } from 'colors';
-import { Utils } from "../client/northstar/utils/Utils";
 
 export enum Method {
     GET,
diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts
index 9f9fc9619..947aa4289 100644
--- a/src/server/Websocket/Websocket.ts
+++ b/src/server/Websocket/Websocket.ts
@@ -199,7 +199,7 @@ export namespace WebSocket {
     function setField(socket: Socket, newValue: Transferable) {
         Database.Instance.update(newValue.id, newValue, () =>
             socket.broadcast.emit(MessageStore.SetField.Message, newValue));
-        if (newValue.type === Types.Text) {
+        if (newValue.type === Types.Text) {  // if the newValue has sring type, then it's suitable for searching -- pass it to SOLR
             Search.updateDocument({ id: newValue.id, data: (newValue as any).data });
         }
     }
@@ -221,6 +221,7 @@ export namespace WebSocket {
         "pdf": ["_t", "url"],
         "audio": ["_t", "url"],
         "web": ["_t", "url"],
+        "script": ["_t", value => value.script.originalScript],
         "RichTextField": ["_t", value => value.Text],
         "date": ["_d", value => new Date(value.date).toISOString()],
         "proxy": ["_i", "fieldId"],
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 529f8d56d..589055fbe 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -2,8 +2,6 @@ import { action, computed, observable, reaction } from "mobx";
 import * as rp from 'request-promise';
 import { DocServer } from "../../../client/DocServer";
 import { Docs, DocumentOptions } from "../../../client/documents/Documents";
-import { Attribute, AttributeGroup, Catalog, Schema } from "../../../client/northstar/model/idea/idea";
-import { ArrayUtil } from "../../../client/northstar/utils/ArrayUtil";
 import { UndoManager } from "../../../client/util/UndoManager";
 import { Doc, DocListCast } from "../../../new_fields/Doc";
 import { List } from "../../../new_fields/List";
@@ -419,77 +417,6 @@ export class CurrentUserUtils {
                 throw new Error("There should be a user id! Why does Dash think there isn't one?");
             }
         });
-        // try {
-        //     const getEnvironment = await fetch("/assets/env.json", { redirect: "follow", method: "GET", credentials: "include" });
-        //     NorthstarSettings.Instance.UpdateEnvironment(await getEnvironment.json());
-        //     await Gateway.Instance.ClearCatalog();
-        //     const extraSchemas = Cast(CurrentUserUtils.UserDocument.DBSchemas, listSpec("string"), []);
-        //     let extras = await Promise.all(extraSchemas.map(sc => Gateway.Instance.GetSchema("", sc)));
-        //     let catprom = CurrentUserUtils.SetNorthstarCatalog(await Gateway.Instance.GetCatalog(), extras);
-        //     // if (catprom) await Promise.all(catprom);
-        // } catch (e) {
-
-        // }
-    }
-
-    /* Northstar catalog ... really just for testing so this should eventually go away */
-    // --------------- Northstar hooks ------------- /
-    static _northstarSchemas: Doc[] = [];
-    @observable private static _northstarCatalog?: Catalog;
-    @computed public static get NorthstarDBCatalog() { return this._northstarCatalog; }
-
-    @action static SetNorthstarCatalog(ctlog: Catalog, extras: Catalog[]) {
-        CurrentUserUtils.NorthstarDBCatalog = ctlog;
-        // if (ctlog && ctlog.schemas) {
-        //     extras.map(ex => ctlog.schemas!.push(ex));
-        //     return ctlog.schemas.map(async schema => {
-        //         let schemaDocuments: Doc[] = [];
-        //         let attributesToBecomeDocs = CurrentUserUtils.GetAllNorthstarColumnAttributes(schema);
-        //         await Promise.all(attributesToBecomeDocs.reduce((promises, attr) => {
-        //             promises.push(DocServer.GetRefField(attr.displayName! + ".alias").then(action((field: Opt<Field>) => {
-        //                 if (field instanceof Doc) {
-        //                     schemaDocuments.push(field);
-        //                 } else {
-        //                     var atmod = new ColumnAttributeModel(attr);
-        //                     let histoOp = new HistogramOperation(schema.displayName!,
-        //                         new AttributeTransformationModel(atmod, AggregateFunction.None),
-        //                         new AttributeTransformationModel(atmod, AggregateFunction.Count),
-        //                         new AttributeTransformationModel(atmod, AggregateFunction.Count));
-        //                     schemaDocuments.push(Docs.Create.HistogramDocument(histoOp, { width: 200, height: 200, title: attr.displayName! }));
-        //                 }
-        //             })));
-        //             return promises;
-        //         }, [] as Promise<void>[]));
-        //         return CurrentUserUtils._northstarSchemas.push(Docs.Create.TreeDocument(schemaDocuments, { width: 50, height: 100, title: schema.displayName! }));
-        //     });
-        // }
-    }
-    public static set NorthstarDBCatalog(ctlog: Catalog | undefined) { this._northstarCatalog = ctlog; }
-
-    public static AddNorthstarSchema(schema: Schema, schemaDoc: Doc) {
-        if (this._northstarCatalog && CurrentUserUtils._northstarSchemas) {
-            this._northstarCatalog.schemas!.push(schema);
-            CurrentUserUtils._northstarSchemas.push(schemaDoc);
-            const schemas = Cast(CurrentUserUtils.UserDocument.DBSchemas, listSpec("string"), []);
-            schemas.push(schema.displayName!);
-            CurrentUserUtils.UserDocument.DBSchemas = new List<string>(schemas);
-        }
-    }
-    public static GetNorthstarSchema(name: string): Schema | undefined {
-        return !this._northstarCatalog || !this._northstarCatalog.schemas ? undefined :
-            ArrayUtil.FirstOrDefault<Schema>(this._northstarCatalog.schemas, (s: Schema) => s.displayName === name);
-    }
-    public static GetAllNorthstarColumnAttributes(schema: Schema) {
-        const recurs = (attrs: Attribute[], g?: AttributeGroup) => {
-            if (g && g.attributes) {
-                attrs.push.apply(attrs, g.attributes);
-                if (g.attributeGroups) {
-                    g.attributeGroups.forEach(ng => recurs(attrs, ng));
-                }
-            }
-            return attrs;
-        };
-        return recurs([] as Attribute[], schema ? schema.rootAttributeGroup : undefined);
     }
 }
 
diff --git a/src/server/updateProtos.ts b/src/server/updateProtos.ts
index 90490eb45..e9860bd61 100644
--- a/src/server/updateProtos.ts
+++ b/src/server/updateProtos.ts
@@ -1,8 +1,7 @@
 import { Database } from "./database";
 
 const protos =
-    ["text", "histogram", "image", "web", "collection", "kvp",
-        "video", "audio", "pdf", "icon", "import", "linkdoc"];
+    ["text", "image", "web", "collection", "kvp", "video", "audio", "pdf", "icon", "import", "linkdoc"];
 
 (async function () {
     await Promise.all(
-- 
cgit v1.2.3-70-g09d2


From d34cb78c3d42f946be62a06bed73fe1997bb25ab Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Wed, 8 Apr 2020 01:48:02 -0400
Subject: fixed bug with getDocTemplate().  fixed inPlace link following when
 there's no inPlaceContainer.

---
 src/client/views/collections/CollectionView.tsx                     | 2 +-
 .../views/collections/collectionFreeForm/CollectionFreeFormView.tsx | 6 ++++--
 src/new_fields/Doc.ts                                               | 2 +-
 3 files changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 5819c829f..6e0e44d35 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -230,7 +230,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
             if (this.props.Document.childDetailed instanceof Doc) {
                 layoutItems.push({ description: "View Child Detailed Layout", event: () => this.props.addDocTab(this.props.Document.childDetailed as Doc, "onRight"), icon: "project-diagram" });
             }
-            layoutItems.push({ description: "Toggle is inPlace Container", event: () => this.props.Document.isInPlaceContainer = !this.props.Document.isInPlaceContainer, icon: "project-diagram" });
+            layoutItems.push({ description: `${this.props.Document.isInPlaceContainer ? "Unset":"Set"} inPlace Container`, event: () => this.props.Document.isInPlaceContainer = !this.props.Document.isInPlaceContainer, icon: "project-diagram" });
 
             !existing && ContextMenu.Instance.addItem({ description: "Layout...", subitems: layoutItems, icon: "hand-point-right" });
 
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index f12dd76d8..df1373b14 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -4,7 +4,7 @@ import { faBraille, faChalkboard, faCompass, faCompressArrowsAlt, faExpandArrows
 import { action, computed, IReactionDisposer, observable, ObservableMap, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
 import { computedFn } from "mobx-utils";
-import { Doc, HeightSym, Opt, WidthSym } from "../../../../new_fields/Doc";
+import { Doc, HeightSym, Opt, WidthSym, DocListCast } from "../../../../new_fields/Doc";
 import { documentSchema, positionSchema } from "../../../../new_fields/documentSchemas";
 import { Id } from "../../../../new_fields/FieldSymbols";
 import { InkData, InkField, InkTool } from "../../../../new_fields/InkField";
@@ -794,7 +794,9 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
 
             const savedState = { px: this.Document._panX, py: this.Document._panY, s: this.Document.scale, pt: this.Document.panTransformType };
 
-            if (!doc.z) this.setPan(newPanX, newPanY, "Ease"); // docs that are floating in their collection can't be panned to from their collection -- need to propagate the pan to a parent freeform somehow
+            if (DocListCast(this.dataDoc[this.props.fieldKey]).includes(doc)) {
+                if (!doc.z) this.setPan(newPanX, newPanY, "Ease"); // docs that are floating in their collection can't be panned to from their collection -- need to propagate the pan to a parent freeform somehow
+            }
             Doc.BrushDoc(this.props.Document);
             this.props.focus(this.props.Document);
             willZoom && this.setScaleToZoom(layoutdoc, scale);
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index 4fc4dc1cf..a9c97fc19 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -899,7 +899,7 @@ export namespace Doc {
 
 Scripting.addGlobal(function renameAlias(doc: any, n: any) { return StrCast(Doc.GetProto(doc).title).replace(/\([0-9]*\)/, "") + `(${n})`; });
 Scripting.addGlobal(function getProto(doc: any) { return Doc.GetProto(doc); });
-Scripting.addGlobal(function getDocTemplate(doc?: any) { Doc.getDocTemplate(doc); });
+Scripting.addGlobal(function getDocTemplate(doc?: any) { return Doc.getDocTemplate(doc); });
 Scripting.addGlobal(function getAlias(doc: any) { return Doc.MakeAlias(doc); });
 Scripting.addGlobal(function getCopy(doc: any, copyProto: any) { return doc.isTemplateDoc ? Doc.ApplyTemplate(doc) : Doc.MakeCopy(doc, copyProto); });
 Scripting.addGlobal(function copyField(field: any) { return ObjectField.MakeCopy(field); });
-- 
cgit v1.2.3-70-g09d2


From 8895ea8bc50b9b69518469e24e66fad58b6bc2e7 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Wed, 8 Apr 2020 14:38:56 -0400
Subject: fixed link previews to work with regions on PDFs, images etc,

---
 src/client/views/DocComponent.tsx                  |  2 +-
 src/client/views/collections/CollectionView.tsx    |  3 +--
 src/client/views/nodes/DocumentView.tsx            | 31 +++++++++++++---------
 src/client/views/nodes/FormattedTextBoxComment.tsx | 17 +++++++-----
 src/client/views/nodes/PDFBox.tsx                  |  2 +-
 src/client/views/pdf/PDFViewer.tsx                 |  2 +-
 6 files changed, 33 insertions(+), 24 deletions(-)

(limited to 'src/client/views/collections/CollectionView.tsx')

diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 0c8ce28c3..bbba2712e 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -86,7 +86,7 @@ export function DocAnnotatableComponent<P extends DocAnnotatableProps, T>(schema
         }
         @action.bound
         addDocument(doc: Doc): boolean {
-            Doc.GetProto(doc).annotationOn = this.props.Document;
+            doc.context = Doc.GetProto(doc).annotationOn = this.props.Document;
             return Doc.AddDocToList(this.dataDoc, this.props.fieldKey + "-" + this._annotationKey, doc) ? true : false;
         }
 
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 6e0e44d35..8192e6751 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -143,7 +143,6 @@ export class CollectionView extends Touchable<FieldViewProps> {
     // moving it into the target.  
     @action.bound
     moveDocument(doc: Doc, targetCollection: Doc | undefined, addDocument: (doc: Doc) => boolean): boolean {
-        doc.context = targetCollection;
         if (Doc.AreProtosEqual(this.props.Document, targetCollection)) {
             return true;
         }
@@ -230,7 +229,7 @@ export class CollectionView extends Touchable<FieldViewProps> {
             if (this.props.Document.childDetailed instanceof Doc) {
                 layoutItems.push({ description: "View Child Detailed Layout", event: () => this.props.addDocTab(this.props.Document.childDetailed as Doc, "onRight"), icon: "project-diagram" });
             }
-            layoutItems.push({ description: `${this.props.Document.isInPlaceContainer ? "Unset":"Set"} inPlace Container`, event: () => this.props.Document.isInPlaceContainer = !this.props.Document.isInPlaceContainer, icon: "project-diagram" });
+            layoutItems.push({ description: `${this.props.Document.isInPlaceContainer ? "Unset" : "Set"} inPlace Container`, event: () => this.props.Document.isInPlaceContainer = !this.props.Document.isInPlaceContainer, icon: "project-diagram" });
 
             !existing && ContextMenu.Instance.addItem({ description: "Layout...", subitems: layoutItems, icon: "hand-point-right" });
 
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index 1a33e3000..867405d54 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -196,27 +196,31 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
         this._mainCont.current && (this.multiTouchDisposer = InteractionUtils.MakeMultiTouchTarget(this._mainCont.current, this.onTouchStart.bind(this)));
         // this._mainCont.current && (this.holdDisposer = InteractionUtils.MakeHoldTouchTarget(this._mainCont.current, this.handle1PointerHoldStart.bind(this)));
 
-        !this.props.dontRegisterView && DocumentManager.Instance.DocumentViews.push(this);
+        if (!this.props.dontRegisterView) {
+            DocumentManager.Instance.DocumentViews.push(this);
+        }
     }
 
     @action
     componentDidUpdate() {
-        this._dropDisposer && this._dropDisposer();
-        this._gestureEventDisposer && this._gestureEventDisposer();
-        this.multiTouchDisposer && this.multiTouchDisposer();
-        this.holdDisposer && this.holdDisposer();
-        this._mainCont.current && (this._dropDisposer = DragManager.MakeDropTarget(this._mainCont.current, this.drop.bind(this)));
-        this._mainCont.current && (this._gestureEventDisposer = GestureUtils.MakeGestureTarget(this._mainCont.current, this.onGesture.bind(this)));
-        this._mainCont.current && (this.multiTouchDisposer = InteractionUtils.MakeMultiTouchTarget(this._mainCont.current, this.onTouchStart.bind(this)));
-        this._mainCont.current && (this.holdDisposer = InteractionUtils.MakeHoldTouchTarget(this._mainCont.current, this.handle1PointerHoldStart.bind(this)));
+        this._dropDisposer?.();
+        this._gestureEventDisposer?.();
+        this.multiTouchDisposer?.();
+        this.holdDisposer?.();
+        if (this._mainCont.current) {
+            this._dropDisposer = DragManager.MakeDropTarget(this._mainCont.current, this.drop.bind(this));
+            this._gestureEventDisposer = GestureUtils.MakeGestureTarget(this._mainCont.current, this.onGesture.bind(this));
+            this.multiTouchDisposer = InteractionUtils.MakeMultiTouchTarget(this._mainCont.current, this.onTouchStart.bind(this));
+            this.holdDisposer = InteractionUtils.MakeHoldTouchTarget(this._mainCont.current, this.handle1PointerHoldStart.bind(this));
+        }
     }
 
     @action
     componentWillUnmount() {
-        this._dropDisposer && this._dropDisposer();
-        this._gestureEventDisposer && this._gestureEventDisposer();
-        this.multiTouchDisposer && this.multiTouchDisposer();
-        this.holdDisposer && this.holdDisposer();
+        this._dropDisposer?.();
+        this._gestureEventDisposer?.();
+        this.multiTouchDisposer?.();
+        this.holdDisposer?.();
         Doc.UnBrushDoc(this.props.Document);
         if (!this.props.dontRegisterView) {
             const index = DocumentManager.Instance.DocumentViews.indexOf(this);
@@ -982,6 +986,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
             LayoutDoc={this.props.LayoutDoc}
             makeLink={this.makeLink}
             rootSelected={this.rootSelected}
+            dontRegisterView={this.props.dontRegisterView}
             fitToBox={this.props.fitToBox}
             LibraryPath={this.props.LibraryPath}
             addDocument={this.props.addDocument}
diff --git a/src/client/views/nodes/FormattedTextBoxComment.tsx b/src/client/views/nodes/FormattedTextBoxComment.tsx
index 20d734244..1e48c76e7 100644
--- a/src/client/views/nodes/FormattedTextBoxComment.tsx
+++ b/src/client/views/nodes/FormattedTextBoxComment.tsx
@@ -2,7 +2,7 @@ import { Mark, ResolvedPos } from "prosemirror-model";
 import { EditorState, Plugin } from "prosemirror-state";
 import { EditorView } from "prosemirror-view";
 import * as ReactDOM from 'react-dom';
-import { Doc } from "../../../new_fields/Doc";
+import { Doc, DocCastAsync } from "../../../new_fields/Doc";
 import { Cast, FieldValue, NumCast } from "../../../new_fields/Types";
 import { emptyFunction, returnEmptyString, returnFalse, Utils, emptyPath } from "../../../Utils";
 import { DocServer } from "../../DocServer";
@@ -100,6 +100,7 @@ export class FormattedTextBoxComment {
     public static Hide() {
         FormattedTextBoxComment.textBox = undefined;
         FormattedTextBoxComment.tooltip && (FormattedTextBoxComment.tooltip.style.display = "none");
+        ReactDOM.unmountComponentAtNode(FormattedTextBoxComment.tooltipText);
     }
     public static SetState(textBox: any, start: number, end: number, mark: Mark) {
         FormattedTextBoxComment.textBox = textBox;
@@ -167,14 +168,18 @@ export class FormattedTextBoxComment {
                     FormattedTextBoxComment.tooltipText.textContent = "target not found...";
                     (FormattedTextBoxComment.tooltipText as any).href = "";
                     const docTarget = mark.attrs.href.replace(Utils.prepend("/doc/"), "").split("?")[0];
-                    docTarget && DocServer.GetRefField(docTarget).then(linkDoc => {
+                    try {
+                        ReactDOM.unmountComponentAtNode(FormattedTextBoxComment.tooltipText);
+                    } catch (e) { }
+                    docTarget && DocServer.GetRefField(docTarget).then(async linkDoc => {
                         if (linkDoc instanceof Doc) {
                             (FormattedTextBoxComment.tooltipText as any).href = mark.attrs.href;
                             FormattedTextBoxComment.linkDoc = linkDoc;
-                            const target = FieldValue(Doc.AreProtosEqual(FieldValue(Cast(linkDoc.anchor1, Doc)), textBox.dataDoc) ? Cast(linkDoc.anchor2, Doc) : (Cast(linkDoc.anchor1, Doc)) || linkDoc);
-                            try {
-                                ReactDOM.unmountComponentAtNode(FormattedTextBoxComment.tooltipText);
-                            } catch (e) { }
+                            const anchor = FieldValue(Doc.AreProtosEqual(FieldValue(Cast(linkDoc.anchor1, Doc)), textBox.dataDoc) ? Cast(linkDoc.anchor2, Doc) : (Cast(linkDoc.anchor1, Doc)) || linkDoc);
+                            const target = anchor?.annotationOn ? await DocCastAsync(anchor.annotationOn) : anchor;
+                            if (anchor !== target && anchor && target) {
+                                target.scrollY = NumCast(anchor?.y);
+                            }
                             if (target) {
                                 ReactDOM.render(<ContentFittingDocumentView
                                     Document={target}
diff --git a/src/client/views/nodes/PDFBox.tsx b/src/client/views/nodes/PDFBox.tsx
index 53ad547b6..f2a3e1484 100644
--- a/src/client/views/nodes/PDFBox.tsx
+++ b/src/client/views/nodes/PDFBox.tsx
@@ -248,7 +248,7 @@ export class PDFBox extends DocAnnotatableComponent<FieldViewProps, PdfDocument>
     _pdfjsRequested = false;
     render() {
         const pdfUrl = Cast(this.dataDoc[this.props.fieldKey], PdfField, null);
-        if (this.props.isSelected() || this.props.Document.scrollY !== undefined) this._everActive = true;
+        if (this.props.isSelected() || this.props.renderDepth <= 1 || this.props.Document.scrollY !== undefined) this._everActive = true;
         if (pdfUrl && (this._everActive || this.props.Document._scrollTop || (this.dataDoc[this.props.fieldKey + "-nativeWidth"] && this.props.ScreenToLocalTransform().Scale < 2.5))) {
             if (pdfUrl instanceof PdfField && this._pdf) {
                 return this.renderPdfView;
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 90cd64f3c..f93c1fa97 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -164,7 +164,7 @@ export class PDFViewer extends DocAnnotatableComponent<IViewerProps, PdfDocument
     }
 
     componentWillUnmount = () => {
-        this._reactionDisposer && this._reactionDisposer();
+        this._reactionDisposer?.();
         this._scrollTopReactionDisposer?.();
         this._annotationReactionDisposer?.();
         this._filterReactionDisposer?.();
-- 
cgit v1.2.3-70-g09d2

