From 1f9baca276426444a4ebea06023402876f033ebe Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Fri, 27 Nov 2020 19:07:43 +0530
Subject: removed override

---
 src/client/views/PropertiesView.tsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 245e612b3..db9475afd 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -416,7 +416,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
         const ownerSame = Doc.CurrentUserEmail !== target.author && docs.filter(doc => doc).every(doc => doc.author === docs[0].author);
         // shifts the current user, owner, public to the top of the doc.
-        tableEntries.unshift(this.sharingItem("Override", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Override"] === docs[0]["acl-Override"]) ? (AclMap.get(target[AclSym]?.["acl-Override"]) || "None") : "-multiple-"));
+        // tableEntries.unshift(this.sharingItem("Override", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Override"] === docs[0]["acl-Override"]) ? (AclMap.get(target[AclSym]?.["acl-Override"]) || "None") : "-multiple-"));
         tableEntries.unshift(this.sharingItem("Public", showAdmin, docs.filter(doc => doc).every(doc => doc["acl-Public"] === docs[0]["acl-Public"]) ? (AclMap.get(target[AclSym]?.["acl-Public"]) || SharingPermissions.None) : "-multiple-"));
         tableEntries.unshift(this.sharingItem("Me", showAdmin, docs.filter(doc => doc).every(doc => doc.author === Doc.CurrentUserEmail) ? "Owner" : effectiveAcls.every(acl => acl === effectiveAcls[0]) ? AclMap.get(effectiveAcls[0])! : "-multiple-", !ownerSame));
         if (ownerSame) tableEntries.unshift(this.sharingItem(StrCast(target.author), showAdmin, "Owner"));
@@ -900,11 +900,11 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                                         />
                                         <div className="propertiesView-acls-checkbox-text">Layout</div>
                                     </div>) : (null)}
-                                    <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
+                                    {/* <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
                                         <button onPointerDown={() => SharingManager.Instance.distributeOverCollection(this.selectedDoc!)}>
                                             <FontAwesomeIcon icon="redo-alt" color="white" size="1x" />
                                         </button>
-                                    </Tooltip>
+                                    </Tooltip> */}
                                 </div>
                                 {this.sharingTable}
                             </div>}
-- 
cgit v1.2.3-70-g09d2


From db31bede84295fcf85f915b0267b69f0db831269 Mon Sep 17 00:00:00 2001
From: anika <anika.ahluwalia@gmail.com>
Date: Thu, 7 Jan 2021 11:23:48 -0600
Subject: shift to right

---
 src/client/views/PropertiesView.tsx                | 45 ++++++++++++++++++++--
 .../views/collections/CollectionTreeView.tsx       |  5 ++-
 src/client/views/nodes/FilterBox.scss              |  9 ++---
 src/client/views/nodes/FilterBox.tsx               |  4 +-
 4 files changed, 51 insertions(+), 12 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 6e33b5c2f..a8b65c114 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -11,7 +11,7 @@ import { InkField } from "../../fields/InkField";
 import { ComputedField } from "../../fields/ScriptField";
 import { Cast, NumCast, StrCast } from "../../fields/Types";
 import { denormalizeEmail, GetEffectiveAcl, SharingPermissions } from "../../fields/util";
-import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse } from "../../Utils";
+import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue } from "../../Utils";
 import { DocumentType } from "../documents/DocumentTypes";
 import { DocumentManager } from "../util/DocumentManager";
 import { SelectionManager } from "../util/SelectionManager";
@@ -29,6 +29,7 @@ import { PropertiesButtons } from "./PropertiesButtons";
 import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector";
 import "./PropertiesView.scss";
 import { DefaultStyleProvider } from "./StyleProvider";
+import { FilterBox } from "./nodes/FilterBox";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -67,6 +68,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @observable openContexts: boolean = true;
     @observable openAppearance: boolean = true;
     @observable openTransform: boolean = true;
+    @observable openFilters: boolean = true;
+
     // @observable selectedUser: string = "";
     // @observable addButtonPressed: boolean = false;
     @observable layoutDocAcls: boolean = false;
@@ -510,8 +513,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         }
     }
 
-
-
     @computed
     get controlPointsButton() {
         const formatInstance = InkStrokeProperties.Instance;
@@ -907,6 +908,44 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             </div>}
                     </div>
 
