aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/documents/Documents.ts1
-rw-r--r--src/client/views/collections/CollectionPivotView.tsx44
-rw-r--r--src/client/views/collections/CollectionSubView.tsx10
-rw-r--r--src/client/views/collections/CollectionTreeView.tsx9
4 files changed, 40 insertions, 24 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 91085cd0f..d7292837c 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -788,7 +788,6 @@ export namespace DocUtils {
});
}
- @undoBatch
export function MakeLink(source: { doc: Doc, ctx?: Doc }, target: { doc: Doc, ctx?: Doc }, title: string = "", description: string = "", id?: string) {
const sv = DocumentManager.Instance.getDocumentView(source.doc);
if (sv && sv.props.ContainingCollectionDoc === target.doc) return;
diff --git a/src/client/views/collections/CollectionPivotView.tsx b/src/client/views/collections/CollectionPivotView.tsx
index 816939a41..f31f1aba6 100644
--- a/src/client/views/collections/CollectionPivotView.tsx
+++ b/src/client/views/collections/CollectionPivotView.tsx
@@ -9,8 +9,8 @@ import { CollectionFreeFormView } from "./collectionFreeForm/CollectionFreeFormV
import { CollectionTreeView } from "./CollectionTreeView";
import { Cast, StrCast, NumCast } from "../../../new_fields/Types";
import { Docs } from "../../documents/Documents";
-import { ScriptField } from "../../../new_fields/ScriptField";
-import { CompileScript } from "../../util/Scripting";
+import { ScriptField, ComputedField } from "../../../new_fields/ScriptField";
+import { CompileScript, Scripting } from "../../util/Scripting";
import { anchorPoints, Flyout } from "../TemplateMenu";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { List } from "../../../new_fields/List";
@@ -25,7 +25,7 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
}
componentDidMount() {
this.props.Document.freeformLayoutEngine = "pivot";
- if (true || !this.props.Document.facetCollection) {
+ if (!this.props.Document.facetCollection) {
const facetCollection = Docs.Create.FreeformDocument([], { title: "facetFilters", yMargin: 0, treeViewHideTitle: true });
facetCollection.target = this.props.Document;
@@ -38,14 +38,12 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
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 targetKey = "childDetailed";
const captured: { [name: string]: Field } = {};
- captured[targetKey] = new PrefetchProxy(childDetailed);
+ 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 },
@@ -76,23 +74,35 @@ export class CollectionPivotView extends CollectionSubView(doc => doc) {
return facets.toArray();
}
- facetClick = (facet: string) => {
- const facetCollection = this.props.Document.facetCollection;
+ /**
+ * Responds to clicking the check box in the flyout menu
+ */
+ facetClick = (facetHeader: string) => {
+ const { Document, fieldKey } = this.props;
+ const facetCollection = Document.facetCollection;
if (facetCollection instanceof Doc) {
- const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facet);
+ const found = DocListCast(facetCollection.data).findIndex(doc => doc.title === facetHeader);
if (found !== -1) {
//Doc.RemoveDocFromList(facetCollection, "data", DocListCast(facetCollection.data)[found]);
(facetCollection.data as List<Doc>).splice(found, 1);
} else {
- const facetValues = new Set<string>();
- this.childDocs.forEach(child => {
- Object.keys(Doc.GetProto(child)).forEach(key => child[key] instanceof Doc && facetValues.add((child[key] as Doc)[facet]?.toString() || "(null)"));
- facetValues.add(child[facet]?.toString() || "(null)");
- });
-
- const newFacetVals = facetValues.toArray().sort().map(val => Docs.Create.TextDocument({ title: val.toString() }));
- const newFacet = Docs.Create.FreeformDocument(newFacetVals, { title: facet, treeViewOpen: true, isFacetFilter: true });
+ const newFacet = Docs.Create.FreeformDocument([], { title: facetHeader, treeViewOpen: true, isFacetFilter: true });
Doc.AddDocToList(facetCollection, "data", newFacet);
+ const { dataDoc } = this;
+ const capturedVariables = {
+ layoutDoc: Document,
+ dataDoc,
+ dataKey: fieldKey,
+ facetHeader
+ };
+ const params = {
+ layoutDoc: Doc.name,
+ dataDoc: Doc.name,
+ dataKey: "string",
+ facetHeader: "string"
+ };
+ newFacet.container = dataDoc;
+ newFacet.data = ComputedField.MakeFunction("readFacetData(layoutDoc, dataDoc, dataKey, facetHeader)", params, capturedVariables);
}
}
}
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 5f4ee3669..9357b0507 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -90,7 +90,15 @@ export function CollectionSubView<T>(schemaCtor: (doc: Doc) => T) {
// 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.props.annotationsKey ? (this.extensionDoc ? this.extensionDoc[this.props.annotationsKey] : undefined) : this.dataDoc[this.props.fieldKey];
+ const { annotationsKey, fieldKey } = this.props;
+ const { extensionDoc, dataDoc } = this;
+ if (annotationsKey) {
+ if (extensionDoc) {
+ return extensionDoc[annotationsKey];
+ }
+ return undefined;
+ }
+ return dataDoc[fieldKey];
}
get childLayoutPairs(): { layout: Doc; data: Doc; }[] {
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 4a6dffc1c..ffaad2ddd 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -373,12 +373,12 @@ class TreeView extends React.Component<TreeViewProps> {
@action
bulletClick = (e: React.MouseEvent) => {
if (this.props.onCheckedClick && this.props.document.type !== DocumentType.COL) {
- this.props.document.treeViewChecked = this.props.document.treeViewChecked === "check" ? "x" : this.props.document.treeViewChecked === "x" ? undefined : "check";
+ // this.props.document.treeViewChecked = this.props.document.treeViewChecked === "check" ? "x" : this.props.document.treeViewChecked === "x" ? undefined : "check";
ScriptCast(this.props.onCheckedClick).script.run({
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" ? false : this.props.document.treeViewChecked === "x" ? "x" : "none",
- context: this.props.treeViewId
+ checked: this.props.document.treeViewChecked === "check" ? "x" : this.props.document.treeViewChecked === "x" ? undefined : "check",
+ context: this.props.treeViewId,
}, console.log);
} else {
this.treeViewOpen = !this.treeViewOpen;
@@ -634,12 +634,11 @@ export class CollectionTreeView extends CollectionSubView(Document) {
}
ContextMenu.Instance.addItem({
description: "Buxton Layout", icon: "eye", event: () => {
- const { TextDocument, ImageDocument, MulticolumnDocument } = Docs.Create;
+ const { TextDocument, ImageDocument } = Docs.Create;
const { Document } = this.props;
const fallback = "http://www.cs.brown.edu/~bcz/face.gif";
const wrapper = Docs.Create.StackingDocument([
ImageDocument(fallback, { title: "hero" }),
- MulticolumnDocument([], { title: "data", height: 100 }),
...["short_description", "year", "company", "degrees_of_freedom"].map(key => TextDocument({ title: key }))
], { autoHeight: true, chromeStatus: "disabled" });
wrapper.disableLOD = true;