From 8fcb1a23224762233ebf3e519b13bc72cdfdf3c5 Mon Sep 17 00:00:00 2001 From: bobzel Date: Tue, 9 Mar 2021 09:49:03 -0500 Subject: got rid of DocHolderBox. changed dontRegisterChildViews to childDontRegisterViews for consistency. --- src/client/views/collections/CollectionStackingView.tsx | 2 +- src/client/views/collections/CollectionTreeView.tsx | 2 +- src/client/views/collections/TreeView.tsx | 2 +- src/client/views/collections/collectionFreeForm/MarqueeView.tsx | 8 +++----- 4 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/client/views/collections') diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 95a95b10d..5bb3c0403 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -224,7 +224,7 @@ export class CollectionStackingView extends CollectionSubView this.props.treeViewHideHeaderFields || BoolCast(this.doc.treeViewHideHeaderFields), BoolCast(this.doc.treeViewPreventOpen), [], this.props.onCheckedClick, - this.onChildClick, this.props.treeViewSkipFields, true, this.whenActiveChanged, this.props.dontRegisterView || Cast(this.props.Document.dontRegisterChildViews, "boolean", null), this); + this.onChildClick, this.props.treeViewSkipFields, true, this.whenActiveChanged, this.props.dontRegisterView || Cast(this.props.Document.childDontRegisterViews, "boolean", null), this); } @computed get titleBar() { const hideTitle = this.props.treeViewHideTitle || this.doc.treeViewHideTitle; diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx index 106129127..7674b1451 100644 --- a/src/client/views/collections/TreeView.tsx +++ b/src/client/views/collections/TreeView.tsx @@ -608,7 +608,7 @@ export class TreeView extends React.Component { whenActiveChanged={this.props.whenActiveChanged} bringToFront={emptyFunction} cantBrush={this.props.treeView.props.cantBrush} - dontRegisterView={BoolCast(this.props.treeView.props.Document.dontRegisterChildViews)} + dontRegisterView={BoolCast(this.props.treeView.props.Document.childDontRegisterViews)} docFilters={returnEmptyFilter} docRangeFilters={returnEmptyFilter} searchFilterDocs={returnEmptyDoclist} diff --git a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx index 2a30e5fd0..e625b5b4b 100644 --- a/src/client/views/collections/collectionFreeForm/MarqueeView.tsx +++ b/src/client/views/collections/collectionFreeForm/MarqueeView.tsx @@ -323,11 +323,9 @@ export class MarqueeView extends React.Component Date: Tue, 9 Mar 2021 10:50:15 -0500 Subject: fixed following portal link to reset camera position. prevent warning errors in loading screen. hide textsidebar until text is selected. fixed link titles to handle case when link anchor is the link document and not infinitely recurse. --- deploy/index.html | 29 +++++++--------------- src/client/documents/Documents.ts | 11 ++++++-- .../collectionFreeForm/CollectionFreeFormView.tsx | 2 +- .../views/nodes/formattedText/FormattedTextBox.tsx | 2 +- 4 files changed, 20 insertions(+), 24 deletions(-) (limited to 'src/client/views/collections') diff --git a/deploy/index.html b/deploy/index.html index f2eb5e2aa..dda0c6457 100644 --- a/deploy/index.html +++ b/deploy/index.html @@ -125,26 +125,15 @@ let load = getCookie("loadtime"); document.startLoad = Date.now(); console.log("Last Load = " + load); - setTimeout(() => { - document.getElementById("dash-progress").style.width = "10%" - document.getElementById("dash-loader-text").innerHTML = "Loading Dash..." - }, load / 10); - setTimeout(() => { - document.getElementById("dash-progress").style.width = "33%" - document.getElementById("dash-loader-text").innerHTML = "Preparing dashboards..." - }, load / 3); - setTimeout(() => { - document.getElementById("dash-progress").style.width = "50%" - document.getElementById("dash-loader-text").innerHTML = "Initializing scripts..." - }, load / 2); - setTimeout(() => { - document.getElementById("dash-progress").style.width = "75%" - document.getElementById("dash-loader-text").innerHTML = "Fetching documents..." - }, load / 4 * 3); - setTimeout(() => { - document.getElementById("dash-progress").style.width = "100%" - document.getElementById("dash-loader-text").innerHTML = "Finalising setup..." - }, load); + let dashmesg = (width, msg) => { + if (document.getElementById("dash-progress")) document.getElementById("dash-progress").style.width = width + if (document.getElementById("dash-progress")) document.getElementById("dash-progress").innerHTML = msg + } + setTimeout(() => dashmesg("10%", "Loading Dash..."), load / 10); + setTimeout(() => dashmesg("33%", "Preparing dashboards..."), load / 3); + setTimeout(() => dashmesg("50%", "Initializing scripts..."), load / 2); + setTimeout(() => dashmesg("75%", "Fetching documents..."), load / 4 * 3); + setTimeout(() => dashmesg("100%", "Finalising setup..."), load);
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index 0da80d2c4..754a0d0f8 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -59,6 +59,7 @@ import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo"; import { DocumentType } from "./DocumentTypes"; import { EquationBox } from "../views/nodes/EquationBox"; import { FunctionPlotBox } from "../views/nodes/FunctionPlotBox"; +import { script } from "googleapis/build/src/apis/script"; const path = require('path'); const defaultNativeImageDim = Number(DFLT_IMAGE_NATIVE_DIM.replace("px", "")); @@ -1135,7 +1136,7 @@ export namespace DocUtils { linkDoc.hidden = true; Doc.GetProto(linkDoc)["acl-Public"] = linkDoc["acl-Public"] = SharingPermissions.Add; linkDoc.layout_linkView = Cast(Cast(Doc.UserDoc()["template-button-link"], Doc, null).dragFactory, Doc, null); - Doc.GetProto(linkDoc).title = ComputedField.MakeFunction('self.anchor1?.title +" (" + (self.linkRelationship||"to") +") " + self.anchor2?.title'); + Doc.GetProto(linkDoc).title = ComputedField.MakeFunction("generateLinkTitle(self)"); showPopup && makeLink(linkDoc, showPopup); return linkDoc; } @@ -1416,4 +1417,10 @@ export namespace DocUtils { } Scripting.addGlobal("Docs", Docs); -Scripting.addGlobal(function makeDelegate(proto: any) { const d = Docs.Create.DelegateDocument(proto, { title: "child of " + proto.title }); return d; }); \ No newline at end of file +Scripting.addGlobal(function makeDelegate(proto: any) { const d = Docs.Create.DelegateDocument(proto, { title: "child of " + proto.title }); return d; }); +Scripting.addGlobal(function generateLinkTitle(self: Doc) { + const anchor1title = self.anchor1 && self.anchor1 !== self ? Cast(self.anchor1, Doc, null).title : ""; + const anchor2title = self.anchor2 && self.anchor2 !== self ? Cast(self.anchor2, Doc, null).title : ""; + const relation = self.linkRelationship || "to"; + return `${anchor1title} (${relation}) ${anchor2title}`; +}) \ 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 660790b11..ec5cb8a61 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx @@ -950,7 +950,7 @@ export class CollectionFreeFormView extends CollectionSubView d?.author).length; - return
Date: Wed, 10 Mar 2021 11:18:25 -0500 Subject: made initial load of filterbox much more efficient by preventing incremental invalidations. fixed display of sliderBox filters. --- src/client/documents/Documents.ts | 5 ++- .../collections/CollectionMasonryViewFieldRow.tsx | 12 +++--- .../views/collections/CollectionStackingView.tsx | 5 +-- src/client/views/nodes/FilterBox.tsx | 47 ++++++++++++++-------- src/client/views/search/SearchBox.tsx | 17 +++++++- 5 files changed, 58 insertions(+), 28 deletions(-) (limited to 'src/client/views/collections') diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts index ac600af8b..357b82cd6 100644 --- a/src/client/documents/Documents.ts +++ b/src/client/documents/Documents.ts @@ -1043,8 +1043,9 @@ export namespace DocUtils { 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; + if (val < min || val > max) return false; + if (val === undefined) { + console.log("Should 'undefined' pass range filter or not?") } } return true; diff --git a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx index 077e50dd2..654727a82 100644 --- a/src/client/views/collections/CollectionMasonryViewFieldRow.tsx +++ b/src/client/views/collections/CollectionMasonryViewFieldRow.tsx @@ -2,22 +2,22 @@ import React = require("react"); import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { action, computed, observable, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { Doc, DocListCast, DataSym } from "../../../fields/Doc"; +import { DataSym, Doc, DocListCast } from "../../../fields/Doc"; +import { Id } from "../../../fields/FieldSymbols"; import { PastelSchemaPalette, SchemaHeaderField } from "../../../fields/SchemaHeaderField"; import { ScriptField } from "../../../fields/ScriptField"; -import { StrCast, NumCast } from "../../../fields/Types"; -import { numberRange, setupMoveUpEvents, emptyFunction, returnEmptyString } from "../../../Utils"; +import { NumCast, StrCast } from "../../../fields/Types"; +import { emptyFunction, numberRange, returnEmptyString, setupMoveUpEvents } from "../../../Utils"; import { Docs } from "../../documents/Documents"; import { DragManager } from "../../util/DragManager"; import { CompileScript } from "../../util/Scripting"; +import { SnappingManager } from "../../util/SnappingManager"; import { Transform } from "../../util/Transform"; import { undoBatch } from "../../util/UndoManager"; import { EditableView } from "../EditableView"; +import { FormattedTextBox } from "../nodes/formattedText/FormattedTextBox"; import { CollectionStackingView } from "./CollectionStackingView"; import "./CollectionStackingView.scss"; -import { SnappingManager } from "../../util/SnappingManager"; -import { FormattedTextBox } from "../nodes/formattedText/FormattedTextBox"; -import { Id } from "../../../fields/FieldSymbols"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx index 5bb3c0403..a8123b051 100644 --- a/src/client/views/collections/CollectionStackingView.tsx +++ b/src/client/views/collections/CollectionStackingView.tsx @@ -20,8 +20,9 @@ import { undoBatch } from "../../util/UndoManager"; import { ContextMenu } from "../ContextMenu"; import { ContextMenuProps } from "../ContextMenuItem"; import { EditableView } from "../EditableView"; +import { LightboxView } from "../LightboxView"; import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView"; -import { DocumentView, DocumentViewProps, DocFocusOptions, ViewAdjustment } from "../nodes/DocumentView"; +import { DocFocusOptions, DocumentView, DocumentViewProps, ViewAdjustment } from "../nodes/DocumentView"; import { FieldViewProps } from "../nodes/FieldView"; import { StyleProp } from "../StyleProvider"; import { CollectionMasonryViewFieldRow } from "./CollectionMasonryViewFieldRow"; @@ -29,8 +30,6 @@ import "./CollectionStackingView.scss"; import { CollectionStackingViewFieldColumn } from "./CollectionStackingViewFieldColumn"; import { CollectionSubView } from "./CollectionSubView"; import { CollectionViewType } from "./CollectionView"; -import { LightboxView } from "../LightboxView"; -import { DocumentType } from "../../documents/DocumentTypes"; const _global = (window /* browser */ || global /* node */) as any; type StackingDocument = makeInterface<[typeof collectionSchema, typeof documentSchema]>; diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx index bdd9334f4..003b3adbe 100644 --- a/src/client/views/nodes/FilterBox.tsx +++ b/src/client/views/nodes/FilterBox.tsx @@ -1,8 +1,8 @@ import React = require("react"); import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { computed } from "mobx"; +import { computed, observable, action, trace, reaction, runInAction } from "mobx"; import { observer } from "mobx-react"; -import { DataSym, Doc, DocListCast, Field, Opt } from "../../../fields/Doc"; +import { DataSym, Doc, DocListCast, Field, Opt, DocListCastAsync } from "../../../fields/Doc"; import { documentSchema } from "../../../fields/documentSchemas"; import { List } from "../../../fields/List"; import { RichTextField } from "../../../fields/RichTextField"; @@ -19,7 +19,6 @@ import { SearchBox } from "../search/SearchBox"; import { FieldView, FieldViewProps } from './FieldView'; import './FilterBox.scss'; import { Scripting } from "../../util/Scripting"; -import { values } from "lodash"; const higflyout = require("@hig/flyout"); export const { anchorPoints } = higflyout; export const Flyout = higflyout.default; @@ -31,9 +30,19 @@ const FilterBoxDocument = makeInterface(documentSchema); export class FilterBox extends ViewBoxBaseComponent(FilterBoxDocument) { public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); } + @observable _loaded = false; + componentDidMount() { + reaction(() => DocListCastAsync(CollectionDockingView.Instance.props.Document.data), + async (activeTabsAsync) => { + const activeTabs = await activeTabsAsync; + activeTabs && (await SearchBox.foreachRecursiveDocAsync(activeTabs, emptyFunction)); + runInAction(() => this._loaded = true); + }, { fireImmediately: true }); + } @computed get allDocs() { + trace(); const allDocs = new Set(); - if (CollectionDockingView.Instance) { + if (this._loaded && CollectionDockingView.Instance) { const activeTabs = DocListCast(CollectionDockingView.Instance.props.Document.data); SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc)); setTimeout(() => CollectionDockingView.Instance.props.Document.allDocuments = new List(Array.from(allDocs))); @@ -42,6 +51,7 @@ export class FilterBox extends ViewBoxBaseComponent script : undefined; } suppressChildClick = () => ScriptField.MakeScript("")!; - render() { - const facetCollection = this.props.Document; - const flyout =
e.stopPropagation()}> + @computed get flyoutpanel() { + return
e.stopPropagation()}> {this._allFacets.map(facet => )}
; + } + render() { + const facetCollection = this.props.Document; return this.props.dontRegisterView ? (null) :
e.stopPropagation()}> - +
Choose Facets @@ -233,7 +245,7 @@ Scripting.addGlobal(function determineCheckedState(layoutDoc: Doc, facetHeader: } return undefined; }); -Scripting.addGlobal(function readFacetData(layoutDoc: Doc, facetHeader: string) { +Scripting.addGlobal(function readFacetData(targetDoc: Doc, facetHeader: string) { const allCollectionDocs = DocListCast(CollectionDockingView.Instance?.props.Document.allDocuments); const set = new Set(); if (facetHeader === "tags") allCollectionDocs.forEach(child => Field.toString(child[facetHeader] as Field).split(":").forEach(key => set.add(key))); @@ -246,7 +258,10 @@ Scripting.addGlobal(function readFacetData(layoutDoc: Doc, facetHeader: string) const doc = new Doc(); doc.system = true; doc.title = facetValue.toString(); - doc.treeViewChecked = ComputedField.MakeFunction("determineCheckedState(layoutDoc, facetHeader, facetValue)", {}, { layoutDoc, facetHeader, facetValue }); + doc.target = targetDoc; + doc.facetHeader = facetHeader; + doc.facetValue = facetValue; + doc.treeViewChecked = ComputedField.MakeFunction("determineCheckedState(self.target, self.facetHeader, self.facetValue)"); return doc; }); return new List(facetValueDocSet); diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index c82d03fce..899fac66d 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -3,7 +3,7 @@ import { Tooltip } from '@material-ui/core'; import { action, computed, IReactionDisposer, observable, reaction, runInAction } from 'mobx'; import { observer } from 'mobx-react'; import * as React from 'react'; -import { Doc, DocListCast, Field, Opt } from '../../../fields/Doc'; +import { Doc, DocListCast, Field, Opt, DocListCastAsync } from '../../../fields/Doc'; import { documentSchema } from "../../../fields/documentSchemas"; import { Copy, Id } from '../../../fields/FieldSymbols'; import { List } from '../../../fields/List'; @@ -185,6 +185,21 @@ export class SearchBox extends ViewBoxBaseComponent void) { + let newarray: Doc[] = []; + while (docs.length > 0) { + newarray = []; + await Promise.all(docs.filter(d => d).map(async d => { + const fieldKey = Doc.LayoutFieldKey(d); + const annos = !Field.toString(Doc.LayoutField(d) as Field).includes("CollectionView"); + const data = d[annos ? fieldKey + "-annotations" : fieldKey]; + const docs = await DocListCastAsync(data); + docs && newarray.push(...docs); + func(d); + })); + docs = newarray; + } + } static foreachRecursiveDoc(docs: Doc[], func: (doc: Doc) => void) { let newarray: Doc[] = []; while (docs.length > 0) { -- cgit v1.2.3-70-g09d2