+                    <div className="propertiesView-settings">
+                        <div className="propertiesView-settings-title"
+                            onPointerDown={action(() => this.openFilters = !this.openFilters)}
+                            style={{ backgroundColor: this.openFilters ? "black" : "" }}>
+                            Filters
+                        <div className="propertiesView-settings-title-icon">
+                                <FontAwesomeIcon icon={this.openFilters ? "caret-down" : "caret-right"} size="lg" color="white" />
+                            </div>
+                        </div>
+                        {!this.openFilters ? (null) :
+                            <div className="propertiesView-settings-content">
+                                <DocumentView
+                                    Document={Doc.UserDoc().myFilter as any as Doc}
+                                    DataDoc={undefined}
+                                    addDocument={undefined}
+                                    addDocTab={returnFalse}
+                                    pinToPres={emptyFunction}
+                                    rootSelected={returnTrue}
+                                    removeDocument={returnFalse}
+                                    ScreenToLocalTransform={this.getTransform}
+                                    PanelWidth={this.docWidth}
+                                    PanelHeight={this.docHeight}
+                                    renderDepth={0}
+                                    scriptContext={CollectionDockingView.Instance.props.Document}
+                                    focus={emptyFunction}
+                                    styleProvider={DefaultStyleProvider}
+                                    parentActive={returnTrue}
+                                    whenActiveChanged={emptyFunction}
+                                    bringToFront={emptyFunction}
+                                    docFilters={returnEmptyFilter}
+                                    docRangeFilters={returnEmptyFilter}
+                                    searchFilterDocs={returnEmptyDoclist}
+                                    ContainingCollectionView={undefined}
+                                    ContainingCollectionDoc={undefined}
+                                />
+                            </div>}
+                    </div>
+
                     {!this.isInk ? (null) :
                         <div className="propertiesView-appearance">
                             <div className="propertiesView-appearance-title"
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index d1e0a0f02..b9ad1680a 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -35,7 +35,8 @@ export type collectionTreeViewProps = {
 };
 
 @observer
-export class CollectionTreeView extends CollectionSubView<Document, Partial<collectionTreeViewProps>>(Document) {
+export class
+    CollectionTreeView extends CollectionSubView<Document, Partial<collectionTreeViewProps>>(Document) {
     private treedropDisposer?: DragManager.DragDropDisposer;
     private _isChildActive = false;
     private _mainEle?: HTMLDivElement;
@@ -212,7 +213,7 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
     render() {
         TraceMobx();
         if (!(this.doc instanceof Doc)) return (null);
-        const background = this.props.treeViewHideTitle && this.props.treeViewHideHeaderFields ? "#D3D3D3" : this.props.styleProvider?.(this.doc, this.props, StyleProp.BackgroundColor);
+        const background = this.props.treeViewHideTitle && this.props.treeViewHideHeaderFields ? "#9F9F9F" : this.props.styleProvider?.(this.doc, this.props, StyleProp.BackgroundColor);
         const paddingX = `${NumCast(this.doc._xPadding, 15)}px`;
         const paddingTop = `${NumCast(this.doc._yPadding, 20)}px`;
         const pointerEvents = !this.props.active() && !SnappingManager.GetIsDragging() && !this._isChildActive ? "none" : undefined;
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index d19fc07d3..8ebc7820a 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -28,9 +28,9 @@
 }
 
 .filterBox-bottom {
-    position: fixed;
-    bottom: 0;
-    width: 100%;
+    // position: fixed;
+    // bottom: 0;
+    // width: 100%;
 }
 
 
@@ -147,9 +147,8 @@
     position: absolute;
     right: 0;
     top: 0;
-    border-left: solid 1px;
     z-index: 1;
-    background-color: #D3D3D3;
+    background-color: #9F9F9F;
 
     .filterBox-addfacet {
         display: inline-block;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index d81fd9fe7..cea1e6742 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -210,13 +210,13 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
             {/* <div className="filterBox-top"> */}
-            <div className="filter-bookmark">
+            {/* <div className="filter-bookmark">
                 <FontAwesomeIcon className="filter-bookmark-icon" icon={"bookmark"} size={"lg"} />
             </div>
 
             <div className="filterBox-title">
                 <span className="filterBox-span">Choose Filters</span>
-            </div>
+            </div> */}
 
             <div className="filterBox-select-bool">
                 <select className="filterBox-selection" onChange={e => this.changeBool(e)}>
-- 
cgit v1.2.3-70-g09d2


From f32df5a6b290318845afb842d938e21b938041d7 Mon Sep 17 00:00:00 2001
From: anika <anika.ahluwalia@gmail.com>
Date: Fri, 8 Jan 2021 01:37:39 -0600
Subject: UI changes and clean up

---
 src/client/util/CurrentUserUtils.ts   |  6 +++---
 src/client/views/MainView.tsx         |  5 +++--
 src/client/views/PropertiesView.tsx   | 10 +++++-----
 src/client/views/nodes/FilterBox.scss | 32 +++++++++++++++++++++-----------
 src/client/views/nodes/FilterBox.tsx  | 27 ++++++++++++++++++++-------
 5 files changed, 52 insertions(+), 28 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index e47c9a0e2..c4f7744ce 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -799,9 +799,9 @@ export class CurrentUserUtils {
             (doc.currentFilter as any as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
             (doc.currentFilter as any as Doc).contextMenuLabels = new List<string>(["Clear All"]);
         }
-        const clearAll = ScriptField.MakeScript(`getProto(self).data = new List([]); scriptContext._docFilters = scriptContext._docRangeFilters = undefined;`, { scriptContext: Doc.name });
-        (doc.myFilter as any as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
-        (doc.myFilter as any as Doc).contextMenuLabels = new List<string>(["Clear All"]);
+        // const clearAll = ScriptField.MakeScript(`getProto(self).data = new List([]); scriptContext._docFilters = scriptContext._docRangeFilters = undefined;`, { scriptContext: Doc.name });
+        // (doc.myFilter as any as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
+        // (doc.myFilter as any as Doc).contextMenuLabels = new List<string>(["Clear All"]);
 
     }
 
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index ab63ebd03..6c0b85f4b 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -165,7 +165,8 @@ export class MainView extends React.Component {
             fa.faWindowMinimize, fa.faWindowRestore, fa.faTextWidth, fa.faTextHeight, fa.faClosedCaptioning, fa.faInfoCircle, fa.faTag, fa.faSyncAlt, fa.faPhotoVideo,
             fa.faArrowAltCircleDown, fa.faArrowAltCircleUp, fa.faArrowAltCircleLeft, fa.faArrowAltCircleRight, fa.faStopCircle, fa.faCheckCircle, fa.faGripVertical,
             fa.faSortUp, fa.faSortDown, fa.faTable, fa.faTh, fa.faThList, fa.faProjectDiagram, fa.faSignature, fa.faColumns, fa.faChevronCircleUp, fa.faUpload, fa.faBorderAll,
-            fa.faBraille, fa.faChalkboard, fa.faPencilAlt, fa.faEyeSlash, fa.faSmile, fa.faIndent, fa.faOutdent, fa.faChartBar, fa.faBan, fa.faPhoneSlash, fa.faGripLines, fa.faBookmark);
+            fa.faBraille, fa.faChalkboard, fa.faPencilAlt, fa.faEyeSlash, fa.faSmile, fa.faIndent, fa.faOutdent, fa.faChartBar, fa.faBan, fa.faPhoneSlash, fa.faGripLines,
+            fa.faSave, fa.faBookmark);
         this.initAuthenticationRouters();
     }
 
@@ -344,7 +345,7 @@ export class MainView extends React.Component {
                         renderDepth={0}
                         scriptContext={CollectionDockingView.Instance.props.Document}
                         focus={emptyFunction}
-                        styleProvider={this._sidebarContent.title === "My Dashboards" ? DashboardStyleProvider : DefaultStyleProvider}
+                        styleProvider={this._sidebarContent.title === "My Dashboards" ? this.DashboardStyleProvider : DefaultStyleProvider}
                         parentActive={returnTrue}
                         whenActiveChanged={emptyFunction}
                         bringToFront={emptyFunction}
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index a8b65c114..1c6ad26e6 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -908,19 +908,19 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             </div>}
                     </div>
 
-                    <div className="propertiesView-settings">
-                        <div className="propertiesView-settings-title"
+                    <div className="propertiesView-sharing">
+                        <div className="propertiesView-sharing-title"
                             onPointerDown={action(() => this.openFilters = !this.openFilters)}
                             style={{ backgroundColor: this.openFilters ? "black" : "" }}>
                             Filters
-                        <div className="propertiesView-settings-title-icon">
+                        <div className="propertiesView-sharing-title-icon">
                                 <FontAwesomeIcon icon={this.openFilters ? "caret-down" : "caret-right"} size="lg" color="white" />
                             </div>
                         </div>
                         {!this.openFilters ? (null) :
-                            <div className="propertiesView-settings-content">
+                            <div className="propertiesView-sharing-content">
                                 <DocumentView
-                                    Document={Doc.UserDoc().myFilter as any as Doc}
+                                    Document={Doc.UserDoc().currentFilter as any as Doc}
                                     DataDoc={undefined}
                                     addDocument={undefined}
                                     addDocTab={returnFalse}
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index 8ebc7820a..59ef2c5cf 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -1,7 +1,7 @@
 .filterBox-flyout {
     display: block;
     text-align: left;
-    font-weight: 200;
+    font-weight: 100;
 
     .filterBox-flyout-facet {
         background-color: white;
@@ -35,22 +35,24 @@
 
 
 .filterBox-saveBookmark {
-    width: 105px;
     background-color: #f5f5f5;
     border-radius: 6px;
-    padding: 5px;
-    margin: 5px;
+    padding-left: 8px;
+    padding-right: 8px;
+    padding-top: 5px;
+    padding-bottom: 5px;
+    margin: 8px;
     display: flex;
-    font-size: 17px;
+    font-size: 11px;
 
     &:hover {
         background-color: white;
     }
 
     .filterBox-saveBookmark-icon {
-        margin-right: 10px;
+        margin-right: 6px;
         margin-top: 4px;
-        margin-left: 10px;
+        margin-left: 2px;
     }
 
 }
@@ -74,7 +76,7 @@
 .filterBox-addWrapper,
 .filterBox-select-matched,
 .filterBox-saveWrapper {
-    font-size: 12px;
+    font-size: 10px;
     justify-content: center;
     justify-items: center;
     padding-bottom: 10px;
@@ -82,7 +84,7 @@
 }
 
 .filterBox-addWrapper {
-    font-size: 15px;
+    font-size: 11px;
     width: 100%;
 }
 
@@ -103,9 +105,15 @@
     border-bottom: 2px solid black;
 }
 
+
+.filterBox-select-bool {
+    margin-top: 6px;
+}
+
 .filterBox-select-text {
     margin-right: 8px;
     margin-left: 8px;
+    margin-top: 3px;
 }
 
 .filterBox-select-box {
@@ -127,12 +135,14 @@
 }
 
 .filterBox-addFilter {
-    width: 100px;
+    width: 120px;
     background-color: #f5f5f5;
-    border-radius: 6px;
+    border-radius: 10px;
     padding: 5px;
     margin: 5px;
     display: flex;
+    text-align: center;
+    justify-content: center;
 
     &:hover {
         background-color: white;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index cea1e6742..611e11b64 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -223,17 +223,22 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     <option value="AND" key="AND">AND</option>
                     <option value="OR" key="OR">OR</option>
                 </select>
-                <div className="filterBox-select-text">specified filters</div>
+                <div className="filterBox-select-text">filters in </div>
+                <select className="filterBox-selection" onChange={e => this.changeScope(e)}>
+                    <option value="Current Dashboard" key="Current Dashboard">Current Dashboard</option>
+                    <option value="Current Tab" key="Current Tab">Current Tab</option>
+                    <option value="Current Collection" key="Current Collection">Current Collection</option>
+                </select>
             </div>
 
-            <div className="filterBox-select-scope">
+            {/* <div className="filterBox-select-scope">
                 <div className="filterBox-select-text">Scope: </div>
                 <select className="filterBox-selection" onChange={e => this.changeScope(e)}>
                     <option value="Current Dashboard" key="Current Dashboard">Current Dashboard</option>
                     <option value="Current Tab" key="Current Tab">Current Tab</option>
                     <option value="Current Collection" key="Current Collection">Current Collection</option>
                 </select>
-            </div>
+            </div> */}
             {/* </div> */}
 
             <div className="filterBox-tree" key="tree">
@@ -291,10 +296,18 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     <div className="filterBox-select-text">documents</div>
                 </div>
 
-                <div className="filterBox-saveWrapper">
-                    <div className="filterBox-saveBookmark">
-                        <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"bookmark"} size={"sm"} />
-                        <div>SAVE</div>
+                <div style={{ display: "flex" }}>
+                    <div className="filterBox-saveWrapper">
+                        <div className="filterBox-saveBookmark">
+                            <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"save"} size={"sm"} />
+                            <div>SAVE</div>
+                        </div>
+                    </div>
+                    <div className="filterBox-saveWrapper">
+                        <div className="filterBox-saveBookmark">
+                            <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"bookmark"} size={"sm"} />
+                            <div>MY FILTERS</div>
+                        </div>
                     </div>
                 </div>
             </div>
-- 
cgit v1.2.3-70-g09d2


From 70344f575caf32ae4bef5ec7f0228da2e6271d59 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Wed, 20 Jan 2021 21:10:59 -0500
Subject: refactored some propertiesview stuff

---
 src/client/views/PropertiesView.tsx | 337 ++++++++++++++++++++----------------
 1 file changed, 185 insertions(+), 152 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 1c6ad26e6..2fb543224 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -399,7 +399,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         const showAdmin = effectiveAcls.every(acl => acl === AclAdmin);
 
         // users in common between all docs
-        const commonKeys = intersection(...docs.map(doc => this.layoutDocAcls ? doc?.[AclSym] && Object.keys(doc[AclSym]) : doc?.[DataSym][AclSym] && Object.keys(doc[DataSym][AclSym])));
+        const commonKeys: string[] = intersection(...docs.map(doc => this.layoutDocAcls ? doc?.[AclSym] && Object.keys(doc[AclSym]) : doc?.[DataSym][AclSym] && Object.keys(doc[DataSym][AclSym])));
 
         const tableEntries = [];
 
@@ -829,6 +829,181 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         </div>;
     }
 
+    @computed get optionsSubMenu() {
+        return <div className="propertiesView-settings" onPointerEnter={action(() => this.inOptions = true)}
+            onPointerLeave={action(() => this.inOptions = false)}>
+            <div className="propertiesView-settings-title"
+                onPointerDown={action(() => this.openOptions = !this.openOptions)}
+                style={{ backgroundColor: this.openOptions ? "black" : "" }}>
+                Options
+                        <div className="propertiesView-settings-title-icon">
+                    <FontAwesomeIcon icon={this.openOptions ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {!this.openOptions ? (null) :
+                <div className="propertiesView-settings-content">
+                    <PropertiesButtons />
+                </div>}
+        </div>;
+    }
+
+    @computed get sharingSubMenu() {
+        return <div className="propertiesView-sharing">
+            <div className="propertiesView-sharing-title"
+                onPointerDown={action(() => this.openSharing = !this.openSharing)}
+                style={{ backgroundColor: this.openSharing ? "black" : "" }}>
+                Sharing {"&"} Permissions
+                        <div className="propertiesView-sharing-title-icon">
+                    <FontAwesomeIcon icon={this.openSharing ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {!this.openSharing ? (null) :
+                <div className="propertiesView-sharing-content">
+                    <div className="propertiesView-buttonContainer">
+                        {!Doc.UserDoc().noviceMode ? (<div className="propertiesView-acls-checkbox">
+                            <Checkbox
+                                color="primary"
+                                onChange={action(() => this.layoutDocAcls = !this.layoutDocAcls)}
+                                checked={this.layoutDocAcls}
+                            />
+                            <div className="propertiesView-acls-checkbox-text">Layout</div>
+                        </div>) : (null)}
+                        {/* <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
+                                        <button onPointerDown={() => SharingManager.Instance.distributeOverCollection(this.selectedDoc!)}>
+                                            <FontAwesomeIcon icon="redo-alt" color="white" size="1x" />
+                                        </button>
+                                    </Tooltip> */}
+                    </div>
+                    {this.sharingTable}
+                </div>}
+        </div>;
+    }
+
+    @computed get filtersSubMenu() {
+        return <div className="propertiesView-sharing">
+            <div className="propertiesView-sharing-title"
+                onPointerDown={action(() => this.openFilters = !this.openFilters)}
+                style={{ backgroundColor: this.openFilters ? "black" : "" }}>
+                Filters
+                        <div className="propertiesView-sharing-title-icon">
+                    <FontAwesomeIcon icon={this.openFilters ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {!this.openFilters ? (null) :
+                <div className="propertiesView-sharing-content">
+                    <DocumentView
+                        Document={Doc.UserDoc().currentFilter as any as Doc}
+                        DataDoc={undefined}
+                        addDocument={undefined}
+                        addDocTab={returnFalse}
+                        pinToPres={emptyFunction}
+                        rootSelected={returnTrue}
+                        removeDocument={returnFalse}
+                        ScreenToLocalTransform={this.getTransform}
+                        PanelWidth={this.docWidth}
+                        PanelHeight={this.docHeight}
+                        renderDepth={0}
+                        scriptContext={CollectionDockingView.Instance.props.Document}
+                        focus={emptyFunction}
+                        styleProvider={DefaultStyleProvider}
+                        parentActive={returnTrue}
+                        whenActiveChanged={emptyFunction}
+                        bringToFront={emptyFunction}
+                        docFilters={returnEmptyFilter}
+                        docRangeFilters={returnEmptyFilter}
+                        searchFilterDocs={returnEmptyDoclist}
+                        ContainingCollectionView={undefined}
+                        ContainingCollectionDoc={undefined}
+                    />
+                </div>}
+        </div>;
+    }
+
+    @computed get inkSubMenu() {
+        return <>
+            {!this.isInk ? (null) :
+                <div className="propertiesView-appearance">
+                    <div className="propertiesView-appearance-title"
+                        onPointerDown={action(() => this.openAppearance = !this.openAppearance)}
+                        style={{ backgroundColor: this.openAppearance ? "black" : "" }}>
+                        Appearance
+                            <div className="propertiesView-appearance-title-icon">
+                            <FontAwesomeIcon icon={this.openAppearance ? "caret-down" : "caret-right"} size="lg" color="white" />
+                        </div>
+                    </div>
+                    {!this.openAppearance ? (null) :
+                        <div className="propertiesView-appearance-content">
+                            {this.appearanceEditor}
+                        </div>}
+                </div>}
+
+            {this.isInk ? <div className="propertiesView-transform">
+                <div className="propertiesView-transform-title"
+                    onPointerDown={action(() => this.openTransform = !this.openTransform)}
+                    style={{ backgroundColor: this.openTransform ? "black" : "" }}>
+                    Transform
+                        <div className="propertiesView-transform-title-icon">
+                        <FontAwesomeIcon icon={this.openTransform ? "caret-down" : "caret-right"} size="lg" color="white" />
+                    </div>
+                </div>
+                {this.openTransform ? <div className="propertiesView-transform-content">
+                    {this.transformEditor}
+                </div> : null}
+            </div> : null}
+        </>;
+    }
+
+    @computed get fieldsSubMenu() {
+        return <div className="propertiesView-fields">
+            <div className="propertiesView-fields-title"
+                onPointerDown={action(() => this.openFields = !this.openFields)}
+                style={{ backgroundColor: this.openFields ? "black" : "" }}>
+                Fields {"&"} Tags
+                            <div className="propertiesView-fields-title-icon">
+                    <FontAwesomeIcon icon={this.openFields ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {!Doc.UserDoc().noviceMode && this.openFields ? <div className="propertiesView-fields-checkbox">
+                {this.fieldsCheckbox}
+                <div className="propertiesView-fields-checkbox-text">Layout</div>
+            </div> : null}
+            {!this.openFields ? (null) :
+                <div className="propertiesView-fields-content">
+                    {Doc.UserDoc().noviceMode ? this.noviceFields : this.expandedField}
+                </div>}
+        </div>;
+    }
+
+    @computed get contextsSubMenu() {
+        return <div className="propertiesView-contexts">
+            <div className="propertiesView-contexts-title"
+                onPointerDown={action(() => this.openContexts = !this.openContexts)}
+                style={{ backgroundColor: this.openContexts ? "black" : "" }}>
+                Contexts
+                        <div className="propertiesView-contexts-title-icon">
+                    <FontAwesomeIcon icon={this.openContexts ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {this.openContexts ? <div className="propertiesView-contexts-content"  >{this.contexts}</div> : null}
+        </div>;
+    }
+
+    @computed get layoutSubMenu() {
+        return <div className="propertiesView-layout">
+            <div className="propertiesView-layout-title"
+                onPointerDown={action(() => this.openLayout = !this.openLayout)}
+                style={{ backgroundColor: this.openLayout ? "black" : "" }}>
+                Layout
+                        <div className="propertiesView-layout-title-icon">
+                    <FontAwesomeIcon icon={this.openLayout ? "caret-down" : "caret-right"} size="lg" color="white" />
+                </div>
+            </div>
+            {this.openLayout ? <div className="propertiesView-layout-content"  >{this.layoutPreview}</div> : null}
+        </div>;
+    }
+
+
+
     /**
      * Handles adding and removing members from the sharing panel
      */
@@ -849,8 +1024,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             </div>;
 
         } else {
-            const novice = Doc.UserDoc().noviceMode;
-
             if (this.selectedDoc && !this.isPres) {
                 return <div className="propertiesView" style={{
                     width: this.props.width,
@@ -863,159 +1036,19 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                     <div className="propertiesView-name">
                         {this.editableTitle}
                     </div>
-                    <div className="propertiesView-settings" onPointerEnter={action(() => this.inOptions = true)}
-                        onPointerLeave={action(() => this.inOptions = false)}>
-                        <div className="propertiesView-settings-title"
-                            onPointerDown={action(() => this.openOptions = !this.openOptions)}
-                            style={{ backgroundColor: this.openOptions ? "black" : "" }}>
-                            Options
-                        <div className="propertiesView-settings-title-icon">
-                                <FontAwesomeIcon icon={this.openOptions ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {!this.openOptions ? (null) :
-                            <div className="propertiesView-settings-content">
-                                <PropertiesButtons />
-                            </div>}
-                    </div>
-                    <div className="propertiesView-sharing">
-                        <div className="propertiesView-sharing-title"
-                            onPointerDown={action(() => this.openSharing = !this.openSharing)}
-                            style={{ backgroundColor: this.openSharing ? "black" : "" }}>
-                            Sharing {"&"} Permissions
-                        <div className="propertiesView-sharing-title-icon">
-                                <FontAwesomeIcon icon={this.openSharing ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {!this.openSharing ? (null) :
-                            <div className="propertiesView-sharing-content">
-                                <div className="propertiesView-buttonContainer">
-                                    {!novice ? (<div className="propertiesView-acls-checkbox">
-                                        <Checkbox
-                                            color="primary"
-                                            onChange={action(() => this.layoutDocAcls = !this.layoutDocAcls)}
-                                            checked={this.layoutDocAcls}
-                                        />
-                                        <div className="propertiesView-acls-checkbox-text">Layout</div>
-                                    </div>) : (null)}
-                                    {/* <Tooltip title={<><div className="dash-tooltip">{"Re-distribute sharing settings"}</div></>}>
-                                        <button onPointerDown={() => SharingManager.Instance.distributeOverCollection(this.selectedDoc!)}>
-                                            <FontAwesomeIcon icon="redo-alt" color="white" size="1x" />
-                                        </button>
-                                    </Tooltip> */}
-                                </div>
-                                {this.sharingTable}
-                            </div>}
-                    </div>
+                    {this.optionsSubMenu}
 
-                    <div className="propertiesView-sharing">
-                        <div className="propertiesView-sharing-title"
-                            onPointerDown={action(() => this.openFilters = !this.openFilters)}
-                            style={{ backgroundColor: this.openFilters ? "black" : "" }}>
-                            Filters
-                        <div className="propertiesView-sharing-title-icon">
-                                <FontAwesomeIcon icon={this.openFilters ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {!this.openFilters ? (null) :
-                            <div className="propertiesView-sharing-content">
-                                <DocumentView
-                                    Document={Doc.UserDoc().currentFilter as any as Doc}
-                                    DataDoc={undefined}
-                                    addDocument={undefined}
-                                    addDocTab={returnFalse}
-                                    pinToPres={emptyFunction}
-                                    rootSelected={returnTrue}
-                                    removeDocument={returnFalse}
-                                    ScreenToLocalTransform={this.getTransform}
-                                    PanelWidth={this.docWidth}
-                                    PanelHeight={this.docHeight}
-                                    renderDepth={0}
-                                    scriptContext={CollectionDockingView.Instance.props.Document}
-                                    focus={emptyFunction}
-                                    styleProvider={DefaultStyleProvider}
-                                    parentActive={returnTrue}
-                                    whenActiveChanged={emptyFunction}
-                                    bringToFront={emptyFunction}
-                                    docFilters={returnEmptyFilter}
-                                    docRangeFilters={returnEmptyFilter}
-                                    searchFilterDocs={returnEmptyDoclist}
-                                    ContainingCollectionView={undefined}
-                                    ContainingCollectionDoc={undefined}
-                                />
-                            </div>}
-                    </div>
+                    {this.sharingSubMenu}
 
-                    {!this.isInk ? (null) :
-                        <div className="propertiesView-appearance">
-                            <div className="propertiesView-appearance-title"
-                                onPointerDown={action(() => this.openAppearance = !this.openAppearance)}
-                                style={{ backgroundColor: this.openAppearance ? "black" : "" }}>
-                                Appearance
-                            <div className="propertiesView-appearance-title-icon">
-                                    <FontAwesomeIcon icon={this.openAppearance ? "caret-down" : "caret-right"} size="lg" color="white" />
-                                </div>
-                            </div>
-                            {!this.openAppearance ? (null) :
-                                <div className="propertiesView-appearance-content">
-                                    {this.appearanceEditor}
-                                </div>}
-                        </div>}
+                    {this.filtersSubMenu}
 
-                    {this.isInk ? <div className="propertiesView-transform">
-                        <div className="propertiesView-transform-title"
-                            onPointerDown={action(() => this.openTransform = !this.openTransform)}
-                            style={{ backgroundColor: this.openTransform ? "black" : "" }}>
-                            Transform
-                        <div className="propertiesView-transform-title-icon">
-                                <FontAwesomeIcon icon={this.openTransform ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {this.openTransform ? <div className="propertiesView-transform-content">
-                            {this.transformEditor}
-                        </div> : null}
-                    </div> : null}
+                    {this.inkSubMenu}
 
-                    <div className="propertiesView-fields">
-                        <div className="propertiesView-fields-title"
-                            onPointerDown={action(() => this.openFields = !this.openFields)}
-                            style={{ backgroundColor: this.openFields ? "black" : "" }}>
-                            Fields {"&"} Tags
-                            <div className="propertiesView-fields-title-icon">
-                                <FontAwesomeIcon icon={this.openFields ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {!novice && this.openFields ? <div className="propertiesView-fields-checkbox">
-                            {this.fieldsCheckbox}
-                            <div className="propertiesView-fields-checkbox-text">Layout</div>
-                        </div> : null}
-                        {!this.openFields ? (null) :
-                            <div className="propertiesView-fields-content">
-                                {novice ? this.noviceFields : this.expandedField}
-                            </div>}
-                    </div>
-                    <div className="propertiesView-contexts">
-                        <div className="propertiesView-contexts-title"
-                            onPointerDown={action(() => this.openContexts = !this.openContexts)}
-                            style={{ backgroundColor: this.openContexts ? "black" : "" }}>
-                            Contexts
-                        <div className="propertiesView-contexts-title-icon">
-                                <FontAwesomeIcon icon={this.openContexts ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {this.openContexts ? <div className="propertiesView-contexts-content"  >{this.contexts}</div> : null}
-                    </div>
-                    <div className="propertiesView-layout">
-                        <div className="propertiesView-layout-title"
-                            onPointerDown={action(() => this.openLayout = !this.openLayout)}
-                            style={{ backgroundColor: this.openLayout ? "black" : "" }}>
-                            Layout
-                        <div className="propertiesView-layout-title-icon">
-                                <FontAwesomeIcon icon={this.openLayout ? "caret-down" : "caret-right"} size="lg" color="white" />
-                            </div>
-                        </div>
-                        {this.openLayout ? <div className="propertiesView-layout-content"  >{this.layoutPreview}</div> : null}
-                    </div>
+                    {this.fieldsSubMenu}
+
+                    {this.contextsSubMenu}
+
+                    {this.layoutSubMenu}
                 </div>;
             }
             if (this.isPres) {
-- 
cgit v1.2.3-70-g09d2


From 7941773a61573db14cbf425d07ab0ff9b8ce5d33 Mon Sep 17 00:00:00 2001
From: anika <anika.ahluwalia@gmail.com>
Date: Wed, 27 Jan 2021 20:35:44 -0500
Subject: minor changes

---
 src/client/views/PropertiesView.tsx   |  2 +-
 src/client/views/StyleProvider.tsx    | 41 ++++++++++++++++++++++++++++++
 src/client/views/nodes/FilterBox.scss |  6 +++++
 src/client/views/nodes/FilterBox.tsx  | 48 +++++++++++++++++++++++++++--------
 4 files changed, 86 insertions(+), 11 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 2fb543224..4b65d01a4 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -28,7 +28,7 @@ import { PresBox } from "./nodes/PresBox";
 import { PropertiesButtons } from "./PropertiesButtons";
 import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector";
 import "./PropertiesView.scss";
-import { DefaultStyleProvider } from "./StyleProvider";
+import { DefaultStyleProvider, FilteringStyleProvider } from "./StyleProvider";
 import { FilterBox } from "./nodes/FilterBox";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx
index 101ecb9ad..85333eee9 100644
--- a/src/client/views/StyleProvider.tsx
+++ b/src/client/views/StyleProvider.tsx
@@ -16,6 +16,7 @@ import { DocumentViewProps } from "./nodes/DocumentView";
 import { FieldViewProps } from './nodes/FieldView';
 import "./StyleProvider.scss";
 import "./collections/TreeView.scss";
+import "./nodes/FilterBox.scss";
 import React = require("react");
 import Color = require('color');
 
@@ -215,6 +216,46 @@ export function DashboardStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps
     }
 }
 
+function changeFilterBool(e: any, doc: Doc) {
+    UndoManager.RunInBatch(() => runInAction(() => {
+        //e.stopPropagation();
+        //doc.lockedPosition = doc.lockedPosition ? undefined : true;
+    }), "changeFilterBool");
+}
+
+function closeFilter(e: React.MouseEvent, doc: Doc) {
+    UndoManager.RunInBatch(() => runInAction(() => {
+        e.stopPropagation();
+        //doc.lockedPosition = doc.lockedPosition ? undefined : true;
+    }), "closeFilter");
+}
+
+
+/**
+ * add (to treeView) for filtering decorations
+ */
+export function FilteringStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps | DocumentViewProps>, property: string) {
+    switch (property.split(":")[0]) {
+        case StyleProp.Decorations:
+            if (doc) {
+                return doc._viewType === CollectionViewType.Docking || (Doc.IsSystem(doc)) ? (null) :
+                    <>
+                        <div>
+                            <select className="filterBox-treeView-selection" onChange={e => changeFilterBool(e, doc)}>
+                                <option value="Is" key="Is">Is</option>
+                                <option value="Is Not" key="Is Not">Is Not</option>
+                            </select>
+                        </div>
+                        <div className="filterBox-treeView-close" onClick={(e) => closeFilter(e, doc)}>
+                            <FontAwesomeIcon icon={"times"} size="sm" />
+                        </div>
+                    </>;
+            }
+        default: return DefaultStyleProvider(doc, props, property);
+
+    }
+}
+
 //
 // a preliminary semantic-"layering/grouping" mechanism for determining interactive properties of documents
 //  currently, the provider tests whether the docuemnt's layer field matches the activeLayer field of the tab.
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index 144f161bc..fb1783ad4 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -33,6 +33,12 @@
     // width: 100%;
 }
 
+.filterBox-select {
+    width: 90%;
+    margin-top: 5px;
+    margin-bottom: 15px;
+}
+
 
 .filterBox-saveBookmark {
     background-color: #e9e9e9;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 2db610e43..c7dc4c155 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -8,7 +8,7 @@ import { List } from "../../../fields/List";
 import { RichTextField } from "../../../fields/RichTextField";
 import { listSpec, makeInterface } from "../../../fields/Schema";
 import { ComputedField, ScriptField } from "../../../fields/ScriptField";
-import { Cast } from "../../../fields/Types";
+import { Cast, StrCast } from "../../../fields/Types";
 import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnOne, returnZero, returnTrue } from "../../../Utils";
 import { Docs } from "../../documents/Documents";
 import { DocumentType } from "../../documents/DocumentTypes";
@@ -27,6 +27,9 @@ export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
 import Select from "react-select";
 import { UserOptions } from "../../util/GroupManager";
+import { DocumentViewProps } from "./DocumentView";
+import { DefaultStyleProvider, StyleProp } from "../StyleProvider";
+import { CollectionViewType } from "../collections/CollectionView";
 
 type FilterBoxDocument = makeInterface<[typeof documentSchema]>;
 const FilterBoxDocument = makeInterface(documentSchema);
@@ -206,6 +209,29 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         console.log(this._filterSelected);
     }
 
+    FilteringStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps | DocumentViewProps>, property: string) {
+        switch (property.split(":")[0]) {
+            case StyleProp.Decorations:
+                if (doc) {
+                    return doc._viewType === CollectionViewType.Docking || (Doc.IsSystem(doc)) ? (null) :
+                        <>
+                            <div>
+                                <select className="filterBox-treeView-selection">
+                                    <option value="Is" key="Is">Is</option>
+                                    <option value="Is Not" key="Is Not">Is Not</option>
+                                </select>
+                            </div>
+                            <div className="filterBox-treeView-close" onClick={e => this.facetClick(StrCast(doc.title))}>
+                                <FontAwesomeIcon icon={"times"} size="sm" />
+                            </div>
+                        </>;
+                }
+            default: return DefaultStyleProvider(doc, props, property);
+
+        }
+    }
+
+
     render() {
         const facetCollection = this.props.Document;
         const flyout = <div className="filterBox-flyout" style={{ width: `100%` }} onWheel={e => e.stopPropagation()}>
@@ -286,7 +312,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     treeViewHideHeaderFields={true}
                     onCheckedClick={this.scriptField}
                     dontRegisterView={true}
-                    styleProvider={this.props.styleProvider}
+                    styleProvider={this.FilteringStyleProvider}
                     scriptContext={this.props.scriptContext}
                     moveDocument={returnFalse}
                     removeDocument={returnFalse}
@@ -297,14 +323,16 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     <div className="filterBox-addFilter"> + add a filter</div>
                 </div>
             </Flyout> */}
-            <Select
-                placeholder="Add a filter..."
-                options={options}
-                isMulti={false}
-                onChange={val => this.facetClick((val as UserOptions).value)}
-                value={null}
-                closeMenuOnSelect={false}
-            />
+            <div className="filterBox-select">
+                <Select
+                    placeholder="Add a filter..."
+                    options={options}
+                    isMulti={false}
+                    onChange={val => this.facetClick((val as UserOptions).value)}
+                    value={null}
+                    closeMenuOnSelect={false}
+                />
+            </div>
 
             <div className="filterBox-bottom">
                 <div className="filterBox-select-matched">
-- 
cgit v1.2.3-70-g09d2


From 6f1fa5e8211518cbb6ebff5cb6849101e36983ab Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Mon, 1 Feb 2021 18:40:01 -0500
Subject: filters changes

---
 .gitignore                            |  3 ++-
 package-lock.json                     |  6 ++---
 package.json                          |  4 ++--
 src/client/util/CurrentUserUtils.ts   |  7 +++---
 src/client/views/EditableView.scss    |  2 ++
 src/client/views/EditableView.tsx     |  1 +
 src/client/views/PropertiesView.tsx   | 19 ++++++++++------
 src/client/views/nodes/FilterBox.scss | 11 +++++-----
 src/client/views/nodes/FilterBox.tsx  | 41 +++++++++++++++++++++++++++++++----
 src/fields/Doc.ts                     |  2 +-
 10 files changed, 70 insertions(+), 26 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/.gitignore b/.gitignore
index 6d4b98289..aeb343fd1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,4 +15,5 @@ src/server/session_manager/logs/**/*.log
 *.crt
 *.key
 *.pfx
-*.properties
\ No newline at end of file
+*.properties
+debug.log
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 42cbc1fd6..ed4f697b6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9062,9 +9062,9 @@
             "integrity": "sha512-vTgEjKjS89C5yHL5qWPpT6BzKuOVqABp+A3Szpbx34pIy3sngxlGaFpgHhfj6fKze1w0QKeOSDbU7SKu7wDvRQ=="
         },
         "mobx": {
-            "version": "5.15.4",
-            "resolved": "https://registry.npmjs.org/mobx/-/mobx-5.15.4.tgz",
-            "integrity": "sha512-xRFJxSU2Im3nrGCdjSuOTFmxVDGeqOHL+TyADCGbT0k4HHqGmx5u2yaHNryvoORpI4DfbzjJ5jPmuv+d7sioFw=="
+            "version": "5.15.7",
+            "resolved": "https://registry.npmjs.org/mobx/-/mobx-5.15.7.tgz",
+            "integrity": "sha512-wyM3FghTkhmC+hQjyPGGFdpehrcX1KOXsDuERhfK2YbJemkUhEB+6wzEN639T21onxlfYBmriA1PFnvxTUhcKw=="
         },
         "mobx-react": {
             "version": "5.4.4",
diff --git a/package.json b/package.json
index 13849c0f3..c7d674cf0 100644
--- a/package.json
+++ b/package.json
@@ -183,8 +183,8 @@
         "lodash": "^4.17.15",
         "material-ui": "^0.20.2",
         "mobile-detect": "^1.4.4",
-        "mobx": "^5.15.3",
-        "mobx-react": "^5.3.5",
+        "mobx": "^5.15.7",
+        "mobx-react": "^5.4.4",
         "mobx-react-devtools": "^6.1.1",
         "mobx-utils": "^5.6.1",
         "mongodb": "^3.5.9",
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index f3fec9ae6..0d31060d4 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -522,7 +522,7 @@ export class CurrentUserUtils {
             { title: "Import", target: Cast(doc.myImportPanel, Doc, null), icon: "upload", click: 'selectMainMenu(self)' },
             { title: "Sharing", target: Cast(doc.mySharedDocs, Doc, null), icon: "users", click: 'selectMainMenu(self)', watchedDocuments: doc.mySharedDocs as Doc },
             { title: "Tools", target: Cast(doc.myTools, Doc, null), icon: "wrench", click: 'selectMainMenu(self)' },
-            { title: "Filter", target: Cast(doc.currentFilter, Doc, null), icon: "filter", click: 'selectMainMenu(self)' },
+            // { title: "Filter", target: Cast(doc.currentFilter, Doc, null), icon: "filter", click: 'selectMainMenu(self)' },
             { title: "Pres. Trails", target: Cast(doc.myPresentations, Doc, null), icon: "pres-trail", click: 'selectMainMenu(self)' },
             { title: "Catalog", target: undefined as any, icon: "file", click: 'selectMainMenu(self)' },
             { title: "Help", target: undefined as any, icon: "question-circle", click: 'selectMainMenu(self)' },
@@ -790,7 +790,7 @@ export class CurrentUserUtils {
         doc.currentFilter === undefined;
         if (doc.currentFilter === undefined) {
             doc.currentFilter = new PrefetchProxy(Docs.Create.FilterDocument({
-                title: "FilterDoc", _height: 500,
+                title: `FilterDoc(${(doc.filterDocCount as number)++})`, _height: 500,
                 treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, forceActive: true, childDropAction: "none",
                 treeViewTruncateTitleWidth: 150, treeViewPreventOpen: false, ignoreClick: true,
                 lockedPosition: true, boxShadow: "0 0", dontRegisterChildViews: true, targetDropAction: "same", system: true
@@ -999,6 +999,8 @@ export class CurrentUserUtils {
         doc["constants-snapThreshold"] = NumCast(doc["constants-snapThreshold"], 10); //
         doc["constants-dragThreshold"] = NumCast(doc["constants-dragThreshold"], 4); //
         Utils.DRAG_THRESHOLD = NumCast(doc["constants-dragThreshold"]);
+        doc.savedFilters = new List<Doc>();
+        doc.filterDocCount = 0;
         this.setupDefaultIconTemplates(doc);  // creates a set of icon templates triggered by the document deoration icon
         this.setupDocTemplates(doc); // sets up the template menu of templates
         this.setupImportSidebar(doc);
@@ -1009,7 +1011,6 @@ export class CurrentUserUtils {
         await this.setupSidebarButtons(doc); // the pop-out left sidebar of tools/panels
         await this.setupMenuPanel(doc, sharingDocumentId, linkDatabaseId);
         if (!doc.globalScriptDatabase) doc.globalScriptDatabase = Docs.Prototypes.MainScriptDocument();
-        // doc.savedFilters = new List<Doc>();
 
         setTimeout(() => this.setupDefaultPresentation(doc), 0); // presentation that's initially triggered
 
diff --git a/src/client/views/EditableView.scss b/src/client/views/EditableView.scss
index 4a89cc69c..5953baec1 100644
--- a/src/client/views/EditableView.scss
+++ b/src/client/views/EditableView.scss
@@ -8,6 +8,8 @@
 }
 
 .editableView-container-editing-oneLine {
+    width: 100%;
+
     span {
         white-space: nowrap;
         overflow: hidden;
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index ed7a8265f..828a2eb78 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -55,6 +55,7 @@ export interface EditableProps {
     color?: string | undefined;
     onDrop?: any;
     placeholder?: string;
+    fullWidth?: boolean; // used in PropertiesView to make the whole key:value input box clickable 
 }
 
 /**
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index c6be7cae1..f0d3f1f3f 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -152,6 +152,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             rows.push(<div className="propertiesView-field" key={"newKeyValue"} style={{ marginTop: "3px" }}>
                 <EditableView
                     key="editableView"
+                    oneLine
                     contents={"add key:value or #tags"}
                     height={13}
                     fontSize={10}
@@ -208,6 +209,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             rows.push(<div className="propertiesView-field" key={"newKeyValue"} style={{ marginTop: "3px" }}>
                 <EditableView
                     key="editableView"
+                    oneLine
                     contents={"add key:value or #tags"}
                     height={13}
                     fontSize={10}
@@ -443,13 +445,15 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         const titles = new Set<string>();
         SelectionManager.Views().forEach(dv => titles.add(StrCast(dv.rootDoc.title)));
         const title = Array.from(titles.keys()).length > 1 ? "--multiple selected--" : StrCast(this.selectedDoc?.title);
-        return <div className="editable-title"><EditableView
-            key="editableView"
-            contents={title}
-            height={25}
-            fontSize={14}
-            GetValue={() => title}
-            SetValue={this.setTitle} /> </div>;
+        return <div className="editable-title">
+            <EditableView
+                key="editableView"
+                contents={title}
+                height={25}
+                fontSize={14}
+                GetValue={() => title}
+                SetValue={this.setTitle} />
+        </div>;
     }
 
     @undoBatch
@@ -1016,6 +1020,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     // }
 
     render() {
+        // console.log(this.props.width);
         if (!this.selectedDoc && !this.isPres) {
             return <div className="propertiesView" style={{ width: this.props.width }}>
                 <div className="propertiesView-title" style={{ width: this.props.width }}>
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index 144f161bc..4b4dfa8a4 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -27,11 +27,11 @@
     }
 }
 
-.filterBox-bottom {
-    // position: fixed;
-    // bottom: 0;
-    // width: 100%;
-}
+// .filterBox-bottom {
+    //     // position: fixed;
+    //     // bottom: 0;
+    //     // width: 100%;
+    // }
 
 
 .filterBox-saveBookmark {
@@ -44,6 +44,7 @@
     margin: 8px;
     display: flex;
     font-size: 11px;
+    cursor: pointer;
 
     &:hover {
         background-color: white;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 63455e3d1..b06bfa8c3 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -33,12 +33,16 @@ const FilterBoxDocument = makeInterface(documentSchema);
 
 @observer
 export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDocument>(FilterBoxDocument) {
+    constructor(props: Readonly<FieldViewProps>) {
+        super(props);
+    }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
     public _filterBoolean = "AND";
     public _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
+    private myFiltersRef = React.createRef<HTMLDivElement>();
 
     @computed get allDocs() {
         const allDocs = new Set<Doc>();
@@ -103,7 +107,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
      * Responds to clicking the check box in the flyout menu
      */
     facetClick = (facetHeader: string) => {
-        const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document;
+        const targetDoc = CollectionDockingView.Instance.props.Document; //SelectionManager.Views()[0].Document; 
         const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader);
         if (found !== -1) {
             (this.dataDoc[this.props.fieldKey] as List<Doc>).splice(found, 1);
@@ -193,6 +197,10 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         console.log(this._filterMatch);
     }
 
+    @computed get yPos() {
+        return this.myFiltersRef.current?.getBoundingClientRect();
+    }
+
 
     @action
     changeSelected = (e: any) => {
@@ -206,6 +214,12 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         console.log(this._filterSelected);
     }
 
+    saveFilter = () => {
+        Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
+        console.log("saved filter");
+        console.log(Doc.UserDoc().savedFilters);
+    }
+
     render() {
         const facetCollection = this.props.Document;
         // const flyout = <div className="filterBox-flyout" style={{ width: `100%` }} onWheel={e => e.stopPropagation()}>
@@ -220,6 +234,16 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
         // const options = this._allFacets.filter(facet => !attributes.some(attribute => attribute.title === facet)).map(facet => ({ value: facet, label: facet }));
         const options = this._allFacets.map(facet => ({ value: facet, label: facet }));
+        // console.log(this.props.Document);
+        // console.log(Doc.UserDoc().currentFilter);
+        console.log(this.yPos);
+        console.log(this.myFiltersRef.current?.getBoundingClientRect());
+
+        const flyout = <>
+            <div className="nothing for now" onWheel={e => e.stopPropagation()}>
+                testing flyout
+            </div>
+        </>;
 
         return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
@@ -320,18 +344,27 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
                 <div style={{ display: "flex" }}>
                     <div className="filterBox-saveWrapper">
-                        <div className="filterBox-saveBookmark">
+                        <div className="filterBox-saveBookmark"
+                            onPointerDown={this.saveFilter}
+                        >
                             <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"save"} size={"sm"} />
                             <div>SAVE</div>
                         </div>
                     </div>
                     <div className="filterBox-saveWrapper">
-                        <div className="filterBox-saveBookmark">
+                        <div className="filterBox-saveBookmark" ref={this.myFiltersRef}>
                             <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"bookmark"} size={"sm"} />
-                            <div>MY FILTERS</div>
+                            <Flyout className="myFilters-flyout" anchorPoint={anchorPoints.TOP} content={flyout}>
+                                <div>MY FILTERS</div>
+                            </Flyout>
                         </div>
                     </div>
                 </div>
+                <div
+                    style={{ width: 200, height: 200, backgroundColor: "black", color: "white" }}
+                >
+                    floot floot
+                </div>
             </div>
         </div>;
     }
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 9aacf5375..493dd2ba4 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1062,7 +1062,7 @@ export namespace Doc {
     // all documents with the specified value for the specified key are included/excluded 
     // based on the modifiers :"check", "x", undefined
     export function setDocFilter(target: Opt<Doc>, key: string, value: any, modifiers?: "remove" | "match" | "check" | "x" | undefined) {
-        console.log("m8");
+        // console.log(key, value, modifiers);
         const container = target ?? CollectionDockingView.Instance.props.Document;
         const docFilters = Cast(container._docFilters, listSpec("string"), []);
         runInAction(() => {
-- 
cgit v1.2.3-70-g09d2


From aede6226aa367ff3137b126e0d0e23e1b2ca84db Mon Sep 17 00:00:00 2001
From: anika <anika.ahluwalia@gmail.com>
Date: Thu, 11 Feb 2021 16:08:38 -0500
Subject: last minor changes before switching branches

---
 src/client/views/PropertiesView.tsx  | 6 +++---
 src/client/views/nodes/FilterBox.tsx | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index c6b94456f..13a594afc 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -68,7 +68,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @observable openContexts: boolean = true;
     @observable openAppearance: boolean = true;
     @observable openTransform: boolean = true;
-    @observable openFilters: boolean = false;
+    @observable openFilters: boolean = true;
 
     // @observable selectedUser: string = "";
     // @observable addButtonPressed: boolean = false;
@@ -1040,8 +1040,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
                     {this.sharingSubMenu}
 
-                    {this.filtersSubMenu}
-
                     {this.inkSubMenu}
 
                     {this.fieldsSubMenu}
@@ -1049,6 +1047,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                     {this.contextsSubMenu}
 
                     {this.layoutSubMenu}
+
+                    {this.filtersSubMenu}
                 </div>;
             }
             if (this.isPres) {
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 6b1cd793e..a1b55f490 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -250,8 +250,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 if (doc) {
                     return doc._viewType === CollectionViewType.Docking || (Doc.IsSystem(doc)) ? (null) :
                         <>
-                            <div>
-                                <select className="filterBox-treeView-selection">
+                            <div style={{ marginRight: "5px", fontSize: "10px" }}>
+                                <select className="filterBox-selection">
                                     <option value="Is" key="Is">Is</option>
                                     <option value="Is Not" key="Is Not">Is Not</option>
                                 </select>
-- 
cgit v1.2.3-70-g09d2


From 0381050cab3cbcf6f1c3552fa86cace3a1654a07 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Mon, 22 Feb 2021 21:25:25 -0500
Subject: filters scope changes

---
 src/client/views/PropertiesView.scss  |  62 ++++++++++++
 src/client/views/PropertiesView.tsx   | 107 +++++++++++++-------
 src/client/views/nodes/FilterBox.scss |  34 +++----
 src/client/views/nodes/FilterBox.tsx  | 182 +++++++++++++++++-----------------
 src/fields/Doc.ts                     |   6 +-
 5 files changed, 240 insertions(+), 151 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.scss b/src/client/views/PropertiesView.scss
index 1365725cb..134c50972 100644
--- a/src/client/views/PropertiesView.scss
+++ b/src/client/views/PropertiesView.scss
@@ -157,6 +157,67 @@
         }
     }
 
+    .propertiesView-filters {
+        //border-bottom: 1px solid black;
+        //padding: 8.5px;
+
+        .propertiesView-filters-title {
+            font-weight: bold;
+            font-size: 12.5px;
+            padding: 4px;
+            display: flex;
+            color: white;
+            padding-left: 8px;
+            background-color: rgb(51, 51, 51);
+
+            &:hover {
+                cursor: pointer;
+            }
+
+            .propertiesView-filters-title-icon {
+                float: right;
+                justify-items: right;
+                align-items: flex-end;
+                margin-left: auto;
+                margin-right: 9px;
+
+                &:hover {
+                    cursor: pointer;
+                }
+            }
+        }
+
+        .propertiesView-filters-content {
+            font-size: 10px;
+            padding: 10px;
+            margin-left: 5px;
+            max-height: 40%;
+            overflow-y: auto;
+
+            .propertiesView-buttonContainer {
+                float: right;
+                display: flex;
+
+                button {
+                    width: 15;
+                    height: 15;
+                    padding: 0;
+                    margin-top: -5;
+                }
+            }
+
+            button {
+                width: 5;
+                height: 5;
+            }
+
+            input {
+                width: 100%;
+            }
+        }
+    }
+
+
     .propertiesView-appearance {
         //border-bottom: 1px solid black;
         //padding: 8.5px;
@@ -332,6 +393,7 @@
             }
         }
     }
+
     .propertiesView-fields {
         //border-bottom: 1px solid black;
         //padding: 8.5px;
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index ae6c7c50c..388b688cd 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -2,10 +2,10 @@ import React = require("react");
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { Checkbox, Tooltip } from "@material-ui/core";
 import { intersection } from "lodash";
-import { action, computed, observable } from "mobx";
+import { action, autorun, computed, Lambda, observable, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
 import { ColorState, SketchPicker } from "react-color";
-import { AclAddonly, AclAdmin, AclEdit, AclPrivate, AclReadonly, AclSym, AclUnset, DataSym, Doc, Field, HeightSym, WidthSym } from "../../fields/Doc";
+import { AclAddonly, AclAdmin, AclEdit, AclPrivate, AclReadonly, AclSym, AclUnset, DataSym, Doc, Field, HeightSym, Opt, WidthSym } from "../../fields/Doc";
 import { Id } from "../../fields/FieldSymbols";
 import { InkField } from "../../fields/InkField";
 import { ComputedField } from "../../fields/ScriptField";
@@ -29,6 +29,7 @@ import { PropertiesButtons } from "./PropertiesButtons";
 import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector";
 import "./PropertiesView.scss";
 import { DefaultStyleProvider, FilteringStyleProvider } from "./StyleProvider";
+import { CurrentUserUtils } from "../util/CurrentUserUtils";
 import { FilterBox } from "./nodes/FilterBox";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
@@ -48,6 +49,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @computed get MAX_EMBED_HEIGHT() { return 200; }
 
     @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
+    @computed get filterDoc() {
+        return FilterBox._filterScope === "Current Collection" ? this.selectedDoc || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+    }
     @computed get selectedDocumentView() {
         if (SelectionManager.Views().length) return SelectionManager.Views()[0];
         if (PresBox.Instance?._selectedArray.size) return DocumentManager.Instance.getDocumentView(PresBox.Instance.rootDoc);
@@ -68,7 +72,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @observable openContexts: boolean = true;
     @observable openAppearance: boolean = true;
     @observable openTransform: boolean = true;
-    @observable openFilters: boolean = true;
+    @observable openFilters: boolean = true; // should be false
+
+    private selectedDocListenerDisposer: Opt<Lambda>;
 
     // @observable selectedUser: string = "";
     // @observable addButtonPressed: boolean = false;
@@ -84,6 +90,15 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @observable _controlBtn: boolean = false;
     @observable _lock: boolean = false;
 
+    componentDidMount() {
+        this.selectedDocListenerDisposer?.();
+        this.selectedDocListenerDisposer = autorun(() => this.openFilters && this.selectedDoc && this.checkFilterDoc());
+    }
+
+    componentWillUnmount() {
+        this.selectedDocListenerDisposer?.();
+    }
+
     @computed get isInk() { return this.selectedDoc?.type === DocumentType.INK; }
 
     rtfWidth = () => {
@@ -885,44 +900,63 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         </div>;
     }
 
+    checkFilterDoc() {
+        if (this.filterDoc.type === DocumentType.COL && !this.filterDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.filterDoc!);
+    }
+
+    saveFilter = () => {
+        this.filterDoc.currentFilter = undefined;
+        CurrentUserUtils.setupFilterDocs(this.filterDoc);
+    }
+
+    myFiltersSelect = (doc: Doc) => {
+        this.filterDoc.currentFilter = doc;
+    }
+
     @computed get filtersSubMenu() {
-        return <div className="propertiesView-sharing">
-            <div className="propertiesView-sharing-title"
+        return <div className="propertiesView-filters">
+            <div className="propertiesView-filters-title"
                 onPointerDown={action(() => this.openFilters = !this.openFilters)}
                 style={{ backgroundColor: this.openFilters ? "black" : "" }}>
                 Filters
-                        <div className="propertiesView-sharing-title-icon">
+                        <div className="propertiesView-filters-title-icon">
                     <FontAwesomeIcon icon={this.openFilters ? "caret-down" : "caret-right"} size="lg" color="white" />
                 </div>
             </div>
-            {!this.openFilters ? (null) :
-                <div className="propertiesView-sharing-content">
-                    <DocumentView
-                        Document={Doc.UserDoc().currentFilter as any as Doc}
-                        DataDoc={undefined}
-                        addDocument={undefined}
-                        addDocTab={returnFalse}
-                        pinToPres={emptyFunction}
-                        rootSelected={returnTrue}
-                        removeDocument={returnFalse}
-                        ScreenToLocalTransform={this.getTransform}
-                        PanelWidth={this.docWidth}
-                        PanelHeight={this.docHeight}
-                        renderDepth={0}
-                        scriptContext={CollectionDockingView.Instance.props.Document}
-                        focus={emptyFunction}
-                        styleProvider={DefaultStyleProvider}
-                        parentActive={returnTrue}
-                        whenActiveChanged={emptyFunction}
-                        bringToFront={emptyFunction}
-                        docFilters={returnEmptyFilter}
-                        docRangeFilters={returnEmptyFilter}
-                        searchFilterDocs={returnEmptyDoclist}
-                        ContainingCollectionView={undefined}
-                        ContainingCollectionDoc={undefined}
-                    />
-                </div>}
-        </div>;
+            {
+                !this.openFilters || !this.filterDoc.currentFilter ? (null) :
+                    <div className="propertiesView-filters-content">
+                        <DocumentView
+                            Document={this.filterDoc.currentFilter as Doc}
+                            DataDoc={undefined}
+                            addDocument={undefined}
+                            addDocTab={returnFalse}
+                            pinToPres={emptyFunction}
+                            rootSelected={returnTrue}
+                            removeDocument={returnFalse}
+                            ScreenToLocalTransform={this.getTransform}
+                            PanelWidth={this.docWidth}
+                            PanelHeight={this.docHeight}
+                            renderDepth={0}
+                            scriptContext={this.filterDoc.currentFilter as Doc}
+                            focus={emptyFunction}
+                            styleProvider={DefaultStyleProvider}
+                            parentActive={returnTrue}
+                            whenActiveChanged={emptyFunction}
+                            bringToFront={emptyFunction}
+                            docFilters={returnEmptyFilter}
+                            docRangeFilters={returnEmptyFilter}
+                            searchFilterDocs={returnEmptyDoclist}
+                            ContainingCollectionView={undefined}
+                            ContainingCollectionDoc={undefined}
+                            filterSaveCallback={this.saveFilter}
+                            myFiltersCallback={this.myFiltersSelect}
+                            docViewPath={returnEmptyDoclist}
+                            layerProvider={undefined}
+                        />
+                    </div>
+            }
+        </div >;
     }
 
     @computed get inkSubMenu() {
@@ -1022,7 +1056,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     // }
 
     render() {
-        // console.log(this.props.width);
         if (!this.selectedDoc && !this.isPres) {
             return <div className="propertiesView" style={{ width: this.props.width }}>
                 <div className="propertiesView-title" style={{ width: this.props.width }}>
@@ -1047,6 +1080,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
                     {this.sharingSubMenu}
 
+                    {this.selectedDoc.type === DocumentType.COL && this.filtersSubMenu}
+
                     {this.inkSubMenu}
 
                     {this.fieldsSubMenu}
@@ -1054,8 +1089,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                     {this.contextsSubMenu}
 
                     {this.layoutSubMenu}
-
-                    {this.filtersSubMenu}
                 </div>;
             }
             if (this.isPres) {
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index b1b3c0f25..4fe1fa2eb 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -28,15 +28,15 @@
 }
 
 // .filterBox-bottom {
-    //     // position: fixed;
-    //     // bottom: 0;
-    //     // width: 100%;
-    // }
+//     // position: fixed;
+//     // bottom: 0;
+//     // width: 100%;
+// }
 
 .filterBox-select {
-    width: 90%;
+    // width: 90%;
     margin-top: 5px;
-    margin-bottom: 15px;
+    // margin-bottom: 15px;
 }
 
 
@@ -64,20 +64,6 @@
 
 }
 
-.filterBox-title {
-
-    justify-content: center;
-    text-align: center;
-    padding-bottom: 13px;
-    font-size: 20px;
-    font-weight: bold;
-
-    .filterBox-span {
-        margin-right: 15px;
-    }
-
-}
-
 .filterBox-select-scope,
 .filterBox-select-bool,
 .filterBox-addWrapper,
@@ -112,6 +98,14 @@
     border-bottom: 2px solid black;
 }
 
+.filterBox-title {
+    font-size: 15;
+    // border: 2px solid black;
+    width: 100%;
+    align-self: center;
+    text-align: center;
+    background-color: #d3d3d3;
+}
 
 .filterBox-select-bool {
     margin-top: 6px;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index ec77775be..987939d65 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 { action, computed } from "mobx";
+import { action, computed, observable, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { DataSym, Doc, DocListCast, Field, Opt } from "../../../fields/Doc";
+import { DataSym, Doc, DocListCast, DocListCastAsync, Field, Opt } from "../../../fields/Doc";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { List } from "../../../fields/List";
 import { RichTextField } from "../../../fields/RichTextField";
@@ -30,22 +30,30 @@ import { UserOptions } from "../../util/GroupManager";
 import { DocumentViewProps } from "./DocumentView";
 import { DefaultStyleProvider, StyleProp } from "../StyleProvider";
 import { CollectionViewType } from "../collections/CollectionView";
+import { CurrentUserUtils } from "../../util/CurrentUserUtils";
 
 type FilterBoxDocument = makeInterface<[typeof documentSchema]>;
 const FilterBoxDocument = makeInterface(documentSchema);
 
 @observer
 export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDocument>(FilterBoxDocument) {
+
+    static Instance: FilterBox;
+
     constructor(props: Readonly<FieldViewProps>) {
         super(props);
+        FilterBox.Instance = this;
+        if (!CollectionDockingView.Instance.props.Document.currentFilter) CurrentUserUtils.setupFilterDocs(CollectionDockingView.Instance.props.Document);
     }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
     public _filterBoolean = "AND";
-    public _filterScope = "Current Dashboard";
+    public static _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
-    private myFiltersRef = React.createRef<HTMLDivElement>();
+    // private myFiltersRef = React.createRef<HTMLDivElement>();
+
+    @observable private showFilterDialog = false;
 
     @computed get allDocs() {
         const allDocs = new Set<Doc>();
@@ -112,10 +120,12 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         return { strings: Array.from(valueSet.keys()), rtFields };
     }
 
-    public static removeFilter = (filterName: string) => {
+    public removeFilter = (filterName: string) => {
         console.log("remove filter");
-        const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document;
-        const filterDoc = Doc.UserDoc().currentFilter as any as Doc;
+        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        // const targetDoc = SelectionManager.Views()[0].props.Document;
+        // const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document;
+        const filterDoc = targetDoc.currentFilter as Doc;
         const attributes = DocListCast(filterDoc["data"]);
         const found = attributes.findIndex(doc => doc.title === filterName);
         if (found !== -1) {
@@ -145,7 +155,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         console.log("facetClick: " + facetHeader);
         console.log(this.props.fieldKey);
 
-        const targetDoc = SelectionManager.Views()[0].Document; // CollectionDockingView.Instance.props.Document;
+        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        // const targetDoc = SelectionManager.Views()[0].props.Document;
         const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader);
         if (found !== -1) {
             // (this.dataDoc[this.props.fieldKey] as List<Doc>).splice(found, 1);
@@ -164,7 +175,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
             //     }
             // }
         } else {
-            const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data);
+            // const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data);
             const facetValues = this.gatherFieldValues(targetDoc, facetHeader);
 
             let nonNumbers = 0;
@@ -179,7 +190,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 }
             });
             let newFacet: Opt<Doc>;
-            if (facetHeader === "text" || facetValues.rtFields / allCollectionDocs.length > 0.1) {
+            if (facetHeader === "text") {//} || facetValues.rtFields / allCollectionDocs.length > 0.1) {
                 newFacet = Docs.Create.TextDocument("", { _width: 100, _height: 25, system: true, _stayInCollection: true, _hideContextMenu: true, treeViewExpandedView: "layout", title: facetHeader, treeViewOpen: true, forceActive: true, ignoreClick: true });
                 Doc.GetProto(newFacet).type = DocumentType.COL; // forces item to show an open/close button instead ofa checkbox
                 newFacet._textBoxPadding = 4;
@@ -225,8 +236,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
     @action
     changeScope = (e: any) => {
-        this._filterScope = e.currentTarget.value;
-        console.log(this._filterScope);
+        FilterBox._filterScope = e.currentTarget.value;
+        console.log(FilterBox._filterScope);
     }
 
     @action
@@ -234,14 +245,9 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         this._filterMatch = e.currentTarget.value;
         console.log(this._filterMatch);
     }
-
-    @computed get yPos() {
-        return this.myFiltersRef.current?.getBoundingClientRect();
-    }
-
-
+    // CHANGE SO DOCKINGVIEW HAS ITS OWN FILTERDOC
     @action
-    changeSelected = (e: any) => {
+    changeSelected = () => {
         if (this._filterSelected) {
             this._filterSelected = false;
             SelectionManager.DeselectAll();
@@ -252,12 +258,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         console.log(this._filterSelected);
     }
 
-    saveFilter = () => {
-        Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
-        console.log("saved filter");
-        console.log(Doc.UserDoc().savedFilters);
-    }
-
     FilteringStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps | DocumentViewProps>, property: string) {
         switch (property.split(":")[0]) {
             case StyleProp.Decorations:
@@ -270,7 +270,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                                     <option value="Is Not" key="Is Not">Is Not</option>
                                 </select>
                             </div>
-                            <div className="filterBox-treeView-close" onClick={e => FilterBox.removeFilter(StrCast(doc.title))}>
+                            <div className="filterBox-treeView-close" onClick={e => this.removeFilter(StrCast(doc.title))}>
                                 <FontAwesomeIcon icon={"times"} size="sm" />
                             </div>
                         </>;
@@ -280,45 +280,47 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         }
     }
 
-
     suppressChildClick = () => ScriptField.MakeScript("")!;
+
+    saveFilter = () => {
+        // const doc: Doc = new Doc;
+        // for (const key of Object.keys(this.props.Document)) {
+        //     doc[key] = SerializationHelper.Serialize(this.props.Document[key] as Field);
+        // }
+        // console.log(doc);
+        runInAction(() => this.showFilterDialog = true);
+        console.log("saved filter");
+    }
+
+    onTitleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
+        this.props.Document.title = e.currentTarget.value || `FilterDoc for ${SelectionManager.Views()[0].Document.title}`;
+    }
+
+    onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
+        if (e.key === "Enter") {
+            runInAction(() => this.showFilterDialog = false);
+            Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
+        }
+    }
+
     render() {
         const facetCollection = this.props.Document;
-        // const flyout = <div className="filterBox-flyout" style={{ width: `100%` }} onWheel={e => e.stopPropagation()}>
-        //     {this._allFacets.map(facet => <label className="filterBox-flyout-facet" key={`${facet}`} onClick={e => this.facetClick(facet)}>
-        //         <input className="filterBox-flyout-facet-check" type="checkbox" onChange={e => { }} checked={DocListCast(this.props.Document[this.props.fieldKey]).some(d => d.title === facet)} />
-        //         <span className="checkmark" />
-        //         {facet}
-        //     </label>)}
-        // </div>;
-
-        // const attributes = this.activeAttributes;
-
-        // const options = this._allFacets.filter(facet => !attributes.some(attribute => attribute.title === facet)).map(facet => ({ value: facet, label: facet }));
-        // const options = this._allFacets.map(facet => ({ value: facet, label: facet }));
-        // console.log(this.props.Document);
-        // console.log(Doc.UserDoc().currentFilter);
-        console.log(this.yPos);
-        console.log(this.myFiltersRef.current?.getBoundingClientRect());
-
-        const flyout = <>
-            <div className="nothing for now" onWheel={e => e.stopPropagation()}>
-                testing flyout
-            </div>
-        </>;
-        const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
 
-        return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
+        const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
+            // console.log("mapping");
+            return <>
+                <div className="???" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.myFiltersCallback?.(doc)}>
+                    {StrCast(doc.title)}
+                </div>
+            </>;
+        }
+        );
 
-            {/* <div className="filterBox-top"> */}
-            {/* <div className="filter-bookmark">
-                <FontAwesomeIcon className="filter-bookmark-icon" icon={"bookmark"} size={"lg"} />
-            </div>
+        const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
 
-            <div className="filterBox-title">
-                <span className="filterBox-span">Choose Filters</span>
-            </div> */}
+        return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
+            <div className="filterBox-title">Current FilterDoc: {this.props.Document.title}</div>
             <div className="filterBox-select-bool">
                 <select className="filterBox-selection" onChange={e => this.changeBool(e)}>
                     <option value="AND" key="AND">AND</option>
@@ -326,21 +328,22 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 </select>
                 <div className="filterBox-select-text">filters in </div>
                 <select className="filterBox-selection" onChange={e => this.changeScope(e)}>
-                    <option value="Current Dashboard" key="Current Dashboard">Current Dashboard</option>
-                    <option value="Current Tab" key="Current Tab">Current Tab</option>
-                    <option value="Current Collection" key="Current Collection">Current Collection</option>
+                    <option value="Current Dashboard" key="Current Dashboard" selected={"Current Dashboard" === FilterBox._filterScope}>Current Dashboard</option>
+                    {/* <option value="Current Tab" key="Current Tab">Current Tab</option> */}
+                    <option value="Current Collection" key="Current Collection" selected={"Current Collection" === FilterBox._filterScope}>Current Collection</option>
                 </select>
             </div>
 
-            {/* <div className="filterBox-select-scope">
-                <div className="filterBox-select-text">Scope: </div>
-                <select className="filterBox-selection" onChange={e => this.changeScope(e)}>
-                    <option value="Current Dashboard" key="Current Dashboard">Current Dashboard</option>
-                    <option value="Current Tab" key="Current Tab">Current Tab</option>
-                    <option value="Current Collection" key="Current Collection">Current Collection</option>
-                </select>
-            </div> */}
-            {/* </div> */}
+            <div className="filterBox-select">
+                <Select
+                    placeholder="Add a filter..."
+                    options={options}
+                    isMulti={false}
+                    onChange={val => this.facetClick((val as UserOptions).value)}
+                    value={null}
+                    closeMenuOnSelect={false}
+                />
+            </div>
 
             <div className="filterBox-tree" key="tree">
                 <CollectionTreeView
@@ -387,21 +390,10 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     <div className="filterBox-addFilter"> + add a filter</div>
                 </div>
             </Flyout> */}
-            <div className="filterBox-select">
-                <Select
-                    placeholder="Add a filter..."
-                    options={options}
-                    isMulti={false}
-                    onChange={val => this.facetClick((val as UserOptions).value)}
-                    value={null}
-                    closeMenuOnSelect={false}
-                />
-            </div>
-
             <div className="filterBox-bottom">
                 <div className="filterBox-select-matched">
                     <input className="filterBox-select-box" type="checkbox"
-                        onChange={e => this.changeSelected(e)} />
+                        onChange={this.changeSelected} />
                     <div className="filterBox-select-text">select</div>
                     <select className="filterBox-selection" onChange={e => this.changeMatch(e)}>
                         <option value="matched" key="matched">matched</option>
@@ -415,24 +407,32 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                         <div className="filterBox-saveBookmark"
                             onPointerDown={this.saveFilter}
                         >
-                            <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"save"} size={"sm"} />
                             <div>SAVE</div>
                         </div>
                     </div>
                     <div className="filterBox-saveWrapper">
-                        <div className="filterBox-saveBookmark" ref={this.myFiltersRef}>
-                            <FontAwesomeIcon className="filterBox-saveBookmark-icon" icon={"bookmark"} size={"sm"} />
+                        <div className="filterBox-saveBookmark">
                             <Flyout className="myFilters-flyout" anchorPoint={anchorPoints.TOP} content={flyout}>
-                                <div>MY FILTERS</div>
+                                <div>FILTERS</div>
                             </Flyout>
                         </div>
                     </div>
+                    <div className="filterBox-saveWrapper">
+                        <div className="filterBox-saveBookmark"
+                            onPointerDown={this.props.filterSaveCallback}
+                        >
+                            <div>NEW</div>
+                        </div>
+                    </div>
                 </div>
-                <div
-                    style={{ width: 200, height: 200, backgroundColor: "black", color: "white" }}
-                >
-                    floot floot
-                </div>
+                {!this.showFilterDialog ? (null) :
+                    <input
+                        className="filterBox-dialog-input"
+                        placeholder="Enter name of filterDoc"
+                        onChange={this.onTitleValueChange}
+                        onKeyDown={this.onKeyDown}
+                    />
+                }
             </div>
         </div>;
     }
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 5e9ab4baa..9b539d1b7 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -25,6 +25,7 @@ import { Cast, FieldValue, NumCast, StrCast, ToConstructor } from "./Types";
 import { AudioField, ImageField, PdfField, VideoField, WebField } from "./URLField";
 import { deleteProperty, GetEffectiveAcl, getField, getter, makeEditable, makeReadOnly, normalizeEmail, setter, SharingPermissions, updateFunction } from "./util";
 import JSZip = require("jszip");
+import { FilterBox } from "../client/views/nodes/FilterBox";
 
 export namespace Field {
     export function toKeyValueString(doc: Doc, key: string): string {
@@ -1063,9 +1064,8 @@ export namespace Doc {
     // all documents with the specified value for the specified key are included/excluded 
     // based on the modifiers :"check", "x", undefined
     export function setDocFilter(target: Opt<Doc>, key: string, value: any, modifiers?: "remove" | "match" | "check" | "x" | undefined) {
-        // console.log(key, value, modifiers);
-        const container = target ?? CollectionDockingView.Instance.props.Document;
-        const docFilters = Cast(container._docFilters, listSpec("string"), []);
+        const container = target ?? FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        const docFilters = Cast(SelectionManager.Views()[0].Document._docFilters, listSpec("string"), []);
         runInAction(() => {
             for (let i = 0; i < docFilters.length; i++) {
                 const fields = docFilters[i].split(":"); // split key:value:modifier
-- 
cgit v1.2.3-70-g09d2


From 02bceed486ecb03b94c757ae669f69912f282cdd Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Tue, 23 Feb 2021 10:34:47 -0500
Subject: current collection vs dashboard works a bit better - they have
 different filterdocs now

---
 src/client/views/PropertiesView.tsx     | 20 +++++++++++++++-----
 src/client/views/nodes/DocumentView.tsx |  4 ++--
 src/client/views/nodes/FilterBox.tsx    |  6 +++---
 src/fields/Doc.ts                       |  2 +-
 4 files changed, 21 insertions(+), 11 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 388b688cd..a159a9948 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -31,6 +31,7 @@ import "./PropertiesView.scss";
 import { DefaultStyleProvider, FilteringStyleProvider } from "./StyleProvider";
 import { CurrentUserUtils } from "../util/CurrentUserUtils";
 import { FilterBox } from "./nodes/FilterBox";
+import { List } from "../../fields/List";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -901,16 +902,25 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     }
 
     checkFilterDoc() {
-        if (this.filterDoc.type === DocumentType.COL && !this.filterDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.filterDoc!);
+        if (this.filterDoc.type === DocumentType.COL && !this.filterDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.filterDoc);
     }
 
-    saveFilter = () => {
+    createNewFilterDoc = () => {
+        const temp = this.filterDoc._docFilters;
+        this.filterDoc._docFilters = new List<string>();
+        (this.filterDoc.currentFilter as Doc)._docFiltersList = temp;
         this.filterDoc.currentFilter = undefined;
         CurrentUserUtils.setupFilterDocs(this.filterDoc);
     }
 
-    myFiltersSelect = (doc: Doc) => {
+    updateFilterDoc = (doc: Doc) => {
+        const temp = doc._docFiltersList;
+        const otherTemp = this.filterDoc._docFilters;
+        this.filterDoc._docFilters = new List<string>();
+        (this.filterDoc.currentFilter as Doc)._docFiltersList = otherTemp;
         this.filterDoc.currentFilter = doc;
+        doc._docFiltersList = new List<string>();
+        this.filterDoc._docFilters = temp;
     }
 
     @computed get filtersSubMenu() {
@@ -949,8 +959,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             searchFilterDocs={returnEmptyDoclist}
                             ContainingCollectionView={undefined}
                             ContainingCollectionDoc={undefined}
-                            filterSaveCallback={this.saveFilter}
-                            myFiltersCallback={this.myFiltersSelect}
+                            createNewFilterDoc={this.createNewFilterDoc}
+                            updateFilterDoc={this.updateFilterDoc}
                             docViewPath={returnEmptyDoclist}
                             layerProvider={undefined}
                         />
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index f99eb1b3b..ee4df97ed 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -120,8 +120,8 @@ export interface DocumentViewSharedProps {
     cantBrush?: boolean; // whether the document doesn't show brush highlighting
     pointerEvents?: string;
     scriptContext?: any; // can be assigned anything and will be passed as 'scriptContext' to any OnClick script that executes on this document
-    filterSaveCallback?: () => void;
-    myFiltersCallback?: (doc: Doc) => void;
+    createNewFilterDoc?: () => void;
+    updateFilterDoc?: (doc: Doc) => void;
 }
 export interface DocumentViewProps extends DocumentViewSharedProps {
     // properties specific to DocumentViews but not to FieldView
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 987939d65..a3a3ec662 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -48,7 +48,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
     public _filterBoolean = "AND";
-    public static _filterScope = "Current Dashboard";
+    @observable public static _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
     // private myFiltersRef = React.createRef<HTMLDivElement>();
@@ -309,7 +309,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
             // console.log("mapping");
             return <>
-                <div className="???" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.myFiltersCallback?.(doc)}>
+                <div className="???" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
                     {StrCast(doc.title)}
                 </div>
             </>;
@@ -419,7 +419,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     </div>
                     <div className="filterBox-saveWrapper">
                         <div className="filterBox-saveBookmark"
-                            onPointerDown={this.props.filterSaveCallback}
+                            onPointerDown={this.props.createNewFilterDoc}
                         >
                             <div>NEW</div>
                         </div>
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 9b539d1b7..4cc0925a9 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1065,7 +1065,7 @@ export namespace Doc {
     // based on the modifiers :"check", "x", undefined
     export function setDocFilter(target: Opt<Doc>, key: string, value: any, modifiers?: "remove" | "match" | "check" | "x" | undefined) {
         const container = target ?? FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
-        const docFilters = Cast(SelectionManager.Views()[0].Document._docFilters, listSpec("string"), []);
+        const docFilters = Cast(container._docFilters, listSpec("string"), []);
         runInAction(() => {
             for (let i = 0; i < docFilters.length; i++) {
                 const fields = docFilters[i].split(":"); // split key:value:modifier
-- 
cgit v1.2.3-70-g09d2


From 1c6a3568005bb25541d45db4b53f1955ff3b0e39 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Thu, 11 Mar 2021 16:22:09 -0500
Subject: adding and/or to filtering, added editableview, changed a bunch of
 things

---
 debug.log                                          |   3 -
 src/client/documents/Documents.ts                  |  29 +++-
 src/client/views/PropertiesView.tsx                |   1 +
 src/client/views/collections/CollectionSubView.tsx |   2 +-
 src/client/views/nodes/FilterBox.tsx               | 176 ++++++++++-----------
 src/fields/Doc.ts                                  |  10 +-
 6 files changed, 114 insertions(+), 107 deletions(-)
 delete mode 100644 debug.log

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/debug.log b/debug.log
deleted file mode 100644
index ff92d4544..000000000
--- a/debug.log
+++ /dev/null
@@ -1,3 +0,0 @@
-[0122/125519.017:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
-[0122/192130.891:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
-[0123/134808.113:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 1726c42d3..5ceb62cbe 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -987,6 +987,13 @@ export namespace DocUtils {
         }
         return false;
     }
+    /**
+     * @param docs 
+     * @param docFilters 
+     * @param docRangeFilters 
+     * @param viewSpecScript 
+     * Given a list of docs and docFilters, @returns the list of Docs that match those filters 
+     */
     export function FilterDocs(docs: Doc[], docFilters: string[], docRangeFilters: string[], viewSpecScript?: ScriptField) {
         const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
         if (!docFilters?.length && !docRangeFilters?.length) {
@@ -1011,14 +1018,19 @@ export namespace DocUtils {
             if (d.cookies && (!filterFacets.cookies || !Object.keys(filterFacets.cookies).some(key => d.cookies === key))) {
                 return false;
             }
+
+            console.log(FilterBox._filterBoolean);
             for (const facetKey of Object.keys(filterFacets).filter(fkey => fkey !== "cookies")) {
                 const facet = filterFacets[facetKey];
+                console.log(facet)
                 const matches = Object.keys(facet).filter(value => value !== "cookies" && facet[value] === "match");
                 const checks = Object.keys(facet).filter(value => facet[value] === "check");
                 const xs = Object.keys(facet).filter(value => facet[value] === "x");
+
+                if (!xs.length && !checks.length && !matches.length) return true;
                 const failsNotEqualFacets = !xs.length ? false : xs.some(value => Doc.matchFieldValue(d, facetKey, value));
                 const satisfiesCheckFacets = !checks.length ? true : checks.some(value => Doc.matchFieldValue(d, facetKey, value));
-                const satisfiesMatchFacets = !matches.length ? true : matches.some(value => {
+                const satisfiesMatchFacets = matches.some(value => {
                     if (facetKey.startsWith("*")) { //  fields starting with a '*' are used to match families of related fields.  ie, *lastModified will match text-lastModified, data-lastModified, etc
                         const allKeys = Array.from(Object.keys(d));
                         allKeys.push(...Object.keys(Doc.GetProto(d)));
@@ -1027,11 +1039,20 @@ export namespace DocUtils {
                     }
                     return Field.toString(d[facetKey] as Field).includes(value);
                 });
-                if (!satisfiesCheckFacets || !satisfiesMatchFacets || failsNotEqualFacets) {
-                    return false;
+                console.log(satisfiesCheckFacets, failsNotEqualFacets);
+                if (FilterBox._filterBoolean === "OR") {
+                    if (satisfiesCheckFacets && !failsNotEqualFacets) {
+                        return true;
+                    }
                 }
+                else {
+                    if (!satisfiesCheckFacets || failsNotEqualFacets) {
+                        return false;
+                    }
+                }
+
             }
-            return true;
+            return FilterBox._filterBoolean === "OR" ? false : true;
         }) : childDocs;
         const rangeFilteredDocs = filteredDocs.filter(d => {
             for (let i = 0; i < docRangeFilters.length; i += 3) {
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 4b6f1c912..499d8ff0c 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -913,6 +913,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     }
 
     updateFilterDoc = (doc: Doc) => {
+        if (doc === this.filterDoc.currentFilter) return; // causes problems if you try to reapply the same doc
         const temp = doc._docFiltersList;
         const otherTemp = this.filterDoc._docFilters;
         this.filterDoc._docFilters = new List<string>();
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 59e1824c1..8b7782948 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -118,7 +118,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
 
             const docsforFilter: Doc[] = [];
             childDocs.forEach((d) => {
-                if (DocUtils.Excluded(d, docFilters)) return;
+                // if (DocUtils.Excluded(d, docFilters)) return;
                 let notFiltered = d.z || ((!searchDocs.length || searchDocs.includes(d)) && (DocUtils.FilterDocs([d], docFilters, docRangeFilters, viewSpecScript).length > 0));
                 const fieldKey = Doc.LayoutFieldKey(d);
                 const annos = !Field.toString(Doc.LayoutField(d) as Field).includes("CollectionView");
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 569f0d23b..88bb91b38 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -9,7 +9,7 @@ import { RichTextField } from "../../../fields/RichTextField";
 import { listSpec, makeInterface } from "../../../fields/Schema";
 import { ComputedField, ScriptField } from "../../../fields/ScriptField";
 import { Cast, StrCast } from "../../../fields/Types";
-import { emptyFunction, emptyPath, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnOne, returnZero, returnTrue } from "../../../Utils";
+import { emptyFunction, returnEmptyDoclist, returnEmptyFilter, returnFalse, returnTrue } from "../../../Utils";
 import { Docs } from "../../documents/Documents";
 import { DocumentType } from "../../documents/DocumentTypes";
 import { CollectionDockingView } from "../collections/CollectionDockingView";
@@ -29,6 +29,7 @@ import { DocumentViewProps } from "./DocumentView";
 import { DefaultStyleProvider, StyleProp } from "../StyleProvider";
 import { CollectionViewType } from "../collections/CollectionView";
 import { CurrentUserUtils } from "../../util/CurrentUserUtils";
+import { EditableView } from "../EditableView";
 
 type FilterBoxDocument = makeInterface<[typeof documentSchema]>;
 const FilterBoxDocument = makeInterface(documentSchema);
@@ -36,23 +37,21 @@ const FilterBoxDocument = makeInterface(documentSchema);
 @observer
 export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDocument>(FilterBoxDocument) {
 
-    static Instance: FilterBox;
-
     constructor(props: Readonly<FieldViewProps>) {
         super(props);
-        FilterBox.Instance = this;
-        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        const targetDoc = this.targetDoc;
         if (!targetDoc) CurrentUserUtils.setupFilterDocs(targetDoc);
     }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
-    public _filterBoolean = "AND";
-    @observable public static _filterScope = "Current Dashboard";
+    @observable static _filterBoolean = "AND";
+    @observable static _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
 
-    @observable private showFilterDialog = false;
-
+    /**
+     * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
+     */
     @computed get targetDoc() {
         return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
     }
@@ -69,8 +68,9 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     @computed get allDocs() {
         trace();
         const allDocs = new Set<Doc>();
-        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        const targetDoc = this.targetDoc;
         if (this._loaded && targetDoc) {
+            // if (targetDoc) {
             const activeTabs = DocListCast(targetDoc.data);
             SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
             setTimeout(() => targetDoc.allDocuments = new List<Doc>(Array.from(allDocs)));
@@ -97,6 +97,9 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         return DocListCast(this.dataDoc[this.props.fieldKey]);
     }
 
+    /**
+     * @returns a string array of the current attributes
+     */
     @computed get currentFacets() {
         return this.activeAttributes.map(attribute => StrCast(attribute.title));
     }
@@ -121,7 +124,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                         subDocs.forEach((t) => {
                             const facetVal = t[facetKey];
                             if (facetVal instanceof RichTextField) rtFields++;
-                            facetVal && valueSet.add(Field.toString(facetVal as Field));
+                            facetVal !== undefined && valueSet.add(Field.toString(facetVal as Field));
                             const fieldKey = Doc.LayoutFieldKey(t);
                             const annos = !Field.toString(Doc.LayoutField(t) as Field).includes("CollectionView");
                             DocListCast(t[annos ? fieldKey + "-annotations" : fieldKey]).forEach((newdoc) => newarray.push(newdoc));
@@ -136,7 +139,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
     public removeFilter = (filterName: string) => {
         console.log("remove filter");
-        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        const targetDoc = this.targetDoc;
         const filterDoc = targetDoc.currentFilter as Doc;
         const attributes = DocListCast(filterDoc["data"]);
         const found = attributes.findIndex(doc => doc.title === filterName);
@@ -166,26 +169,25 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
         console.log("facetClick: " + facetHeader);
         console.log(this.props.fieldKey);
-
-        const targetDoc = FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
-        // const targetDoc = SelectionManager.Views()[0].props.Document;
+        const targetDoc = this.targetDoc;
         const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader);
         if (found !== -1) {
-            // (this.dataDoc[this.props.fieldKey] as List<Doc>).splice(found, 1);
-            // const docFilter = Cast(targetDoc._docFilters, listSpec("string"));
-            // if (docFilter) {
-            //     let index: number;
-            //     while ((index = docFilter.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) {
-            //         docFilter.splice(index, 1);
-            //     }
-            // }
-            // const docRangeFilters = Cast(targetDoc._docRangeFilters, listSpec("string"));
-            // if (docRangeFilters) {
-            //     let index: number;
-            //     while ((index = docRangeFilters.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) {
-            //         docRangeFilters.splice(index, 3);
-            //     }
-            // }
+            // comment this bit out later once the x works in treeview
+            (this.dataDoc[this.props.fieldKey] as List<Doc>).splice(found, 1);
+            const docFilter = Cast(targetDoc._docFilters, listSpec("string"));
+            if (docFilter) {
+                let index: number;
+                while ((index = docFilter.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) {
+                    docFilter.splice(index, 1);
+                }
+            }
+            const docRangeFilters = Cast(targetDoc._docRangeFilters, listSpec("string"));
+            if (docRangeFilters) {
+                let index: number;
+                while ((index = docRangeFilters.findIndex(item => item.split(":")[0] === facetHeader)) !== -1) {
+                    docRangeFilters.splice(index, 3);
+                }
+            }
         } else {
             const allCollectionDocs = DocListCast((targetDoc.data as any)[0].data);
             const facetValues = this.gatherFieldValues(targetDoc, facetHeader);
@@ -208,6 +210,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 newFacet._textBoxPadding = 4;
                 const scriptText = `setDocFilter(this?.target, "${facetHeader}", text, "match")`;
                 newFacet.onTextChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, text: "string" });
+                // function foo (this:doc, text:string)
+                // "this" should be the item called noot (maybe) or the treeview doc itself
             } else if (facetHeader !== "tags" && nonNumbers / facetValues.strings.length < .1) {
                 newFacet = Docs.Create.SliderDocument({ title: facetHeader, _overflow: "visible", _fitWidth: true, _height: 40, _stayInCollection: true, _hideContextMenu: true, treeViewExpandedView: "layout", treeViewOpen: true });
                 const newFacetField = Doc.LayoutFieldKey(newFacet);
@@ -227,8 +231,10 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 newFacet.title = facetHeader;
                 newFacet.treeViewOpen = true;
                 newFacet.type = DocumentType.COL;
-                newFacet.target = targetDoc;
-                newFacet.data = ComputedField.MakeFunction(`readFacetData(self.target, "${facetHeader}")`);
+                const capturedVariables = { layoutDoc: targetDoc, system: true, _stayInCollection: true, _hideContextMenu: true, dataDoc: (targetDoc.data as any)[0][DataSym] };
+                newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, "${facetHeader}")`, {}, capturedVariables);
+                // newFacet.target = targetDoc;
+                // newFacet.data = ComputedField.MakeFunction(`readFacetData(self.target, "${facetHeader}")`);
             }
             newFacet && Doc.AddDocToList(this.dataDoc, this.props.fieldKey, newFacet);
         }
@@ -242,20 +248,17 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
     @action
     changeBool = (e: any) => {
-        this._filterBoolean = e.currentTarget.value;
-        console.log(this._filterBoolean);
+        FilterBox._filterBoolean = e.currentTarget.value;
     }
 
     @action
     changeScope = (e: any) => {
         FilterBox._filterScope = e.currentTarget.value;
-        console.log(FilterBox._filterScope);
     }
 
     @action
     changeMatch = (e: any) => {
         this._filterMatch = e.currentTarget.value;
-        console.log(this._filterMatch);
     }
     @action
     changeSelected = () => {
@@ -266,7 +269,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
             this._filterSelected = true;
             // helper method to select specified docs
         }
-        console.log(this._filterSelected);
     }
 
     FilteringStyleProvider(doc: Opt<Doc>, props: Opt<FieldViewProps | DocumentViewProps>, property: string) {
@@ -294,51 +296,62 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     suppressChildClick = () => ScriptField.MakeScript("")!;
 
     saveFilter = () => {
-        // const doc: Doc = new Doc;
-        // for (const key of Object.keys(this.props.Document)) {
-        //     doc[key] = SerializationHelper.Serialize(this.props.Document[key] as Field);
-        // }
-        // console.log(doc);
-        runInAction(() => this.showFilterDialog = true);
+        Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
         console.log("saved filter");
     }
 
-    onTitleValueChange = (e: React.ChangeEvent<HTMLInputElement>) => {
-        this.props.Document.title = e.currentTarget.value || `FilterDoc for ${SelectionManager.Views()[0].Document.title}`;
+    onTitleValueChange = (val: string) => {
+        this.props.Document.title = val || `FilterDoc for ${SelectionManager.Views()[0].Document.title}`;
+        return true;
     }
 
-    onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
-        if (e.key === "Enter") {
-            runInAction(() => this.showFilterDialog = false);
-            Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
-        }
-    }
-
-    render() {
-        const facetCollection = this.props.Document;
-
-        const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
+    @computed get flyoutPanel() {
+        return DocListCast(Doc.UserDoc().savedFilters).map(doc => {
             // console.log("mapping");
             return <>
-                <div className="???" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
+                <div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
                     {StrCast(doc.title)}
                 </div>
             </>;
         }
         );
+    }
 
-        const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
+    render() {
+        const facetCollection = this.props.Document;
+        // const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
+        //     // console.log("mapping");
+        //     return <>
+        //         <div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
+        //             {StrCast(doc.title)}
+        //         </div>
+        //     </>;
+        // }
+        // );
 
+        // TODO uncomment the line below when the treeview x works
+        // const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
+        const options = this._allFacets.map(facet => ({ value: facet, label: facet }));
         return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
-            <div className="filterBox-title">Current FilterDoc: {this.props.Document.title}</div>
+            <div className="filterBox-title">
+                <EditableView
+                    key="editableView"
+                    contents={this.props.Document.title}
+                    height={24}
+                    fontSize={15}
+                    GetValue={() => StrCast(this.props.Document.title)}
+                    SetValue={this.onTitleValueChange}
+                />
+            </div>
+
             <div className="filterBox-select-bool">
-                <select className="filterBox-selection" onChange={e => this.changeBool(e)}>
+                <select className="filterBox-selection" onChange={this.changeBool}>
                     <option value="AND" key="AND">AND</option>
                     <option value="OR" key="OR">OR</option>
                 </select>
                 <div className="filterBox-select-text">filters in </div>
-                <select className="filterBox-selection" onChange={e => this.changeScope(e)}>
+                <select className="filterBox-selection" onChange={this.changeScope}>
                     <option value="Current Dashboard" key="Current Dashboard" selected={"Current Dashboard" === FilterBox._filterScope}>Current Dashboard</option>
                     {/* <option value="Current Tab" key="Current Tab">Current Tab</option> */}
                     <option value="Current Collection" key="Current Collection" selected={"Current Collection" === FilterBox._filterScope}>Current Collection</option>
@@ -354,26 +367,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     value={null}
                     closeMenuOnSelect={false}
                 />
-                {/* @computed get flyoutpanel() {
-        return <div className="filterBox-flyout" style={{ width: `100%`, height: this.props.PanelHeight() - 30 }} onWheel={e => e.stopPropagation()}>
-            {this._allFacets.map(facet => <label className="filterBox-flyout-facet" key={`${facet}`} onClick={e => this.facetClick(facet)}>
-                <input type="checkbox" onChange={emptyFunction} checked={DocListCast(this.props.Document[this.props.fieldKey]).some(d => d.title === facet)} />
-                <span className="checkmark" />
-                {facet}
-            </label>)}
-        </div>;
-    }
-    render() {
-        const facetCollection = this.props.Document;
-
-        return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
-            <div className="filterBox-addFacet" style={{ width: "100%" }} onPointerDown={e => e.stopPropagation()}>
-                <Flyout anchorPoint={anchorPoints.LEFT_TOP} content={this.flyoutpanel}>
-                    <div className="filterBox-addFacetButton">
-                        <FontAwesomeIcon icon={"edit"} size={"lg"} />
-                        <span className="filterBox-span">Choose Facets</span>
-                    </div>
-                </Flyout> */}
             </div>
 
             <div className="filterBox-tree" key="tree">
@@ -444,7 +437,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     </div>
                     <div className="filterBox-saveWrapper">
                         <div className="filterBox-saveBookmark">
-                            <Flyout className="myFilters-flyout" anchorPoint={anchorPoints.TOP} content={flyout}>
+                            <Flyout className="myFilters-flyout" anchorPoint={anchorPoints.TOP} content={this.flyoutPanel}>
                                 <div>FILTERS</div>
                             </Flyout>
                         </div>
@@ -457,14 +450,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                         </div>
                     </div>
                 </div>
-                {!this.showFilterDialog ? (null) :
-                    <input
-                        className="filterBox-dialog-input"
-                        placeholder="Enter name of filterDoc"
-                        onChange={this.onTitleValueChange}
-                        onKeyDown={this.onKeyDown}
-                    />
-                }
             </div>
         </div>;
     }
@@ -480,7 +465,7 @@ Scripting.addGlobal(function determineCheckedState(layoutDoc: Doc, facetHeader:
     }
     return undefined;
 });
-Scripting.addGlobal(function readFacetData(targetDoc: Doc, facetHeader: string) {
+Scripting.addGlobal(function readFacetData(layoutDoc: Doc, facetHeader: string) {
     const allCollectionDocs = DocListCast(CollectionDockingView.Instance?.props.Document.allDocuments);
     const set = new Set<string>();
     if (facetHeader === "tags") allCollectionDocs.forEach(child => Field.toString(child[facetHeader] as Field).split(":").forEach(key => set.add(key)));
@@ -493,10 +478,11 @@ Scripting.addGlobal(function readFacetData(targetDoc: Doc, facetHeader: string)
         const doc = new Doc();
         doc.system = true;
         doc.title = facetValue.toString();
-        doc.target = targetDoc;
-        doc.facetHeader = facetHeader;
-        doc.facetValue = facetValue;
-        doc.treeViewChecked = ComputedField.MakeFunction("determineCheckedState(self.target, self.facetHeader, self.facetValue)");
+        doc.treeViewChecked = ComputedField.MakeFunction("determineCheckedState(layoutDoc, facetHeader, facetValue)", {}, { layoutDoc, facetHeader, facetValue });
+        // doc.target = layoutDoc;
+        // doc.facetHeader = facetHeader;
+        // doc.facetValue = facetValue;
+        // doc.treeViewChecked = ComputedField.MakeFunction("determineCheckedState(self.target, self.facetHeader, self.facetValue)");
         return doc;
     });
     return new List<Doc>(facetValueDocSet);
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 75d15c409..b0d77f0de 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1049,7 +1049,7 @@ export namespace Doc {
         doc.layoutKey = deiconify || "layout";
     }
     export function setDocFilterRange(target: Doc, key: string, range?: number[]) {
-        const container = target ?? CollectionDockingView.Instance.props.Document;
+        const container = target ?? FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
         const docRangeFilters = Cast(container._docRangeFilters, listSpec("string"), []);
         for (let i = 0; i < docRangeFilters.length; i += 3) {
             if (docRangeFilters[i] === key) {
@@ -1065,9 +1065,11 @@ export namespace Doc {
         }
     }
 
-    // filters document in a container collection:
-    // all documents with the specified value for the specified key are included/excluded 
-    // based on the modifiers :"check", "x", undefined
+    /**
+    * Filters document in a container collection:
+    * all documents with the specified value for the specified key are included/excluded
+    * based on the modifiers :"check", "x", undefined
+    */
     export function setDocFilter(target: Opt<Doc>, key: string, value: any, modifiers?: "remove" | "match" | "check" | "x" | undefined) {
         const container = target ?? FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
         const docFilters = Cast(container._docFilters, listSpec("string"), []);
-- 
cgit v1.2.3-70-g09d2


From 8811fb0f177ed1448fa7b3d08ff42145254a0475 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Sun, 14 Mar 2021 21:21:05 -0400
Subject: minor

---
 .gitignore                          | 3 ++-
 src/client/views/PropertiesView.tsx | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/.gitignore b/.gitignore
index aeb343fd1..43b63a362 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,5 @@ src/server/session_manager/logs/**/*.log
 *.key
 *.pfx
 *.properties
-debug.log
\ No newline at end of file
+debug.log
+.vscodeignore
\ No newline at end of file
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 128256733..8bffb0778 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -919,6 +919,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         CurrentUserUtils.setupFilterDocs(this.filterDoc);
     }
 
+    /**
+     * Updates this.filterDoc's currentFilter and saves the docFilters on the currentFilter
+     */
     updateFilterDoc = (doc: Doc) => {
         if (doc === this.filterDoc.currentFilter) return; // causes problems if you try to reapply the same doc
         const temp = doc._docFiltersList;
@@ -953,7 +956,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             removeDocument={returnFalse}
                             ScreenToLocalTransform={this.getTransform}
                             PanelWidth={this.docWidth}
-                            PanelHeight={() => this.docHeight}
+                            PanelHeight={this.docHeight}
                             renderDepth={0}
                             scriptContext={this.filterDoc.currentFilter as Doc}
                             focus={emptyFunction}
-- 
cgit v1.2.3-70-g09d2


From 9c612838c775a6fa9737963618aeebbc427e794c Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Wed, 17 Mar 2021 21:56:31 -0400
Subject: converted dockingview.instance to dashboard + started commenting

---
 src/client/views/PropertiesView.tsx  | 11 +++---
 src/client/views/nodes/FilterBox.tsx | 73 +++++++++++++++++++++++++++---------
 2 files changed, 61 insertions(+), 23 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 8bffb0778..c677478cb 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -51,7 +51,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
     @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
     @computed get filterDoc() {
-        return FilterBox._filterScope === "Current Collection" ? this.selectedDoc || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        return FilterBox.targetDoc;
     }
     @computed get selectedDocumentView() {
         if (SelectionManager.Views().length) return SelectionManager.Views()[0];
@@ -59,8 +59,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         return undefined;
     }
     @computed get isPres(): boolean {
-        if (this.selectedDoc?.type === DocumentType.PRES) return true;
-        return false;
+        return this.selectedDoc?.type === DocumentType.PRES;
     }
     @computed get dataDoc() { return this.selectedDoc?.[DataSym]; }
 
@@ -934,7 +933,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     }
 
     @computed get filtersSubMenu() {
-        return <div className="propertiesView-filters">
+        return !this.filterDoc?.currentFilter ? (null) : <div className="propertiesView-filters">
             <div className="propertiesView-filters-title"
                 onPointerDown={action(() => this.openFilters = !this.openFilters)}
                 style={{ backgroundColor: this.openFilters ? "black" : "" }}>
@@ -944,7 +943,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                 </div>
             </div>
             {
-                !this.openFilters || !this.filterDoc.currentFilter ? (null) :
+                !this.openFilters ? (null) :
                     <div className="propertiesView-filters-content">
                         <DocumentView
                             Document={this.filterDoc.currentFilter as Doc}
@@ -1100,7 +1099,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
                     {this.sharingSubMenu}
 
-                    {this.selectedDoc.type === DocumentType.COL && this.filtersSubMenu}
+                    {this.filtersSubMenu}
 
                     {this.inkSubMenu}
 
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 541693cdf..d410d2b33 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -40,7 +40,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     constructor(props: Readonly<FieldViewProps>) {
         super(props);
         const targetDoc = FilterBox.targetDoc;
-        if (!targetDoc) CurrentUserUtils.setupFilterDocs(targetDoc);
+        if (targetDoc && !targetDoc.currentFilter) CurrentUserUtils.setupFilterDocs(targetDoc);
     }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
@@ -49,11 +49,43 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     public _filterSelected = false;
     public _filterMatch = "matched";
 
+    @computed static get currentContainingCollectionDoc() {
+        let docView: any = SelectionManager.Views()[0];
+        let doc = docView.Document;
+
+        while (docView && doc && doc.type !== "collection") {
+            doc = docView.props.ContainingCollectionDoc;
+            docView = docView.props.ContainingCollectionView;
+        }
+
+        return doc;
+    }
+
+    // /**
+    //  * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
+    //  */
+
+
+    // trying to get this to work rather than the version below this
+
+    // @computed static get targetDoc() {
+    //     console.log(FilterBox.currentContainingCollectionDoc.type);
+    //     if (FilterBox._filterScope === "Current Collection") {
+    //         return FilterBox.currentContainingCollectionDoc;
+    //     }
+    //     else return CollectionDockingView.Instance.props.Document;
+    //     // return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+    // }
+
+
     /**
-     * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
-     */
+    * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
+    */
     @computed static get targetDoc() {
-        return FilterBox._filterScope === "Current Collection" ? SelectionManager.Views()[0].Document || CollectionDockingView.Instance.props.Document : CollectionDockingView.Instance.props.Document;
+        if (FilterBox._filterScope === "Current Collection") {
+            return SelectionManager.Views()[0].Document.type === "collection" ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0].props.ContainingCollectionDoc!;
+        }
+        else return CurrentUserUtils.ActiveDashboard;
     }
 
     @observable _loaded = false;
@@ -70,7 +102,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         const allDocs = new Set<Doc>();
         const targetDoc = FilterBox.targetDoc;
         if (this._loaded && targetDoc) {
-            // if (targetDoc) {
             const activeTabs = DocListCast(targetDoc.data);
             SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
             setTimeout(() => targetDoc.allDocuments = new List<Doc>(Array.from(allDocs)));
@@ -247,20 +278,30 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         return script ? () => script : undefined;
     }
 
+    /**
+     * Changes the value of the variable that determines whether filters are ANDed or ORed together
+     */
     @action
     changeBool = (e: any) => {
         FilterBox._filterBoolean = e.currentTarget.value;
     }
 
+    /**
+     * Changes the value of the variable that determines whether the filters should apply to the dashboard or the collection
+     */
     @action
     changeScope = (e: any) => {
         FilterBox._filterScope = e.currentTarget.value;
     }
 
+    /**
+     * Changes whether to select matched or unmatched documents
+     */
     @action
     changeMatch = (e: any) => {
         this._filterMatch = e.currentTarget.value;
     }
+
     @action
     changeSelected = () => {
         if (this._filterSelected) {
@@ -296,19 +337,26 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
     suppressChildClick = () => ScriptField.MakeScript("")!;
 
+    /**
+     * Adds a filterDoc to the list of saved filters
+     */
     saveFilter = () => {
         Doc.AddDocToList(Doc.UserDoc(), "savedFilters", this.props.Document);
-        console.log("saved filter");
     }
 
+    /**
+     * Changes the title of the filterDoc
+     */
     onTitleValueChange = (val: string) => {
-        this.props.Document.title = val || `FilterDoc for ${SelectionManager.Views()[0].Document.title}`;
+        this.props.Document.title = val || `FilterDoc for ${FilterBox.targetDoc.title}`;
         return true;
     }
 
+    /**
+     * The flyout from which you can select a saved filter to apply
+     */
     @computed get flyoutPanel() {
         return DocListCast(Doc.UserDoc().savedFilters).map(doc => {
-            // console.log("mapping");
             return <>
                 <div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
                     {StrCast(doc.title)}
@@ -320,15 +368,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
     render() {
         const facetCollection = this.props.Document;
-        // const flyout = DocListCast(Doc.UserDoc().savedFilters).map(doc => {
-        //     // console.log("mapping");
-        //     return <>
-        //         <div className="filterBox-tempFlyout" onWheel={e => e.stopPropagation()} style={{ height: 50, border: "2px" }} onPointerDown={() => this.props.updateFilterDoc?.(doc)}>
-        //             {StrCast(doc.title)}
-        //         </div>
-        //     </>;
-        // }
-        // );
 
         // TODO uncomment the line below when the treeview x works
         // const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
-- 
cgit v1.2.3-70-g09d2


From a8c02cba0bf96e435e062f2251890243ad8f49e0 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Wed, 17 Mar 2021 22:36:16 -0400
Subject: made and/or a property of the document so it's saved with the filter

---
 src/client/documents/Documents.ts    | 4 ++--
 src/client/util/CurrentUserUtils.ts  | 5 +++--
 src/client/views/PropertiesView.tsx  | 3 +++
 src/client/views/nodes/FilterBox.tsx | 9 ++++-----
 4 files changed, 12 insertions(+), 9 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 0d2f04569..ef6623f20 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1040,7 +1040,7 @@ export namespace DocUtils {
                     return Field.toString(d[facetKey] as Field).includes(value);
                 });
                 // if we're ORing them together, the default return is false, and we return true for a doc if it satisfies any one set of criteria
-                if (FilterBox._filterBoolean === "OR") {
+                if ((FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR") {
                     if (satisfiesCheckFacets && !failsNotEqualFacets && satisfiesMatchFacets) return true;
                 }
                 // if we're ANDing them together, the default return is true, and we return false for a doc if it doesn't satisfy any set of criteria
@@ -1049,7 +1049,7 @@ export namespace DocUtils {
                 }
 
             }
-            return FilterBox._filterBoolean === "OR" ? false : true;
+            return (FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR" ? false : true;
         }) : childDocs;
         const rangeFilteredDocs = filteredDocs.filter(d => {
             for (let i = 0; i < docRangeFilters.length; i += 3) {
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 88bb1207f..157a88de7 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -810,8 +810,9 @@ export class CurrentUserUtils {
                 _lockedPosition: true, boxShadow: "0 0", childDontRegisterViews: true, targetDropAction: "same", system: true
             });
             const clearAll = ScriptField.MakeScript(`getProto(self).data = new List([])`);
-            (doc.currentFilter as any as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
-            (doc.currentFilter as any as Doc).contextMenuLabels = new List<string>(["Clear All"]);
+            (doc.currentFilter as Doc).contextMenuScripts = new List<ScriptField>([clearAll!]);
+            (doc.currentFilter as Doc).contextMenuLabels = new List<string>(["Clear All"]);
+            (doc.currentFilter as Doc).filterBoolean = "AND";
         }
     }
 
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index c677478cb..b4e15b536 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -74,6 +74,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
     @observable openTransform: boolean = true;
     @observable openFilters: boolean = true; // should be false
 
+    /**
+     * autorun to set up the filter doc of a collection if that collection has been selected and the filters panel is open
+     */
     private selectedDocListenerDisposer: Opt<Lambda>;
 
     // @observable selectedUser: string = "";
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index d410d2b33..2ed3dc21f 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -44,7 +44,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
-    @observable static _filterBoolean = "AND";
     @observable static _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
@@ -279,11 +278,11 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     }
 
     /**
-     * Changes the value of the variable that determines whether filters are ANDed or ORed together
+     * Sets whether filters are ANDed or ORed together
      */
     @action
     changeBool = (e: any) => {
-        FilterBox._filterBoolean = e.currentTarget.value;
+        (FilterBox.targetDoc.currentFilter as Doc).filterBoolean = e.currentTarget.value;
     }
 
     /**
@@ -388,8 +387,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
             <div className="filterBox-select-bool">
                 <select className="filterBox-selection" onChange={this.changeBool}>
-                    <option value="AND" key="AND">AND</option>
-                    <option value="OR" key="OR">OR</option>
+                    <option value="AND" key="AND" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "AND"}>AND</option>
+                    <option value="OR" key="OR" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR"}>OR</option>
                 </select>
                 <div className="filterBox-select-text">filters in </div>
                 <select className="filterBox-selection" onChange={this.changeScope}>
-- 
cgit v1.2.3-70-g09d2


From 5e29ff3ea44ee885bd3a90ecbf4d9cdb11b245f6 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Thu, 18 Mar 2021 01:33:56 -0400
Subject: why won't this document from hell change height

---
 src/client/documents/Documents.ts    |  2 +-
 src/client/util/CurrentUserUtils.ts  |  2 +-
 src/client/views/PropertiesView.tsx  |  1 +
 src/client/views/nodes/FilterBox.tsx | 11 +++--------
 4 files changed, 6 insertions(+), 10 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index ef6623f20..0c16d9f8f 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -167,7 +167,7 @@ export class DocumentOptions {
     description?: string; // added for links
     layout?: string | Doc; // default layout string for a document
     contentPointerEvents?: string;  // pointer events allowed for content of a document view.  eg. set to "none" in menuSidebar for sharedDocs so that you can select a document, but not interact with its contents
-    childLimitHeight?: number; // whether to limit the height of colleciton children.  0 - means  height can be no bigger than width
+    childLimitHeight?: number; // whether to limit the height of collection children.  0 - means  height can be no bigger than width
     childLayoutTemplate?: Doc; // template for collection to use to render its children (see PresBox or Buxton layout in tree view)
     childLayoutString?: string; // template string for collection to use to render its children
     childDontRegisterViews?: boolean;
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 157a88de7..993eba889 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -804,7 +804,7 @@ export class CurrentUserUtils {
         doc.currentFilter === undefined;
         if (doc.currentFilter === undefined) {
             doc.currentFilter = Docs.Create.FilterDocument({
-                title: "FilterDoc", _height: 20,
+                title: "FilterDoc", _height: 150,
                 treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, _forceActive: true, childDropAction: "none",
                 treeViewTruncateTitleWidth: 150, treeViewPreventOpen: false, ignoreClick: true,
                 _lockedPosition: true, boxShadow: "0 0", childDontRegisterViews: true, targetDropAction: "same", system: true
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index b4e15b536..1f4685bf2 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -975,6 +975,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             updateFilterDoc={this.updateFilterDoc}
                             docViewPath={returnEmptyDoclist}
                             layerProvider={undefined}
+                            dontCenter="y"
                         />
                     </div>
             }
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 2ed3dc21f..01372c284 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -424,7 +424,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     ContainingCollectionDoc={this.props.ContainingCollectionDoc}
                     ContainingCollectionView={this.props.ContainingCollectionView}
                     PanelWidth={this.props.PanelWidth}
-                    PanelHeight={() => 100}
+                    PanelHeight={this.props.PanelHeight}
                     rootSelected={this.props.rootSelected}
                     renderDepth={1}
                     dropAction={this.props.dropAction}
@@ -450,13 +450,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     removeDocument={returnFalse}
                     addDocument={returnFalse} />
             </div>
-            {/* <Flyout className="filterBox-flyout" anchorPoint={anchorPoints.RIGHT_TOP} content={flyout}>
-                <div className="filterBox-addWrapper">
-                    <div className="filterBox-addFilter"> + add a filter</div>
-                </div>
-            </Flyout> */}
             <div className="filterBox-bottom">
-                <div className="filterBox-select-matched">
+                {/* <div className="filterBox-select-matched">
                     <input className="filterBox-select-box" type="checkbox"
                         onChange={this.changeSelected} />
                     <div className="filterBox-select-text">select</div>
@@ -465,7 +460,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                         <option value="unmatched" key="unmatched">unmatched</option>
                     </select>
                     <div className="filterBox-select-text">documents</div>
-                </div>
+                </div> */}
 
                 <div style={{ display: "flex" }}>
                     <div className="filterBox-saveWrapper">
-- 
cgit v1.2.3-70-g09d2


From 4df769e20b9588fea61b602ec67ca2208fc3d747 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Thu, 25 Mar 2021 02:25:12 -0400
Subject: filters is going to kill me the files I should look at on return to
 this branch are documents.ts, propertiesview, colsubview, colview, filterbox

---
 src/client/documents/Documents.ts                  |  8 ++++----
 src/client/views/PropertiesView.scss               |  3 +--
 src/client/views/PropertiesView.tsx                |  2 +-
 src/client/views/collections/CollectionSubView.tsx | 14 ++++++++++----
 src/client/views/collections/CollectionView.tsx    |  2 +-
 src/client/views/nodes/FilterBox.tsx               |  8 ++++----
 6 files changed, 21 insertions(+), 16 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 0c16d9f8f..3e29a4edf 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -990,7 +990,7 @@ export namespace DocUtils {
      * @param viewSpecScript 
      * Given a list of docs and docFilters, @returns the list of Docs that match those filters 
      */
-    export function FilterDocs(docs: Doc[], docFilters: string[], docRangeFilters: string[], viewSpecScript?: ScriptField) {
+    export function FilterDocs(docs: Doc[], docFilters: string[], docRangeFilters: string[], viewSpecScript?: ScriptField, parentCollection?: Doc) {
         const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
         if (!docFilters?.length && !docRangeFilters?.length) {
             return childDocs.filter(d => !d.cookies);  // remove documents that need a cookie if there are no filters to provide one
@@ -1040,16 +1040,16 @@ export namespace DocUtils {
                     return Field.toString(d[facetKey] as Field).includes(value);
                 });
                 // if we're ORing them together, the default return is false, and we return true for a doc if it satisfies any one set of criteria
-                if ((FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR") {
+                if (((FilterBox._filterScope === "Current Collection" ? parentCollection || CurrentUserUtils.ActiveDashboard : CurrentUserUtils.ActiveDashboard).currentFilter as Doc)?.filterBoolean === "OR") {
                     if (satisfiesCheckFacets && !failsNotEqualFacets && satisfiesMatchFacets) return true;
                 }
                 // if we're ANDing them together, the default return is true, and we return false for a doc if it doesn't satisfy any set of criteria
                 else {
-                    if (!satisfiesCheckFacets || failsNotEqualFacets || (matches.length && satisfiesMatchFacets)) return false;
+                    if (!satisfiesCheckFacets || failsNotEqualFacets || (matches.length && !satisfiesMatchFacets)) return false;
                 }
 
             }
-            return (FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR" ? false : true;
+            return ((FilterBox._filterScope === "Current Collection" ? parentCollection || CurrentUserUtils.ActiveDashboard : CurrentUserUtils.ActiveDashboard).currentFilter as Doc)?.filterBoolean === "OR" ? false : true;
         }) : childDocs;
         const rangeFilteredDocs = filteredDocs.filter(d => {
             for (let i = 0; i < docRangeFilters.length; i += 3) {
diff --git a/src/client/views/PropertiesView.scss b/src/client/views/PropertiesView.scss
index 7c6d507b8..04934d50b 100644
--- a/src/client/views/PropertiesView.scss
+++ b/src/client/views/PropertiesView.scss
@@ -191,8 +191,7 @@
             font-size: 10px;
             padding: 10px;
             margin-left: 5px;
-            max-height: 40%;
-            overflow-y: scroll;
+            max-height: 40%;overflow-y: scroll;
 
             .propertiesView-buttonContainer {
                 float: right;
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 1f4685bf2..1e96d62d2 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -51,7 +51,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
     @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
     @computed get filterDoc() {
-        return FilterBox.targetDoc;
+        return FilterBox._filterScope === "Current Collection" ? this.selectedDoc! : CurrentUserUtils.ActiveDashboard;
     }
     @computed get selectedDocumentView() {
         if (SelectionManager.Views().length) return SelectionManager.Views()[0];
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 05e9ac265..3e6deaf3a 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -82,7 +82,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             return Cast(this.dataField, listSpec(Doc));
         }
         docFilters = () => {
-            return [...this.props.docFilters(), ...Cast(this.props.Document._docFilters, listSpec("string"), [])];
+            return [...this.props.docFilters(), ...Cast(FilterBox._filterScope === "Current Collection" ? this.props.Document._docFilters : CurrentUserUtils.ActiveDashboard._docFilters, listSpec("string"), [])];
         }
         docRangeFilters = () => {
             return [...this.props.docRangeFilters(), ...Cast(this.props.Document._docRangeFilters, listSpec("string"), [])];
@@ -114,10 +114,15 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                 return childDocs.filter(cd => !cd.cookies); // remove any documents that require a cookie if there are no filters to provide one
             }
 
+            // console.log(CurrentUserUtils.ActiveDashboard._docFilters);
+            if (!this.props.Document._docFilters && this.props.Document.currentFilter) {
+                (this.props.Document.currentFilter as Doc).filterBoolean = (this.props.ContainingCollectionDoc?.currentFilter as Doc)?.filterBoolean;
+            }
             const docsforFilter: Doc[] = [];
+            console.log(this.props.Document.system);
             childDocs.forEach((d) => {
                 // if (DocUtils.Excluded(d, docFilters)) return;
-                let notFiltered = d.z || ((!searchDocs.length || searchDocs.includes(d)) && (DocUtils.FilterDocs([d], docFilters, docRangeFilters, viewSpecScript).length > 0));
+                let notFiltered = d.z || ((!searchDocs.length || searchDocs.includes(d)) && (DocUtils.FilterDocs([d], docFilters, docRangeFilters, viewSpecScript, this.props.Document).length > 0));
                 const fieldKey = Doc.LayoutFieldKey(d);
                 const annos = !Field.toString(Doc.LayoutField(d) as Field).includes("CollectionView");
                 const data = d[annos ? fieldKey + "-annotations" : fieldKey];
@@ -125,13 +130,13 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                     let subDocs = DocListCast(data);
                     if (subDocs.length > 0) {
                         let newarray: Doc[] = [];
-                        notFiltered = notFiltered || (!searchDocs.length && DocUtils.FilterDocs(subDocs, docFilters, docRangeFilters, viewSpecScript).length);
+                        notFiltered = notFiltered || (!searchDocs.length && DocUtils.FilterDocs(subDocs, docFilters, docRangeFilters, viewSpecScript, this.props.Document).length);
                         while (subDocs.length > 0 && !notFiltered) {
                             newarray = [];
                             subDocs.forEach((t) => {
                                 const fieldKey = Doc.LayoutFieldKey(t);
                                 const annos = !Field.toString(Doc.LayoutField(t) as Field).includes("CollectionView");
-                                notFiltered = notFiltered || ((!searchDocs.length || searchDocs.includes(t)) && ((!docFilters.length && !docRangeFilters.length) || DocUtils.FilterDocs([t], docFilters, docRangeFilters, viewSpecScript).length));
+                                notFiltered = notFiltered || ((!searchDocs.length || searchDocs.includes(t)) && ((!docFilters.length && !docRangeFilters.length) || DocUtils.FilterDocs([t], docFilters, docRangeFilters, viewSpecScript, this.props.Document).length));
                                 DocListCast(t[annos ? fieldKey + "-annotations" : fieldKey]).forEach((newdoc) => newarray.push(newdoc));
                             });
                             subDocs = newarray;
@@ -481,4 +486,5 @@ import { SelectionManager } from "../../util/SelectionManager";
 import { OverlayView } from "../OverlayView";
 import { Hypothesis } from "../../util/HypothesisUtils";
 import { GetEffectiveAcl } from "../../../fields/util";
+import { FilterBox } from "../nodes/FilterBox";
 
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 4f37747b0..020bb374a 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -122,7 +122,7 @@ export class CollectionView extends Touchable<CollectionViewProps> {
      * Applies the collection/dashboard's current filter attributes to the doc being added
      */
     addFilterAttributes = (doc: Doc) => {
-        Cast(FilterBox.targetDoc._docFilters, listSpec("string"))?.forEach(attribute => {
+        Cast((FilterBox._filterScope === "Current Collection" ? this.props.Document : CurrentUserUtils.ActiveDashboard)._docFilters, listSpec("string"))?.forEach(attribute => {
             if (attribute.charAt(0).toUpperCase() === attribute.charAt(0)) {
                 const fields = attribute.split(':');
                 if (fields[2] === "check") doc[DataSym][fields[0]] = fields[1];
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 01372c284..b9a981e77 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -81,8 +81,9 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
     */
     @computed static get targetDoc() {
+        console.log("recomputing");
         if (FilterBox._filterScope === "Current Collection") {
-            return SelectionManager.Views()[0].Document.type === "collection" ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0].props.ContainingCollectionDoc!;
+            return SelectionManager.Views()[0]?.Document.type === "collection" ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0]?.props.ContainingCollectionDoc!;
         }
         else return CurrentUserUtils.ActiveDashboard;
     }
@@ -97,7 +98,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
             }, { fireImmediately: true });
     }
     @computed get allDocs() {
-        trace();
+        // trace();
         const allDocs = new Set<Doc>();
         const targetDoc = FilterBox.targetDoc;
         if (this._loaded && targetDoc) {
@@ -109,7 +110,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     }
 
     @computed get _allFacets() {
-        trace();
+        // trace();
         const noviceReqFields = ["author", "tags", "text", "type"];
         const noviceLayoutFields: string[] = [];//["_curPage"];
         const noviceFields = [...noviceReqFields, ...noviceLayoutFields];
@@ -117,7 +118,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         const keys = new Set<string>(noviceFields);
         this.allDocs.forEach(doc => SearchBox.documentKeys(doc).filter(key => keys.add(key)));
         return Array.from(keys.keys()).filter(key => key[0]).filter(key => key[0] === "#" || key.indexOf("lastModified") !== -1 || (key[0] === key[0].toUpperCase() && !key.startsWith("_")) || noviceFields.includes(key) || !Doc.UserDoc().noviceMode).sort();
-        // return [];
     }
 
 
-- 
cgit v1.2.3-70-g09d2


From d913e2dd6f5a292cf1bc90e65280133642219949 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Mon, 5 Apr 2021 01:27:06 -0400
Subject: deleted some commented code + other small stuff

---
 src/client/views/PropertiesView.scss                |  3 ++-
 src/client/views/PropertiesView.tsx                 |  4 ++--
 src/client/views/collections/CollectionTreeView.tsx |  3 +--
 src/client/views/nodes/FilterBox.scss               |  4 ++++
 src/client/views/nodes/FilterBox.tsx                | 13 +++----------
 5 files changed, 12 insertions(+), 15 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.scss b/src/client/views/PropertiesView.scss
index 04934d50b..7c6d507b8 100644
--- a/src/client/views/PropertiesView.scss
+++ b/src/client/views/PropertiesView.scss
@@ -191,7 +191,8 @@
             font-size: 10px;
             padding: 10px;
             margin-left: 5px;
-            max-height: 40%;overflow-y: scroll;
+            max-height: 40%;
+            overflow-y: scroll;
 
             .propertiesView-buttonContainer {
                 float: right;
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 9fc19253e..9c1b8e593 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -965,8 +965,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             scriptContext={this.filterDoc.currentFilter as Doc}
                             focus={emptyFunction}
                             styleProvider={DefaultStyleProvider}
-                            parentActive={returnTrue}
-                            whenActiveChanged={emptyFunction}
+                            isContentActive={returnTrue}
+                            whenChildContentsActiveChanged={emptyFunction}
                             bringToFront={emptyFunction}
                             docFilters={returnEmptyFilter}
                             docRangeFilters={returnEmptyFilter}
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index 37600fa4d..ed0ed63b3 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -37,8 +37,7 @@ export type collectionTreeViewProps = {
 };
 
 @observer
-export class
-    CollectionTreeView extends CollectionSubView<Document, Partial<collectionTreeViewProps>>(Document) {
+export class CollectionTreeView extends CollectionSubView<Document, Partial<collectionTreeViewProps>>(Document) {
     private treedropDisposer?: DragManager.DragDropDisposer;
     private _mainEle?: HTMLDivElement;
     MainEle = () => this._mainEle;
diff --git a/src/client/views/nodes/FilterBox.scss b/src/client/views/nodes/FilterBox.scss
index 4fe1fa2eb..107ad2e36 100644
--- a/src/client/views/nodes/FilterBox.scss
+++ b/src/client/views/nodes/FilterBox.scss
@@ -161,6 +161,10 @@
     z-index: 1;
     background-color: #9F9F9F;
 
+    .filterBox-tree {
+        z-index: 0;
+    }
+
     .filterBox-addfacet {
         display: inline-block;
         width: 200px;
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 1d3f6a7cc..af95c96fb 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -2,7 +2,7 @@ import React = require("react");
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { computed, observable, action, trace, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { DataSym, Doc, DocListCast, Field, Opt, DocListCastAsync } from "../../../fields/Doc";
+import { Doc, DocListCast, Field, Opt, DocListCastAsync } from "../../../fields/Doc";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { List } from "../../../fields/List";
 import { RichTextField } from "../../../fields/RichTextField";
@@ -198,9 +198,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
      * Responds to clicking the check box in the flyout menu
      */
     facetClick = (facetHeader: string) => {
-
-        console.log("facetClick: " + facetHeader);
-        console.log(this.props.fieldKey);
         const targetDoc = FilterBox.targetDoc;
         const found = this.activeAttributes.findIndex(doc => doc.title === facetHeader);
         if (found !== -1) {
@@ -242,8 +239,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 newFacet._textBoxPadding = 4;
                 const scriptText = `setDocFilter(this?.target, "${facetHeader}", text, "match")`;
                 newFacet.onTextChanged = ScriptField.MakeScript(scriptText, { this: Doc.name, text: "string" });
-                // function foo (this:doc, text:string)
-                // "this" should be the item called noot (maybe) or the treeview doc itself
             } else if (facetHeader !== "tags" && nonNumbers / facetValues.strings.length < .1) {
                 newFacet = Docs.Create.SliderDocument({ title: facetHeader, _overflow: "visible", _fitWidth: true, _height: 40, _stayInCollection: true, _hideContextMenu: true, treeViewExpandedView: "layout", treeViewOpen: true });
                 const newFacetField = Doc.LayoutFieldKey(newFacet);
@@ -265,8 +260,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 newFacet.layout = CollectionView.LayoutString("data");
                 newFacet.layoutKey = "layout";
                 newFacet.type = DocumentType.COL;
-                // const capturedVariables = { layoutDoc: targetDoc, system: true, _stayInCollection: true, _hideContextMenu: true, dataDoc: (targetDoc.data as any)[0][DataSym] };
-                // newFacet.data = ComputedField.MakeFunction(`readFacetData(layoutDoc, "${facetHeader}")`, {}, capturedVariables);
                 newFacet.target = targetDoc;
                 newFacet.data = ComputedField.MakeFunction(`readFacetData(self.target, "${facetHeader}")`);
             }
@@ -390,8 +383,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
 
             <div className="filterBox-select-bool">
                 <select className="filterBox-selection" onChange={this.changeBool}>
-                    <option value="AND" key="AND" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "AND"}>AND</option>
-                    <option value="OR" key="OR" selected={(FilterBox.targetDoc.currentFilter as Doc).filterBoolean === "OR"}>OR</option>
+                    <option value="AND" key="AND" selected={(FilterBox.targetDoc.currentFilter as Doc)?.filterBoolean === "AND"}>AND</option>
+                    <option value="OR" key="OR" selected={(FilterBox.targetDoc.currentFilter as Doc)?.filterBoolean === "OR"}>OR</option>
                 </select>
                 <div className="filterBox-select-text">filters in </div>
                 <select className="filterBox-selection" onChange={this.changeScope}>
-- 
cgit v1.2.3-70-g09d2


From 27d385f999d66eba973a5beccaa4dd239eb6c57b Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 5 Apr 2021 15:01:13 -0400
Subject: set height for doc filters in property view.

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

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 9c1b8e593..863d6fd73 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -949,7 +949,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             </div>
             {
                 !this.openFilters ? (null) :
-                    <div className="propertiesView-filters-content">
+                    <div className="propertiesView-filters-content" style={{ height: this.docHeight() }}>
                         <DocumentView
                             Document={this.filterDoc.currentFilter as Doc}
                             DataDoc={undefined}
-- 
cgit v1.2.3-70-g09d2


From 647d49f4d33eada3cbd3a6e679d6097a76234f1d Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 5 Apr 2021 15:46:24 -0400
Subject: fixes for docfilter autoheight

---
 src/client/views/PropertiesView.tsx                 |  7 ++++---
 src/client/views/collections/CollectionTreeView.tsx |  3 ++-
 src/client/views/nodes/FilterBox.tsx                | 10 +++++++---
 3 files changed, 13 insertions(+), 7 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 863d6fd73..1bd5a8410 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -937,8 +937,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         this.filterDoc._docFilters = temp;
     }
 
+    filterSubHeight = () => (this.filterDoc.currentFilter as Doc)[HeightSym]();
     @computed get filtersSubMenu() {
-        return !this.filterDoc?.currentFilter ? (null) : <div className="propertiesView-filters">
+        return !(this.filterDoc?.currentFilter instanceof Doc) ? (null) : <div className="propertiesView-filters">
             <div className="propertiesView-filters-title"
                 onPointerDown={action(() => this.openFilters = !this.openFilters)}
                 style={{ backgroundColor: this.openFilters ? "black" : "" }}>
@@ -949,7 +950,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             </div>
             {
                 !this.openFilters ? (null) :
-                    <div className="propertiesView-filters-content" style={{ height: this.docHeight() }}>
+                    <div className="propertiesView-filters-content" style={{ height: this.filterSubHeight() + 15 }}>
                         <DocumentView
                             Document={this.filterDoc.currentFilter as Doc}
                             DataDoc={undefined}
@@ -960,7 +961,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             removeDocument={returnFalse}
                             ScreenToLocalTransform={this.getTransform}
                             PanelWidth={this.docWidth}
-                            PanelHeight={this.docHeight}
+                            PanelHeight={this.filterSubHeight}
                             renderDepth={0}
                             scriptContext={this.filterDoc.currentFilter as Doc}
                             focus={emptyFunction}
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index b97d11629..a9e73583d 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -65,8 +65,9 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
     refList: Set<any> = new Set();
     observer: any;
     computeHeight = () => {
-        this.rootDoc._height = this.paddingTop() + 26/* bcz: ugh: title bar height hack ... get ref and compute instead */ +
+        const hgt = this.paddingTop() + 26/* bcz: ugh: title bar height hack ... get ref and compute instead */ +
             Array.from(this.refList).reduce((p, r) => p + Number(getComputedStyle(r).height.replace("px", "")), 0);
+        this.props.setHeight(hgt);
     }
     unobserveHeight = (ref: any) => this.refList.delete(ref);
     observerHeight = (ref: any) => {
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index af95c96fb..65de0a296 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -2,7 +2,7 @@ import React = require("react");
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { computed, observable, action, trace, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { Doc, DocListCast, Field, Opt, DocListCastAsync } from "../../../fields/Doc";
+import { Doc, DocListCast, Field, Opt, DocListCastAsync, HeightSym } from "../../../fields/Doc";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { List } from "../../../fields/List";
 import { RichTextField } from "../../../fields/RichTextField";
@@ -360,7 +360,11 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         }
         );
     }
+    setTreeHeight = (hgt: number) => {
+        this.layoutDoc._height = hgt + 140; // 50?  need to add all the border sizes together.
+    }
 
+    layoutHeight = () => this.layoutDoc[HeightSym]();
     render() {
         const facetCollection = this.props.Document;
 
@@ -412,7 +416,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     fieldKey={this.props.fieldKey}
                     CollectionView={undefined}
                     disableDocBrushing={true}
-                    setHeight={returnFalse} // if the tree view can trigger the height of the filter box to change, then this needs to be filled in.
+                    setHeight={this.setTreeHeight} // if the tree view can trigger the height of the filter box to change, then this needs to be filled in.
                     onChildClick={this.suppressChildClick}
                     docFilters={returnEmptyFilter}
                     docRangeFilters={returnEmptyFilter}
@@ -420,7 +424,7 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     ContainingCollectionDoc={this.props.ContainingCollectionDoc}
                     ContainingCollectionView={this.props.ContainingCollectionView}
                     PanelWidth={this.props.PanelWidth}
-                    PanelHeight={this.props.PanelHeight}
+                    PanelHeight={this.layoutHeight}
                     rootSelected={this.props.rootSelected}
                     renderDepth={1}
                     dropAction={this.props.dropAction}
-- 
cgit v1.2.3-70-g09d2


From dec600d6f57ffd2ac4983f2f13d79d8ed394ee4a Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 5 Apr 2021 15:54:32 -0400
Subject: cleanup from last.

---
 src/client/views/PropertiesView.tsx  | 7 +++----
 src/client/views/nodes/FilterBox.tsx | 1 -
 2 files changed, 3 insertions(+), 5 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 1bd5a8410..df4dd7788 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -937,7 +937,6 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
         this.filterDoc._docFilters = temp;
     }
 
-    filterSubHeight = () => (this.filterDoc.currentFilter as Doc)[HeightSym]();
     @computed get filtersSubMenu() {
         return !(this.filterDoc?.currentFilter instanceof Doc) ? (null) : <div className="propertiesView-filters">
             <div className="propertiesView-filters-title"
@@ -950,7 +949,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             </div>
             {
                 !this.openFilters ? (null) :
-                    <div className="propertiesView-filters-content" style={{ height: this.filterSubHeight() + 15 }}>
+                    <div className="propertiesView-filters-content" style={{ height: this.filterDoc.currentFilter[HeightSym]() + 15 }}>
                         <DocumentView
                             Document={this.filterDoc.currentFilter as Doc}
                             DataDoc={undefined}
@@ -960,8 +959,8 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             rootSelected={returnTrue}
                             removeDocument={returnFalse}
                             ScreenToLocalTransform={this.getTransform}
-                            PanelWidth={this.docWidth}
-                            PanelHeight={this.filterSubHeight}
+                            PanelWidth={() => this.props.width}
+                            PanelHeight={this.filterDoc.currentFilter[HeightSym]}
                             renderDepth={0}
                             scriptContext={this.filterDoc.currentFilter as Doc}
                             focus={emptyFunction}
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index 65de0a296..501d02dc4 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -371,7 +371,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         // TODO uncomment the line below when the treeview x works
         // const options = this._allFacets.filter(facet => this.currentFacets.indexOf(facet) === -1).map(facet => ({ value: facet, label: facet }));
         const options = this._allFacets.map(facet => ({ value: facet, label: facet }));
-        console.log(this.props.PanelHeight());
         return this.props.dontRegisterView ? (null) : <div className="filterBox-treeView" style={{ width: "100%" }}>
 
             <div className="filterBox-title">
-- 
cgit v1.2.3-70-g09d2


From 00127a4fccbd00eb3d05699a3a14f52feb7b57db Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Tue, 6 Apr 2021 00:14:21 -0400
Subject: minor cleanup + style across files

---
 src/client/views/DocumentDecorations.tsx            | 10 +++++-----
 src/client/views/PropertiesView.tsx                 |  4 ++--
 src/client/views/StyleProvider.tsx                  |  1 +
 src/client/views/collections/CollectionTreeView.tsx |  2 +-
 src/client/views/collections/TreeView.tsx           |  2 +-
 src/client/views/nodes/FilterBox.tsx                |  7 +++----
 src/client/views/nodes/LinkDocPreview.tsx           |  2 +-
 7 files changed, 14 insertions(+), 14 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/DocumentDecorations.tsx b/src/client/views/DocumentDecorations.tsx
index ce7ff1bbd..e23374cea 100644
--- a/src/client/views/DocumentDecorations.tsx
+++ b/src/client/views/DocumentDecorations.tsx
@@ -83,7 +83,7 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b
             UndoManager.RunInBatch(() => titleFieldKey && SelectionManager.Views().forEach(d => {
                 titleFieldKey === "title" && (d.dataDoc["title-custom"] = !this._accumulatedTitle.startsWith("-"));
                 //@ts-ignore
-                Doc.SetInPlace(d.rootDoc, titleFieldKey, +this._accumulatedTitle == this._accumulatedTitle ? +this._accumulatedTitle : this._accumulatedTitle, true);
+                Doc.SetInPlace(d.rootDoc, titleFieldKey, +this._accumulatedTitle === this._accumulatedTitle ? +this._accumulatedTitle : this._accumulatedTitle, true);
             }), "title blur");
         }
     }
@@ -376,10 +376,10 @@ export class DocumentDecorations extends React.Component<{ boundsLeft: number, b
         this._inkDragDocs.map(oldbds => ({ oldbds, inkPts: Cast(oldbds.doc.data, InkField)?.inkData || [] }))
             .forEach(({ oldbds: { doc, x, y, width, height }, inkPts }) => {
                 Doc.GetProto(doc).data = new InkField(inkPts.map(ipt =>  // (new x — oldx) + newWidth * (oldxpoint /oldWidth)
-                    ({
-                        X: (NumCast(doc.x) - x) + NumCast(doc.width) * ipt.X / width,
-                        Y: (NumCast(doc.y) - y) + NumCast(doc.height) * ipt.Y / height
-                    })));
+                ({
+                    X: (NumCast(doc.x) - x) + NumCast(doc.width) * ipt.X / width,
+                    Y: (NumCast(doc.y) - y) + NumCast(doc.height) * ipt.Y / height
+                })));
                 Doc.SetNativeWidth(doc, undefined);
                 Doc.SetNativeHeight(doc, undefined);
             });
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index df4dd7788..782a0e29e 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -951,7 +951,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                 !this.openFilters ? (null) :
                     <div className="propertiesView-filters-content" style={{ height: this.filterDoc.currentFilter[HeightSym]() + 15 }}>
                         <DocumentView
-                            Document={this.filterDoc.currentFilter as Doc}
+                            Document={this.filterDoc.currentFilter}
                             DataDoc={undefined}
                             addDocument={undefined}
                             addDocTab={returnFalse}
@@ -962,7 +962,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             PanelWidth={() => this.props.width}
                             PanelHeight={this.filterDoc.currentFilter[HeightSym]}
                             renderDepth={0}
-                            scriptContext={this.filterDoc.currentFilter as Doc}
+                            scriptContext={this.filterDoc.currentFilter}
                             focus={emptyFunction}
                             styleProvider={DefaultStyleProvider}
                             isContentActive={returnTrue}
diff --git a/src/client/views/StyleProvider.tsx b/src/client/views/StyleProvider.tsx
index d1e2fefcb..3853d5888 100644
--- a/src/client/views/StyleProvider.tsx
+++ b/src/client/views/StyleProvider.tsx
@@ -18,6 +18,7 @@ import "./collections/TreeView.scss";
 import "./nodes/FilterBox.scss";
 import React = require("react");
 import Color = require('color');
+import { FieldViewProps } from './nodes/FieldView';
 
 export enum StyleLayers {
     Background = "background"
diff --git a/src/client/views/collections/CollectionTreeView.tsx b/src/client/views/collections/CollectionTreeView.tsx
index a9e73583d..959864a60 100644
--- a/src/client/views/collections/CollectionTreeView.tsx
+++ b/src/client/views/collections/CollectionTreeView.tsx
@@ -59,7 +59,7 @@ export class CollectionTreeView extends CollectionSubView<Document, Partial<coll
     componentWillMount() {
         this._disposers.autoheight = reaction(() => this.rootDoc.autoHeight,
             auto => auto && this.computeHeight(),
-            { fireImmediately: true })
+            { fireImmediately: true });
     }
 
     refList: Set<any> = new Set();
diff --git a/src/client/views/collections/TreeView.tsx b/src/client/views/collections/TreeView.tsx
index 2c3a6c0d7..5df33afe0 100644
--- a/src/client/views/collections/TreeView.tsx
+++ b/src/client/views/collections/TreeView.tsx
@@ -174,7 +174,7 @@ export class TreeView extends React.Component<TreeViewProps> {
 
     componentWillUnmount() {
         this._selDisposer?.();
-        this._treeEle && this.props.unobserveHeight(this._treeEle)
+        this._treeEle && this.props.unobserveHeight(this._treeEle);
         document.removeEventListener("pointermove", this.onDragMove, true);
         document.removeEventListener("pointermove", this.onDragUp, true);
     }
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index ae5b79aec..30d7ed187 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -82,9 +82,8 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
     */
     @computed static get targetDoc() {
-        console.log("recomputing");
         if (FilterBox._filterScope === "Current Collection") {
-            return SelectionManager.Views()[0]?.Document.type === "collection" ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0]?.props.ContainingCollectionDoc!;
+            return SelectionManager.Views()[0]?.Document.type === DocumentType.COL ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0]?.props.ContainingCollectionDoc!;
         }
         else return CurrentUserUtils.ActiveDashboard;
     }
@@ -172,10 +171,10 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     public removeFilter = (filterName: string) => {
         const targetDoc = FilterBox.targetDoc;
         const filterDoc = targetDoc.currentFilter as Doc;
-        const attributes = DocListCast(filterDoc["data"]);
+        const attributes = DocListCast(filterDoc.data);
         const found = attributes.findIndex(doc => doc.title === filterName);
         if (found !== -1) {
-            (filterDoc["data"] as List<Doc>).splice(found, 1);
+            (filterDoc.data as List<Doc>).splice(found, 1);
             const docFilter = Cast(targetDoc._docFilters, listSpec("string"));
             if (docFilter) {
                 let index: number;
diff --git a/src/client/views/nodes/LinkDocPreview.tsx b/src/client/views/nodes/LinkDocPreview.tsx
index 45e3c8382..b73fb10df 100644
--- a/src/client/views/nodes/LinkDocPreview.tsx
+++ b/src/client/views/nodes/LinkDocPreview.tsx
@@ -26,7 +26,7 @@ interface LinkDocPreviewProps {
 @observer
 export class LinkDocPreview extends React.Component<LinkDocPreviewProps> {
     @action public static Clear() { LinkDocPreview.LinkInfo = undefined; }
-    @action public static SetLinkInfo(info?: LinkDocPreviewProps) { LinkDocPreview.LinkInfo != info && (LinkDocPreview.LinkInfo = info); }
+    @action public static SetLinkInfo(info?: LinkDocPreviewProps) { LinkDocPreview.LinkInfo !== info && (LinkDocPreview.LinkInfo = info); }
 
     _infoRef = React.createRef<HTMLDivElement>();
     @observable public static LinkInfo: Opt<LinkDocPreviewProps>;
-- 
cgit v1.2.3-70-g09d2


From a6d6eec7557325ef8a99f7cc545c17313afce9a1 Mon Sep 17 00:00:00 2001
From: usodhi <61431818+usodhi@users.noreply.github.com>
Date: Tue, 6 Apr 2021 13:09:32 -0400
Subject: added docrangefilters to updating filterdoc

---
 src/client/views/PropertiesView.tsx | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 782a0e29e..0b1d75970 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -916,9 +916,12 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
      * Creates a new currentFilter for this.filterDoc, 
      */
     createNewFilterDoc = () => {
-        const temp = this.filterDoc._docFilters;
+        const currentDocFilters = this.filterDoc._docFilters;
+        const currentDocRangeFilters = this.filterDoc._docRangeFilters;
         this.filterDoc._docFilters = new List<string>();
-        (this.filterDoc.currentFilter as Doc)._docFiltersList = temp;
+        this.filterDoc._docRangeFilters = new List<string>();
+        (this.filterDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
+        (this.filterDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
         this.filterDoc.currentFilter = undefined;
         CurrentUserUtils.setupFilterDocs(this.filterDoc);
     }
@@ -928,13 +931,21 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
      */
     updateFilterDoc = (doc: Doc) => {
         if (doc === this.filterDoc.currentFilter) return; // causes problems if you try to reapply the same doc
-        const temp = doc._docFiltersList;
-        const otherTemp = this.filterDoc._docFilters;
+        const savedDocFilters = doc._docFiltersList;
+        const currentDocFilters = this.filterDoc._docFilters;
         this.filterDoc._docFilters = new List<string>();
-        (this.filterDoc.currentFilter as Doc)._docFiltersList = otherTemp;
+        (this.filterDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
         this.filterDoc.currentFilter = doc;
         doc._docFiltersList = new List<string>();
-        this.filterDoc._docFilters = temp;
+        this.filterDoc._docFilters = savedDocFilters;
+
+        const savedDocRangeFilters = doc._docRangeFiltersList;
+        const currentDocRangeFilters = this.filterDoc._docRangeFilters;
+        this.filterDoc._docRangeFilters = new List<string>();
+        (this.filterDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
+        this.filterDoc.currentFilter = doc;
+        doc._docRangeFiltersList = new List<string>();
+        this.filterDoc._docRangeFilters = savedDocRangeFilters;
     }
 
     @computed get filtersSubMenu() {
-- 
cgit v1.2.3-70-g09d2


From 69563c0c81a3e6ade2fe460af8fad76cef3a3897 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 6 Apr 2021 18:39:20 -0400
Subject: reverted back to not setting 'system' for non-system documents.

---
 src/client/documents/Documents.ts                  | 2 +-
 src/client/views/PropertiesView.tsx                | 2 +-
 src/client/views/collections/CollectionSubView.tsx | 2 +-
 src/fields/Doc.ts                                  | 1 -
 4 files changed, 3 insertions(+), 4 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 65dd826ef..3b40f0cc7 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -652,7 +652,7 @@ export namespace Docs {
             const viewKeys = ["x", "y", "system"]; // keys that should be addded to the view document even though they don't begin with an "_"
             const { omit: dataProps, extract: viewProps } = OmitKeys(options, viewKeys, "^_");
 
-            dataProps.system = viewProps.system ? (viewProps.system) : (viewProps.system = false);
+            dataProps.system = viewProps.system;
             dataProps.isPrototype = true;
             dataProps.author = Doc.CurrentUserEmail;
             dataProps.creationDate = new DateField;
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 0b1d75970..92fe3acb5 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -28,7 +28,7 @@ import { PresBox } from "./nodes/PresBox";
 import { PropertiesButtons } from "./PropertiesButtons";
 import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector";
 import "./PropertiesView.scss";
-import { DefaultStyleProvider, FilteringStyleProvider } from "./StyleProvider";
+import { DefaultStyleProvider } from "./StyleProvider";
 import { CurrentUserUtils } from "../util/CurrentUserUtils";
 import { FilterBox } from "./nodes/FilterBox";
 import { List } from "../../fields/List";
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index bc5a6129c..b998555d8 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -122,7 +122,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             const docsforFilter: Doc[] = [];
             childDocs.forEach((d) => {
                 // if (DocUtils.Excluded(d, docFilters)) return;
-                let notFiltered = d.z || d.system || ((!searchDocs.length || searchDocs.includes(d)) && (DocUtils.FilterDocs([d], docFilters, docRangeFilters, viewSpecScript, this.props.Document).length > 0));
+                let notFiltered = d.z || Doc.IsSystem(d) || ((!searchDocs.length || searchDocs.includes(d)) && (DocUtils.FilterDocs([d], docFilters, docRangeFilters, viewSpecScript, this.props.Document).length > 0));
                 const fieldKey = Doc.LayoutFieldKey(d);
                 const annos = !Field.toString(Doc.LayoutField(d) as Field).includes("CollectionView");
                 const data = d[annos ? fieldKey + "-annotations" : fieldKey];
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 06b1b8539..01d0a8176 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1147,7 +1147,6 @@ export namespace Doc {
             dragFactory["dragFactory-count"] = NumCast(dragFactory["dragFactory-count"]) + 1;
             Doc.SetInPlace(ndoc, "title", ndoc.title + " " + NumCast(dragFactory["dragFactory-count"]).toString(), true);
         }
-        ndoc && (ndoc.system = false);
         return ndoc;
     }
     export function delegateDragFactory(dragFactory: Doc) {
-- 
cgit v1.2.3-70-g09d2


From 797ebbe8a82c54104a96c6e570310fb1d02da69c Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 7 Apr 2021 12:15:20 -0400
Subject: removed scope option for filters in favor of selecting dashboard.

---
 src/client/documents/Documents.ts    |  4 +--
 src/client/util/CurrentUserUtils.ts  |  2 +-
 src/client/views/PropertiesView.tsx  | 56 +++++++++++++++++-------------------
 src/client/views/nodes/FilterBox.tsx | 53 ++++++----------------------------
 4 files changed, 38 insertions(+), 77 deletions(-)

(limited to 'src/client/views/PropertiesView.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 3b40f0cc7..560806078 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1005,7 +1005,7 @@ export namespace DocUtils {
                     return Field.toString(d[facetKey] as Field).includes(value);
                 });
                 // if we're ORing them together, the default return is false, and we return true for a doc if it satisfies any one set of criteria
-                if (((FilterBox._filterScope === "Current Collection" ? parentCollection || CurrentUserUtils.ActiveDashboard : CurrentUserUtils.ActiveDashboard).currentFilter as Doc)?.filterBoolean === "OR") {
+                if ((parentCollection?.currentFilter as Doc)?.filterBoolean === "OR") {
                     if (satisfiesCheckFacets && !failsNotEqualFacets && satisfiesMatchFacets) return true;
                 }
                 // if we're ANDing them together, the default return is true, and we return false for a doc if it doesn't satisfy any set of criteria
@@ -1014,7 +1014,7 @@ export namespace DocUtils {
                 }
 
             }
-            return ((FilterBox._filterScope === "Current Collection" ? parentCollection || CurrentUserUtils.ActiveDashboard : CurrentUserUtils.ActiveDashboard).currentFilter as Doc)?.filterBoolean === "OR" ? false : true;
+            return (parentCollection?.currentFilter as Doc)?.filterBoolean === "OR" ? false : true;
         }) : childDocs;
         const rangeFilteredDocs = filteredDocs.filter(d => {
             for (let i = 0; i < docRangeFilters.length; i += 3) {
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 4b0a49180..417a1f405 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -806,7 +806,7 @@ export class CurrentUserUtils {
         // setup Filter item
         if (doc.currentFilter === undefined) {
             doc.currentFilter = Docs.Create.FilterDocument({
-                title: "FilterDoc", _height: 150,
+                title: "unnamed filter", _height: 150,
                 treeViewHideTitle: true, _xMargin: 5, _yMargin: 5, _gridGap: 5, _forceActive: true, childDropAction: "none",
                 treeViewTruncateTitleWidth: 150, ignoreClick: true,
                 _lockedPosition: true, boxShadow: "0 0", childDontRegisterViews: true, targetDropAction: "same", system: true, _autoHeight: true, _fitWidth: true
diff --git a/src/client/views/PropertiesView.tsx b/src/client/views/PropertiesView.tsx
index 92fe3acb5..bb0ad4c66 100644
--- a/src/client/views/PropertiesView.tsx
+++ b/src/client/views/PropertiesView.tsx
@@ -30,7 +30,6 @@ import { PropertiesDocContextSelector } from "./PropertiesDocContextSelector";
 import "./PropertiesView.scss";
 import { DefaultStyleProvider } from "./StyleProvider";
 import { CurrentUserUtils } from "../util/CurrentUserUtils";
-import { FilterBox } from "./nodes/FilterBox";
 import { List } from "../../fields/List";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
@@ -49,10 +48,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
     @computed get MAX_EMBED_HEIGHT() { return 200; }
 
-    @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc; }
-    @computed get filterDoc() {
-        return FilterBox._filterScope === "Current Collection" ? this.selectedDoc! : CurrentUserUtils.ActiveDashboard;
-    }
+    @computed get selectedDoc() { return SelectionManager.SelectedSchemaDoc() || this.selectedDocumentView?.rootDoc || CurrentUserUtils.ActiveDashboard; }
     @computed get selectedDocumentView() {
         if (SelectionManager.Views().length) return SelectionManager.Views()[0];
         if (PresBox.Instance?._selectedArray.size) return DocumentManager.Instance.getDocumentView(PresBox.Instance.rootDoc);
@@ -909,47 +905,47 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
      * If it doesn't exist, it creates it.
      */
     checkFilterDoc() {
-        if (this.filterDoc.type === DocumentType.COL && !this.filterDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.filterDoc);
+        if (this.selectedDoc.type === DocumentType.COL && !this.selectedDoc.currentFilter) CurrentUserUtils.setupFilterDocs(this.selectedDoc);
     }
 
     /**
      * Creates a new currentFilter for this.filterDoc, 
      */
     createNewFilterDoc = () => {
-        const currentDocFilters = this.filterDoc._docFilters;
-        const currentDocRangeFilters = this.filterDoc._docRangeFilters;
-        this.filterDoc._docFilters = new List<string>();
-        this.filterDoc._docRangeFilters = new List<string>();
-        (this.filterDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
-        (this.filterDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
-        this.filterDoc.currentFilter = undefined;
-        CurrentUserUtils.setupFilterDocs(this.filterDoc);
+        const currentDocFilters = this.selectedDoc._docFilters;
+        const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
+        this.selectedDoc._docFilters = new List<string>();
+        this.selectedDoc._docRangeFilters = new List<string>();
+        (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
+        (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
+        this.selectedDoc.currentFilter = undefined;
+        CurrentUserUtils.setupFilterDocs(this.selectedDoc);
     }
 
     /**
      * Updates this.filterDoc's currentFilter and saves the docFilters on the currentFilter
      */
     updateFilterDoc = (doc: Doc) => {
-        if (doc === this.filterDoc.currentFilter) return; // causes problems if you try to reapply the same doc
+        if (doc === this.selectedDoc.currentFilter) return; // causes problems if you try to reapply the same doc
         const savedDocFilters = doc._docFiltersList;
-        const currentDocFilters = this.filterDoc._docFilters;
-        this.filterDoc._docFilters = new List<string>();
-        (this.filterDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
-        this.filterDoc.currentFilter = doc;
+        const currentDocFilters = this.selectedDoc._docFilters;
+        this.selectedDoc._docFilters = new List<string>();
+        (this.selectedDoc.currentFilter as Doc)._docFiltersList = currentDocFilters;
+        this.selectedDoc.currentFilter = doc;
         doc._docFiltersList = new List<string>();
-        this.filterDoc._docFilters = savedDocFilters;
+        this.selectedDoc._docFilters = savedDocFilters;
 
         const savedDocRangeFilters = doc._docRangeFiltersList;
-        const currentDocRangeFilters = this.filterDoc._docRangeFilters;
-        this.filterDoc._docRangeFilters = new List<string>();
-        (this.filterDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
-        this.filterDoc.currentFilter = doc;
+        const currentDocRangeFilters = this.selectedDoc._docRangeFilters;
+        this.selectedDoc._docRangeFilters = new List<string>();
+        (this.selectedDoc.currentFilter as Doc)._docRangeFiltersList = currentDocRangeFilters;
+        this.selectedDoc.currentFilter = doc;
         doc._docRangeFiltersList = new List<string>();
-        this.filterDoc._docRangeFilters = savedDocRangeFilters;
+        this.selectedDoc._docRangeFilters = savedDocRangeFilters;
     }
 
     @computed get filtersSubMenu() {
-        return !(this.filterDoc?.currentFilter instanceof Doc) ? (null) : <div className="propertiesView-filters">
+        return !(this.selectedDoc?.currentFilter instanceof Doc) ? (null) : <div className="propertiesView-filters">
             <div className="propertiesView-filters-title"
                 onPointerDown={action(() => this.openFilters = !this.openFilters)}
                 style={{ backgroundColor: this.openFilters ? "black" : "" }}>
@@ -960,9 +956,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
             </div>
             {
                 !this.openFilters ? (null) :
-                    <div className="propertiesView-filters-content" style={{ height: this.filterDoc.currentFilter[HeightSym]() + 15 }}>
+                    <div className="propertiesView-filters-content" style={{ height: this.selectedDoc.currentFilter[HeightSym]() + 15 }}>
                         <DocumentView
-                            Document={this.filterDoc.currentFilter}
+                            Document={this.selectedDoc.currentFilter}
                             DataDoc={undefined}
                             addDocument={undefined}
                             addDocTab={returnFalse}
@@ -971,9 +967,9 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
                             removeDocument={returnFalse}
                             ScreenToLocalTransform={this.getTransform}
                             PanelWidth={() => this.props.width}
-                            PanelHeight={this.filterDoc.currentFilter[HeightSym]}
+                            PanelHeight={this.selectedDoc.currentFilter[HeightSym]}
                             renderDepth={0}
-                            scriptContext={this.filterDoc.currentFilter}
+                            scriptContext={this.selectedDoc.currentFilter}
                             focus={emptyFunction}
                             styleProvider={DefaultStyleProvider}
                             isContentActive={returnTrue}
diff --git a/src/client/views/nodes/FilterBox.tsx b/src/client/views/nodes/FilterBox.tsx
index d7f51c57b..05bb69d61 100644
--- a/src/client/views/nodes/FilterBox.tsx
+++ b/src/client/views/nodes/FilterBox.tsx
@@ -27,7 +27,6 @@ import Select from "react-select";
 import { UserOptions } from "../../util/GroupManager";
 import { DocumentViewProps } from "./DocumentView";
 import { DefaultStyleProvider, StyleProp } from "../StyleProvider";
-import { CollectionViewType } from "../collections/CollectionView";
 import { CurrentUserUtils } from "../../util/CurrentUserUtils";
 import { EditableView } from "../EditableView";
 import { undoBatch } from "../../util/UndoManager";
@@ -45,7 +44,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     }
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(FilterBox, fieldKey); }
 
-    @observable static _filterScope = "Current Dashboard";
     public _filterSelected = false;
     public _filterMatch = "matched";
 
@@ -82,10 +80,10 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
     * @returns the relevant doc according to the value of FilterBox._filterScope i.e. either the Current Dashboard or the Current Collection
     */
     @computed static get targetDoc() {
-        if (FilterBox._filterScope === "Current Collection") {
+        if (SelectionManager.Views().length) {
             return SelectionManager.Views()[0]?.Document.type === DocumentType.COL ? SelectionManager.Views()[0].Document : SelectionManager.Views()[0]?.props.ContainingCollectionDoc!;
         }
-        else return CurrentUserUtils.ActiveDashboard;
+        return CurrentUserUtils.ActiveDashboard;
     }
 
     @observable _loaded = false;
@@ -97,16 +95,17 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                 runInAction(() => this._loaded = true);
             }, { fireImmediately: true });
     }
+    @observable _allDocs = [] as Doc[];
     @computed get allDocs() {
         // trace();
-        const allDocs = new Set<Doc>();
         const targetDoc = FilterBox.targetDoc;
         if (this._loaded && targetDoc) {
+            const allDocs = new Set<Doc>();
             const activeTabs = DocListCast(targetDoc.data);
             SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allDocs.add(doc));
-            setTimeout(() => targetDoc.allDocuments = new List<Doc>(Array.from(allDocs)));
+            setTimeout(action(() => this._allDocs = Array.from(allDocs)));
         }
-        return allDocs;
+        return this._allDocs;
     }
 
     @computed get _allFacets() {
@@ -270,34 +269,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
         (FilterBox.targetDoc.currentFilter as Doc).filterBoolean = e.currentTarget.value;
     }
 
-    /**
-     * Changes the value of the variable that determines whether the filters should apply to the dashboard or the collection.
-     * 
-     * Saves the Dashboard's filters (on its currentFilter filterdoc) when it shifts to Current Collection so it doesn't get passed into this.props.docFIlters() in CollectionSubView (in the docFilters function).
-     */
-    @action
-    changeScope = (e: any) => {
-        if (FilterBox._filterScope === "Current Dashboard" && e.currentTarget.value === "Current Collection") {
-            const currentDashboardDocFilters = CurrentUserUtils.ActiveDashboard._docFilters;
-            CurrentUserUtils.ActiveDashboard._docFilters = new List<string>();
-            (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docFilterList = currentDashboardDocFilters;
-
-            const currentDashboardDocRangeFilters = CurrentUserUtils.ActiveDashboard._docRangeFilters;
-            CurrentUserUtils.ActiveDashboard._docRangeFilters = new List<string>();
-            (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docRangeFilterList = currentDashboardDocRangeFilters;
-        }
-        else if (FilterBox._filterScope === "Current Collection" && e.currentTarget.value === "Current Dashboard") {
-            const savedDashboardDocFilters = (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docFilterList;
-            (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docFilterList = undefined;
-            CurrentUserUtils.ActiveDashboard._docFilters = savedDashboardDocFilters;
-
-            const savedDashboardDocRangeFilters = (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docRangeFilterList;
-            (CurrentUserUtils.ActiveDashboard.currentFilter as Doc)._docRangeFilterList = undefined;
-            CurrentUserUtils.ActiveDashboard._docRangeFilters = savedDashboardDocRangeFilters;
-        }
-        FilterBox._filterScope = e.currentTarget.value;
-    }
-
     /**
      * Changes whether to select matched or unmatched documents
      */
@@ -415,14 +386,6 @@ export class FilterBox extends ViewBoxBaseComponent<FieldViewProps, FilterBoxDoc
                     <option value="OR" key="OR" selected={(FilterBox.targetDoc.currentFilter as Doc)?.filterBoolean === "OR"}>OR</option>
                 </select>
                 <div className="filterBox-select-text">filters in </div>
-                <select className="filterBox-selection" onChange={this.changeScope}>
-                    <option value="Current Dashboard" key="Current Dashboard" selected={"Current Dashboard" === FilterBox._filterScope}>Current Dashboard</option>
-                    {/* <option value="Current Tab" key="Current Tab">Current Tab</option> */}
-                    {SelectionManager.Views()?.[0].Document.type === DocumentType.COL ?
-                        <option value="Current Collection" key="Current Collection" selected={"Current Collection" === FilterBox._filterScope}>Current Collection</option>
-                        : (null)}
-
-                </select>
             </div>
 
             <div className="filterBox-select">
@@ -526,7 +489,9 @@ Scripting.addGlobal(function determineCheckedState(layoutDoc: Doc, facetHeader:
     return undefined;
 });
 Scripting.addGlobal(function readFacetData(layoutDoc: Doc, facetHeader: string) {
-    const allCollectionDocs = DocListCast(layoutDoc.allDocuments);
+    const allCollectionDocs = new Set<Doc>();
+    const activeTabs = DocListCast(layoutDoc.data);
+    SearchBox.foreachRecursiveDoc(activeTabs, (doc: Doc) => allCollectionDocs.add(doc));
     const set = new Set<string>();
     if (facetHeader === "tags") allCollectionDocs.forEach(child => Field.toString(child[facetHeader] as Field).split(":").forEach(key => set.add(key)));
     else allCollectionDocs.forEach(child => set.add(Field.toString(child[facetHeader] as Field)));
-- 
cgit v1.2.3-70-g09d2

