aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-01-22 12:53:40 -0500
committerbob <bcz@cs.brown.edu>2020-01-22 12:53:40 -0500
commit6b1e9b68c3d409df6ea2a8909b99d5d8d75226c5 (patch)
treec019bec49bfb8079ce1f83dbf6a6944a45bf6787 /src
parent5a6f6868dc25b2b24c6c7f4a7bc25670e6a35f47 (diff)
various fixes to pivot view related things.
Diffstat (limited to 'src')
-rw-r--r--src/client/documents/Documents.ts3
-rw-r--r--src/client/views/collections/CollectionPivotView.tsx39
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx33
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx6
-rw-r--r--src/client/views/collections/collectionFreeForm/MarqueeView.tsx1
-rw-r--r--src/scraping/buxton/scraper.py6
-rw-r--r--src/server/authentication/models/current_user_utils.ts2
7 files changed, 45 insertions, 45 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 634c223a7..e86ed52f3 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -88,7 +88,7 @@ export interface DocumentOptions {
defaultBackgroundColor?: string;
dropAction?: dropActionType;
chromeStatus?: string;
- disableLOD?: boolean;
+ LODdisable?: boolean;
columnWidth?: number;
fontSize?: number;
curPage?: number;
@@ -107,6 +107,7 @@ export interface DocumentOptions {
ischecked?: ScriptField; // returns whether a font icon box is checked
activePen?: Doc; // which pen document is currently active (used as the radio button state for the 'unhecked' pen tool scripts)
onClick?: ScriptField;
+ onChildClick?: ScriptField; // script given to children of a collection to execute when they are clicked
onPointerDown?: ScriptField;
onPointerUp?: ScriptField;
dragFactory?: Doc; // document to create when dragging with a suitable onDragStart script
diff --git a/src/client/views/collections/CollectionPivotView.tsx b/src/client/views/collections/CollectionPivotView.tsx
index 8e712e370..f23540529 100644
--- a/src/client/views/collections/CollectionPivotView.tsx
+++ b/src/client/views/collections/CollectionPivotView.tsx
@@ -26,36 +26,33 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
componentDidMount() {
this.props.Document.freeformLayoutEngine = "pivot";
if (!this.props.Document.facetCollection) {
- const facetCollection = Docs.Create.FreeformDocument([], { title: "facetFilters", yMargin: 0, treeViewHideTitle: true });
+ const facetCollection = Docs.Create.TreeDocument([], { title: "facetFilters", yMargin: 0, treeViewHideTitle: true });
facetCollection.target = this.props.Document;
- const scriptText = "setDocFilter(context.target, heading, this.title, checked)";
+ const scriptText = "setDocFilter(containingTreeView.target, heading, this.title, checked)";
const script = CompileScript(scriptText, {
- params: { this: Doc.name, heading: "boolean", checked: "boolean", context: Doc.name },
+ params: { this: Doc.name, heading: "boolean", checked: "boolean", containingTreeView: Doc.name },
typecheck: false,
editable: true,
});
if (script.compiled) {
facetCollection.onCheckedClick = new ScriptField(script);
}
- this._narrativeDisposer = reaction(() => this.props.Document.childDetailed,
- (childDetailed) =>
- DocCastAsync(childDetailed).then(childDetailed => {
- if (childDetailed instanceof Doc) {
- const captured: { [name: string]: Field } = {};
- captured.childDetailed = new PrefetchProxy(childDetailed);
- const openDocText = "const alias = getAlias(this); Doc.ApplyTemplateTo(childDetailed, alias, 'layout_detailed'); useRightSplit(alias); ";
- const openDocScript = CompileScript(openDocText, {
- params: { this: Doc.name, heading: "boolean", context: Doc.name },
- typecheck: false,
- editable: true,
- capturedVariables: captured
- });
- if (openDocScript.compiled) {
- this.props.Document.onChildClick = new ScriptField(openDocScript);
- }
+ const openDocText = "const alias = getAlias(this); Doc.ApplyTemplateTo(childDetailed, alias, 'layout_detailed'); useRightSplit(alias); ";
+ this._narrativeDisposer = reaction(() => DocCastAsync(this.props.Document.childDetailed),
+ (childDetailedPromise) => childDetailedPromise.then(childDetailed => {
+ if (childDetailed) {
+ const openDocScript = CompileScript(openDocText, {
+ params: { this: Doc.name, heading: "boolean", containingTreeView: Doc.name },
+ capturedVariables: { childDetailed: new PrefetchProxy(childDetailed) },
+ typecheck: false,
+ editable: true,
+ });
+ if (openDocScript.compiled) {
+ this.props.Document.onChildClick = new ScriptField(openDocScript);
}
- }), { fireImmediately: true });
+ }
+ }), { fireImmediately: true });
this.props.Document.facetCollection = facetCollection;
this.props.Document.fitToBox = true;
}
@@ -84,7 +81,7 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
if (found !== -1) {
(facetCollection.data as List<Doc>).splice(found, 1);
} else {
- const newFacet = Docs.Create.FreeformDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
+ 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);
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 2433cc40e..bef587786 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -32,6 +32,7 @@ import { Templates } from '../Templates';
import { CollectionSubView } from "./CollectionSubView";
import "./CollectionTreeView.scss";
import React = require("react");
+import { CollectionViewType } from './CollectionView';
export interface TreeViewProps {
@@ -377,7 +378,7 @@ class TreeView extends React.Component<TreeViewProps> {
this: this.props.document.isTemplateField && this.props.dataDoc ? this.props.dataDoc : this.props.document,
heading: this.props.containingCollection.title,
checked: this.props.document.treeViewChecked === "check" ? "x" : this.props.document.treeViewChecked === "x" ? undefined : "check",
- context: this.props.treeViewId,
+ containingTreeView: this.props.treeViewId,
}, console.log);
} else {
this.treeViewOpen = !this.treeViewOpen;
@@ -635,32 +636,32 @@ export class CollectionTreeView extends CollectionSubView(Document) {
description: "Buxton Layout", icon: "eye", event: () => {
const { TextDocument, ImageDocument, MulticolumnDocument } = Docs.Create;
const { Document } = this.props;
- const fallback = "http://www.cs.brown.edu/~bcz/face.gif";
- const imageRack = MulticolumnDocument([], { title: "data", height: 100 });
- const wrapper = Docs.Create.StackingDocument([
- ImageDocument(fallback, { title: "hero" }),
- imageRack,
- ...["short_description", "year", "company", "degrees_of_freedom"].map(key => TextDocument({ title: key }))
- ], { autoHeight: true, chromeStatus: "disabled", disableLOD: true, title: "detailed layout stack" });
- wrapper.isTemplateDoc = makeTemplate(wrapper);
- imageRack.onChildClick = ScriptField.MakeFunction(`containingCollection.resolvedDataDoc.hero = copyField(this.data)`, { containingCollection: Doc.name });
-
- const cardLayout = ImageDocument(fallback);
+ const fallbackImg = "http://www.cs.brown.edu/~bcz/face.gif";
+
+ const detailedLayout = Docs.Create.StackingDocument([
+ ImageDocument(fallbackImg, { title: "activeHero" }),
+ MulticolumnDocument([], { title: "data", height: 100, onChildClick: ScriptField.MakeFunction(`containingCollection.resolvedDataDoc.activeHero = copyField(this.data)`, { containingCollection: Doc.name }) }),
+ TextDocument({ title: "short_description", autoHeight: true }),
+ ...["year", "company", "degrees_of_freedom"].map(key => TextDocument({ title: key, height: 30 }))
+ ], { autoHeight: true, chromeStatus: "disabled", title: "detailed layout stack" });
+ detailedLayout.isTemplateDoc = makeTemplate(detailedLayout);
+
+ const cardLayout = ImageDocument(fallbackImg, { isTemplateDoc: true, isTemplateField: true }); // this acts like a template doc and a template field ... a little weird, but seems to work?
cardLayout.proto!.layout = ImageBox.LayoutString("hero");
cardLayout.showTitle = "title";
cardLayout.showTitleHover = "titlehover";
- cardLayout.isTemplateField = true; // make this document act like a template field
- cardLayout.isTemplateDoc = true; // but it's also a template doc itself... a little weird
Document.childLayout = cardLayout;
- Document.childDetailed = wrapper;
+ Document.childDetailed = detailedLayout;
+ Document.viewType = CollectionViewType.Pivot;
+ Document.pivotField = "company";
}
});
const existingOnClick = ContextMenu.Instance.findByDescription("OnClick...");
const onClicks: ContextMenuProps[] = existingOnClick && "subitems" in existingOnClick ? existingOnClick.subitems : [];
onClicks.push({
description: "Edit onChecked Script", icon: "edit", event: (obj: any) => ScriptBox.EditButtonScript("On Checked Changed ...", this.props.Document,
- "onCheckedClick", obj.x, obj.y, { heading: "boolean", checked: "boolean", context: Doc.name })
+ "onCheckedClick", obj.x, obj.y, { heading: "boolean", checked: "boolean", treeViewContainer: Doc.name })
});
!existingOnClick && ContextMenu.Instance.addItem({ description: "OnClick...", subitems: onClicks, icon: "hand-point-right" });
}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index 5c6336248..32097816d 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -59,11 +59,7 @@ export function computePivotLayout(poolData: ObservableMap<string, any>, pivotDo
let numCols = NumCast(pivotDoc.pivotNumColumns, Math.ceil(Math.sqrt(minSize)));
const docMap = new Map<Doc, ViewDefBounds>();
const groupNames: PivotData[] = [];
- if (panelDim[0] < 2500) numCols = Math.min(5, numCols);
- if (panelDim[0] < 2000) numCols = Math.min(4, numCols);
- if (panelDim[0] < 1400) numCols = Math.min(3, numCols);
- if (panelDim[0] < 1000) numCols = Math.min(2, numCols);
- if (panelDim[0] < 600) numCols = 1;
+ numCols = Math.min(panelDim[0] / pivotAxisWidth, numCols)
const expander = 1.05;
const gap = .15;
diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
index 523edb918..584d18372 100644
--- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
+++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx
@@ -331,6 +331,7 @@ export class MarqueeView extends React.Component<SubCollectionViewProps & Marque
defaultBackgroundColor: this.props.isAnnotationOverlay ? undefined : chosenColor,
width: bounds.width,
height: bounds.height,
+ LODdisable: true,
title: "a nested collection",
});
// const dataExtensionField = Doc.CreateDocumentExtensionForField(newCollection, "data");
diff --git a/src/scraping/buxton/scraper.py b/src/scraping/buxton/scraper.py
index e80979616..ea0a9cb88 100644
--- a/src/scraping/buxton/scraper.py
+++ b/src/scraping/buxton/scraper.py
@@ -102,7 +102,7 @@ def write_collection(parse_results, display_fields, storage_key, viewType):
fields["backgroundColor"] = "white"
fields["viewType"] = 2
fields["author"] = "Bill Buxton"
- fields["disableLOD"] = True
+ fields["LODdisable"] = True
fields["creationDate"] = {
"date": datetime.datetime.utcnow().microsecond,
"__type": "date"
@@ -112,6 +112,10 @@ def write_collection(parse_results, display_fields, storage_key, viewType):
"url": parse_results["image_urls"][0],
"__type": "image"
}
+ fields["activeHero"] = {
+ "url": parse_results["image_urls"][0],
+ "__type": "image"
+ }
fields["isPrototype"] = True
fields["page"] = -1
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index e502a06b8..406d71085 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -47,7 +47,7 @@ export class CurrentUserUtils {
doc.noteTypes = Docs.Create.TreeDocument(notes, { title: "Note Types", height: 75 });
doc.activePen = doc;
const docProtoData: { title: string, icon: string, drag?: string, ignoreClick?: boolean, click?: string, ischecked?: string, activePen?: Doc, backgroundColor?: string, dragFactory?: Doc }[] = [
- { title: "collection", icon: "folder", ignoreClick: true, drag: 'Docs.Create.FreeformDocument([], { nativeWidth: undefined, nativeHeight: undefined, width: 150, height: 100, title: "freeform" })' },
+ { title: "collection", icon: "folder", ignoreClick: true, drag: 'Docs.Create.FreeformDocument([], { nativeWidth: undefined, nativeHeight: undefined, LODdisable: true, width: 150, height: 100, title: "freeform" })' },
{ title: "preview", icon: "expand", ignoreClick: true, drag: 'Docs.Create.DocumentDocument(ComputedField.MakeFunction("selectedDocs(this,true,[_last_])?.[0]"), { width: 250, height: 250, title: "container" })' },
{ title: "todo item", icon: "check", ignoreClick: true, drag: 'getCopy(this.dragFactory, true)', dragFactory: notes[notes.length - 1] },
{ title: "web page", icon: "globe-asia", ignoreClick: true, drag: 'Docs.Create.WebDocument("https://en.wikipedia.org/wiki/Hedgehog", { width: 300, height: 300, title: "New Webpage" })' },