From 1bbbb660e8f1f5e0165e4ab6d3d4ac1340cb2e23 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 8 Apr 2020 23:23:52 -0700
Subject: menu no longer buried under search resuslts, filter booleans now
 passed onto new search docs, and minor ui tweaks

---
 src/client/views/search/SearchBox.tsx | 51 ++++++++++++++++++++++++++---------
 1 file changed, 38 insertions(+), 13 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 49b6b18ca..bc77bff2e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -19,13 +19,14 @@ import { FieldView } from '../nodes/FieldView';
 import { DocumentType } from "../../documents/DocumentTypes";
 import { DocumentView } from '../nodes/DocumentView';
 import { SelectionManager } from '../../util/SelectionManager';
+import { FilterQuery } from 'mongodb';
 
 library.add(faTimes);
 
 export interface SearchProps {
     id: string;
     searchQuery?: string;
-    filterQquery?: string;
+    filterQuery?: filterData;
 }
 
 export enum Keys {
@@ -34,6 +35,13 @@ export enum Keys {
     DATA = "data"
 }
 
+export interface filterData{
+    deletedDocsStatus: boolean;
+    authorFieldStatus: boolean;
+    titleFieldStatus:boolean;
+    basicWordStatus:boolean;
+    icons: string[];
+}
 @observer
 export class SearchBox extends React.Component<SearchProps> {
 
@@ -65,6 +73,7 @@ export class SearchBox extends React.Component<SearchProps> {
     @observable private _nodeStatus: boolean = false;
     @observable private _keyStatus: boolean = false;
 
+    @observable private newAssign: boolean = true;
 
     constructor(props: any) {
         super(props);
@@ -77,9 +86,18 @@ export class SearchBox extends React.Component<SearchProps> {
             this.inputRef.current.focus();
             runInAction(() => this._searchbarOpen = true);
         }
-        if (this.props.searchQuery && this.props.filterQquery) {
+        if (this.props.searchQuery && this.props.filterQuery && this.newAssign) {
             console.log(this.props.searchQuery);
             const sq = this.props.searchQuery;
+            runInAction(() => {
+
+            this._deletedDocsStatus=this.props.filterQuery!.deletedDocsStatus;
+            this._authorFieldStatus=this.props.filterQuery!.authorFieldStatus
+            this._titleFieldStatus=this.props.filterQuery!.titleFieldStatus;
+            this._basicWordStatus=this.props.filterQuery!.basicWordStatus;
+            this._icons=this.props.filterQuery!.icons;
+            this.newAssign=false;
+            });
             runInAction(() => {
                 this._searchString = sq;
                 this.submitSearch();
@@ -166,10 +184,10 @@ export class SearchBox extends React.Component<SearchProps> {
         }
 
         //if should be searched in a specific collection
-        if (this._collectionStatus) {
-            query = this.addCollectionFilter(query);
-            query = query.replace(/\s+/g, ' ').trim();
-        }
+        // if (this._collectionStatus) {
+        //     query = this.addCollectionFilter(query);
+        //     query = query.replace(/\s+/g, ' ').trim();
+        // }
         return query;
     }
 
@@ -416,7 +434,14 @@ export class SearchBox extends React.Component<SearchProps> {
                 y += 300;
             }
         }
-        return Docs.Create.QueryDocument({ _autoHeight: true, title: this._searchString, filterQuery: this.filterQuery, searchQuery: this._searchString });
+        const filter : filterData = {
+            deletedDocsStatus: this._deletedDocsStatus,
+            authorFieldStatus: this._authorFieldStatus,
+            titleFieldStatus: this._titleFieldStatus,
+            basicWordStatus: this._basicWordStatus,
+            icons: this._icons,
+        }
+        return Docs.Create.QueryDocument({ _autoHeight: true, title: this._searchString, filterQuery: filter, searchQuery: this._searchString });
     }
 
     @action.bound
@@ -450,10 +475,10 @@ export class SearchBox extends React.Component<SearchProps> {
         const scrollY = e ? e.currentTarget.scrollTop : this._resultsRef.current ? this._resultsRef.current.scrollTop : 0;
         const itemHght = 53;
         const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
-        const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this._resultsRef.current.getBoundingClientRect().height / itemHght)));
-
+        //const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this._resultsRef.current.getBoundingClientRect().height / itemHght)));
+        const endIndex= 30;
         this._endIndex = endIndex === -1 ? 12 : endIndex;
-
+        this._endIndex=30;
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             this._visibleElements = [<div className="no-result">No Search Results</div>];
             return;
@@ -649,11 +674,11 @@ export class SearchBox extends React.Component<SearchProps> {
                     <input value={this._searchString} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
                         style={{ width: this._searchbarOpen ? "500px" : "100px" }} />
-                    <button className="searchBox-barChild searchBox-filter" title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
+                    <button className="searchBox-barChild searchBox-filter" style={{transform:"none"}} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
                 </div>
 
-                <div id={`filterhead${this.props.id}`} className="filter-form" >
-                    <div id={`filterhead2${this.props.id}`} className="filter-header" style={this._filterOpen ? {} : {}}>
+                <div id={`filterhead${this.props.id}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
+                    <div id={`filterhead2${this.props.id}`} className="filter-header"  >
                         <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button>
                         <button className="filter-item" style={this._keyStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleKeyChange}>Keys</button>
                         <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button>
-- 
cgit v1.2.3-70-g09d2


From 5cad16a30c983690f5a2b9c14fa59779df933df3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 14 Apr 2020 22:14:47 -0700
Subject: adding linear doc wrapper to docs in seaarch menu

---
 solr-8.3.1/bin/solr-8983.pid          |   2 +-
 src/client/views/SearchDocBox.tsx     | 432 ----------------------------------
 src/client/views/nodes/QueryBox.tsx   |   2 +-
 src/client/views/search/SearchBox.tsx |  97 +++++++-
 4 files changed, 95 insertions(+), 438 deletions(-)
 delete mode 100644 src/client/views/SearchDocBox.tsx

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 5fee47e8f..657969121 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-81262
+5763
diff --git a/src/client/views/SearchDocBox.tsx b/src/client/views/SearchDocBox.tsx
deleted file mode 100644
index cd9666af8..000000000
--- a/src/client/views/SearchDocBox.tsx
+++ /dev/null
@@ -1,432 +0,0 @@
-import { library } from "@fortawesome/fontawesome-svg-core";
-import { faBullseye, faLink } from "@fortawesome/free-solid-svg-icons";
-import { action, computed, observable, runInAction } from "mobx";
-import { observer } from "mobx-react";
-//import "./SearchBoxDoc.scss";
-import { Doc, DocListCast } from "../../new_fields/Doc";
-import { Id } from "../../new_fields/FieldSymbols";
-import { BoolCast, Cast, NumCast, StrCast } from "../../new_fields/Types";
-import { returnFalse } from "../../Utils";
-import { Docs } from "../documents/Documents";
-import { SearchUtil } from "../util/SearchUtil";
-import { EditableView } from "./EditableView";
-import { ContentFittingDocumentView } from "./nodes/ContentFittingDocumentView";
-import { FieldView, FieldViewProps } from "./nodes/FieldView";
-import { FilterBox } from "./search/FilterBox";
-import { SearchItem } from "./search/SearchItem";
-import React = require("react");
-
-export interface RecProps {
-    documents: { preview: Doc, similarity: number }[];
-    node: Doc;
-
-}
-
-library.add(faBullseye, faLink);
-export const keyPlaceholder = "Query";
-
-@observer
-export class SearchDocBox extends React.Component<FieldViewProps> {
-
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchDocBox, fieldKey); }
-
-    // @observable private _display: boolean = false;
-    @observable private _pageX: number = 0;
-    @observable private _pageY: number = 0;
-    @observable private _width: number = 0;
-    @observable private _height: number = 0;
-    @observable.shallow private _docViews: JSX.Element[] = [];
-    // @observable private _documents: { preview: Doc, score: number }[] = [];
-    private previewDocs: Doc[] = [];
-
-    constructor(props: FieldViewProps) {
-        super(props);
-        this.editingMetadata = this.editingMetadata || false;
-        //SearchBox.Instance = this;
-        this.resultsScrolled = this.resultsScrolled.bind(this);
-    }
-
-
-    @computed
-    private get editingMetadata() {
-        return BoolCast(this.props.Document.editingMetadata);
-    }
-
-    private set editingMetadata(value: boolean) {
-        this.props.Document.editingMetadata = value;
-    }
-
-    static readonly buffer = 20;
-
-    componentDidMount() {
-        runInAction(() => {
-            console.log("didit"
-            );
-            this.query = StrCast(this.props.Document.searchText);
-            this.content = (Docs.Create.TreeDocument(DocListCast(Doc.GetProto(this.props.Document).data), { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs:` + this.query }));
-
-        });
-        if (this.inputRef.current) {
-            this.inputRef.current.focus();
-            runInAction(() => {
-                this._searchbarOpen = true;
-            });
-        }
-    }
-
-    @observable
-    private content: Doc | undefined;
-
-    @action
-    updateKey = async (newKey: string) => {
-        this.query = newKey;
-        if (newKey.length > 1) {
-            let newdocs = await this.getAllResults(this.query);
-            let things = newdocs.docs
-            console.log(things);
-            console.log(this.content);
-            runInAction(() => {
-                this.content = Docs.Create.TreeDocument(things, { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs:` + this.query });
-            });
-            console.log(this.content);
-        }
-
-
-        //this.keyRef.current && this.keyRef.current.setIsFocused(false);
-        //this.query.length === 0 && (this.query = keyPlaceholder);
-        return true;
-    }
-
-    @computed
-    public get query() {
-        return StrCast(this.props.Document.query);
-    }
-
-    public set query(value: string) {
-        this.props.Document.query = value;
-    }
-
-    @observable private _searchString: string = "";
-    @observable private _resultsOpen: boolean = false;
-    @observable private _searchbarOpen: boolean = false;
-    @observable private _results: [Doc, string[], string[]][] = [];
-    private _resultsSet = new Map<Doc, number>();
-    @observable private _openNoResults: boolean = false;
-    @observable private _visibleElements: JSX.Element[] = [];
-
-    private resultsRef = React.createRef<HTMLDivElement>();
-    public inputRef = React.createRef<HTMLInputElement>();
-
-    private _isSearch: ("search" | "placeholder" | undefined)[] = [];
-    private _numTotalResults = -1;
-    private _endIndex = -1;
-
-
-    private _maxSearchIndex: number = 0;
-    private _curRequest?: Promise<any> = undefined;
-
-    @action
-    getViews = async (doc: Doc) => {
-        const results = await SearchUtil.GetViewsOfDocument(doc);
-        let toReturn: Doc[] = [];
-        await runInAction(() => {
-            toReturn = results;
-        });
-        return toReturn;
-    }
-
-    @action.bound
-    onChange(e: React.ChangeEvent<HTMLInputElement>) {
-        this._searchString = e.target.value;
-
-        this._openNoResults = false;
-        this._results = [];
-        this._resultsSet.clear();
-        this._visibleElements = [];
-        this._numTotalResults = -1;
-        this._endIndex = -1;
-        this._curRequest = undefined;
-        this._maxSearchIndex = 0;
-    }
-
-    enter = async (e: React.KeyboardEvent) => {
-        console.log(e.key);
-        if (e.key === "Enter") {
-            let newdocs = await this.getAllResults(this.query)
-            let things = newdocs.docs
-            console.log(things);
-            this.content = Docs.Create.TreeDocument(things, { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs: "Results"` });
-
-        }
-    }
-
-
-    @action
-    submitSearch = async () => {
-        let query = this._searchString;
-        query = FilterBox.Instance.getFinalQuery(query);
-        this._results = [];
-        this._resultsSet.clear();
-        this._isSearch = [];
-        this._visibleElements = [];
-        FilterBox.Instance.closeFilter();
-
-        //if there is no query there should be no result
-        if (query === "") {
-            return;
-        }
-        else {
-            this._endIndex = 12;
-            this._maxSearchIndex = 0;
-            this._numTotalResults = -1;
-            await this.getResults(query);
-        }
-
-        runInAction(() => {
-            this._resultsOpen = true;
-            this._searchbarOpen = true;
-            this._openNoResults = true;
-            this.resultsScrolled();
-        });
-    }
-
-    getAllResults = async (query: string) => {
-        return SearchUtil.Search(query, true, { fq: this.filterQuery, start: 0, rows: 10000000 });
-    }
-
-    private get filterQuery() {
-        const types = FilterBox.Instance.filterTypes;
-        const includeDeleted = FilterBox.Instance.getDataStatus();
-        return "NOT baseProto_b:true" + (includeDeleted ? "" : " AND NOT deleted_b:true") + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}" OR type_t:"extension"`).join(" ")})` : "");
-    }
-
-
-    private NumResults = 25;
-    private lockPromise?: Promise<void>;
-    getResults = async (query: string) => {
-        if (this.lockPromise) {
-            await this.lockPromise;
-        }
-        this.lockPromise = new Promise(async res => {
-            while (this._results.length <= this._endIndex && (this._numTotalResults === -1 || this._maxSearchIndex < this._numTotalResults)) {
-                this._curRequest = SearchUtil.Search(query, true, { fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*" }).then(action(async (res: SearchUtil.DocSearchResult) => {
-
-                    // happens at the beginning
-                    if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
-                        this._numTotalResults = res.numFound;
-                    }
-
-                    const highlighting = res.highlighting || {};
-                    const highlightList = res.docs.map(doc => highlighting[doc[Id]]);
-                    const lines = new Map<string, string[]>();
-                    res.docs.map((doc, i) => lines.set(doc[Id], res.lines[i]));
-                    const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc));
-                    const highlights: typeof res.highlighting = {};
-                    docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
-                    const filteredDocs = FilterBox.Instance.filterDocsByType(docs);
-                    runInAction(() => {
-                        // this._results.push(...filteredDocs);
-                        filteredDocs.forEach(doc => {
-                            const index = this._resultsSet.get(doc);
-                            const highlight = highlights[doc[Id]];
-                            const line = lines.get(doc[Id]) || [];
-                            const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
-                            if (index === undefined) {
-                                this._resultsSet.set(doc, this._results.length);
-                                this._results.push([doc, hlights, line]);
-                            } else {
-                                this._results[index][1].push(...hlights);
-                                this._results[index][2].push(...line);
-                            }
-                        });
-                    });
-
-                    this._curRequest = undefined;
-                }));
-                this._maxSearchIndex += this.NumResults;
-
-                await this._curRequest;
-            }
-            this.resultsScrolled();
-            res();
-        });
-        return this.lockPromise;
-    }
-
-    collectionRef = React.createRef<HTMLSpanElement>();
-    startDragCollection = async () => {
-        const res = await this.getAllResults(FilterBox.Instance.getFinalQuery(this._searchString));
-        const filtered = FilterBox.Instance.filterDocsByType(res.docs);
-        // console.log(this._results)
-        const docs = filtered.map(doc => {
-            const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
-            if (isProto) {
-                return Doc.MakeDelegate(doc);
-            } else {
-                return Doc.MakeAlias(doc);
-            }
-        });
-        let x = 0;
-        let y = 0;
-        for (const doc of docs.map(d => Doc.Layout(d))) {
-            doc.x = x;
-            doc.y = y;
-            const size = 200;
-            const aspect = NumCast(doc._nativeHeight) / NumCast(doc._nativeWidth, 1);
-            if (aspect > 1) {
-                doc._height = size;
-                doc._width = size / aspect;
-            } else if (aspect > 0) {
-                doc._width = size;
-                doc._height = size * aspect;
-            } else {
-                doc._width = size;
-                doc._height = size;
-            }
-            x += 250;
-            if (x > 1000) {
-                x = 0;
-                y += 300;
-            }
-        }
-        //return Docs.Create.TreeDocument(docs, { _width: 200, _height: 400, backgroundColor: "grey", title: `Search Docs: "${this._searchString}"` });
-        return Docs.Create.QueryDocument(docs, { _width: 200, _height: 400, searchText: this._searchString, title: `Query Docs: "${this._searchString}"` });
-    }
-
-    @action.bound
-    openSearch(e: React.SyntheticEvent) {
-        e.stopPropagation();
-        this._openNoResults = false;
-        FilterBox.Instance.closeFilter();
-        this._resultsOpen = true;
-        this._searchbarOpen = true;
-        FilterBox.Instance._pointerTime = e.timeStamp;
-    }
-
-    @action.bound
-    closeSearch = () => {
-        FilterBox.Instance.closeFilter();
-        this.closeResults();
-        this._searchbarOpen = false;
-    }
-
-    @action.bound
-    closeResults() {
-        this._resultsOpen = false;
-        this._results = [];
-        this._resultsSet.clear();
-        this._visibleElements = [];
-        this._numTotalResults = -1;
-        this._endIndex = -1;
-        this._curRequest = undefined;
-    }
-
-    @action
-    resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
-        if (!this.resultsRef.current) return;
-        const scrollY = e ? e.currentTarget.scrollTop : this.resultsRef.current ? this.resultsRef.current.scrollTop : 0;
-        const itemHght = 53;
-        const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
-        const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this.resultsRef.current.getBoundingClientRect().height / itemHght)));
-
-        this._endIndex = endIndex === -1 ? 12 : endIndex;
-
-        if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
-            this._visibleElements = [<div className="no-result">No Search Results</div>];
-            return;
-        }
-
-        if (this._numTotalResults <= this._maxSearchIndex) {
-            this._numTotalResults = this._results.length;
-        }
-
-        // only hit right at the beginning
-        // visibleElements is all of the elements (even the ones you can't see)
-        else if (this._visibleElements.length !== this._numTotalResults) {
-            // undefined until a searchitem is put in there
-            this._visibleElements = Array<JSX.Element>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-            // indicates if things are placeholders
-            this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-        }
-
-        for (let i = 0; i < this._numTotalResults; i++) {
-            //if the index is out of the window then put a placeholder in
-            //should ones that have already been found get set to placeholders?
-            if (i < startIndex || i > endIndex) {
-                if (this._isSearch[i] !== "placeholder") {
-                    this._isSearch[i] = "placeholder";
-                    this._visibleElements[i] = <div className="searchBox-placeholder" key={`searchBox-placeholder-${i}`}>Loading...</div>;
-                }
-            }
-            else {
-                if (this._isSearch[i] !== "search") {
-                    let result: [Doc, string[], string[]] | undefined = undefined;
-                    if (i >= this._results.length) {
-                        this.getResults(this._searchString);
-                        if (i < this._results.length) result = this._results[i];
-                        if (result) {
-                            const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
-                            this._isSearch[i] = "search";
-                        }
-                    }
-                    else {
-                        result = this._results[i];
-                        if (result) {
-                            const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
-                            this._isSearch[i] = "search";
-                        }
-                    }
-                }
-            }
-        }
-        if (this._maxSearchIndex >= this._numTotalResults) {
-            this._visibleElements.length = this._results.length;
-            this._isSearch.length = this._results.length;
-        }
-    }
-
-    @computed
-    get resFull() { return this._numTotalResults <= 8; }
-
-    @computed
-    get resultHeight() { return this._numTotalResults * 70; }
-
-    render() {
-        const isEditing = this.editingMetadata;
-        return (
-            <div style={{ pointerEvents: "all" }}>
-                <ContentFittingDocumentView {...this.props}
-                    Document={this.content}
-                    rootSelected={returnFalse}
-                    getTransform={this.props.ScreenToLocalTransform}>
-                </ContentFittingDocumentView>
-                <div
-                    style={{
-                        position: "absolute",
-                        right: 0,
-                        width: 20,
-                        height: 20,
-                        background: "black",
-                        pointerEvents: "all",
-                        opacity: 1,
-                        transition: "0.4s opacity ease",
-                        zIndex: 99,
-                        top: 0,
-                    }}
-                    title={"Add Metadata"}
-                    onClick={action(() => { this.editingMetadata = !this.editingMetadata })}
-                />
-                <div className="editableclass" onKeyPress={this.enter} style={{ opacity: isEditing ? 1 : 0, pointerEvents: isEditing ? "auto" : "none", transition: "0.4s opacity ease", position: "absolute", top: 0, left: 0, height: 20, width: "-webkit-fill-available" }}>
-                    <EditableView
-                        contents={this.query}
-                        SetValue={this.updateKey}
-                        GetValue={() => ""}
-                    />
-                </div>
-            </div >
-        );
-    }
-
-}
\ No newline at end of file
diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index 419768719..1b3f6280a 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -28,7 +28,7 @@ export class QueryBox extends DocAnnotatableComponent<FieldViewProps, QueryDocum
     render() {
         const dragging = !SelectionManager.GetIsDragging() ? "" : "-dragging";
         return <div className={`queryBox${dragging}`} onWheel={(e) => e.stopPropagation()} >
-            <SearchBox id={this.props.Document[Id]} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
+            <SearchBox id={this.props.Document[Id]} Document={this.props.Document} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
         </div >;
     }
 }
\ No newline at end of file
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index bc77bff2e..f23525bdb 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -8,9 +8,9 @@ import * as rp from 'request-promise';
 import { Doc } from '../../../new_fields/Doc';
 import { Id } from '../../../new_fields/FieldSymbols';
 import { Cast, NumCast, StrCast } from '../../../new_fields/Types';
-import { Utils } from '../../../Utils';
-import { Docs } from '../../documents/Documents';
-import { SetupDrag } from '../../util/DragManager';
+import { Utils, returnTrue, emptyFunction, returnFalse, emptyPath, returnOne } from '../../../Utils';
+import { Docs, DocumentOptions } from '../../documents/Documents';
+import { SetupDrag, DragManager } from '../../util/DragManager';
 import { SearchUtil } from '../../util/SearchUtil';
 import "./SearchBox.scss";
 import { SearchItem } from './SearchItem';
@@ -20,11 +20,20 @@ import { DocumentType } from "../../documents/DocumentTypes";
 import { DocumentView } from '../nodes/DocumentView';
 import { SelectionManager } from '../../util/SelectionManager';
 import { FilterQuery } from 'mongodb';
+import { CollectionLinearView } from '../collections/CollectionLinearView';
+import { CurrentUserUtils } from '../../../server/authentication/models/current_user_utils';
+import { CollectionDockingView } from '../collections/CollectionDockingView';
+import { ScriptField } from '../../../new_fields/ScriptField';
+import { PrefetchProxy } from '../../../new_fields/Proxy';
+import { List } from '../../../new_fields/List';
+import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
+
 
 library.add(faTimes);
 
 export interface SearchProps {
     id: string;
+    Document: Doc;
     searchQuery?: string;
     filterQuery?: filterData;
 }
@@ -80,8 +89,14 @@ export class SearchBox extends React.Component<SearchProps> {
         SearchBox.Instance = this;
         this.resultsScrolled = this.resultsScrolled.bind(this);
     }
-
+    @observable setupButtons =false;
     componentDidMount = () => {
+        console.log(this.setupButtons);
+        if (this.setupButtons==false){
+        console.log("Yuh");
+            this.setupDocTypeButtons();
+        runInAction(()=>this.setupButtons==true);
+    }
         if (this.inputRef.current) {
             this.inputRef.current.focus();
             runInAction(() => this._searchbarOpen = true);
@@ -663,6 +678,79 @@ export class SearchBox extends React.Component<SearchProps> {
     @action.bound
     updateDataStatus() { this._deletedDocsStatus = !this._deletedDocsStatus; }
 
+    addButtonDoc = (doc: Doc) => Doc.AddDocToList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
+    remButtonDoc = (doc: Doc) => Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
+    moveButtonDoc = (doc: Doc, targetCollection: Doc | undefined, addDocument: (document: Doc) => boolean) => this.remButtonDoc(doc) && addDocument(doc);
+    
+    @computed get docButtons() {
+        const nodeBtns = this.props.Document.nodeButtons;
+        if (nodeBtns instanceof Doc) {
+            return <div id="hi">
+                <CollectionLinearView
+                    Document={nodeBtns}
+                    DataDoc={undefined}
+                    LibraryPath={emptyPath}
+                    fieldKey={"data"}
+                    dropAction={"alias"}
+                    annotationsKey={""}
+                    rootSelected={returnTrue}
+                    bringToFront={emptyFunction}
+                    select={emptyFunction}
+                    active={returnFalse}
+                    isSelected={returnFalse}
+                    moveDocument={this.moveButtonDoc}
+                    CollectionView={undefined}
+                    addDocument={this.addButtonDoc}
+                    addDocTab={returnFalse}
+                    pinToPres={emptyFunction}
+                    removeDocument={this.remButtonDoc}
+                    onClick={undefined}
+                    ScreenToLocalTransform={this.buttonBarXf}
+                    ContentScaling={returnOne}
+                    PanelWidth={this.flyoutWidthFunc}
+                    PanelHeight={this.getContentsHeight}
+                    renderDepth={0}
+                    focus={emptyFunction}
+                    whenActiveChanged={emptyFunction}
+                    ContainingCollectionView={undefined}
+                    ContainingCollectionDoc={undefined} />
+            </div>;
+        }
+        return (null);
+    }
+
+    setupDocTypeButtons() {
+        let doc = this.props.Document;
+        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, dontDecorateSelection: true, dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
+        const blist = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, {
+            ...opts,
+            _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", dontDecorateSelection: true, forceActive: true,
+            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }),
+            backgroundColor: "black", treeViewPreventOpen: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true
+        })) as any as Doc;
+
+
+        doc.None = ficon({ onClick: undefined, title: "none button", icon: "ban" });
+        doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
+        doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
+        doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
+        doc.Image = ficon({ onClick: undefined, title: "image button", icon: "image" });
+        doc.Link = ficon({ onClick: undefined, title: "link button", icon: "link" });
+        doc.PDF = ficon({ onClick: undefined, title: "pdf button", icon: "file-pdf" });
+        doc.TEXT = ficon({ onClick: undefined, title: "text button", icon: "sticky-note" });
+        doc.Vid = ficon({ onClick: undefined, title: "vid button", icon: "video" });
+        doc.Web = ficon({ onClick: undefined, title: "web button", icon: "globe-asia" });
+
+        let buttons = [doc.None as Doc, doc.Music as Doc, doc.Col as Doc, doc.Hist as Doc,
+        doc.Image as Doc, doc.Link as Doc, doc.PDF as Doc, doc.TEXT as Doc, doc.Vid as Doc, doc.Web as Doc];
+
+        const dragCreators = Docs.Create.MasonryDocument(CurrentUserUtils.setupCreatorButtons(doc), {
+            _width: 500, _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
+            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
+        });
+        doc.nodeButtons= dragCreators;
+    }
+
     render() {
 
         return (
@@ -685,6 +773,7 @@ export class SearchBox extends React.Component<SearchProps> {
                     </div>
                     <div id={`node${this.props.id}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         <IconBar />
+                        {this.docButtons}
                     </div>
                     <div className="filter-key" id={`key${this.props.id}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         <div className="filter-keybar">
-- 
cgit v1.2.3-70-g09d2


From c7c146adbd0b188eba56139ab914edaf73774d3f Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 15 Apr 2020 19:07:01 -0700
Subject: search menu is now partially a nested document

---
 src/client/views/nodes/QueryBox.tsx   |  7 +++-
 src/client/views/search/SearchBox.tsx | 76 +++++++++++++++++------------------
 2 files changed, 44 insertions(+), 39 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index 1b3f6280a..04f815e91 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -26,9 +26,14 @@ export class QueryBox extends DocAnnotatableComponent<FieldViewProps, QueryDocum
     }
 
     render() {
+        let side = false;
+        if (this.dataDoc.searchQuery===undefined){
+            console.log("YAAA");
+            side = true;
+        }
         const dragging = !SelectionManager.GetIsDragging() ? "" : "-dragging";
         return <div className={`queryBox${dragging}`} onWheel={(e) => e.stopPropagation()} >
-            <SearchBox id={this.props.Document[Id]} Document={this.props.Document} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
+            <SearchBox id={this.props.Document[Id]} sideBar={side} Document={this.props.Document} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
         </div >;
     }
 }
\ No newline at end of file
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index f23525bdb..532b151c5 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -8,7 +8,7 @@ import * as rp from 'request-promise';
 import { Doc } from '../../../new_fields/Doc';
 import { Id } from '../../../new_fields/FieldSymbols';
 import { Cast, NumCast, StrCast } from '../../../new_fields/Types';
-import { Utils, returnTrue, emptyFunction, returnFalse, emptyPath, returnOne } from '../../../Utils';
+import { Utils, returnTrue, emptyFunction, returnFalse, emptyPath, returnOne, returnEmptyString } from '../../../Utils';
 import { Docs, DocumentOptions } from '../../documents/Documents';
 import { SetupDrag, DragManager } from '../../util/DragManager';
 import { SearchUtil } from '../../util/SearchUtil';
@@ -27,6 +27,8 @@ import { ScriptField } from '../../../new_fields/ScriptField';
 import { PrefetchProxy } from '../../../new_fields/Proxy';
 import { List } from '../../../new_fields/List';
 import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
+import { Transform } from '../../util/Transform';
+import { MainView } from "../MainView";
 
 
 library.add(faTimes);
@@ -34,6 +36,7 @@ library.add(faTimes);
 export interface SearchProps {
     id: string;
     Document: Doc;
+    sideBar?: Boolean;
     searchQuery?: string;
     filterQuery?: filterData;
 }
@@ -508,7 +511,7 @@ export class SearchBox extends React.Component<SearchProps> {
         else if (this._visibleElements.length !== this._numTotalResults) {
             // undefined until a searchitem is put in there
             this._visibleElements = Array<JSX.Element>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-            // indicates if things are placeholders
+            // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
         }
 
@@ -684,36 +687,37 @@ export class SearchBox extends React.Component<SearchProps> {
     
     @computed get docButtons() {
         const nodeBtns = this.props.Document.nodeButtons;
+        let width = () => NumCast(this.props.Document.width);
+        if (this.props.sideBar===true){
+            width = MainView.Instance.flyoutWidthFunc;
+        }
         if (nodeBtns instanceof Doc) {
-            return <div id="hi">
-                <CollectionLinearView
-                    Document={nodeBtns}
-                    DataDoc={undefined}
-                    LibraryPath={emptyPath}
-                    fieldKey={"data"}
-                    dropAction={"alias"}
-                    annotationsKey={""}
-                    rootSelected={returnTrue}
-                    bringToFront={emptyFunction}
-                    select={emptyFunction}
-                    active={returnFalse}
-                    isSelected={returnFalse}
-                    moveDocument={this.moveButtonDoc}
-                    CollectionView={undefined}
-                    addDocument={this.addButtonDoc}
-                    addDocTab={returnFalse}
-                    pinToPres={emptyFunction}
-                    removeDocument={this.remButtonDoc}
-                    onClick={undefined}
-                    ScreenToLocalTransform={this.buttonBarXf}
-                    ContentScaling={returnOne}
-                    PanelWidth={this.flyoutWidthFunc}
-                    PanelHeight={this.getContentsHeight}
-                    renderDepth={0}
-                    focus={emptyFunction}
-                    whenActiveChanged={emptyFunction}
-                    ContainingCollectionView={undefined}
-                    ContainingCollectionDoc={undefined} />
+            return <div id="hi" style={{height:"100px",}}>
+                <DocumentView
+                Document={nodeBtns}
+                DataDoc={undefined}
+                LibraryPath={emptyPath}
+                addDocument={undefined}
+                addDocTab={returnFalse}
+                rootSelected={returnTrue}
+                pinToPres={emptyFunction}
+                onClick={undefined}
+                removeDocument={undefined}
+                ScreenToLocalTransform={Transform.Identity}
+                ContentScaling={returnOne}
+                PanelWidth={width}
+                PanelHeight={() => 100}
+                renderDepth={0}
+                backgroundColor={returnEmptyString}
+                focus={emptyFunction}
+                parentActive={returnTrue}
+                whenActiveChanged={emptyFunction}
+                bringToFront={emptyFunction}
+                ContainingCollectionView={undefined}
+                ContainingCollectionDoc={undefined}
+                zoomToScale={emptyFunction}
+                getScale={returnOne}
+            />
             </div>;
         }
         return (null);
@@ -721,16 +725,13 @@ export class SearchBox extends React.Component<SearchProps> {
 
     setupDocTypeButtons() {
         let doc = this.props.Document;
-        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, dontDecorateSelection: true, dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
+        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts, dontDecorateSelection: true, backgroundColor: "#121721", dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
         const blist = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, {
             ...opts,
             _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", dontDecorateSelection: true, forceActive: true,
             dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }),
             backgroundColor: "black", treeViewPreventOpen: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true
         })) as any as Doc;
-
-
-        doc.None = ficon({ onClick: undefined, title: "none button", icon: "ban" });
         doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
         doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
         doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
@@ -744,8 +745,8 @@ export class SearchBox extends React.Component<SearchProps> {
         let buttons = [doc.None as Doc, doc.Music as Doc, doc.Col as Doc, doc.Hist as Doc,
         doc.Image as Doc, doc.Link as Doc, doc.PDF as Doc, doc.TEXT as Doc, doc.Vid as Doc, doc.Web as Doc];
 
-        const dragCreators = Docs.Create.MasonryDocument(CurrentUserUtils.setupCreatorButtons(doc), {
-            _width: 500, _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
+        const dragCreators = Docs.Create.MasonryDocument(buttons, {
+            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
             dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
         });
         doc.nodeButtons= dragCreators;
@@ -772,7 +773,6 @@ export class SearchBox extends React.Component<SearchProps> {
                         <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button>
                     </div>
                     <div id={`node${this.props.id}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-                        <IconBar />
                         {this.docButtons}
                     </div>
                     <div className="filter-key" id={`key${this.props.id}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-- 
cgit v1.2.3-70-g09d2


From a4ed4ba21dbbc802f3512d3c06fdc94a38f56e87 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 20 Apr 2020 22:00:39 -0700
Subject: more button menu flexibility

---
 src/client/views/search/SearchBox.scss |  2 -
 src/client/views/search/SearchBox.tsx  | 73 +++++++++++++++++++++++++++++-----
 2 files changed, 63 insertions(+), 12 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index 804a623f7..c13873b1a 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -131,7 +131,6 @@
         color: grey;
         transform-origin: top;
         border-top: 0px;
-        //padding-top: 5px;
         margin-left: 10px;
         margin-right: 10px;
         overflow:hidden;
@@ -145,7 +144,6 @@
         color: grey;
         transform-origin: top;
         border-top: 0px;
-        //padding-top: 5px;
         margin-left: 10px;
         margin-right: 10px;
         overflow:hidden;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 90f995a8c..36dff4438 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -98,6 +98,7 @@ export class SearchBox extends React.Component<SearchProps> {
         if (this.setupButtons==false){
         console.log("Yuh");
             this.setupDocTypeButtons();
+            this.setupKeyButtons()
         runInAction(()=>this.setupButtons==true);
     }
         if (this.inputRef.current) {
@@ -717,15 +718,48 @@ export class SearchBox extends React.Component<SearchProps> {
         return (null);
     }
 
+
+    @computed get keyButtons() {
+        const nodeBtns = this.props.Document.keyButtons;
+        let width = () => NumCast(this.props.Document.width);
+        if (this.props.sideBar===true){
+            width = MainView.Instance.flyoutWidthFunc;
+        }
+        if (nodeBtns instanceof Doc) {
+            return <div id="hi" style={{height:"100px",}}>
+                <DocumentView
+                Document={nodeBtns}
+                DataDoc={undefined}
+                LibraryPath={emptyPath}
+                addDocument={undefined}
+                addDocTab={returnFalse}
+                rootSelected={returnTrue}
+                pinToPres={emptyFunction}
+                onClick={undefined}
+                removeDocument={undefined}
+                ScreenToLocalTransform={Transform.Identity}
+                ContentScaling={returnOne}
+                PanelWidth={width}
+                PanelHeight={() => 100}
+                renderDepth={0}
+                backgroundColor={returnEmptyString}
+                focus={emptyFunction}
+                parentActive={returnTrue}
+                whenActiveChanged={emptyFunction}
+                bringToFront={emptyFunction}
+                ContainingCollectionView={undefined}
+                ContainingCollectionDoc={undefined}
+                NativeHeight={()=>100}
+                NativeWidth={width}
+            />
+            </div>;
+        }
+        return (null);
+    }
+
     setupDocTypeButtons() {
         let doc = this.props.Document;
         const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  backgroundColor: "#121721", dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
-        const blist = (opts: DocumentOptions, docs: Doc[]) => new PrefetchProxy(Docs.Create.LinearDocument(docs, {
-            ...opts,
-            _gridGap: 5, _xMargin: 5, _yMargin: 5, _height: 42, _width: 100, boxShadow: "0 0", forceActive: true,
-            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }),
-            backgroundColor: "black", treeViewPreventOpen: true, lockedPosition: true, _chromeStatus: "disabled", linearViewIsExpanded: true
-        })) as any as Doc;
         doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
         doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
         doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
@@ -746,6 +780,24 @@ export class SearchBox extends React.Component<SearchProps> {
         doc.nodeButtons= dragCreators;
     }
 
+
+    setupKeyButtons() {
+        let doc = this.props.Document;
+        const button = (opts: DocumentOptions) => new PrefetchProxy( Docs.Create.ButtonDocument({...opts,
+            _width: 35, _height: 25, fontSize: 10,  
+            letterSpacing: "0px", textTransform: "unset", borderRounding: "16px",
+        }))as any as Doc;
+        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
+
+        let buttons = [doc.title as Doc];
+
+        const dragCreators = Docs.Create.MasonryDocument(buttons, {
+            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
+            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
+        });
+        doc.keyButtons= dragCreators;
+    }
+
     render() {
 
         return (
@@ -770,11 +822,12 @@ export class SearchBox extends React.Component<SearchProps> {
                         {this.docButtons}
                     </div>
                     <div className="filter-key" id={`key${this.props.id}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-                        <div className="filter-keybar">
-                            <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
+                        {/* <div className="filter-keybar"> */}
+                            {/* <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
                             <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
-                            <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button>
-                        </div>
+                            <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button> */}
+                            {this.keyButtons}
+                        {/* </div> */}
                     </div>
                 </div>
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
-- 
cgit v1.2.3-70-g09d2


From 0e192cd810be35c9c81cd93e8f4d550d8fe02d59 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 22 Apr 2020 01:58:17 -0700
Subject: document buttons change on hover and click

---
 src/client/documents/Documents.ts       |  4 ++-
 src/client/views/nodes/DocumentView.tsx |  2 +-
 src/client/views/nodes/LabelBox.tsx     | 15 ++++++++---
 src/client/views/search/SearchBox.scss  | 40 ++++++++++++++--------------
 src/client/views/search/SearchBox.tsx   | 46 ++++++++++++++++++++++++++-------
 5 files changed, 71 insertions(+), 36 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 2b5727254..db423fc84 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -157,9 +157,11 @@ export interface DocumentOptions {
     selectedIndex?: number;
     syntaxColor?: string; // can be applied to text for syntax highlighting all matches in the text
     searchText?: string, //for searchbox
-    searchQuery?: string, // for queryBox
+    searchQuery?: string, // for quersyBox
     filterQuery?: filterData,
     linearViewIsExpanded?: boolean; // is linear view expanded
+    border?: string; //for searchbox
+    hovercolor?:string;
 }
 
 class EmptyBox {
diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx
index c0d530160..40a29b6b9 100644
--- a/src/client/views/nodes/DocumentView.tsx
+++ b/src/client/views/nodes/DocumentView.tsx
@@ -1153,7 +1153,7 @@ export class DocumentView extends DocComponent<DocumentViewProps, Document>(Docu
                 pointerEvents: this.ignorePointerEvents ? "none" : "all",
                 color: StrCast(this.layoutDoc.color, "inherit"),
                 outline: highlighting && !borderRounding ? `${highlightColors[fullDegree]} ${highlightStyles[fullDegree]} ${localScale}px` : "solid 0px",
-                border: highlighting && borderRounding ? `${highlightStyles[fullDegree]} ${highlightColors[fullDegree]} ${localScale}px` : undefined,
+                border: this.layoutDoc.border ? StrCast(this.layoutDoc.border) : highlighting && borderRounding ? `${highlightStyles[fullDegree]} ${highlightColors[fullDegree]} ${localScale}px` : undefined,
                 boxShadow: this.props.Document.isTemplateForField ? "black 0.2vw 0.2vw 0.8vw" : undefined,
                 background: finalColor,
                 opacity: this.Document.opacity
diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx
index 391e359cc..fca38763e 100644
--- a/src/client/views/nodes/LabelBox.tsx
+++ b/src/client/views/nodes/LabelBox.tsx
@@ -1,6 +1,6 @@
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { faEdit } from '@fortawesome/free-regular-svg-icons';
-import { action } from 'mobx';
+import { action, computed, observable, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import { Doc, DocListCast } from '../../../new_fields/Doc';
@@ -61,17 +61,26 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps, LabelDocument
             e.stopPropagation();
         }
     }
+
+
+
+    @observable backColor= "unset";
+
+    @observable clicked = false;
     // (!missingParams || !missingParams.length ? "" : "(" + missingParams.map(m => m + ":").join(" ") + ")")
     render() {
         const params = Cast(this.paramsDoc["onClick-paramFieldKeys"], listSpec("string"), []);
         const missingParams = params?.filter(p => !this.paramsDoc[p]);
         params?.map(p => DocListCast(this.paramsDoc[p])); // bcz: really hacky form of prefetching ... 
+        console.log(this.backColor);
         return (
-            <div className="labelBox-outerDiv" ref={this.createDropTarget} onContextMenu={this.specificContextMenu}
+            <div className="labelBox-outerDiv" onClick={()=>runInAction(()=>{this.clicked=!this.clicked; this.clicked? this.backColor=StrCast(this.layoutDoc.hovercolor) : this.backColor ="unset"})} onMouseLeave={()=>runInAction(()=>{ !this.clicked ?this.backColor="unset" : null})} 
+            onMouseOver={()=>runInAction(()=>{this.backColor=StrCast(this.layoutDoc.hovercolor);})}ref={this.createDropTarget} onContextMenu={this.specificContextMenu}
                 style={{ boxShadow: this.layoutDoc.opacity ? StrCast(this.layoutDoc.boxShadow) : "" }}>
                 <div className="labelBox-mainButton" style={{
                     background: StrCast(this.layoutDoc.backgroundColor),
-                    color: StrCast(this.layoutDoc.color, "inherit"),
+                    color: StrCast(this.layoutDoc.color),
+                    backgroundColor:this.backColor,
                     fontSize: NumCast(this.layoutDoc.fontSize) || "inherit",
                     letterSpacing: StrCast(this.layoutDoc.letterSpacing),
                     textTransform: StrCast(this.layoutDoc.textTransform) as any
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index c13873b1a..e3b3de898 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -131,8 +131,7 @@
         color: grey;
         transform-origin: top;
         border-top: 0px;
-        margin-left: 10px;
-        margin-right: 10px;
+
         overflow:hidden;
         transition:height 0.3s ease-out;
         height:0px;
@@ -144,29 +143,28 @@
         color: grey;
         transform-origin: top;
         border-top: 0px;
-        margin-left: 10px;
-        margin-right: 10px;
         overflow:hidden;
         transition:height 0.3s ease-out;
         height:0px;
-        .filter-keybar {
-            display: flex;
-            flex-wrap: wrap;
-            justify-content: space-evenly;
-            height: auto;
-            width: 100%;
-            flex-direction: row-reverse;
-            margin-top:5px;
-            
-            .filter-item {
-                position: relative;
-                border:1px solid grey;
-                border-radius: 16px;
-    
-            }
-        }
-
 
+        .labelBox-mainButton:hover{
+            color:"White";
+        }
+        // .filter-keybar {
+        //     display: flex;
+        //     flex-wrap: wrap;
+        //     justify-content: space-evenly;
+        //     height: auto;
+        //     width: 100%;
+        //     flex-direction: row-reverse;
+        //     margin-top:5px;
+            
+        //     .filter-item {
+        //         position: relative;
+        //         border:1px solid grey;
+        //         border-radius: 16px;
+        //     }
+        // }
     }
 }
 
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 36dff4438..f5be4f5aa 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -98,7 +98,8 @@ export class SearchBox extends React.Component<SearchProps> {
         if (this.setupButtons==false){
         console.log("Yuh");
             this.setupDocTypeButtons();
-            this.setupKeyButtons()
+            this.setupKeyButtons();
+            this.setupDefaultButtons();
         runInAction(()=>this.setupButtons==true);
     }
         if (this.inputRef.current) {
@@ -563,6 +564,7 @@ export class SearchBox extends React.Component<SearchProps> {
 
     @action.bound
     handleNodeChange = () => {
+        console.log("oi!");
         this._nodeStatus = !this._nodeStatus;
         if (this._nodeStatus) {
             this.expandSection(`node${this.props.id}`);
@@ -718,7 +720,6 @@ export class SearchBox extends React.Component<SearchProps> {
         return (null);
     }
 
-
     @computed get keyButtons() {
         const nodeBtns = this.props.Document.keyButtons;
         let width = () => NumCast(this.props.Document.width);
@@ -726,7 +727,7 @@ export class SearchBox extends React.Component<SearchProps> {
             width = MainView.Instance.flyoutWidthFunc;
         }
         if (nodeBtns instanceof Doc) {
-            return <div id="hi" style={{height:"100px",}}>
+            return <div id="hi" style={{height:"35px",}}>
                 <DocumentView
                 Document={nodeBtns}
                 DataDoc={undefined}
@@ -759,7 +760,10 @@ export class SearchBox extends React.Component<SearchProps> {
 
     setupDocTypeButtons() {
         let doc = this.props.Document;
-        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  backgroundColor: "#121721", dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100, _height: 100 })) as any as Doc;
+        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  
+        dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100,
+         _height: 100 })) as any as Doc;
+        //backgroundColor: "#121721",       
         doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
         doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
         doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
@@ -784,16 +788,39 @@ export class SearchBox extends React.Component<SearchProps> {
     setupKeyButtons() {
         let doc = this.props.Document;
         const button = (opts: DocumentOptions) => new PrefetchProxy( Docs.Create.ButtonDocument({...opts,
-            _width: 35, _height: 25, fontSize: 10,  
-            letterSpacing: "0px", textTransform: "unset", borderRounding: "16px",
+            _width: 35, _height: 30,
+            borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
+            fontSize: 7,
         }))as any as Doc;
         doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
+        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange()`)});
+        doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
 
-        let buttons = [doc.title as Doc];
+        let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
 
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
-            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
-            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
+            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 50, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5
+            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), 
+        });
+        doc.keyButtons= dragCreators;
+    }
+
+    setupDefaultButtons() {
+        let doc = this.props.Document;
+        const button = (opts: DocumentOptions) => new PrefetchProxy( Docs.Create.ButtonDocument({...opts,
+            _width: 35, _height: 30,
+            borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
+            fontSize: 7,
+        }))as any as Doc;
+        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
+        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange`)});
+        doc.nodes = button({ title: "Nodes", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
+
+        let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
+
+        const dragCreators = Docs.Create.MasonryDocument(buttons, {
+            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 50, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5
+            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), 
         });
         doc.keyButtons= dragCreators;
     }
@@ -827,7 +854,6 @@ export class SearchBox extends React.Component<SearchProps> {
                             <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
                             <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button> */}
                             {this.keyButtons}
-                        {/* </div> */}
                     </div>
                 </div>
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
-- 
cgit v1.2.3-70-g09d2


From d2884635f82f28e75c69ca25919800c9cd91f925 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 22 Apr 2020 14:40:45 -0700
Subject: scripting buttons

---
 src/client/views/search/SearchBox.scss |  8 ++--
 src/client/views/search/SearchBox.tsx  | 71 ++++++++++++++++++++++++++++------
 src/new_fields/Doc.ts                  | 10 ++++-
 3 files changed, 72 insertions(+), 17 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index e3b3de898..af67f466c 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -103,14 +103,14 @@
 
 
     .filter-header {
-        display: flex;
+        //display: flex;
         position: relative;
-        flex-wrap:wrap;
+        //flex-wrap:wrap;
         right: 1px;
         color: grey;
-        flex-direction: row-reverse;
+        //flex-direction: row-reverse;
         transform-origin: top;
-        justify-content: space-evenly;
+        //justify-content: space-evenly;
         margin-bottom: 5px;
         overflow:hidden;
         transition:height 0.3s ease-out;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index f5be4f5aa..a33cb1e06 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -29,6 +29,7 @@ import { List } from '../../../new_fields/List';
 import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
 import { Transform } from '../../util/Transform';
 import { MainView } from "../MainView";
+import { Scripting } from '../../util/Scripting';
 
 
 library.add(faTimes);
@@ -758,6 +759,44 @@ export class SearchBox extends React.Component<SearchProps> {
         return (null);
     }
 
+    @computed get defaultButtons() {
+        const defBtns = this.props.Document.defaultButtons;
+        let width = () => NumCast(this.props.Document.width);
+        if (this.props.sideBar===true){
+            width = MainView.Instance.flyoutWidthFunc;
+        }
+        if (defBtns instanceof Doc) {
+            return <div id="hi" style={{height:"35px",}}>
+                <DocumentView
+                Document={defBtns}
+                DataDoc={undefined}
+                LibraryPath={emptyPath}
+                addDocument={undefined}
+                addDocTab={returnFalse}
+                rootSelected={returnTrue}
+                pinToPres={emptyFunction}
+                onClick={undefined}
+                removeDocument={undefined}
+                ScreenToLocalTransform={Transform.Identity}
+                ContentScaling={returnOne}
+                PanelWidth={width}
+                PanelHeight={() => 100}
+                renderDepth={0}
+                backgroundColor={returnEmptyString}
+                focus={emptyFunction}
+                parentActive={returnTrue}
+                whenActiveChanged={emptyFunction}
+                bringToFront={emptyFunction}
+                ContainingCollectionView={undefined}
+                ContainingCollectionDoc={undefined}
+                NativeHeight={()=>100}
+                NativeWidth={width}
+            />
+            </div>;
+        }
+        return (null);
+    }
+
     setupDocTypeButtons() {
         let doc = this.props.Document;
         const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  
@@ -793,7 +832,7 @@ export class SearchBox extends React.Component<SearchProps> {
             fontSize: 7,
         }))as any as Doc;
         doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
-        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange()`)});
+        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`handleNodeChange()`)});
         doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
 
         let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
@@ -812,17 +851,15 @@ export class SearchBox extends React.Component<SearchProps> {
             borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
             fontSize: 7,
         }))as any as Doc;
-        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
-        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`this.handleNodeChange`)});
+        doc.keywords=button({ title: "Keywords", onClick:ScriptField.MakeScript("handleNodeChange(this)")});
+        doc.keys=button({ title: "Keys", onClick:ScriptField.MakeScript(`this.handleNodeChange`)});
         doc.nodes = button({ title: "Nodes", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
-
-        let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
-
+        let buttons = [doc.keywords as Doc, doc.keys as Doc, doc.nodes as Doc];
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
-            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 50, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5
+            _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 60, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5
             //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), 
         });
-        doc.keyButtons= dragCreators;
+        doc.defaultButtons= dragCreators;
     }
 
     render() {
@@ -841,9 +878,10 @@ export class SearchBox extends React.Component<SearchProps> {
 
                 <div id={`filterhead${this.props.id}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
                     <div id={`filterhead2${this.props.id}`} className="filter-header"  >
-                        <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button>
+                        {this.defaultButtons}
+                        {/* <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button>
                         <button className="filter-item" style={this._keyStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleKeyChange}>Keys</button>
-                        <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button>
+                        <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button> */}
                     </div>
                     <div id={`node${this.props.id}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         {this.docButtons}
@@ -853,7 +891,7 @@ export class SearchBox extends React.Component<SearchProps> {
                             {/* <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
                             <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
                             <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button> */}
-                            {this.keyButtons}
+                        {this.keyButtons}
                     </div>
                 </div>
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
@@ -866,4 +904,13 @@ export class SearchBox extends React.Component<SearchProps> {
             </div>
         );
     }
-}
\ No newline at end of file
+}
+
+// Scripting.addGlobal(function handleNodeChange(doc: any) {
+//     console.log("oi");
+//     doc.handleNodeChange();
+    
+//     // const dv = DocumentManager.Instance.getDocumentView(doc);
+//     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
+//     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
+// });
\ No newline at end of file
diff --git a/src/new_fields/Doc.ts b/src/new_fields/Doc.ts
index bcf0d1aec..c54806f37 100644
--- a/src/new_fields/Doc.ts
+++ b/src/new_fields/Doc.ts
@@ -918,4 +918,12 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo
     return docs.length ? new List(docs) : prevValue;
 });
 Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: "check" | "x" | undefined) { Doc.setDocFilter(container, key, value, modifiers); });
-Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
\ No newline at end of file
+Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
+Scripting.addGlobal(function handleNodeChange(doc: any) {
+    console.log("oi");
+    doc.handleNodeChange();
+    
+    // const dv = DocumentManager.Instance.getDocumentView(doc);
+    // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
+    // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
+});
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 15ee40ea8da5140ba5db62185b4a26d36bf6255e Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 27 Apr 2020 15:44:43 -0700
Subject: refactored searchbox doctype out from querybox class to help with
 displaying search results as different collection types

---
 src/client/documents/DocumentTypes.ts              |   2 +-
 src/client/documents/Documents.ts                  |  10 +-
 src/client/views/nodes/DocumentContentsView.tsx    |   4 +-
 src/client/views/nodes/QueryBox.tsx                |   7 +-
 src/client/views/search/SearchBox.tsx              | 114 ++++++++++++++-------
 .../authentication/models/current_user_utils.ts    |   7 +-
 6 files changed, 93 insertions(+), 51 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index de366763b..3c34ff1c8 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -13,7 +13,7 @@ export enum DocumentType {
     INK = "ink",        // ink stroke
     SCREENSHOT = "screenshot",  // view of a desktop application
     FONTICON = "fonticonbox",   // font icon
-    QUERY = "query",            // search query
+    SEARCH = "search",            // search query
     LABEL = "label",            // simple text label
     BUTTON = "button",          // onClick button
     WEBCAM = "webcam",          // webcam
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index db423fc84..50326231c 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -39,7 +39,7 @@ import { filterData} from "../views/search/SearchBox";
 //import { PresField } from "../../new_fields/PresField";
 import { PresElementBox } from "../views/presentationview/PresElementBox";
 import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo";
-import { QueryBox } from "../views/nodes/QueryBox";
+import { SearchBox } from "../views/search/SearchBox";
 import { ColorBox } from "../views/nodes/ColorBox";
 import { LinkAnchorBox } from "../views/nodes/LinkAnchorBox";
 import { DocHolderBox } from "../views/nodes/DocumentBox";
@@ -191,8 +191,8 @@ export namespace Docs {
                 layout: { view: FormattedTextBox, dataField: "text" },
                 options: { _height: 150, _xMargin: 10, _yMargin: 10 }
             }],
-            [DocumentType.QUERY, {
-                layout: { view: QueryBox, dataField: data },
+            [DocumentType.SEARCH, {
+                layout: { view: SearchBox, dataField: data },
                 options: { _width: 400 }
             }],
             [DocumentType.COLOR, {
@@ -534,8 +534,8 @@ export namespace Docs {
             return instance;
         }
 
-        export function QueryDocument(options: DocumentOptions = {}) {
-            return InstanceFromProto(Prototypes.get(DocumentType.QUERY), "", options);
+        export function SearchDocument(options: DocumentOptions = {}) {
+            return InstanceFromProto(Prototypes.get(DocumentType.SEARCH), "", options);
         }
 
         export function ColorDocument(options: DocumentOptions = {}) {
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 7522af3a3..083638198 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -24,7 +24,7 @@ import { ImageBox } from "./ImageBox";
 import { KeyValueBox } from "./KeyValueBox";
 import { PDFBox } from "./PDFBox";
 import { PresBox } from "./PresBox";
-import { QueryBox } from "./QueryBox";
+import { SearchBox } from "../search/SearchBox";
 import { ColorBox } from "./ColorBox";
 import { DashWebRTCVideo } from "../webcam/DashWebRTCVideo";
 import { LinkAnchorBox } from "./LinkAnchorBox";
@@ -111,7 +111,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
                     components={{
                         FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, LabelBox, SliderBox, FieldView,
                         CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
-                        PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, QueryBox,
+                        PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, SearchBox,
                         ColorBox, DashWebRTCVideo, LinkAnchorBox, InkingStroke, DocHolderBox, LinkBox, ScriptingBox,
                         RecommendationsBox, ScreenshotBox
                     }}
diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index 7929c6c33..eb57b98d2 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -33,7 +33,10 @@ export class QueryBox extends ViewBoxAnnotatableComponent<FieldViewProps, QueryD
         }
         const dragging = !SelectionManager.GetIsDragging() ? "" : "-dragging";
         return <div className={`queryBox${dragging}`} onWheel={(e) => e.stopPropagation()} >
-            <SearchBox id={this.props.Document[Id]} sideBar={side} Document={this.props.Document} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
+            
+            <SearchBox Document={this.props.Document}  />
         </div >;
     }
-}
\ No newline at end of file
+}
+
+//<SearchBox id={this.props.Document[Id]} sideBar={side} Document={this.props.Document} searchQuery={StrCast(this.dataDoc.searchQuery)} filterQuery={this.dataDoc.filterQuery} />
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index a33cb1e06..327617319 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -15,7 +15,7 @@ import { SearchUtil } from '../../util/SearchUtil';
 import "./SearchBox.scss";
 import { SearchItem } from './SearchItem';
 import { IconBar } from './IconBar';
-import { FieldView } from '../nodes/FieldView';
+import { FieldView, FieldViewProps } from '../nodes/FieldView';
 import { DocumentType } from "../../documents/DocumentTypes";
 import { DocumentView } from '../nodes/DocumentView';
 import { SelectionManager } from '../../util/SelectionManager';
@@ -30,17 +30,31 @@ import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMu
 import { Transform } from '../../util/Transform';
 import { MainView } from "../MainView";
 import { Scripting } from '../../util/Scripting';
-
+import { CollectionView, CollectionViewType } from '../collections/CollectionView';
+import { ViewBoxBaseComponent } from "../DocComponent";
+import { documentSchema } from "../../../new_fields/documentSchemas";
+import { makeInterface, createSchema } from '../../../new_fields/Schema';
 
 library.add(faTimes);
 
-export interface SearchProps {
-    id: string;
-    Document: Doc;
-    sideBar?: Boolean;
-    searchQuery?: string;
-    filterQuery?: filterData;
-}
+// export interface SearchProps {
+//     id: string;
+//     Document: Doc;
+//     sideBar?: Boolean;
+//     searchQuery?: string;
+//     filterQuery?: filterData;
+// }
+
+export const searchSchema = createSchema({
+    id: "string",
+    Document: Doc,
+    sideBar: "boolean",
+    searchQuery: "string",
+});
+
+//add back filterquery
+
+
 
 export enum Keys {
     TITLE = "title",
@@ -55,8 +69,13 @@ export interface filterData{
     basicWordStatus:boolean;
     icons: string[];
 }
+
+type SearchBoxDocument = makeInterface<[typeof documentSchema, typeof searchSchema]>;
+const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
+
+//React.Component<SearchProps> 
 @observer
-export class SearchBox extends React.Component<SearchProps> {
+export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDocument>(SearchBoxDocument) {
 
     @observable private _searchString: string = "";
     @observable private _resultsOpen: boolean = false;
@@ -64,6 +83,7 @@ export class SearchBox extends React.Component<SearchProps> {
     @observable private _results: [Doc, string[], string[]][] = [];
     @observable private _openNoResults: boolean = false;
     @observable private _visibleElements: JSX.Element[] = [];
+    @observable private _visibleDocuments: Doc[] = [];
 
     private _resultsSet = new Map<Doc, number>();
     private _resultsRef = React.createRef<HTMLDivElement>();
@@ -107,20 +127,20 @@ export class SearchBox extends React.Component<SearchProps> {
             this.inputRef.current.focus();
             runInAction(() => this._searchbarOpen = true);
         }
-        if (this.props.searchQuery && this.props.filterQuery && this.newAssign) {
-            console.log(this.props.searchQuery);
-            const sq = this.props.searchQuery;
+        if (this.rootDoc.searchQuery&& this.newAssign) {
+            console.log(this.rootDoc.searchQuery);
+            const sq = this.rootDoc.searchQuery;
             runInAction(() => {
 
-            this._deletedDocsStatus=this.props.filterQuery!.deletedDocsStatus;
-            this._authorFieldStatus=this.props.filterQuery!.authorFieldStatus
-            this._titleFieldStatus=this.props.filterQuery!.titleFieldStatus;
-            this._basicWordStatus=this.props.filterQuery!.basicWordStatus;
-            this._icons=this.props.filterQuery!.icons;
+            // this._deletedDocsStatus=this.props.filterQuery!.deletedDocsStatus;
+            // this._authorFieldStatus=this.props.filterQuery!.authorFieldStatus
+            // this._titleFieldStatus=this.props.filterQuery!.titleFieldStatus;
+            // this._basicWordStatus=this.props.filterQuery!.basicWordStatus;
+            // this._icons=this.props.filterQuery!.icons;
             this.newAssign=false;
             });
             runInAction(() => {
-                this._searchString = sq;
+                this._searchString = StrCast(sq);
                 this.submitSearch();
             });
         }
@@ -334,6 +354,7 @@ export class SearchBox extends React.Component<SearchProps> {
         this._resultsSet.clear();
         this._isSearch = [];
         this._visibleElements = [];
+        this._visibleDocuments = [];
         if (query !== "") {
             this._endIndex = 12;
             this._maxSearchIndex = 0;
@@ -457,7 +478,7 @@ export class SearchBox extends React.Component<SearchProps> {
             basicWordStatus: this._basicWordStatus,
             icons: this._icons,
         }
-        return Docs.Create.QueryDocument({ _autoHeight: true, title: this._searchString, filterQuery: filter, searchQuery: this._searchString });
+        return Docs.Create.SearchDocument({ _autoHeight: true, title: this._searchString, filterQuery: filter, searchQuery: this._searchString });
     }
 
     @action.bound
@@ -480,6 +501,7 @@ export class SearchBox extends React.Component<SearchProps> {
         this._results = [];
         this._resultsSet.clear();
         this._visibleElements = [];
+        this._visibleDocuments=[];
         this._numTotalResults = -1;
         this._endIndex = -1;
         this._curRequest = undefined;
@@ -497,6 +519,7 @@ export class SearchBox extends React.Component<SearchProps> {
         this._endIndex=30;
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             this._visibleElements = [<div className="no-result">No Search Results</div>];
+            //this._visibleDocuments= Docs.Create.
             return;
         }
 
@@ -509,6 +532,8 @@ export class SearchBox extends React.Component<SearchProps> {
         else if (this._visibleElements.length !== this._numTotalResults) {
             // undefined until a searchitem is put in there
             this._visibleElements = Array<JSX.Element>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
+            this._visibleDocuments = Array<Doc>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
+
             // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
         }
@@ -531,6 +556,7 @@ export class SearchBox extends React.Component<SearchProps> {
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
+                            this._visibleDocuments[i]= result[0];
                             this._isSearch[i] = "search";
                         }
                     }
@@ -539,6 +565,7 @@ export class SearchBox extends React.Component<SearchProps> {
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
+                            this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
                         }
                     }
@@ -547,6 +574,7 @@ export class SearchBox extends React.Component<SearchProps> {
         }
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
+            this._visibleDocuments.length = this._results.length;
             this._isSearch.length = this._results.length;
         }
     }
@@ -568,10 +596,10 @@ export class SearchBox extends React.Component<SearchProps> {
         console.log("oi!");
         this._nodeStatus = !this._nodeStatus;
         if (this._nodeStatus) {
-            this.expandSection(`node${this.props.id}`);
+            this.expandSection(`node${this.props.Document[Id]}`);
         }
         else {
-            this.collapseSection(`node${this.props.id}`);
+            this.collapseSection(`node${this.props.Document[Id]}`);
         }
     }
 
@@ -579,10 +607,10 @@ export class SearchBox extends React.Component<SearchProps> {
     handleKeyChange = () => {
         this._keyStatus = !this._keyStatus;
         if (this._keyStatus) {
-            this.expandSection(`key${this.props.id}`);
+            this.expandSection(`key${this.props.Document[Id]}`);
         }
         else {
-            this.collapseSection(`key${this.props.id}`);
+            this.collapseSection(`key${this.props.Document[Id]}`);
         }
     }
 
@@ -590,11 +618,11 @@ export class SearchBox extends React.Component<SearchProps> {
     handleFilterChange = () => {
         this._filterOpen = !this._filterOpen;
         if (this._filterOpen) {
-            this.expandSection(`filterhead${this.props.id}`);
-            document.getElementById(`filterhead${this.props.id}`)!.style.padding = "5";
+            this.expandSection(`filterhead${this.props.Document[Id]}`);
+            document.getElementById(`filterhead${this.props.Document[Id]}`)!.style.padding = "5";
         }
         else {
-            this.collapseSection(`filterhead${this.props.id}`);
+            this.collapseSection(`filterhead${this.props.Document[Id]}`);
 
 
         }
@@ -607,7 +635,7 @@ export class SearchBox extends React.Component<SearchProps> {
 
 
     collapseSection(thing: string) {
-        const id = this.props.id;
+        const id = this.props.Document[Id];
         const element = document.getElementById(thing)!;
         // get the height of the element's inner content, regardless of its actual size
         const sectionHeight = element.scrollHeight;
@@ -686,7 +714,7 @@ export class SearchBox extends React.Component<SearchProps> {
     @computed get docButtons() {
         const nodeBtns = this.props.Document.nodeButtons;
         let width = () => NumCast(this.props.Document.width);
-        if (this.props.sideBar===true){
+        if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
         if (nodeBtns instanceof Doc) {
@@ -724,7 +752,7 @@ export class SearchBox extends React.Component<SearchProps> {
     @computed get keyButtons() {
         const nodeBtns = this.props.Document.keyButtons;
         let width = () => NumCast(this.props.Document.width);
-        if (this.props.sideBar===true){
+        if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
         if (nodeBtns instanceof Doc) {
@@ -762,7 +790,7 @@ export class SearchBox extends React.Component<SearchProps> {
     @computed get defaultButtons() {
         const defBtns = this.props.Document.defaultButtons;
         let width = () => NumCast(this.props.Document.width);
-        if (this.props.sideBar===true){
+        if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
         if (defBtns instanceof Doc) {
@@ -861,11 +889,11 @@ export class SearchBox extends React.Component<SearchProps> {
         });
         doc.defaultButtons= dragCreators;
     }
-
+    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().presentationTemplate, Doc, null) : undefined;
     render() {
 
         return (
-            <div className="searchBox-container">
+            <div style={{pointerEvents:"all"}}className="searchBox-container">
                 <div className="searchBox-bar">
                     <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => this._searchString ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
@@ -876,17 +904,17 @@ export class SearchBox extends React.Component<SearchProps> {
                     <button className="searchBox-barChild searchBox-filter" style={{transform:"none"}} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
                 </div>
 
-                <div id={`filterhead${this.props.id}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
-                    <div id={`filterhead2${this.props.id}`} className="filter-header"  >
+                <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
+                    <div id={`filterhead2${this.props.Document[Id]}`} className="filter-header"  >
                         {this.defaultButtons}
                         {/* <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button>
                         <button className="filter-item" style={this._keyStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleKeyChange}>Keys</button>
                         <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button> */}
                     </div>
-                    <div id={`node${this.props.id}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
+                    <div id={`node${this.props.Document[Id]}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         {this.docButtons}
                     </div>
-                    <div className="filter-key" id={`key${this.props.id}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
+                    <div className="filter-key" id={`key${this.props.Document[Id]}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         {/* <div className="filter-keybar"> */}
                             {/* <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
                             <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
@@ -894,12 +922,22 @@ export class SearchBox extends React.Component<SearchProps> {
                         {this.keyButtons}
                     </div>
                 </div>
+                {/* <CollectionView {...this.props}
+                        PanelHeight={this.panelHeight}
+                        moveDocument={returnFalse}
+                        childLayoutTemplate={this.childLayoutTemplate}
+                        addDocument={this.addDocument}
+                        removeDocument={returnFalse}
+                        focus={this.selectElement}
+                        ScreenToLocalTransform={this.getTransform} /> */}
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
                     height: this.resFull ? "auto" : this.resultHeight,
                     overflow: "visibile" // this.resFull ? "auto" : "visible"
                 }} ref={this._resultsRef}>
                     {this._visibleElements}
+                    
+                    
                 </div>
             </div>
         );
@@ -910,7 +948,7 @@ export class SearchBox extends React.Component<SearchProps> {
 //     console.log("oi");
 //     doc.handleNodeChange();
     
-//     // const dv = DocumentManager.Instance.getDocumentView(doc);
+//     // const dv = DocumentManager.Instance.getD  ocumentView(doc);
 //     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
 //     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
 // });
\ No newline at end of file
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 9235a97b0..c03779002 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -87,7 +87,7 @@ export class CurrentUserUtils {
             { title: "use stamp", icon: "stamp", click: 'activateStamp(this.activePen.pen = sameDocs(this.activePen.pen, this) ? undefined : this)', backgroundColor: "orange", ischecked: `sameDocs(this.activePen.pen, this)`, activePen: doc },
             { title: "use eraser", icon: "eraser", click: 'activateEraser(this.activePen.pen = sameDocs(this.activePen.pen, this) ? undefined : this);', ischecked: `sameDocs(this.activePen.pen, this)`, backgroundColor: "pink", activePen: doc },
             { title: "use drag", icon: "mouse-pointer", click: 'deactivateInk();this.activePen.pen = this;', ischecked: `sameDocs(this.activePen.pen, this)`, backgroundColor: "white", activePen: doc },
-            { title: "query", icon: "bolt", ignoreClick: true, drag: 'Docs.Create.QueryDocument({ _width: 200, title: "an image of a cat" })' },
+            { title: "query", icon: "bolt", ignoreClick: true, drag: 'Docs.Create.SearchDocument({ _width: 200, title: "an image of a cat" })' },
             // { title: "buxton", icon: "cloud-upload-alt", ignoreClick: true, drag: "Docs.Create.Buxton()" },
         ];
         return docProtoData.filter(d => !alreadyCreatedButtons?.includes(d.title)).map(data => Docs.Create.FontIconDocument({
@@ -254,7 +254,7 @@ export class CurrentUserUtils {
         return Docs.Create.ButtonDocument({
             _width: 50, _height: 25, title: "Search", fontSize: 10,
             letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-            sourcePanel: Docs.Create.QueryDocument({ title: "search stack", }),
+            sourcePanel: Docs.Create.SearchDocument({ title: "search stack", }),
             targetContainer: sidebarContainer,
             lockedPosition: true,
             onClick: ScriptField.MakeScript("this.targetContainer.proto = this.sourcePanel")
@@ -279,11 +279,12 @@ export class CurrentUserUtils {
         }));
     }
 
+    // forceActive: true
     /// sets up the default list of buttons to be shown in the expanding button menu at the bottom of the Dash window
     static setupExpandingButtons(doc: Doc) {
         const queryTemplate = Docs.Create.MulticolumnDocument(
             [
-                Docs.Create.QueryDocument({ title: "query", _height: 200, forceActive: true }),
+                Docs.Create.SearchDocument({ title: "query", _height: 200, forceActive:true }),
                 Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true, forceActive: true })
             ],
             { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, _autoHeight: false, forceActive: true, hideFilterView: true });
-- 
cgit v1.2.3-70-g09d2


From e4b7b54eecc307ec52f6105f92c3d87449458641 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 28 Apr 2020 02:02:40 -0700
Subject: nested collection view now in search box, search item doc type cast
 over stacking view, but with bugs

---
 src/client/documents/DocumentTypes.ts              |  1 +
 src/client/documents/Documents.ts                  |  8 +++
 src/client/views/nodes/FieldView.tsx               |  3 +
 src/client/views/nodes/QueryBox.tsx                |  2 +-
 src/client/views/search/SearchBox.tsx              | 40 ++++++++++---
 src/client/views/search/SearchItem.tsx             | 69 ++++++++++++----------
 .../authentication/models/current_user_utils.ts    |  3 +
 7 files changed, 86 insertions(+), 40 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/DocumentTypes.ts b/src/client/documents/DocumentTypes.ts
index 3c34ff1c8..36d3e1c52 100644
--- a/src/client/documents/DocumentTypes.ts
+++ b/src/client/documents/DocumentTypes.ts
@@ -31,6 +31,7 @@ export enum DocumentType {
     COLOR = "color",            // color picker (view of a color picker for a color string)
     YOUTUBE = "youtube",        // youtube directory (view of you tube search results)
     DOCHOLDER = "docholder",    // nested document (view of a document)
+    SEARCHITEM= "searchitem",
 
     LINKDB = "linkdb",          // database of links  ??? why do we have this
     RECOMMENDATION = "recommendation", // view of a recommendation
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 50326231c..e5b3c8a97 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -38,6 +38,7 @@ import { filterData} from "../views/search/SearchBox";
 //import { PresBox } from "../views/nodes/PresBox";
 //import { PresField } from "../../new_fields/PresField";
 import { PresElementBox } from "../views/presentationview/PresElementBox";
+import { SearchItem } from "../views/search/SearchItem";
 import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo";
 import { SearchBox } from "../views/search/SearchBox";
 import { ColorBox } from "../views/nodes/ColorBox";
@@ -277,6 +278,9 @@ export namespace Docs {
             [DocumentType.PRESELEMENT, {
                 layout: { view: PresElementBox, dataField: data }
             }],
+            [DocumentType.SEARCHITEM, {
+                layout: { view: SearchItem, dataField: data }
+            }],
             [DocumentType.INK, {
                 layout: { view: InkingStroke, dataField: data },
                 options: { backgroundColor: "transparent" }
@@ -671,6 +675,10 @@ export namespace Docs {
             return InstanceFromProto(Prototypes.get(DocumentType.PRESELEMENT), undefined, { ...(options || {}) });
         }
 
+        export function SearchItemBoxDocument(options?: DocumentOptions) {
+            return InstanceFromProto(Prototypes.get(DocumentType.SEARCHITEM), undefined, { ...(options || {}) });
+        }
+
         export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
             const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Docking, dockingConfig: config }, id);
             Doc.GetProto(inst).data = new List<Doc>(documents);
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index a3790d38b..6198212b5 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -51,6 +51,9 @@ export interface FieldViewProps {
     ContentScaling: () => number;
     ChromeHeight?: () => number;
     childLayoutTemplate?: () => Opt<Doc>;
+    highlighting?: string[];
+    lines?: string[];
+    doc?: Doc;
 }
 
 @observer
diff --git a/src/client/views/nodes/QueryBox.tsx b/src/client/views/nodes/QueryBox.tsx
index eb57b98d2..fb47a01d7 100644
--- a/src/client/views/nodes/QueryBox.tsx
+++ b/src/client/views/nodes/QueryBox.tsx
@@ -34,7 +34,7 @@ export class QueryBox extends ViewBoxAnnotatableComponent<FieldViewProps, QueryD
         const dragging = !SelectionManager.GetIsDragging() ? "" : "-dragging";
         return <div className={`queryBox${dragging}`} onWheel={(e) => e.stopPropagation()} >
             
-            <SearchBox Document={this.props.Document}  />
+            <SearchBox  Document={this.props.Document}  />
         </div >;
     }
 }
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 327617319..5ef71ca41 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -533,7 +533,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // undefined until a searchitem is put in there
             this._visibleElements = Array<JSX.Element>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
             this._visibleDocuments = Array<Doc>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-
             // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
         }
@@ -555,7 +554,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
+                            result[0].query=this._searchString;
+                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            Doc.AddDocToList(this.props.Document, undefined, result[0])
+
                             this._visibleDocuments[i]= result[0];
                             this._isSearch[i] = "search";
                         }
@@ -564,8 +566,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
+                            result[0].query=this._searchString;
+                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             this._visibleDocuments[i] = result[0];
+                            Doc.AddDocToList(this.props.Document, undefined, result[0])
                             this._isSearch[i] = "search";
                         }
                     }
@@ -729,7 +733,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 pinToPres={emptyFunction}
                 onClick={undefined}
                 removeDocument={undefined}
-                ScreenToLocalTransform={Transform.Identity}
+                ScreenToLocalTransform={this.getTransform}
                 ContentScaling={returnOne}
                 PanelWidth={width}
                 PanelHeight={() => 100}
@@ -767,7 +771,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 pinToPres={emptyFunction}
                 onClick={undefined}
                 removeDocument={undefined}
-                ScreenToLocalTransform={Transform.Identity}
+                ScreenToLocalTransform={this.getTransform}
                 ContentScaling={returnOne}
                 PanelWidth={width}
                 PanelHeight={() => 100}
@@ -805,7 +809,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 pinToPres={emptyFunction}
                 onClick={undefined}
                 removeDocument={undefined}
-                ScreenToLocalTransform={Transform.Identity}
+                ScreenToLocalTransform={this.getTransform}
                 ContentScaling={returnOne}
                 PanelWidth={width}
                 PanelHeight={() => 100}
@@ -889,7 +893,23 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         });
         doc.defaultButtons= dragCreators;
     }
-    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().presentationTemplate, Doc, null) : undefined;
+    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().searchItemTemplate, Doc, null) : undefined;
+    getTransform = () => {
+    return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
+    }
+    panelHeight = () => {
+        return this.props.PanelHeight() - 50;
+    }
+    selectElement = (doc: Doc) => {
+        //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
+    }
+
+    addDocument = (doc: Doc) => {
+        const newPinDoc = Doc.MakeAlias(doc);
+        newPinDoc.presentationTargetDoc = doc;
+        return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
+    }
+
     render() {
 
         return (
@@ -922,14 +942,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         {this.keyButtons}
                     </div>
                 </div>
-                {/* <CollectionView {...this.props}
+                <CollectionView {...this.props}
+                        children={this._visibleDocuments}
+                        Document={this.props.Document}
                         PanelHeight={this.panelHeight}
                         moveDocument={returnFalse}
                         childLayoutTemplate={this.childLayoutTemplate}
                         addDocument={this.addDocument}
                         removeDocument={returnFalse}
                         focus={this.selectElement}
-                        ScreenToLocalTransform={this.getTransform} /> */}
+                        ScreenToLocalTransform={this.getTransform} />
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
                     height: this.resFull ? "auto" : this.resultHeight,
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index fe2000700..f25464eb0 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -22,6 +22,10 @@ import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView"
 import { SearchBox } from "./SearchBox";
 import "./SearchItem.scss";
 import "./SelectorContextMenu.scss";
+import { FieldViewProps, FieldView } from "../nodes/FieldView";
+import { ViewBoxBaseComponent } from "../DocComponent";
+import { makeInterface } from "../../../new_fields/Schema";
+import { documentSchema } from "../../../new_fields/documentSchemas";
 
 export interface SearchItemProps {
     doc: Doc;
@@ -122,30 +126,35 @@ export class LinkContextMenu extends React.Component<LinkMenuProps> {
 
 }
 
+
+type SearchSchema = makeInterface<[typeof documentSchema]>;
+const SearchDocument = makeInterface(documentSchema);
+
 @observer
-export class SearchItem extends React.Component<SearchItemProps> {
+export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) {
+    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); }
 
     @observable _selected: boolean = false;
 
     onClick = () => {
         // I dont think this is the best functionality because clicking the name of the collection does that. Change it back if you'd like
-        DocumentManager.Instance.jumpToDocument(this.props.doc, false);
+        DocumentManager.Instance.jumpToDocument(this.props.doc!, false);
     }
     @observable _useIcons = true;
     @observable _displayDim = 50;
 
     componentDidMount() {
-        Doc.SetSearchQuery(this.props.query);
-        this.props.doc.searchMatch = true;
+        Doc.SetSearchQuery(StrCast(this.props.doc!.query));
+        this.props.doc!.searchMatch = true;
     }
     componentWillUnmount() {
-        this.props.doc.searchMatch = undefined;
+        this.props.doc!.searchMatch = undefined;
     }
 
     //@computed
     @action
     public DocumentIcon() {
-        const layoutresult = StrCast(this.props.doc.type);
+        const layoutresult = StrCast(this.props.doc!.type);
         if (!this._useIcons) {
             const returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
             const returnYDimension = () => this._displayDim;
@@ -156,10 +165,10 @@ export class SearchItem extends React.Component<SearchItemProps> {
                 })}
                 onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} >
                 <ContentFittingDocumentView
-                    Document={this.props.doc}
+                    Document={this.props.doc!}
                     LibraryPath={emptyPath}
                     rootSelected={returnFalse}
-                    fitToBox={StrCast(this.props.doc.type).indexOf(DocumentType.COL) !== -1}
+                    fitToBox={StrCast(this.props.doc!.type).indexOf(DocumentType.COL) !== -1}
                     addDocument={returnFalse}
                     removeDocument={returnFalse}
                     addDocTab={returnFalse}
@@ -198,35 +207,35 @@ export class SearchItem extends React.Component<SearchItemProps> {
     nextHighlight = (e: React.PointerEvent) => {
         e.preventDefault();
         e.button === 0 && SearchBox.Instance.openSearch(e);
-        this.props.doc.searchMatch = false;
-        setTimeout(() => this.props.doc.searchMatch = true, 0);
+        this.props.doc!.searchMatch = false;
+        setTimeout(() => this.props.doc!.searchMatch = true, 0);
     }
     highlightDoc = (e: React.PointerEvent) => {
-        if (this.props.doc.type === DocumentType.LINK) {
-            if (this.props.doc.anchor1 && this.props.doc.anchor2) {
+        if (this.props.doc!.type === DocumentType.LINK) {
+            if (this.props.doc!.anchor1 && this.props.doc!.anchor2) {
 
-                const doc1 = Cast(this.props.doc.anchor1, Doc, null);
-                const doc2 = Cast(this.props.doc.anchor2, Doc, null);
+                const doc1 = Cast(this.props.doc!.anchor1, Doc, null);
+                const doc2 = Cast(this.props.doc!.anchor2, Doc, null);
                 Doc.BrushDoc(doc1);
                 Doc.BrushDoc(doc2);
             }
         } else {
-            Doc.BrushDoc(this.props.doc);
+            Doc.BrushDoc(this.props.doc!);
         }
         e.stopPropagation();
     }
 
     unHighlightDoc = (e: React.PointerEvent) => {
-        if (this.props.doc.type === DocumentType.LINK) {
-            if (this.props.doc.anchor1 && this.props.doc.anchor2) {
+        if (this.props.doc!.type === DocumentType.LINK) {
+            if (this.props.doc!.anchor1 && this.props.doc!.anchor2) {
 
-                const doc1 = Cast(this.props.doc.anchor1, Doc, null);
-                const doc2 = Cast(this.props.doc.anchor2, Doc, null);
+                const doc1 = Cast(this.props.doc!.anchor1, Doc, null);
+                const doc2 = Cast(this.props.doc!.anchor2, Doc, null);
                 Doc.UnBrushDoc(doc1);
                 Doc.UnBrushDoc(doc2);
             }
         } else {
-            Doc.UnBrushDoc(this.props.doc);
+            Doc.UnBrushDoc(this.props.doc!);
         }
     }
 
@@ -236,7 +245,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
         ContextMenu.Instance.clearItems();
         ContextMenu.Instance.addItem({
             description: "Copy ID", event: () => {
-                Utils.CopyText(this.props.doc[Id]);
+                Utils.CopyText(this.props.doc![Id]);
             },
             icon: "fingerprint"
         });
@@ -261,7 +270,7 @@ export class SearchItem extends React.Component<SearchItemProps> {
             Math.abs(e.clientY - this._downY) > Utils.DRAG_THRESHOLD) {
             document.removeEventListener("pointermove", this.onPointerMoved);
             document.removeEventListener("pointerup", this.onPointerUp);
-            const doc = Doc.IsPrototype(this.props.doc) ? Doc.MakeDelegate(this.props.doc) : this.props.doc;
+            const doc = Doc.IsPrototype(this.props.doc!) ? Doc.MakeDelegate(this.props.doc!) : this.props.doc!;
             DragManager.StartDocumentDrag([this._target], new DragManager.DocumentDragData([doc]), e.clientX, e.clientY);
         }
     }
@@ -272,29 +281,29 @@ export class SearchItem extends React.Component<SearchItemProps> {
 
     @computed
     get contextButton() {
-        return <ParentDocSelector Document={this.props.doc} addDocTab={(doc, where) => CollectionDockingView.AddRightSplit(doc)} />;
+        return <ParentDocSelector Document={this.props.doc!} addDocTab={(doc, where) => CollectionDockingView.AddRightSplit(doc)} />;
     }
 
     render() {
-        const doc1 = Cast(this.props.doc.anchor1, Doc);
-        const doc2 = Cast(this.props.doc.anchor2, Doc);
+        const doc1 = Cast(this.props.doc!.anchor1, Doc);
+        const doc2 = Cast(this.props.doc!.anchor2, Doc);
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
                     <div className="searchItem-title-container">
-                        <div className="searchItem-title">{StrCast(this.props.doc.title)}</div>
-                        <div className="searchItem-highlighting">{this.props.highlighting.length ? "Matched fields:" + this.props.highlighting.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}</div>
-                        {this.props.lines.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)}
+                        <div className="searchItem-title">{StrCast(this.props.doc!.title)}</div>
+                        <div className="searchItem-highlighting">{this.props.highlighting!.length ? "Matched fields:" + this.props.highlighting!.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}</div>
+                        {this.props.lines!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)}
                     </div>
                 </div>
                 <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
                     <div className={`icon-${this._useIcons ? "icons" : "live"}`}>
                         <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
-                        <div className="searchItem-label">{this.props.doc.type ? this.props.doc.type : "Other"}</div>
+                        <div className="searchItem-label">{this.props.doc!.type ? this.props.doc!.type : "Other"}</div>
                     </div>
                 </div>
                 <div className="searchItem-context" title="Drag as document">
-                    {(doc1 instanceof Doc && doc2 instanceof Doc) && this.props.doc.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
+                    {(doc1 instanceof Doc && doc2 instanceof Doc) && this.props.doc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
                         this.contextButton}
                 </div>
             </div>
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index c03779002..3ca6b1b3a 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -251,6 +251,7 @@ export class CurrentUserUtils {
 
     // setup the Search button which will display the search panel.  
     static setupSearchPanel(sidebarContainer: Doc) {
+
         return Docs.Create.ButtonDocument({
             _width: 50, _height: 25, title: "Search", fontSize: 10,
             letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
@@ -331,6 +332,8 @@ export class CurrentUserUtils {
 
     // the initial presentation Doc to use
     static setupDefaultPresentation(doc: Doc) {
+        doc.searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
+
         doc.presentationTemplate = new PrefetchProxy(Docs.Create.PresElementBoxDocument({ title: "pres element template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
         doc.curPresentation = Docs.Create.PresDocument(new List<Doc>(), { title: "Presentation", _viewType: CollectionViewType.Stacking, _LODdisable: true, _chromeStatus: "replaced", _showTitle: "title", boxShadow: "0 0" });
     }
-- 
cgit v1.2.3-70-g09d2


From 9aab1f5e7dc7438dfa8a93afe03bd5746315c994 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 29 Apr 2020 13:49:55 -0700
Subject: bugfixing

---
 src/client/documents/Documents.ts               |  2 +-
 src/client/views/nodes/DocumentContentsView.tsx |  3 ++-
 src/client/views/search/SearchBox.tsx           | 31 +++++++++++++++++--------
 3 files changed, 24 insertions(+), 12 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index e5b3c8a97..d440ed287 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -539,7 +539,7 @@ export namespace Docs {
         }
 
         export function SearchDocument(options: DocumentOptions = {}) {
-            return InstanceFromProto(Prototypes.get(DocumentType.SEARCH), "", options);
+            return InstanceFromProto(Prototypes.get(DocumentType.SEARCH), new List<Doc>([]), options);
         }
 
         export function ColorDocument(options: DocumentOptions = {}) {
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index 083638198..cb9e9f5ba 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -25,6 +25,7 @@ import { KeyValueBox } from "./KeyValueBox";
 import { PDFBox } from "./PDFBox";
 import { PresBox } from "./PresBox";
 import { SearchBox } from "../search/SearchBox";
+import { SearchItem } from "../search/SearchItem"
 import { ColorBox } from "./ColorBox";
 import { DashWebRTCVideo } from "../webcam/DashWebRTCVideo";
 import { LinkAnchorBox } from "./LinkAnchorBox";
@@ -111,7 +112,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
                     components={{
                         FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, LabelBox, SliderBox, FieldView,
                         CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
-                        PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, SearchBox,
+                        PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, SearchBox, SearchItem,
                         ColorBox, DashWebRTCVideo, LinkAnchorBox, InkingStroke, DocHolderBox, LinkBox, ScriptingBox,
                         RecommendationsBox, ScreenshotBox
                     }}
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 5ef71ca41..a22052f2e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -348,6 +348,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async () => {
+        this.dataDoc[this.fieldKey] = new List<Doc>([]);
         const query = this._searchString;
         this.getFinalQuery(query);
         this._results = [];
@@ -555,10 +556,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             result[0].query=this._searchString;
-                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
-                            Doc.AddDocToList(this.props.Document, undefined, result[0])
+                            //Make alias
+                            result[0].lines=new List<string>(result[2]);
+                            result[0].highlighting=new List<string>(highlights);
 
-                            this._visibleDocuments[i]= result[0];
+                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            debugger;
+                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
+                            //this.fieldkey + dash search results
+                            //ask about document parmater in collection view
                             this._isSearch[i] = "search";
                         }
                     }
@@ -567,9 +573,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             result[0].query=this._searchString;
+                            result[0].lines=new List<string>(result[2]);
+                            result[0].highlighting=new List<string>(highlights);
+
                             this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
-                            this._visibleDocuments[i] = result[0];
-                            Doc.AddDocToList(this.props.Document, undefined, result[0])
+                            debugger;
+
+                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
                             this._isSearch[i] = "search";
                         }
                     }
@@ -632,6 +642,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
+   //layoutDoc 
+
     @computed
     get menuHeight() {
         return document.getElementById("hi")?.clientHeight;
@@ -717,7 +729,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     
     @computed get docButtons() {
         const nodeBtns = this.props.Document.nodeButtons;
-        let width = () => NumCast(this.props.Document.width);
+        let width = () => NumCast(this.props.Document._width);
         if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
@@ -755,7 +767,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @computed get keyButtons() {
         const nodeBtns = this.props.Document.keyButtons;
-        let width = () => NumCast(this.props.Document.width);
+        let width = () => NumCast(this.props.Document._width);
         if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
@@ -793,7 +805,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @computed get defaultButtons() {
         const defBtns = this.props.Document.defaultButtons;
-        let width = () => NumCast(this.props.Document.width);
+        let width = () => NumCast(this.props.Document._width);
         if (this.rootDoc.sideBar===true){
             width = MainView.Instance.flyoutWidthFunc;
         }
@@ -909,7 +921,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         newPinDoc.presentationTargetDoc = doc;
         return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
     }
-
+    //Make id layour document
     render() {
 
         return (
@@ -943,7 +955,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     </div>
                 </div>
                 <CollectionView {...this.props}
-                        children={this._visibleDocuments}
                         Document={this.props.Document}
                         PanelHeight={this.panelHeight}
                         moveDocument={returnFalse}
-- 
cgit v1.2.3-70-g09d2


From 1848c78f889470d6c558f709efe1b521402b2793 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 29 Apr 2020 20:56:31 -0700
Subject: search results now display as search item docs in stacking view

---
 src/client/views/search/SearchBox.tsx  | 39 +++++++-------
 src/client/views/search/SearchItem.tsx | 94 +++++++++++++++++++---------------
 2 files changed, 72 insertions(+), 61 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index a4f1b7d34..e784580e5 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -79,8 +79,9 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
 @observer
 export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDocument>(SearchBoxDocument) {
 
-    private get _searchString() { return this.props.searchQuery; }
-    private set _searchString(value) { this.props.setSearchQuery(value); }
+    // private get _searchString() { return this.rootDoc.searchQuery; }
+    // private set _searchString(value) { this.rootDoc.setSearchQuery(value); }
+    @observable private _searchString: string ="";
     @observable private _resultsOpen: boolean = false;
     @observable private _searchbarOpen: boolean = false;
     @observable private _results: [Doc, string[], string[]][] = [];
@@ -340,6 +341,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async () => {
+        console.log(this._searchString);
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         const query = this._searchString;
         this.getFinalQuery(query);
@@ -368,15 +370,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
     private get filterQuery() {
-        const types = this.filterTypes;
-        const baseExpr = "NOT baseProto_b:true";
-        const includeDeleted = this.getDataStatus() ? "" : " NOT deleted_b:true";
-        const includeIcons = this.getDataStatus() ? "" : " NOT type_t:fonticonbox";
-        const typeExpr = !types ? "" : ` (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}"`).join(" ")})`;
-        // fq: type_t:collection OR {!join from=id to=proto_i}type_t:collection   q:text_t:hello
-        const query = [baseExpr, includeDeleted, includeIcons, typeExpr].join(" AND ").replace(/AND $/, "");
-        return query;
-    }
+        // const types = this.filterTypes;
+        // const baseExpr = "NOT baseProto_b:true";
+        // const includeDeleted = this.getDataStatus() ? "" : " NOT deleted_b:true";
+        // const includeIcons = this.getDataStatus() ? "" : " NOT type_t:fonticonbox";
+        // const typeExpr = !types ? "" : ` (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}"`).join(" ")})`;
+        // // fq: type_t:collection OR {!join from=id to=proto_i}type_t:collection   q:text_t:hello
+        // const query = [baseExpr, includeDeleted, includeIcons, typeExpr].join(" AND ").replace(/AND $/, "");
+        // return query;
+        return "";
+        }
 
     getDataStatus() { return this._deletedDocsStatus; }
 
@@ -402,7 +405,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc));
                     const highlights: typeof res.highlighting = {};
                     docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
-                    const filteredDocs = this.filterDocsByType(docs);
+                    const filteredDocs = docs;
+                    //this.filterDocsByType(docs);
                     runInAction(() => {
                         //this._results.push(...filteredDocs);
                         filteredDocs.forEach(doc => {
@@ -556,10 +560,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0].highlighting=new List<string>(highlights);
 
                             this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
-                            debugger;
-                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
-                            //this.fieldkey + dash search results
-                            //ask about document parmater in collection view
+                            result[0].targetDoc=result[0];
+                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
                     }
@@ -572,8 +574,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0].highlighting=new List<string>(highlights);
 
                             this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
-                            debugger;
-
+                            result[0].targetDoc=result[0];
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
                             this._isSearch[i] = "search";
                         }
@@ -963,7 +964,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     height: this.resFull ? "auto" : this.resultHeight,
                     overflow: "visibile" // this.resFull ? "auto" : "visible"
                 }} ref={this._resultsRef}>
-                    {this._visibleElements}
+                    {this._visibleElements.length}
                     
                     
                 </div>
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index f25464eb0..fa94edb1e 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -4,7 +4,7 @@ import { faCaretUp, faChartBar, faFile, faFilePdf, faFilm, faFingerprint, faGlob
 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 import { action, computed, observable, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { Doc } from "../../../new_fields/Doc";
+import { Doc, DocCastAsync } from "../../../new_fields/Doc";
 import { Id } from "../../../new_fields/FieldSymbols";
 import { Cast, NumCast, StrCast } from "../../../new_fields/Types";
 import { emptyFunction, emptyPath, returnFalse, Utils, returnTrue } from "../../../Utils";
@@ -24,7 +24,7 @@ import "./SearchItem.scss";
 import "./SelectorContextMenu.scss";
 import { FieldViewProps, FieldView } from "../nodes/FieldView";
 import { ViewBoxBaseComponent } from "../DocComponent";
-import { makeInterface } from "../../../new_fields/Schema";
+import { makeInterface, createSchema } from "../../../new_fields/Schema";
 import { documentSchema } from "../../../new_fields/documentSchemas";
 
 export interface SearchItemProps {
@@ -128,8 +128,15 @@ export class LinkContextMenu extends React.Component<LinkMenuProps> {
 
 
 type SearchSchema = makeInterface<[typeof documentSchema]>;
+
+export const SearchSchema = createSchema({
+    targetDoc: Doc,
+});
+
 const SearchDocument = makeInterface(documentSchema);
 
+
+
 @observer
 export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) {
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); }
@@ -138,23 +145,23 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     onClick = () => {
         // I dont think this is the best functionality because clicking the name of the collection does that. Change it back if you'd like
-        DocumentManager.Instance.jumpToDocument(this.props.doc!, false);
+        DocumentManager.Instance.jumpToDocument(this.targetDoc, false);
     }
     @observable _useIcons = true;
     @observable _displayDim = 50;
 
     componentDidMount() {
-        Doc.SetSearchQuery(StrCast(this.props.doc!.query));
-        this.props.doc!.searchMatch = true;
+        Doc.SetSearchQuery(StrCast(this.targetDoc.query));
+        this.targetDoc.searchMatch = true;
     }
     componentWillUnmount() {
-        this.props.doc!.searchMatch = undefined;
+        this.targetDoc.searchMatch = undefined;
     }
 
     //@computed
     @action
     public DocumentIcon() {
-        const layoutresult = StrCast(this.props.doc!.type);
+        const layoutresult = StrCast(this.targetDoc.type);
         if (!this._useIcons) {
             const returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
             const returnYDimension = () => this._displayDim;
@@ -165,10 +172,10 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                 })}
                 onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} >
                 <ContentFittingDocumentView
-                    Document={this.props.doc!}
+                    Document={this.targetDoc}
                     LibraryPath={emptyPath}
                     rootSelected={returnFalse}
-                    fitToBox={StrCast(this.props.doc!.type).indexOf(DocumentType.COL) !== -1}
+                    fitToBox={StrCast(this.targetDoc.type).indexOf(DocumentType.COL) !== -1}
                     addDocument={returnFalse}
                     removeDocument={returnFalse}
                     addDocTab={returnFalse}
@@ -207,36 +214,36 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     nextHighlight = (e: React.PointerEvent) => {
         e.preventDefault();
         e.button === 0 && SearchBox.Instance.openSearch(e);
-        this.props.doc!.searchMatch = false;
-        setTimeout(() => this.props.doc!.searchMatch = true, 0);
+        this.targetDoc!.searchMatch = false;
+        setTimeout(() => this.targetDoc!.searchMatch = true, 0);
     }
     highlightDoc = (e: React.PointerEvent) => {
-        if (this.props.doc!.type === DocumentType.LINK) {
-            if (this.props.doc!.anchor1 && this.props.doc!.anchor2) {
+        // if (this.targetDoc!.type === DocumentType.LINK) {
+        //     if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
 
-                const doc1 = Cast(this.props.doc!.anchor1, Doc, null);
-                const doc2 = Cast(this.props.doc!.anchor2, Doc, null);
-                Doc.BrushDoc(doc1);
-                Doc.BrushDoc(doc2);
-            }
-        } else {
-            Doc.BrushDoc(this.props.doc!);
-        }
+        //         const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+        //         const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+        //         Doc.BrushDoc(doc1);
+        //         Doc.BrushDoc(doc2);
+        //     }
+        // } else {
+        //     Doc.BrushDoc(this.targetDoc!);
+        // }
         e.stopPropagation();
     }
 
     unHighlightDoc = (e: React.PointerEvent) => {
-        if (this.props.doc!.type === DocumentType.LINK) {
-            if (this.props.doc!.anchor1 && this.props.doc!.anchor2) {
+        // if (this.targetDoc!.type === DocumentType.LINK) {
+        //     if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
 
-                const doc1 = Cast(this.props.doc!.anchor1, Doc, null);
-                const doc2 = Cast(this.props.doc!.anchor2, Doc, null);
-                Doc.UnBrushDoc(doc1);
-                Doc.UnBrushDoc(doc2);
-            }
-        } else {
-            Doc.UnBrushDoc(this.props.doc!);
-        }
+        //         const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+        //         const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+        //         Doc.UnBrushDoc(doc1);
+        //         Doc.UnBrushDoc(doc2);
+        //     }
+        // } else {
+        //     Doc.UnBrushDoc(this.targetDoc!);
+        // }
     }
 
     onContextMenu = (e: React.MouseEvent) => {
@@ -245,7 +252,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         ContextMenu.Instance.clearItems();
         ContextMenu.Instance.addItem({
             description: "Copy ID", event: () => {
-                Utils.CopyText(this.props.doc![Id]);
+                Utils.CopyText(StrCast(this.targetDoc[Id]));
             },
             icon: "fingerprint"
         });
@@ -270,7 +277,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             Math.abs(e.clientY - this._downY) > Utils.DRAG_THRESHOLD) {
             document.removeEventListener("pointermove", this.onPointerMoved);
             document.removeEventListener("pointerup", this.onPointerUp);
-            const doc = Doc.IsPrototype(this.props.doc!) ? Doc.MakeDelegate(this.props.doc!) : this.props.doc!;
+            const doc = Doc.IsPrototype(this.targetDoc) ? Doc.MakeDelegate(this.targetDoc) : this.targetDoc;
             DragManager.StartDocumentDrag([this._target], new DragManager.DocumentDragData([doc]), e.clientX, e.clientY);
         }
     }
@@ -281,30 +288,33 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     @computed
     get contextButton() {
-        return <ParentDocSelector Document={this.props.doc!} addDocTab={(doc, where) => CollectionDockingView.AddRightSplit(doc)} />;
+        return <ParentDocSelector Document={this.targetDoc} addDocTab={(doc, where) => CollectionDockingView.AddRightSplit(doc)} />;
     }
 
+    @computed get searchElementDoc() { return this.rootDoc; }
+    @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
+
     render() {
-        const doc1 = Cast(this.props.doc!.anchor1, Doc);
-        const doc2 = Cast(this.props.doc!.anchor2, Doc);
+        // const doc1 = Cast(this.targetDoc!.anchor1, Doc);
+        // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
                     <div className="searchItem-title-container">
-                        <div className="searchItem-title">{StrCast(this.props.doc!.title)}</div>
-                        <div className="searchItem-highlighting">{this.props.highlighting!.length ? "Matched fields:" + this.props.highlighting!.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}</div>
-                        {this.props.lines!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)}
+                        <div className="searchItem-title">{StrCast(this.targetDoc.title)}</div>
+                        {/* <div className="searchItem-highlighting">{this.props.highlighting!.length ? "Matched fields:" + this.targetDoc.highlighting!.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}</div> */}
+                        {/* {this.props.lines!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)} */}
                     </div>
                 </div>
                 <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
                     <div className={`icon-${this._useIcons ? "icons" : "live"}`}>
                         <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
-                        <div className="searchItem-label">{this.props.doc!.type ? this.props.doc!.type : "Other"}</div>
+                        <div className="searchItem-label">{this.targetDoc.type ? this.targetDoc.type : "Other"}</div>
                     </div>
                 </div>
                 <div className="searchItem-context" title="Drag as document">
-                    {(doc1 instanceof Doc && doc2 instanceof Doc) && this.props.doc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
-                        this.contextButton}
+                    {/* {(doc1 instanceof Doc && doc2 instanceof Doc) && this.targetDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
+                        this.contextButton} */}
                 </div>
             </div>
         </div>;
-- 
cgit v1.2.3-70-g09d2


From a1d6cf23a902215b91433d26724a75a1844bd4dd Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 12 May 2020 23:02:23 -0700
Subject: setting up facets

---
 solr-8.3.1/bin/solr-8983.pid                       |  2 +-
 solr-8.3.1/server/solr/dash/conf/schema.xml        |  2 +
 src/client/util/SearchUtil.ts                      |  2 +
 src/client/views/search/SearchBox.tsx              | 63 +++++++++++++++-------
 src/client/views/search/SearchItem.tsx             | 11 ++--
 .../authentication/models/current_user_utils.ts    |  1 -
 6 files changed, 57 insertions(+), 24 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index a873e717c..19d1e65cc 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-39661
+5999
diff --git a/solr-8.3.1/server/solr/dash/conf/schema.xml b/solr-8.3.1/server/solr/dash/conf/schema.xml
index c0a4bab07..314ee8f5d 100644
--- a/solr-8.3.1/server/solr/dash/conf/schema.xml
+++ b/solr-8.3.1/server/solr/dash/conf/schema.xml
@@ -44,6 +44,8 @@
   <field name="text" type="text" indexed="true" stored="false" uninvertible="false" multiValued="true"/>
   <field name="id" type="string" indexed="true" stored="true" uninvertible="false" required="true"/>
   <field name="_version_" type="plong" indexed="true" stored="true"/>
+  <field name="proto_i" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" />
+
 
   <dynamicField name="*_t" type="text" indexed="true" stored="true" uninvertible="false" docValues="false"/>
   <dynamicField name="*_n" type="pdouble" indexed="true" stored="true" uninvertible="false" docValues="false"/>
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index 6501da34a..c2be385ae 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -35,7 +35,9 @@ export namespace SearchUtil {
     export async function Search(query: string, returnDocs: boolean, options: SearchParams = {}) {
         query = query || "*"; //If we just have a filter query, search for * as the query
         const rpquery = Utils.prepend("/dashsearch");
+        console.log(query);
         const gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
+        console.log(gotten);
         const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten);
         if (!returnDocs) {
             return result;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index e784580e5..632bcd211 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -116,12 +116,26 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         super(props);
         SearchBox.Instance = this;
         this.resultsScrolled = this.resultsScrolled.bind(this);
+        this.rootDoc._viewType = CollectionViewType.Stacking;
+
+       new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", 
+       backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
+
+
+        if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
+            Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
+            // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
+            // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
+            // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
+            // stored on each pres element.  
+            (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
+                { field: "string", data: Doc.name, container: Doc.name });
+        }
     }
     @observable setupButtons =false;
     componentDidMount = () => {
         console.log(this.setupButtons);
         if (this.setupButtons==false){
-        console.log("Yuh");
             this.setupDocTypeButtons();
             this.setupKeyButtons();
             this.setupDefaultButtons();
@@ -144,7 +158,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this.newAssign=false;
             });
             runInAction(() => {
-                this._searchString = StrCast(sq);
+                this.layoutDoc._searchString = StrCast(sq);
                 this.submitSearch();
             });
         }
@@ -156,7 +170,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
-        this._searchString = e.target.value;
+        this.layoutDoc._searchString = e.target.value;
 
         this._openNoResults = false;
         this._results = [];
@@ -341,9 +355,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async () => {
-        console.log(this._searchString);
+        console.log(StrCast(this.layoutDoc._searchString));
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
-        const query = this._searchString;
+        const query = StrCast(this.layoutDoc._searchString);
         this.getFinalQuery(query);
         this._results = [];
         this._resultsSet.clear();
@@ -438,7 +452,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
-        const res = await this.getAllResults(this.getFinalQuery(this._searchString));
+        const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
         const filtered = this.filterDocsByType(res.docs);
         const docs = filtered.map(doc => {
             const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
@@ -478,7 +492,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             basicWordStatus: this._basicWordStatus,
             icons: this._icons,
         }
-        return Docs.Create.SearchDocument({ _autoHeight: true, title: this._searchString, filterQuery: filter, searchQuery: this._searchString });
+        return Docs.Create.SearchDocument({ _autoHeight: true, title: StrCast(this.layoutDoc._searchString), filterQuery: filter, searchQuery: StrCast(this.layoutDoc._searchString) });
     }
 
     @action.bound
@@ -550,16 +564,17 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 if (this._isSearch[i] !== "search") {
                     let result: [Doc, string[], string[]] | undefined = undefined;
                     if (i >= this._results.length) {
-                        this.getResults(this._searchString);
+                        this.getResults(StrCast(this.layoutDoc._searchString));
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            result[0].query=this._searchString;
+                            result[0].query=StrCast(this.layoutDoc._searchString);
                             //Make alias
                             result[0].lines=new List<string>(result[2]);
-                            result[0].highlighting=new List<string>(highlights);
+                            result[0].highlighting=highlights.join(", ");
 
-                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            this._visibleDocuments[i] = result[0];
+                            //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
@@ -569,11 +584,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            result[0].query=this._searchString;
+                            result[0].query=StrCast(this.layoutDoc._searchString);
                             result[0].lines=new List<string>(result[2]);
-                            result[0].highlighting=new List<string>(highlights);
+                            result[0].highlighting=highlights.join(", ");
 
-                            this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
                             this._isSearch[i] = "search";
@@ -901,7 +917,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         });
         doc.defaultButtons= dragCreators;
     }
-    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? Cast(Doc.UserDoc().searchItemTemplate, Doc, null) : undefined;
+    @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
+
+    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined;
     getTransform = () => {
     return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
     }
@@ -923,10 +941,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         return (
             <div style={{pointerEvents:"all"}}className="searchBox-container">
                 <div className="searchBox-bar">
-                    <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => this._searchString ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
+                    <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
                     </span>
-                    <input value={this._searchString} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
+                    <input value={StrCast(this.layoutDoc._searchString)} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
                         style={{ width: this._searchbarOpen ? "500px" : "100px" }} />
                     <button className="searchBox-barChild searchBox-filter" style={{transform:"none"}} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
@@ -980,4 +998,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 //     // const dv = DocumentManager.Instance.getD  ocumentView(doc);
 //     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
 //     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
-// });
\ No newline at end of file
+// });
+
+Scripting.addGlobal(function lookupSearchBoxField(container: Doc, field: string, data: Doc) {
+    // if (field === 'indexInPres') return DocListCast(container[StrCast(container.presentationFieldKey)]).indexOf(data);
+    // if (field === 'presCollapsedHeight') return container._viewType === CollectionViewType.Stacking ? 50 : 46;
+    // if (field === 'presStatus') return container.presStatus;
+    // if (field === '_itemIndex') return container._itemIndex;
+        if (field == "query") return container._searchString;
+    return undefined;
+});
\ No newline at end of file
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 28874ede0..c3010e6c4 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -144,21 +144,23 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     @observable _selected: boolean = false;
 
     onClick = () => {
-        // I dont think this is the best functionality because clicking the name of the collection does that. Change it back if you'd like
         DocumentManager.Instance.jumpToDocument(this.targetDoc, false);
     }
     @observable _useIcons = true;
     @observable _displayDim = 50;
 
+    @computed get query() { return StrCast(this.lookupField("query")); }
+
     componentDidMount() {
-        Doc.SetSearchQuery(StrCast(this.targetDoc.query));
+
+        console.log(this.query);
+        Doc.SetSearchQuery(this.query);
         this.targetDoc.searchMatch = true;
     }
     componentWillUnmount() {
         this.targetDoc.searchMatch = undefined;
     }
 
-    //@computed
     @action
     public DocumentIcon() {
         const layoutresult = StrCast(this.targetDoc.type);
@@ -308,7 +310,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                 <div className="searchItem-body" onClick={this.onClick}>
                     <div className="searchItem-title-container">
                         <div className="searchItem-title">{StrCast(this.targetDoc.title)}</div>
-                        {/* <div className="searchItem-highlighting">{this.props.highlighting!.length ? "Matched fields:" + this.targetDoc.highlighting!.join(", ") : this.props.lines.length ? this.props.lines[0] : ""}</div> */}
+                        <div className="searchItem-highlighting">{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : //this.props.lines.length ? this.props.lines[0] : 
+                        ""}</div>
                         {/* {this.props.lines!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)} */}
                     </div>
                 </div>
diff --git a/src/server/authentication/models/current_user_utils.ts b/src/server/authentication/models/current_user_utils.ts
index 782582930..bc024356d 100644
--- a/src/server/authentication/models/current_user_utils.ts
+++ b/src/server/authentication/models/current_user_utils.ts
@@ -633,7 +633,6 @@ export class CurrentUserUtils {
 
     // the initial presentation Doc to use
     static setupDefaultPresentation(doc: Doc) {
-        doc.searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
         if (doc["template-presentation"] === undefined) {
             doc["template-presentation"] = new PrefetchProxy(Docs.Create.PresElementBoxDocument({
                 title: "pres element template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data"
-- 
cgit v1.2.3-70-g09d2


From 2cc452ccb09147cd56f19b5ddadd82c3e81a9123 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 13 May 2020 16:59:06 -0700
Subject: building infrastucure for buckets

---
 solr-8.3.1/bin/solr-8983.pid                |  2 +-
 solr-8.3.1/server/solr/dash/conf/schema.xml |  2 +-
 src/client/views/search/SearchBox.tsx       | 20 ++++++++--
 src/client/views/search/SearchItem.tsx      | 57 ++++++++++++++++++++++++++++-
 src/server/ApiManagers/SearchManager.ts     |  5 ++-
 src/server/Websocket/Websocket.ts           |  9 +++--
 6 files changed, 84 insertions(+), 11 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 19d1e65cc..83b9efec3 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-5999
+9117
diff --git a/solr-8.3.1/server/solr/dash/conf/schema.xml b/solr-8.3.1/server/solr/dash/conf/schema.xml
index 314ee8f5d..3424ee7f7 100644
--- a/solr-8.3.1/server/solr/dash/conf/schema.xml
+++ b/solr-8.3.1/server/solr/dash/conf/schema.xml
@@ -44,7 +44,7 @@
   <field name="text" type="text" indexed="true" stored="false" uninvertible="false" multiValued="true"/>
   <field name="id" type="string" indexed="true" stored="true" uninvertible="false" required="true"/>
   <field name="_version_" type="plong" indexed="true" stored="true"/>
-  <field name="proto_i" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" />
+  <field name="proto" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" />
 
 
   <dynamicField name="*_t" type="text" indexed="true" stored="true" uninvertible="false" docValues="false"/>
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 632bcd211..016ff254b 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -550,6 +550,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
         }
+        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
+        bucket.targetDoc = bucket;
+     
+        bucket._viewType === CollectionViewType.Stacking;
+
+        bucket.isBucket=true;
+
+        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
 
         for (let i = 0; i < this._numTotalResults; i++) {
             //if the index is out of the window then put a placeholder in
@@ -562,6 +570,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
             else {
                 if (this._isSearch[i] !== "search") {
+
                     let result: [Doc, string[], string[]] | undefined = undefined;
                     if (i >= this._results.length) {
                         this.getResults(StrCast(this.layoutDoc._searchString));
@@ -576,7 +585,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             this._visibleDocuments[i] = result[0];
                             //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
-                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                           
+                            Doc.AddDocToList(bucket, this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
                     }
@@ -591,7 +601,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
-                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0])
+
+                            Doc.AddDocToList(bucket, this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
                     }
@@ -927,7 +938,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         return this.props.PanelHeight() - 50;
     }
     selectElement = (doc: Doc) => {
-        //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
+        //this.gotoDocument(this.childDocs.indexOf(doc), NumCasst(this.layoutDoc._itemIndex));
     }
 
     addDocument = (doc: Doc) => {
@@ -972,11 +983,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         Document={this.props.Document}
                         PanelHeight={this.panelHeight}
                         moveDocument={returnFalse}
+                        NativeHeight={()=>400}
                         childLayoutTemplate={this.childLayoutTemplate}
                         addDocument={this.addDocument}
                         removeDocument={returnFalse}
                         focus={this.selectElement}
-                        ScreenToLocalTransform={this.getTransform} />
+                        ScreenToLocalTransform={Transform.Identity} />
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
                     height: this.resFull ? "auto" : this.resultHeight,
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index c3010e6c4..564df4232 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -15,7 +15,7 @@ import { SearchUtil } from "../../util/SearchUtil";
 import { Transform } from "../../util/Transform";
 import { SEARCH_THUMBNAIL_SIZE } from "../../views/globalCssVariables.scss";
 import { CollectionDockingView } from "../collections/CollectionDockingView";
-import { CollectionViewType } from "../collections/CollectionView";
+import { CollectionViewType, CollectionView } from "../collections/CollectionView";
 import { ParentDocSelector } from "../collections/ParentDocumentSelector";
 import { ContextMenu } from "../ContextMenu";
 import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView";
@@ -26,6 +26,10 @@ import { FieldViewProps, FieldView } from "../nodes/FieldView";
 import { ViewBoxBaseComponent } from "../DocComponent";
 import { makeInterface, createSchema } from "../../../new_fields/Schema";
 import { documentSchema } from "../../../new_fields/documentSchemas";
+import { PrefetchProxy } from "../../../new_fields/Proxy";
+import { Docs } from "../../documents/Documents";
+import { ScriptField } from "../../../new_fields/ScriptField";
+import { CollectionStackingView } from "../collections/CollectionStackingView";
 
 export interface SearchItemProps {
     doc: Doc;
@@ -53,6 +57,7 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
     constructor(props: SearchItemProps) {
         super(props);
         this.fetchDocuments();
+        
     }
 
     async fetchDocuments() {
@@ -139,8 +144,25 @@ const SearchDocument = makeInterface(documentSchema);
 
 @observer
 export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) {
+    
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); }
 
+    constructor(props:any){
+        super(props);
+        this.targetDoc._viewType= CollectionViewType.Stacking;
+        this.rootDoc._viewType = CollectionViewType.Stacking;
+        if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
+            Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
+            // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
+            // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
+            // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
+            // stored on each pres element.  
+            (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
+                { field: "string", data: Doc.name, container: Doc.name });
+        }
+
+    }
+
     @observable _selected: boolean = false;
 
     onClick = () => {
@@ -302,9 +324,41 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     @computed get searchElementDoc() { return this.rootDoc; }
     @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
 
+    @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
+    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined;
+    getTransform = () => {
+    return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
+    }
+    panelHeight = () => {
+        return this.props.PanelHeight();
+    }
+    selectElement = (doc: Doc) => {
+        //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
+    }
+
+    addDocument = (doc: Doc) => {
+        const newPinDoc = Doc.MakeAlias(doc);
+        newPinDoc.presentationTargetDoc = doc;
+        return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
+    }
     render() {
         // const doc1 = Cast(this.targetDoc!.anchor1, Doc);
         // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
+        if (this.targetDoc.isBucket === true){
+            this.props.Document._viewType=CollectionViewType.Stacking;  
+            this.props.Document._height=160;
+
+            return <CollectionView {...this.props}
+            Document={this.props.Document}
+            PanelHeight={this.panelHeight}
+            moveDocument={returnFalse}
+            childLayoutTemplate={this.childLayoutTemplate}
+            addDocument={this.addDocument}
+            removeDocument={returnFalse}
+            focus={this.selectElement}
+            ScreenToLocalTransform={this.getTransform} />
+        }
+        else {
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
@@ -327,5 +381,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                 </div>
             </div>
         </div>;
+        }
     }
 } 
\ No newline at end of file
diff --git a/src/server/ApiManagers/SearchManager.ts b/src/server/ApiManagers/SearchManager.ts
index 753c31fcf..6638c50e4 100644
--- a/src/server/ApiManagers/SearchManager.ts
+++ b/src/server/ApiManagers/SearchManager.ts
@@ -176,7 +176,7 @@ export namespace SolrManager {
         "audio": ["_t", "url"],
         "web": ["_t", "url"],
         "date": ["_d", value => new Date(value.date).toISOString()],
-        "proxy": ["_i", "fieldId"],
+        // "proxy": ["_i", "fieldId"],
         "list": ["_l", list => {
             const results = [];
             for (const value of list.fields) {
@@ -193,8 +193,11 @@ export namespace SolrManager {
         if (val === null || val === undefined) {
             return;
         }
+        console.log(val);
         const type = val.__type || typeof val;
+        console.log(type);
         let suffix = suffixMap[type];
+        console.log(suffix);
         if (!suffix) {
             return;
         }
diff --git a/src/server/Websocket/Websocket.ts b/src/server/Websocket/Websocket.ts
index 844535056..f92c2a1f3 100644
--- a/src/server/Websocket/Websocket.ts
+++ b/src/server/Websocket/Websocket.ts
@@ -216,7 +216,7 @@ export namespace WebSocket {
         "script": ["_t", value => value.script.originalScript],
         "RichTextField": ["_t", value => value.Text],
         "date": ["_d", value => new Date(value.date).toISOString()],
-        "proxy": ["_i", "fieldId"],
+        // "proxy": ["_i", "fieldId"],
         "list": ["_l", list => {
             const results = [];
             for (const value of list.fields) {
@@ -230,15 +230,18 @@ export namespace WebSocket {
     };
 
     function ToSearchTerm(val: any): { suffix: string, value: any } | undefined {
+        // console.log(val);
+
         if (val === null || val === undefined) {
             return;
         }
         const type = val.__type || typeof val;
+        // console.log(type);
+
         let suffix = suffixMap[type];
         if (!suffix) {
             return;
         }
-
         if (Array.isArray(suffix)) {
             const accessor = suffix[1];
             if (typeof accessor === "function") {
@@ -248,7 +251,7 @@ export namespace WebSocket {
             }
             suffix = suffix[0];
         }
-
+        // console.log(suffix);
         return { suffix, value: val };
     }
 
-- 
cgit v1.2.3-70-g09d2


From 3b366a85d3544a87174d92657ad684ac46cb6117 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 13 May 2020 21:50:52 -0700
Subject: bucket ui

---
 .../views/collections/CollectionStackingView.tsx   |  5 ++++-
 src/client/views/search/SearchBox.tsx              |  3 +++
 src/client/views/search/SearchItem.scss            | 23 ++++++++++++++++++++++
 src/client/views/search/SearchItem.tsx             | 13 ++++++++++--
 4 files changed, 41 insertions(+), 3 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index 821a6d476..376e7c087 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -47,6 +47,8 @@ export class CollectionStackingView extends CollectionSubView(StackingDocument)
     @computed get xMargin() { return NumCast(this.props.Document._xMargin, 2 * Math.min(this.gridGap, .05 * this.props.PanelWidth())); }
     @computed get yMargin() { return Math.max(this.props.Document._showTitle && !this.props.Document._showTitleHover ? 30 : 0, NumCast(this.props.Document._yMargin, 0)); } // 2 * this.gridGap)); }
     @computed get gridGap() { return NumCast(this.props.Document._gridGap, 10); }
+    @computed get searchDoc() { return BoolCast(this.props.Document._searchDoc, false); }
+
     @computed get isStackingView() { return BoolCast(this.props.Document.singleColumn, true); }
     @computed get numGroupColumns() { return this.isStackingView ? Math.max(1, this.Sections.size + (this.showAddAGroup ? 1 : 0)) : 1; }
     @computed get showAddAGroup() { return (this.pivotField && (this.props.Document._chromeStatus !== 'view-mode' && this.props.Document._chromeStatus !== 'disabled')); }
@@ -75,7 +77,8 @@ export class CollectionStackingView extends CollectionSubView(StackingDocument)
             const dxf = () => this.getDocTransform(d, dref.current!);
             this._docXfs.push({ dxf, width, height });
             const rowSpan = Math.ceil((height() + this.gridGap) / this.gridGap);
-            const style = this.isStackingView ? { width: width(), marginTop: i ? this.gridGap : 0, height: height() } : { gridRowEnd: `span ${rowSpan}` };
+            
+            const style = this.isStackingView ? { width: width(), marginTop: i || this.searchDoc? this.gridGap : 0, marginBottom: this.searchDoc? 10:0, height: height() } : { gridRowEnd: `span ${rowSpan}` };
             return <div className={`collectionStackingView-${this.isStackingView ? "columnDoc" : "masonryDoc"}`} key={d[Id]} ref={dref} style={style} >
                 {this.getDisplayDoc(d, (!d.isTemplateDoc && !d.isTemplateForField && !d.PARAMS) ? undefined : this.props.DataDoc, dxf, width)}
             </div>;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 016ff254b..103e9a298 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -554,6 +554,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         bucket.targetDoc = bucket;
      
         bucket._viewType === CollectionViewType.Stacking;
+        bucket.bucketfield = "Default";
 
         bucket.isBucket=true;
 
@@ -948,6 +949,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     //Make id layour document
     render() {
+        this.props.Document._gridGap=20;
+        this.props.Document._searchDoc=true;
 
         return (
             <div style={{pointerEvents:"all"}}className="searchBox-container">
diff --git a/src/client/views/search/SearchItem.scss b/src/client/views/search/SearchItem.scss
index 469f062b2..9996e0a50 100644
--- a/src/client/views/search/SearchItem.scss
+++ b/src/client/views/search/SearchItem.scss
@@ -160,4 +160,27 @@
 
 .collection-item {
     width: 35px;
+}
+
+.bucket-title{
+    width:auto;
+    padding: 5px;
+    height: auto;
+    top: -18;
+    z-index: 55;
+    position: absolute;
+}
+
+.bucket-expand{
+    bottom: 0;
+    position: absolute;
+    width: 100%;
+    height: 15;
+    transform:none;
+    .bucket-expand:hover{
+        transform:none;
+    }
+    button:hover{
+        transform:none;
+    }
 }
\ No newline at end of file
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 564df4232..5cef3b627 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -346,9 +346,15 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
         if (this.targetDoc.isBucket === true){
             this.props.Document._viewType=CollectionViewType.Stacking;  
-            this.props.Document._height=160;
+            this.props.Document._chromeStatus='disabled';
 
-            return <CollectionView {...this.props}
+            this.props.Document._height=185;
+
+            return <div>
+            <div className="bucket-title">
+                {StrCast(this.rootDoc.bucketfield)}
+            </div>
+            <CollectionView {...this.props}
             Document={this.props.Document}
             PanelHeight={this.panelHeight}
             moveDocument={returnFalse}
@@ -357,6 +363,9 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             removeDocument={returnFalse}
             focus={this.selectElement}
             ScreenToLocalTransform={this.getTransform} />
+            <button className="bucket-expand">
+            </button>
+            </div>
         }
         else {
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
-- 
cgit v1.2.3-70-g09d2


From b53d19c5a09978990d6b7fd084ebf4bfbb173cec Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 14 May 2020 01:50:27 -0700
Subject: ui

---
 src/client/views/search/SearchBox.tsx  | 52 +++++++++++++++++++++++++---------
 src/client/views/search/SearchItem.tsx | 13 ++++++++-
 2 files changed, 51 insertions(+), 14 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 103e9a298..728ae0eae 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -81,7 +81,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     // private get _searchString() { return this.rootDoc.searchQuery; }
     // private set _searchString(value) { this.rootDoc.setSearchQuery(value); }
-    @observable private _searchString: string ="";
+    @observable _searchString: string ="";
     @observable private _resultsOpen: boolean = false;
     @observable private _searchbarOpen: boolean = false;
     @observable private _results: [Doc, string[], string[]][] = [];
@@ -357,6 +357,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     submitSearch = async () => {
         console.log(StrCast(this.layoutDoc._searchString));
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
+        this.buckets=[];
         const query = StrCast(this.layoutDoc._searchString);
         this.getFinalQuery(query);
         this._results = [];
@@ -364,12 +365,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._isSearch = [];
         this._visibleElements = [];
         this._visibleDocuments = [];
+        console.log(query);
         if (query !== "") {
+            console.log("yes")
             this._endIndex = 12;
             this._maxSearchIndex = 0;
             this._numTotalResults = -1;
+            console.log("yesss");
             await this.getResults(query);
-
             runInAction(() => {
                 this._resultsOpen = true;
                 this._searchbarOpen = true;
@@ -378,6 +381,26 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             });
         }
     }
+    
+    @action private makebuckets(){
+        console.log("we made it");
+        console.log(this._numTotalResults);
+        while (this.buckets!.length <this._numTotalResults/3){
+            console.log("yeet");
+
+            let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
+            bucket.targetDoc = bucket;      
+            bucket._viewType === CollectionViewType.Stacking;
+            bucket.bucketfield = "Default";
+            bucket.isBucket=true;
+            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
+            this.buckets!.push(bucket);
+            console.log(this.buckets!.length);
+            
+            }
+    }
+
+    @observable buckets:Doc[]|undefined;
 
     getAllResults = async (query: string) => {
         return SearchUtil.Search(query, true, { fq: this.filterQuery, start: 0, rows: 10000000 });
@@ -524,6 +547,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @action
     resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
         if (!this._resultsRef.current) return;
+        this.makebuckets();
+
         const scrollY = e ? e.currentTarget.scrollTop : this._resultsRef.current ? this._resultsRef.current.scrollTop : 0;
         const itemHght = 53;
         const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
@@ -550,15 +575,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
         }
-        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
-        bucket.targetDoc = bucket;
-     
-        bucket._viewType === CollectionViewType.Stacking;
-        bucket.bucketfield = "Default";
 
-        bucket.isBucket=true;
-
-        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
 
         for (let i = 0; i < this._numTotalResults; i++) {
             //if the index is out of the window then put a placeholder in
@@ -577,7 +594,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         this.getResults(StrCast(this.layoutDoc._searchString));
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
+                            if (StrCast(result[0].type)!=="search"){
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
+                            
                             result[0].query=StrCast(this.layoutDoc._searchString);
                             //Make alias
                             result[0].lines=new List<string>(result[2]);
@@ -586,14 +605,19 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             this._visibleDocuments[i] = result[0];
                             //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
-                           
-                            Doc.AddDocToList(bucket, this.props.fieldKey, result[0]);
+                            console.log(this.buckets!.length);
+
+                            Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
+                        }
+
                     }
                     else {
                         result = this._results[i];
                         if (result) {
+                            if (StrCast(result[0].type)!=="search"){
+
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             result[0].query=StrCast(this.layoutDoc._searchString);
                             result[0].lines=new List<string>(result[2]);
@@ -602,9 +626,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
+                            console.log(this.buckets!.length);
 
-                            Doc.AddDocToList(bucket, this.props.fieldKey, result[0]);
+                            Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
+                            }
                         }
                     }
                 }
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 5cef3b627..6e319b104 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -341,6 +341,14 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         newPinDoc.presentationTargetDoc = doc;
         return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
     }
+
+    newsearch(){
+       runInAction(()=>{
+        SearchBox.Instance._searchString="";
+        SearchBox.Instance.submitSearch();
+       }) 
+    }
+
     render() {
         // const doc1 = Cast(this.targetDoc!.anchor1, Doc);
         // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
@@ -357,13 +365,16 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             <CollectionView {...this.props}
             Document={this.props.Document}
             PanelHeight={this.panelHeight}
+            whenActiveChanged={emptyFunction}
+            onClick={undefined}
+
             moveDocument={returnFalse}
             childLayoutTemplate={this.childLayoutTemplate}
             addDocument={this.addDocument}
             removeDocument={returnFalse}
             focus={this.selectElement}
             ScreenToLocalTransform={this.getTransform} />
-            <button className="bucket-expand">
+            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, fontFamily:"Arial, sans-serif"}}>See all results...
             </button>
             </div>
         }
-- 
cgit v1.2.3-70-g09d2


From d86a60f534c47773801a53f8992f9d2f3bc4db1c Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 20 May 2020 23:32:57 -0700
Subject: working on search syntax

---
 src/client/util/SearchUtil.ts         | 9 +++++----
 src/client/views/search/SearchBox.tsx | 4 +---
 2 files changed, 6 insertions(+), 7 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index 1939b3e77..77fac3711 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -4,6 +4,7 @@ import { Doc } from '../../new_fields/Doc';
 import { Id } from '../../new_fields/FieldSymbols';
 import { Utils } from '../../Utils';
 import { DocumentType } from '../documents/DocumentTypes';
+import { StringMap } from 'libxmljs';
 
 export namespace SearchUtil {
     export type HighlightingResult = { [id: string]: { [key: string]: string[] } };
@@ -29,7 +30,8 @@ export namespace SearchUtil {
         rows?: number;
         fq?: string;
         allowAliases?: boolean;
-
+        "facet"?:string;
+        "facet.field"?: string;
     }
     export function Search(query: string, returnDocs: true, options?: SearchParams): Promise<DocSearchResult>;
     export function Search(query: string, returnDocs: false, options?: SearchParams): Promise<IdSearchResult>;
@@ -38,9 +40,8 @@ export namespace SearchUtil {
         const rpquery = Utils.prepend("/dashsearch");
         console.log(rpquery);
         console.log(options);
-        query = query + '&facet=true&facet.field=_height&facet.limit=3';
-        const gotten = await rp.get(rpquery+)
-        // const gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
+        console.log({ qs: { ...options, q: query } });
+        const gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
         console.log(gotten);
         const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten);
         console.log(result);
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 728ae0eae..a1631951e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -383,10 +383,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     
     @action private makebuckets(){
-        console.log("we made it");
         console.log(this._numTotalResults);
         while (this.buckets!.length <this._numTotalResults/3){
-            console.log("yeet");
 
             let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
             bucket.targetDoc = bucket;      
@@ -429,7 +427,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
         this.lockPromise = new Promise(async res => {
             while (this._results.length <= this._endIndex && (this._numTotalResults === -1 || this._maxSearchIndex < this._numTotalResults)) {
-                this._curRequest = SearchUtil.Search(query, true, { fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*" }).then(action(async (res: SearchUtil.DocSearchResult) => {
+                this._curRequest = SearchUtil.Search(query, true, {fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*", "facet":"on", "facet.field":"_height" }).then(action(async (res: SearchUtil.DocSearchResult) => {
                     // happens at the beginning
                     if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
                         this._numTotalResults = res.numFound;
-- 
cgit v1.2.3-70-g09d2


From ad423a30fed48a558d655b1dc70e88d10627ee52 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 4 Jun 2020 00:54:26 -0400
Subject: bucket dictionary

---
 src/client/views/search/SearchBox.tsx | 41 ++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 8 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 7ada7574c..2be398028 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -95,6 +95,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     public inputRef = React.createRef<HTMLInputElement>();
 
     private _isSearch: ("search" | "placeholder" | undefined)[] = [];
+    private _isSorted: ("sorted" | "placeholder" | undefined)[] = [];
+
     private _numTotalResults = -1;
     private _endIndex = -1;
 
@@ -104,7 +106,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     private _curRequest?: Promise<any> = undefined;
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchBox, fieldKey); }
 
-
+    private new_buckets: { [characterName: string]: number} = {};
     //if true, any keywords can be used. if false, all keywords are required.
     //this also serves as an indicator if the word status filter is applied
     @observable private _basicWordStatus: boolean = false;
@@ -359,32 +361,36 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         console.log(StrCast(this.layoutDoc._searchString));
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.buckets=[];
+        this.new_buckets={};
         const query = StrCast(this.layoutDoc._searchString);
         this.getFinalQuery(query);
         this._results = [];
         this._resultsSet.clear();
         this._isSearch = [];
+        this._isSorted=[];
         this._visibleElements = [];
         this._visibleDocuments = [];
         console.log(query);
         if (query !== "") {
-            console.log("yes")
             this._endIndex = 12;
             this._maxSearchIndex = 0;
             this._numTotalResults = -1;
-            console.log("yesss");
             await this.getResults(query);
             runInAction(() => {
                 this._resultsOpen = true;
                 this._searchbarOpen = true;
                 this._openNoResults = true;
                 this.resultsScrolled();
+
             });
         }
     }
     
     @action private makebuckets(){
         console.log(this._numTotalResults);
+        this._results.forEach(element => {
+            
+        });
         while (this.buckets!.length <this._numTotalResults/3){
 
             let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
@@ -433,7 +439,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
                         this._numTotalResults = res.numFound;
                     }
-
                     const highlighting = res.highlighting || {};
                     const highlightList = res.docs.map(doc => highlighting[doc[Id]]);
                     const lines = new Map<string, string[]>();
@@ -467,6 +472,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 await this._curRequest;
             }
             this.resultsScrolled();
+
             res();
         });
         return this.lockPromise;
@@ -573,6 +579,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._visibleDocuments = Array<Doc>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
             // indicates if things are placeholders 
             this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
+            this._isSorted = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
+
         }
 
 
@@ -582,6 +590,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             if (i < startIndex || i > endIndex) {
                 if (this._isSearch[i] !== "placeholder") {
                     this._isSearch[i] = "placeholder";
+                    this._isSorted[i]="placeholder";
                     this._visibleElements[i] = <div className="searchBox-placeholder" key={`searchBox-placeholder-${i}`}>Loading...</div>;
                 }
             }
@@ -594,6 +603,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
                             if (StrCast(result[0].type)!=="search"){
+
+                            if(this.new_buckets[StrCast(result[0].type)]===undefined){
+                                this.new_buckets[StrCast(result[0].type)]=1;
+                            }
+                            else { 
+                                this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
+                            }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             
                             result[0].query=StrCast(this.layoutDoc._searchString);
@@ -604,7 +620,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             this._visibleDocuments[i] = result[0];
                             //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
-                            console.log(this.buckets!.length);
 
                             Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
@@ -616,7 +631,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         result = this._results[i];
                         if (result) {
                             if (StrCast(result[0].type)!=="search"){
-
+                            if(this.new_buckets[StrCast(result[0].type)]===undefined){
+                                this.new_buckets[StrCast(result[0].type)]=1;
+                            }
+                            else { 
+                                this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
+                            }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             result[0].query=StrCast(this.layoutDoc._searchString);
                             result[0].lines=new List<string>(result[2]);
@@ -625,9 +645,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
-                            console.log(this.buckets!.length);
 
-                            Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
+                            //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                             }
                         }
@@ -635,6 +654,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
+        for (let i = 0; i < this._numTotalResults; i++) {
+            if (this._isSearch[i] === "search" && this._isSorted[i]==="placeholder") {
+                console.log(this.new_buckets);
+                this._isSorted[i]="sorted"; 
+            }
+        }
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
             this._visibleDocuments.length = this._results.length;
-- 
cgit v1.2.3-70-g09d2


From c709da751cb1f98c89f3c9a3e81aa6524cc9173e Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 4 Jun 2020 17:08:00 -0400
Subject: sorting in buckets works

---
 solr-8.3.1/bin/solr-8983.pid          |   2 +-
 src/client/util/SearchUtil.ts         |   4 --
 src/client/views/search/SearchBox.tsx | 103 +++++++++++++++++++++++++++++-----
 3 files changed, 89 insertions(+), 20 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 448f2547b..5559899bb 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-5663
+846
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index 15f1f9494..ef6665c43 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -38,13 +38,9 @@ export namespace SearchUtil {
     export async function Search(query: string, returnDocs: boolean, options: SearchParams = {}) {
         query = query || "*"; //If we just have a filter query, search for * as the query
         const rpquery = Utils.prepend("/dashsearch");
-        console.log(rpquery);
-        console.log(options);
         console.log({ qs: { ...options, q: query } });
         const gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
-        console.log(gotten);
         const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten);
-        console.log(result);
         if (!returnDocs) {
             return result;
         }
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 2be398028..0ae9b4bb3 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -137,7 +137,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     @observable setupButtons =false;
     componentDidMount = () => {
-        console.log(this.setupButtons);
         if (this.setupButtons==false){
             this.setupDocTypeButtons();
             this.setupKeyButtons();
@@ -149,7 +148,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             runInAction( () => {this._searchbarOpen = true});
         }
         if (this.rootDoc.searchQuery&& this.newAssign) {
-            console.log(this.rootDoc.searchQuery);
             const sq = this.rootDoc.searchQuery;
             runInAction(() => {
 
@@ -358,7 +356,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async () => {
-        console.log(StrCast(this.layoutDoc._searchString));
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.buckets=[];
         this.new_buckets={};
@@ -370,7 +367,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._isSorted=[];
         this._visibleElements = [];
         this._visibleDocuments = [];
-        console.log(query);
         if (query !== "") {
             this._endIndex = 12;
             this._maxSearchIndex = 0;
@@ -387,7 +383,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     
     @action private makebuckets(){
-        console.log(this._numTotalResults);
         this._results.forEach(element => {
             
         });
@@ -399,11 +394,67 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             bucket.bucketfield = "Default";
             bucket.isBucket=true;
             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
-            this.buckets!.push(bucket);
-            console.log(this.buckets!.length);
-            
+            this.buckets!.push(bucket);            
             }
     }
+    @observable firststring: string = "";
+    @observable secondstring: string = "";
+
+    @observable bucketcount:number[]=[];
+
+    @action private makenewbuckets(){
+        let highcount=0;
+        let secondcount=0;
+        this.firststring="";
+        this.secondstring="";
+        this.buckets=[];
+        this.bucketcount=[];
+        this.dataDoc[this.fieldKey] = new List<Doc>([]);
+        for (var key in this.new_buckets){
+            if (this.new_buckets[key]>highcount){
+                secondcount===highcount;
+                this.secondstring=this.firststring;
+                highcount=this.new_buckets[key];
+                this.firststring= key;
+            }
+            else if (this.new_buckets[key]>secondcount){
+                secondcount=this.new_buckets[key];
+                this.secondstring= key;
+            }
+        }
+
+        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket` });
+        bucket.targetDoc = bucket;      
+        bucket._viewType === CollectionViewType.Stacking;
+        bucket.bucketfield = "Default";
+        bucket.isBucket=true;
+        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
+        this.buckets!.push(bucket);
+        this.bucketcount[0]=0;
+        
+        if (this.firststring!==""){
+        let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.firststring });
+        firstbucket.targetDoc = firstbucket;      
+        firstbucket._viewType === CollectionViewType.Stacking;
+        firstbucket.bucketfield = this.firststring;
+        firstbucket.isBucket=true;
+        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, firstbucket);
+        this.buckets!.push(firstbucket);
+        this.bucketcount[1]=0;
+
+        }
+
+        if (this.secondstring!==""){
+        let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+        secondbucket.targetDoc = secondbucket;      
+        secondbucket._viewType === CollectionViewType.Stacking;
+        secondbucket.bucketfield = this.secondstring;
+        secondbucket.isBucket=true;
+        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, secondbucket);
+        this.buckets!.push(secondbucket);
+        this.bucketcount[2]=0;
+        }
+    }
 
     @observable buckets:Doc[]|undefined;
 
@@ -481,8 +532,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
         const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
-        const filtered = this.filterDocsByType(res.docs);
-        const docs = filtered.map(doc => {
+       // const filtered = this.filterDocsByType(res.docs);
+       const filtered = res.docs 
+       const docs = filtered.map(doc => {
             const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
             if (isProto) {
                 return Doc.MakeDelegate(doc);
@@ -621,7 +673,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
 
-                            Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
+                            //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
                         }
@@ -643,23 +695,45 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0].highlighting=highlights.join(", ");
 
                             //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
+                            if(i<this._visibleDocuments.length){
                             this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
 
                             //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                             }
+                            }
                         }
                     }
                 }
             }
         }
+        this.makenewbuckets();
         for (let i = 0; i < this._numTotalResults; i++) {
-            if (this._isSearch[i] === "search" && this._isSorted[i]==="placeholder") {
-                console.log(this.new_buckets);
+            console.log(this._isSearch[i],this._isSorted[i]);
+            if (this._isSearch[i] === "search" && (this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
+                let result = this._results[i];
+                if (StrCast(result[0].type)=== this.firststring && this.bucketcount[1]<3){
+                    Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
+                    this.bucketcount[1]+=1;
+                }
+                else if (StrCast(result[0].type)=== this.secondstring && this.bucketcount[1]<3){
+                    Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
+                    this.bucketcount[2]+=1;
+                }
+                else if (this.bucketcount[0]<3){
+                    Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
+                    this.bucketcount[0]+=1;
+
+                }
                 this._isSorted[i]="sorted"; 
             }
         }
+        if (this.bucketcount[0]===0){
+            Doc.RemoveDocFromList(this.dataDoc, this.props.fieldKey, this.buckets![0]);
+            }
+        
+
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
             this._visibleDocuments.length = this._results.length;
@@ -667,6 +741,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
+
     @computed
     get resFull() { return this._numTotalResults <= 8; }
 
@@ -681,7 +756,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action.bound
     handleNodeChange = () => {
-        console.log("oi!");
         this._nodeStatus = !this._nodeStatus;
         if (this._nodeStatus) {
             this.expandSection(`node${this.props.Document[Id]}`);
@@ -754,7 +828,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
     expandSection(thing: string) {
-        console.log("expand");
         const element = document.getElementById(thing)!;
         // get the height of the element's inner content, regardless of its actual size
         const sectionHeight = element.scrollHeight;
-- 
cgit v1.2.3-70-g09d2


From f36be06355bff894ff1bb19ba6493a77c2732778 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 4 Jun 2020 20:16:27 -0400
Subject: highlights

---
 src/client/views/search/SearchBox.tsx  | 54 ++++++++++++++++++++--------------
 src/client/views/search/SearchItem.tsx |  9 +++---
 2 files changed, 36 insertions(+), 27 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 0ae9b4bb3..c38c4c1b9 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -382,21 +382,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
     
-    @action private makebuckets(){
-        this._results.forEach(element => {
-            
-        });
-        while (this.buckets!.length <this._numTotalResults/3){
-
-            let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `bucket` });
-            bucket.targetDoc = bucket;      
-            bucket._viewType === CollectionViewType.Stacking;
-            bucket.bucketfield = "Default";
-            bucket.isBucket=true;
-            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
-            this.buckets!.push(bucket);            
-            }
-    }
     @observable firststring: string = "";
     @observable secondstring: string = "";
 
@@ -423,9 +408,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
         }
 
-        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket` });
+        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket`});
         bucket.targetDoc = bucket;      
         bucket._viewType === CollectionViewType.Stacking;
+        // targetawait Cast(bucket.targetDoc, Doc)!._height=185;
+        bucket._height=185;
         bucket.bucketfield = "Default";
         bucket.isBucket=true;
         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
@@ -434,6 +421,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         
         if (this.firststring!==""){
         let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.firststring });
+        firstbucket._height=185;
+
         firstbucket.targetDoc = firstbucket;      
         firstbucket._viewType === CollectionViewType.Stacking;
         firstbucket.bucketfield = this.firststring;
@@ -446,6 +435,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
         if (this.secondstring!==""){
         let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+        secondbucket._height=185;
         secondbucket.targetDoc = secondbucket;      
         secondbucket._viewType === CollectionViewType.Stacking;
         secondbucket.bucketfield = this.secondstring;
@@ -485,7 +475,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
         this.lockPromise = new Promise(async res => {
             while (this._results.length <= this._endIndex && (this._numTotalResults === -1 || this._maxSearchIndex < this._numTotalResults)) {
-                this._curRequest = SearchUtil.Search(query, true, {fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*", "facet":"on", "facet.field":"_height" }).then(action(async (res: SearchUtil.DocSearchResult) => {
+                this._curRequest = SearchUtil.Search(query, true, {fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*",}).then(action(async (res: SearchUtil.DocSearchResult) => {
                     // happens at the beginning
                     if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
                         this._numTotalResults = res.numFound;
@@ -604,7 +594,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @action
     resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
         if (!this._resultsRef.current) return;
-        this.makebuckets();
 
         const scrollY = e ? e.currentTarget.scrollTop : this._resultsRef.current ? this._resultsRef.current.scrollTop : 0;
         const itemHght = 53;
@@ -666,7 +655,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             
                             result[0].query=StrCast(this.layoutDoc._searchString);
                             //Make alias
-                            result[0].lines=new List<string>(result[2]);
+                            let lines = new List<string>(result[2]);
+                            result[0].lines=lines
                             result[0].highlighting=highlights.join(", ");
 
                             this._visibleDocuments[i] = result[0];
@@ -708,6 +698,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
+        // if (this._numTotalResults>3){
         this.makenewbuckets();
         for (let i = 0; i < this._numTotalResults; i++) {
             console.log(this._isSearch[i],this._isSorted[i]);
@@ -729,10 +720,31 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 this._isSorted[i]="sorted"; 
             }
         }
+        console.log(this.bucketcount[0]);
+        console.log(this.bucketcount[1]);
+        console.log(this.bucketcount[2]);
+        if (this.buckets![0]){
+        this.buckets![0]._height = this.bucketcount[0]*53 + 21;
+        }
+        if (this.buckets![1]){
+        this.buckets![1]._height = this.bucketcount[1]*53 + 21;
+        }
+        if (this.buckets![2]){  
+        this.buckets![2]._height = this.bucketcount[2]*53 + 21;
+        }
+
         if (this.bucketcount[0]===0){
             Doc.RemoveDocFromList(this.dataDoc, this.props.fieldKey, this.buckets![0]);
             }
-        
+        // }
+        // else {
+        //     for (let i = 0; i < this._numTotalResults; i++) {
+        //         if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
+        //             let result = this._results[i];
+        //             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+        //         }
+        //     }
+        // }
 
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
@@ -790,8 +802,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
-   //layoutDoc 
-
     @computed
     get menuHeight() {
         return document.getElementById("hi")?.clientHeight;
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 14aa985ae..103aa8017 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -24,7 +24,7 @@ import "./SearchItem.scss";
 import "./SelectorContextMenu.scss";
 import { FieldViewProps, FieldView } from "../nodes/FieldView";
 import { ViewBoxBaseComponent } from "../DocComponent";
-import { makeInterface, createSchema } from "../../../fields/Schema";
+import { makeInterface, createSchema, listSpec } from "../../../fields/Schema";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { PrefetchProxy } from "../../../fields/Proxy";
 import { Docs } from "../../documents/Documents";
@@ -356,7 +356,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             this.props.Document._viewType=CollectionViewType.Stacking;  
             this.props.Document._chromeStatus='disabled';
 
-            this.props.Document._height=185;
+            this.props.Document._height=this.targetDoc._height;
 
             return <div>
             <div className="bucket-title">
@@ -384,9 +384,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                 <div className="searchItem-body" onClick={this.onClick}>
                     <div className="searchItem-title-container">
                         <div className="searchItem-title">{StrCast(this.targetDoc.title)}</div>
-                        <div className="searchItem-highlighting">{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : //this.props.lines.length ? this.props.lines[0] : 
-                        ""}</div>
-                        {/* {this.props.lines!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)} */}
+                        <div className="searchItem-highlighting">{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : Cast(this.targetDoc.lines, listSpec("string"))!.length ? Cast(this.targetDoc.lines, listSpec("string"))![0] : ""}</div>
+                        {Cast(this.targetDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">{l}</div>)}
                     </div>
                 </div>
                 <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
-- 
cgit v1.2.3-70-g09d2


From ce716a382b83f4f05de651a96871877cd772f3af Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 4 Jun 2020 23:22:42 -0400
Subject: expand bucket

---
 src/client/views/search/SearchBox.tsx  | 18 +++++-------
 src/client/views/search/SearchItem.tsx | 54 +++++++++++++++++-----------------
 2 files changed, 35 insertions(+), 37 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index c38c4c1b9..525969565 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -80,9 +80,8 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
 @observer
 export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDocument>(SearchBoxDocument) {
 
-    // private get _searchString() { return this.rootDoc.searchQuery; }
-    // private set _searchString(value) { this.rootDoc.setSearchQuery(value); }
-    @observable _searchString: string ="";
+    @computed get _searchString() { return this.layoutDoc.searchQuery; }
+    @computed set _searchString(value) { this.layoutDoc.searchQuery=(value); }
     @observable private _resultsOpen: boolean = false;
     @observable private _searchbarOpen: boolean = false;
     @observable private _results: [Doc, string[], string[]][] = [];
@@ -355,7 +354,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
 
     @action
-    submitSearch = async () => {
+    submitSearch = async (reset?:boolean) => {
+        console.log("yes");
+        if (reset){
+            this.layoutDoc._searchString="";
+        }
+        console.log(this.layoutDoc._searchString);  
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.buckets=[];
         this.new_buckets={};
@@ -660,10 +664,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0].highlighting=highlights.join(", ");
 
                             this._visibleDocuments[i] = result[0];
-                            //<SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             result[0].targetDoc=result[0];
 
-                            //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                         }
                         }
@@ -683,13 +685,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0].query=StrCast(this.layoutDoc._searchString);
                             result[0].lines=new List<string>(result[2]);
                             result[0].highlighting=highlights.join(", ");
-
-                            //this._visibleElements[i] = <SearchItem {...this.props} doc={result[0]} lines={result[2]} highlighting={highlights} />;
                             if(i<this._visibleDocuments.length){
                             this._visibleDocuments[i]=result[0];
                             result[0].targetDoc=result[0];
-
-                            //Doc.AddDocToList(this.buckets![Math.floor(i/3)], this.props.fieldKey, result[0]);
                             this._isSearch[i] = "search";
                             }
                             }
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 103aa8017..a8d664ad8 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -248,32 +248,32 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         setTimeout(() => this.targetDoc!.searchMatch = true, 0);
     }
     highlightDoc = (e: React.PointerEvent) => {
-        // if (this.targetDoc!.type === DocumentType.LINK) {
-        //     if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
-
-        //         const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
-        //         const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
-        //         Doc.BrushDoc(doc1);
-        //         Doc.BrushDoc(doc2);
-        //     }
-        // } else {
-        //     Doc.BrushDoc(this.targetDoc!);
-        // }
+        if (this.targetDoc!.type === DocumentType.LINK) {
+            if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
+
+                const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+                const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+                Doc.BrushDoc(doc1);
+                Doc.BrushDoc(doc2);
+            }
+        } else {
+            Doc.BrushDoc(this.targetDoc!);
+        }
         e.stopPropagation();
     }
 
     unHighlightDoc = (e: React.PointerEvent) => {
-        // if (this.targetDoc!.type === DocumentType.LINK) {
-        //     if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
-
-        //         const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
-        //         const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
-        //         Doc.UnBrushDoc(doc1);
-        //         Doc.UnBrushDoc(doc2);
-        //     }
-        // } else {
-        //     Doc.UnBrushDoc(this.targetDoc!);
-        // }
+        if (this.targetDoc!.type === DocumentType.LINK) {
+            if (this.targetDoc!.anchor1 && this.targetDoc!.anchor2) {
+
+                const doc1 = Cast(this.targetDoc!.anchor1, Doc, null);
+                const doc2 = Cast(this.targetDoc!.anchor2, Doc, null);
+                Doc.UnBrushDoc(doc1);
+                Doc.UnBrushDoc(doc2);
+            }
+        } else {
+            Doc.UnBrushDoc(this.targetDoc!);
+        }
     }
 
     onContextMenu = (e: React.MouseEvent) => {
@@ -345,13 +345,13 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     newsearch(){
        runInAction(()=>{
         SearchBox.Instance._searchString="";
-        SearchBox.Instance.submitSearch();
+        SearchBox.Instance.submitSearch(true);
        }) 
     }
 
     render() {
-        // const doc1 = Cast(this.targetDoc!.anchor1, Doc);
-        // const doc2 = Cast(this.targetDoc!.anchor2, Doc);
+        const doc1 = Cast(this.targetDoc!.anchor1, Doc);
+        const doc2 = Cast(this.targetDoc!.anchor2, Doc);
         if (this.targetDoc.isBucket === true){
             this.props.Document._viewType=CollectionViewType.Stacking;  
             this.props.Document._chromeStatus='disabled';
@@ -395,8 +395,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                     </div>
                 </div>
                 <div className="searchItem-context" title="Drag as document">
-                    {/* {(doc1 instanceof Doc && doc2 instanceof Doc) && this.targetDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
-                        this.contextButton} */}
+                    {(doc1 instanceof Doc && doc2 instanceof Doc) && this.targetDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
+                        this.contextButton}
                 </div>
             </div>
         </div>;
-- 
cgit v1.2.3-70-g09d2


From b8e81dc8a87ad0e4c5147553f326f3f4931b355b Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Fri, 5 Jun 2020 22:27:17 -0400
Subject: bugfixing filtr menu

---
 src/client/views/search/SearchBox.tsx | 77 +++++++++++++----------------------
 src/fields/Doc.ts                     | 16 ++++----
 2 files changed, 38 insertions(+), 55 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 525969565..15bddcd8a 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -37,17 +37,8 @@ import { documentSchema } from "../../../fields/documentSchemas";
 import { makeInterface, createSchema } from '../../../fields/Schema';
 import { listSpec } from '../../../fields/Schema';
 
-
 library.add(faTimes);
 
-// export interface SearchProps {
-//     id: string;
-//     Document: Doc;
-//     sideBar?: Boolean;
-//     searchQuery?: string;
-//     filterQuery?: filterData;
-// }
-
 export const searchSchema = createSchema({
     id: "string",
     Document: Doc,
@@ -57,8 +48,6 @@ export const searchSchema = createSchema({
 
 //add back filterquery
 
-
-
 export enum Keys {
     TITLE = "title",
     AUTHOR = "author",
@@ -115,8 +104,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable private newAssign: boolean = true;
 
     constructor(props: any) {
+        
         super(props);
         SearchBox.Instance = this;
+        Scripting.addGlobal(this.handleNodeChange);
+        Scripting.addGlobal(this.handleKeyChange);
+        Scripting.addGlobal(this.handleWordQueryChange);
+
         this.resultsScrolled = this.resultsScrolled.bind(this);
         this.rootDoc._viewType = CollectionViewType.Stacking;
 
@@ -210,10 +204,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     //this also serves as an indicator if the word status filter is applied
     @observable private _filterOpen: boolean = false;
     //if icons = all icons, then no icon filter is applied
-    get _icons() { return this.props.searchFileTypes; }
-    set _icons(value) {
-        this.props.setSearchFileTypes(value);
-    }
+    // get _icons() { return this.props.searchFileTypes; }
+    // set _icons(value) {
+    //     this.props.setSearchFileTypes(value);
+    // }
+    @observable _icons: string[] = this._allIcons;
     //if all of these are true, no key filter is applied
     @observable private _titleFieldStatus: boolean = true;
     @observable private _authorFieldStatus: boolean = true;
@@ -238,11 +233,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             query = query.replace(/\s+/g, ' ').trim();
         }
 
-        //if should be searched in a specific collection
-        // if (this._collectionStatus) {
-        //     query = this.addCollectionFilter(query);
-        //     query = query.replace(/\s+/g, ' ').trim();
-        // }
+        // if should be searched in a specific collection
+        if (this._collectionStatus) {
+            query = this.addCollectionFilter(query);
+            query = query.replace(/\s+/g, ' ').trim();
+        }
         return query;
     }
 
@@ -415,7 +410,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket`});
         bucket.targetDoc = bucket;      
         bucket._viewType === CollectionViewType.Stacking;
-        // targetawait Cast(bucket.targetDoc, Doc)!._height=185;
         bucket._height=185;
         bucket.bucketfield = "Default";
         bucket.isBucket=true;
@@ -457,15 +451,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
     private get filterQuery() {
-        // const types = this.filterTypes;
-        // const baseExpr = "NOT baseProto_b:true";
-        // const includeDeleted = this.getDataStatus() ? "" : " NOT deleted_b:true";
-        // const includeIcons = this.getDataStatus() ? "" : " NOT type_t:fonticonbox";
+        const types = this.filterTypes;
+        const baseExpr = "NOT baseProto_b:true";
+        const includeDeleted = this.getDataStatus() ? "" : " NOT deleted_b:true";
+        const includeIcons = this.getDataStatus() ? "" : " NOT type_t:fonticonbox";
         // const typeExpr = !types ? "" : ` (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}"`).join(" ")})`;
-        // // fq: type_t:collection OR {!join from=id to=proto_i}type_t:collection   q:text_t:hello
-        // const query = [baseExpr, includeDeleted, includeIcons, typeExpr].join(" AND ").replace(/AND $/, "");
-        // return query;
-        return "";
+        // fq: type_t:collection OR {!join from=id to=proto_i}type_t:collection   q:text_t:hello
+        const query = [baseExpr, includeDeleted, includeIcons].join(" AND ").replace(/AND $/, "");
+        return query;
         }
 
     getDataStatus() { return this._deletedDocsStatus; }
@@ -491,10 +484,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc));
                     const highlights: typeof res.highlighting = {};
                     docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
-                    const filteredDocs = docs;
-                    //this.filterDocsByType(docs);
+                    const filteredDocs = this.filterDocsByType(docs);
                     runInAction(() => {
-                        //this._results.push(...filteredDocs);
                         filteredDocs.forEach(doc => {
                             const index = this._resultsSet.get(doc);
                             const highlight = highlights[doc[Id]];
@@ -526,8 +517,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
         const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
-       // const filtered = this.filterDocsByType(res.docs);
-       const filtered = res.docs 
+       const filtered = this.filterDocsByType(res.docs);
        const docs = filtered.map(doc => {
             const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
             if (isProto) {
@@ -1001,7 +991,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  
         dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100,
          _height: 100 })) as any as Doc;
-        //backgroundColor: "#121721",       
         doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
         doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
         doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
@@ -1050,9 +1039,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
             _fontSize: 7,
         }))as any as Doc;
-        doc.keywords=button({ title: "Keywords", onClick:ScriptField.MakeScript("handleNodeChange(this)")});
-        doc.keys=button({ title: "Keys", onClick:ScriptField.MakeScript(`this.handleNodeChange`)});
-        doc.nodes = button({ title: "Nodes", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
+        doc.keywords=button({ title: "Keywords", onClick:ScriptField.MakeScript("handleWordQueryChange(self)")});
+        doc.keys=button({ title: "Keys", onClick:ScriptField.MakeScript(`handleKeyChange(self)`)});
+        doc.nodes = button({ title: "Nodes", onClick:ScriptField.MakeScript("handleNodeChange(self)")});
         let buttons = [doc.keywords as Doc, doc.keys as Doc, doc.nodes as Doc];
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
             _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 60, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",_yMargin: 5
@@ -1137,15 +1126,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 }
 
-// Scripting.addGlobal(function handleNodeChange(doc: any) {
-//     console.log("oi");
-//     doc.handleNodeChange();
-    
-//     // const dv = DocumentManager.Instance.getD  ocumentView(doc);
-//     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
-//     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
-// });
-
 Scripting.addGlobal(function lookupSearchBoxField(container: Doc, field: string, data: Doc) {
     // if (field === 'indexInPres') return DocListCast(container[StrCast(container.presentationFieldKey)]).indexOf(data);
     // if (field === 'presCollapsedHeight') return container._viewType === CollectionViewType.Stacking ? 50 : 46;
@@ -1153,4 +1133,5 @@ Scripting.addGlobal(function lookupSearchBoxField(container: Doc, field: string,
     // if (field === '_itemIndex') return container._itemIndex;
         if (field == "query") return container._searchString;
     return undefined;
-});
\ No newline at end of file
+});
+
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 0a003e4f2..62eac379b 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1148,11 +1148,13 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo
 });
 Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: "check" | "x" | undefined) { Doc.setDocFilter(container, key, value, modifiers); });
 Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
-Scripting.addGlobal(function handleNodeChange(doc: any) {
-    console.log("oi");
-    doc.handleNodeChange();
+// Scripting.addGlobal(function handleNodeChange(doc: any) {
+//     console.log("oi");
+//     // console.log(doc);
+//     console.log(this);
+//     this.handleNodeChange();
     
-    // const dv = DocumentManager.Instance.getDocumentView(doc);
-    // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
-    // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
-});
\ No newline at end of file
+//     // const dv = DocumentManager.Instance.getDocumentView(doc);
+//     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
+//     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
+// });
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From e2a29915b100cb9a1580e224e0cfdfb8be669208 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 8 Jun 2020 14:22:27 -0400
Subject: fixed filtering on search, allowing buckets to expand searches

---
 solr-8.3.1/bin/solr-8983.pid           |   2 +-
 src/client/util/Scripting.ts           |   2 +-
 src/client/views/search/SearchBox.tsx  | 118 +++++++++++++++++++++------------
 src/client/views/search/SearchItem.tsx |  13 ++--
 src/fields/Doc.ts                      |  10 ---
 5 files changed, 85 insertions(+), 60 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 5559899bb..6642ad1da 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-846
+2696
diff --git a/src/client/util/Scripting.ts b/src/client/util/Scripting.ts
index ab577315c..98bbffcd7 100644
--- a/src/client/util/Scripting.ts
+++ b/src/client/util/Scripting.ts
@@ -93,7 +93,7 @@ export function scriptingGlobal(constructor: { new(...args: any[]): any }) {
     Scripting.addGlobal(constructor);
 }
 
-const _scriptingGlobals: { [name: string]: any } = {};
+export const _scriptingGlobals: { [name: string]: any } = {};
 let scriptingGlobals: { [name: string]: any } = _scriptingGlobals;
 
 function Run(script: string | undefined, customParams: string[], diagnostics: any[], originalScript: string, options: ScriptOptions): CompileResult {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 15bddcd8a..8e188df38 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -30,12 +30,14 @@ import { List } from '../../../fields/List';
 import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
 import { Transform } from '../../util/Transform';
 import { MainView } from "../MainView";
-import { Scripting } from '../../util/Scripting';
+import { Scripting,_scriptingGlobals } from '../../util/Scripting';
 import { CollectionView, CollectionViewType } from '../collections/CollectionView';
 import { ViewBoxBaseComponent } from "../DocComponent";
 import { documentSchema } from "../../../fields/documentSchemas";
 import { makeInterface, createSchema } from '../../../fields/Schema';
 import { listSpec } from '../../../fields/Schema';
+import * as _ from "lodash";
+
 
 library.add(faTimes);
 
@@ -107,9 +109,18 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         
         super(props);
         SearchBox.Instance = this;
+        if (!_scriptingGlobals.hasOwnProperty("handleNodeChange")){
         Scripting.addGlobal(this.handleNodeChange);
-        Scripting.addGlobal(this.handleKeyChange);
-        Scripting.addGlobal(this.handleWordQueryChange);
+        }
+        if (!_scriptingGlobals.hasOwnProperty("handleKeyChange")){
+            Scripting.addGlobal(this.handleKeyChange);
+        }
+        if (!_scriptingGlobals.hasOwnProperty("handleWordQueryChange")){
+            Scripting.addGlobal(this.handleWordQueryChange);
+        }
+        if (!_scriptingGlobals.hasOwnProperty("updateIcon")){
+            Scripting.addGlobal(this.updateIcon);
+        }
 
         this.resultsScrolled = this.resultsScrolled.bind(this);
         this.rootDoc._viewType = CollectionViewType.Stacking;
@@ -178,6 +189,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
+            runInAction(()=>{this.expandedBucket=false});
             this.submitSearch();
         }
     }
@@ -348,9 +360,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     get fieldFiltersApplied() { return !(this._authorFieldStatus && this._titleFieldStatus); }
 
 
+    @observable expandedBucket:boolean=false;
     @action
     submitSearch = async (reset?:boolean) => {
-        console.log("yes");
+        console.log(this._icons);
         if (reset){
             this.layoutDoc._searchString="";
         }
@@ -411,7 +424,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         bucket.targetDoc = bucket;      
         bucket._viewType === CollectionViewType.Stacking;
         bucket._height=185;
-        bucket.bucketfield = "Default";
+        bucket.bucketfield = "results";
         bucket.isBucket=true;
         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
         this.buckets!.push(bucket);
@@ -686,7 +699,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
-        // if (this._numTotalResults>3){
+        if (this._numTotalResults>3 && this.expandedBucket===false){
         this.makenewbuckets();
         for (let i = 0; i < this._numTotalResults; i++) {
             console.log(this._isSearch[i],this._isSorted[i]);
@@ -701,9 +714,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     this.bucketcount[2]+=1;
                 }
                 else if (this.bucketcount[0]<3){
-                    Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
-                    this.bucketcount[0]+=1;
-
+                    //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
+                    //this.bucketcount[0]+=1;
+                    const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
+                    result[0].query=StrCast(this.layoutDoc._searchString);
+                    result[0].lines=new List<string>(result[2]);
+                    result[0].highlighting=highlights.join(", ");
+                    result[0].targetDoc=result[0];
+                    Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                 }
                 this._isSorted[i]="sorted"; 
             }
@@ -721,18 +739,24 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this.buckets![2]._height = this.bucketcount[2]*53 + 21;
         }
 
-        if (this.bucketcount[0]===0){
-            Doc.RemoveDocFromList(this.dataDoc, this.props.fieldKey, this.buckets![0]);
-            }
-        // }
-        // else {
-        //     for (let i = 0; i < this._numTotalResults; i++) {
-        //         if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
-        //             let result = this._results[i];
-        //             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-        //         }
+        // if (this.bucketcount[0]===0){
+        //     Doc.RemoveDocFromList(this.dataDoc, this.props.fieldKey, this.buckets![0]);
         //     }
-        // }
+        }
+            
+        else {
+                for (let i = 0; i < this._numTotalResults; i++) {
+                    if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
+                        let result = this._results[i];
+                        const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
+                        result[0].query=StrCast(this.layoutDoc._searchString);
+                        result[0].lines=new List<string>(result[2]);
+                        result[0].highlighting=highlights.join(", ");
+                        result[0].targetDoc=result[0];
+                        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                    }
+                }
+            }
 
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
@@ -986,22 +1010,39 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         return (null);
     }
 
+    @action.bound
+    updateIcon= async (icon: string) =>{
+        if (this._icons.includes(icon)){
+            _.pull(this._icons, icon);
+            let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
+            console.log(cap);
+            let doc = await Cast(this.props.Document[cap], Doc)
+            doc!.backgroundColor= "";
+        }
+        else{
+            this._icons.push(icon);
+            let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
+            let doc = await Cast(this.props.Document[cap], Doc)
+            doc!.backgroundColor= "aaaaa3";
+        }
+        console.log(this._icons);
+    }
+
     setupDocTypeButtons() {
         let doc = this.props.Document;
         const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  
         dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100,
          _height: 100 })) as any as Doc;
-        doc.Music = ficon({ onClick: undefined, title: "mussic button", icon: "music" });
-        doc.Col = ficon({ onClick: undefined, title: "col button", icon: "object-group" });
-        doc.Hist = ficon({ onClick: undefined, title: "hist button", icon: "chart-bar" });
-        doc.Image = ficon({ onClick: undefined, title: "image button", icon: "image" });
-        doc.Link = ficon({ onClick: undefined, title: "link button", icon: "link" });
-        doc.PDF = ficon({ onClick: undefined, title: "pdf button", icon: "file-pdf" });
-        doc.TEXT = ficon({ onClick: undefined, title: "text button", icon: "sticky-note" });
-        doc.Vid = ficon({ onClick: undefined, title: "vid button", icon: "video" });
-        doc.Web = ficon({ onClick: undefined, title: "web button", icon: "globe-asia" });
-
-        let buttons = [doc.None as Doc, doc.Music as Doc, doc.Col as Doc, doc.Hist as Doc,
+        doc.Music = ficon({ onClick: ScriptField.MakeScript(`updateIcon("audio")`), title: "music button", icon: "music" });
+        doc.Col  = ficon({ onClick: ScriptField.MakeScript(`updateIcon("collection")`), title: "col button", icon: "object-group" });
+        doc.Image = ficon({ onClick: ScriptField.MakeScript(`updateIcon("image")`), title: "image button", icon: "image" });
+        doc.Link = ficon({ onClick: ScriptField.MakeScript(`updateIcon("link")`), title: "link button", icon: "link" });
+        doc.Pdf = ficon({ onClick: ScriptField.MakeScript(`updateIcon("pdf")`), title: "pdf button", icon: "file-pdf" });
+        doc.Text = ficon({ onClick: ScriptField.MakeScript(`updateIcon("rtf")`), title: "text button", icon: "sticky-note" });
+        doc.Vid = ficon({ onClick: ScriptField.MakeScript(`updateIcon("video")`), title: "vid button", icon: "video" });
+        doc.Web = ficon({ onClick: ScriptField.MakeScript(`updateIcon("web")`), title: "web button", icon: "globe-asia" });
+
+        let buttons = [doc.None as Doc, doc.Music as Doc, doc.Col as Doc, doc.Hist as Doc,  
         doc.Image as Doc, doc.Link as Doc, doc.PDF as Doc, doc.TEXT as Doc, doc.Vid as Doc, doc.Web as Doc];
 
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
@@ -1036,7 +1077,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         let doc = this.props.Document;
         const button = (opts: DocumentOptions) => new PrefetchProxy( Docs.Create.ButtonDocument({...opts,
             _width: 35, _height: 30,
-            borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
+            borderRounding: "16px", border:"1px solid grey", color:"white", 
+            //hovercolor: "rgb(170, 170, 163)", 
+            letterSpacing: "2px",
             _fontSize: 7,
         }))as any as Doc;
         doc.keywords=button({ title: "Keywords", onClick:ScriptField.MakeScript("handleWordQueryChange(self)")});
@@ -1087,18 +1130,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
                     <div id={`filterhead2${this.props.Document[Id]}`} className="filter-header"  >
                         {this.defaultButtons}
-                        {/* <button className="filter-item" style={this._basicWordStatus ? { background: "#aaaaa3", } : {}} onClick={this.handleWordQueryChange}>Keywords</button>
-                        <button className="filter-item" style={this._keyStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleKeyChange}>Keys</button>
-                        <button className="filter-item" style={this._nodeStatus ? { background: "#aaaaa3" } : {}} onClick={this.handleNodeChange}>Nodes</button> */}
                     </div>
                     <div id={`node${this.props.Document[Id]}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
                         {this.docButtons}
                     </div>
                     <div className="filter-key" id={`key${this.props.Document[Id]}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-                        {/* <div className="filter-keybar"> */}
-                            {/* <button className="filter-item" style={this._titleFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateTitleStatus}>Title</button>
-                            <button className="filter-item" style={this._deletedDocsStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateDataStatus}>Deleted Docs</button>
-                            <button className="filter-item" style={this._authorFieldStatus ? { background: "#aaaaa3", } : {}} onClick={this.updateAuthorStatus}>Author</button> */}
                         {this.keyButtons}
                     </div>
                 </div>
@@ -1117,9 +1153,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     height: this.resFull ? "auto" : this.resultHeight,
                     overflow: "visibile" // this.resFull ? "auto" : "visible"
                 }} ref={this._resultsRef}>
-                    {this._visibleElements.length}
-                    
-                    
+                    {this._visibleElements.length}           
                 </div>
             </div>
         );
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index a8d664ad8..a9a8b563b 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -344,8 +344,11 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     newsearch(){
        runInAction(()=>{
-        SearchBox.Instance._searchString="";
-        SearchBox.Instance.submitSearch(true);
+        if (StrCast(this.rootDoc.bucketfield)!=="results"){
+        SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)];
+        }
+        SearchBox.Instance.expandedBucket= true;
+        SearchBox.Instance.submitSearch();
        }) 
     }
 
@@ -355,26 +358,24 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         if (this.targetDoc.isBucket === true){
             this.props.Document._viewType=CollectionViewType.Stacking;  
             this.props.Document._chromeStatus='disabled';
-
             this.props.Document._height=this.targetDoc._height;
 
             return <div>
             <div className="bucket-title">
-                {StrCast(this.rootDoc.bucketfield)}
+                {StrCast(this.rootDoc.bucketfield)==="results"? null:StrCast(this.rootDoc.bucketfield)}
             </div>
             <CollectionView {...this.props}
             Document={this.props.Document}
             PanelHeight={this.panelHeight}
             whenActiveChanged={emptyFunction}
             onClick={undefined}
-
             moveDocument={returnFalse}
             childLayoutTemplate={this.childLayoutTemplate}
             addDocument={this.addDocument}
             removeDocument={returnFalse}
             focus={this.selectElement}
             ScreenToLocalTransform={this.getTransform} />
-            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, fontFamily:"Arial, sans-serif"}}>See all results...
+            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, fontFamily:"Arial, sans-serif"}}>See all {StrCast(this.rootDoc.bucketfield)}...
             </button>
             </div>
         }
diff --git a/src/fields/Doc.ts b/src/fields/Doc.ts
index 62eac379b..e14e4996b 100644
--- a/src/fields/Doc.ts
+++ b/src/fields/Doc.ts
@@ -1148,13 +1148,3 @@ Scripting.addGlobal(function selectedDocs(container: Doc, excludeCollections: bo
 });
 Scripting.addGlobal(function setDocFilter(container: Doc, key: string, value: any, modifiers?: "check" | "x" | undefined) { Doc.setDocFilter(container, key, value, modifiers); });
 Scripting.addGlobal(function setDocFilterRange(container: Doc, key: string, range: number[]) { Doc.setDocFilterRange(container, key, range); });
-// Scripting.addGlobal(function handleNodeChange(doc: any) {
-//     console.log("oi");
-//     // console.log(doc);
-//     console.log(this);
-//     this.handleNodeChange();
-    
-//     // const dv = DocumentManager.Instance.getDocumentView(doc);
-//     // if (dv?.props.Document.layoutKey === layoutKey) dv?.switchViews(otherKey !== "layout", otherKey.replace("layout_", ""));
-//     // else dv?.switchViews(true, layoutKey.replace("layout_", ""));
-// });
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 033e92675fe517a742e067bcfe5ca7a32a832b0b Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 8 Jun 2020 17:01:15 -0400
Subject: visual bugs for filter buttons

---
 src/client/views/search/SearchBox.tsx  | 40 ++++++++++++++++++++++++----------
 src/client/views/search/SearchItem.tsx |  1 +
 2 files changed, 29 insertions(+), 12 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 8e188df38..1d03e78a9 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -37,6 +37,7 @@ import { documentSchema } from "../../../fields/documentSchemas";
 import { makeInterface, createSchema } from '../../../fields/Schema';
 import { listSpec } from '../../../fields/Schema';
 import * as _ from "lodash";
+import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
 
 
 library.add(faTimes);
@@ -363,7 +364,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable expandedBucket:boolean=false;
     @action
     submitSearch = async (reset?:boolean) => {
-        console.log(this._icons);
+        this.checkIcons();
         if (reset){
             this.layoutDoc._searchString="";
         }
@@ -529,7 +530,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
-        const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
+    const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
        const filtered = this.filterDocsByType(res.docs);
        const docs = filtered.map(doc => {
             const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
@@ -1017,15 +1018,29 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
             console.log(cap);
             let doc = await Cast(this.props.Document[cap], Doc)
-            doc!.backgroundColor= "";
+            doc!.backgroundColor= "black";
         }
         else{
             this._icons.push(icon);
             let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
             let doc = await Cast(this.props.Document[cap], Doc)
-            doc!.backgroundColor= "aaaaa3";
+            doc!.backgroundColor= "grey";
         }
-        console.log(this._icons);
+    }
+
+    @action.bound
+    checkIcons = async ()=>{
+        for (let i=0; i<this._allIcons.length; i++){
+        
+            let cap = this._allIcons[i].charAt(0).toUpperCase() + this._allIcons[i].slice(1)
+            let doc = await Cast(this.props.Document[cap], Doc)
+            if (this._icons.includes(this._allIcons[i])){
+                doc!.backgroundColor= "grey";
+            }
+            else{
+                doc!.backgroundColor= "black";
+            }
+    }
     }
 
     setupDocTypeButtons() {
@@ -1033,23 +1048,24 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({ ...opts,  
         dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100,
          _height: 100 })) as any as Doc;
-        doc.Music = ficon({ onClick: ScriptField.MakeScript(`updateIcon("audio")`), title: "music button", icon: "music" });
-        doc.Col  = ficon({ onClick: ScriptField.MakeScript(`updateIcon("collection")`), title: "col button", icon: "object-group" });
+        doc.Audio = ficon({ onClick: ScriptField.MakeScript(`updateIcon("audio")`), title: "music button", icon: "music" });
+        doc.Collection  = ficon({ onClick: ScriptField.MakeScript(`updateIcon("collection")`), title: "col button", icon: "object-group" });
         doc.Image = ficon({ onClick: ScriptField.MakeScript(`updateIcon("image")`), title: "image button", icon: "image" });
         doc.Link = ficon({ onClick: ScriptField.MakeScript(`updateIcon("link")`), title: "link button", icon: "link" });
         doc.Pdf = ficon({ onClick: ScriptField.MakeScript(`updateIcon("pdf")`), title: "pdf button", icon: "file-pdf" });
-        doc.Text = ficon({ onClick: ScriptField.MakeScript(`updateIcon("rtf")`), title: "text button", icon: "sticky-note" });
-        doc.Vid = ficon({ onClick: ScriptField.MakeScript(`updateIcon("video")`), title: "vid button", icon: "video" });
+        doc.Rtf = ficon({ onClick: ScriptField.MakeScript(`updateIcon("rtf")`), title: "text button", icon: "sticky-note" });
+        doc.Video = ficon({ onClick: ScriptField.MakeScript(`updateIcon("video")`), title: "vid button", icon: "video" });
         doc.Web = ficon({ onClick: ScriptField.MakeScript(`updateIcon("web")`), title: "web button", icon: "globe-asia" });
 
-        let buttons = [doc.None as Doc, doc.Music as Doc, doc.Col as Doc, doc.Hist as Doc,  
-        doc.Image as Doc, doc.Link as Doc, doc.PDF as Doc, doc.TEXT as Doc, doc.Vid as Doc, doc.Web as Doc];
+        let buttons = [doc.None as Doc, doc.Audio as Doc, doc.Collection as Doc, 
+        doc.Image as Doc, doc.Link as Doc, doc.Pdf as Doc, doc.Rtf as Doc, doc.Video as Doc, doc.Web as Doc];
 
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
             _width: 500, backgroundColor:"#121721", _autoHeight: true, columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
             dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
         });
         doc.nodeButtons= dragCreators;
+        this.checkIcons()
     }
 
 
@@ -1112,7 +1128,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     //Make id layour document
     render() {
-        this.props.Document._gridGap=20;
+        this.props.Document._gridGap=5;
         this.props.Document._searchDoc=true;
 
         return (
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index a9a8b563b..97ca0ee69 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -346,6 +346,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
        runInAction(()=>{
         if (StrCast(this.rootDoc.bucketfield)!=="results"){
         SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)];
+        SearchBox.Instance._icons=SearchBox.Instance._icons;
         }
         SearchBox.Instance.expandedBucket= true;
         SearchBox.Instance.submitSearch();
-- 
cgit v1.2.3-70-g09d2


From 2767e06d90eeeb25283d2939208a463f8b52ee6e Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 9 Jun 2020 18:17:41 -0400
Subject:  bugfixing and cosmetic changes

---
 solr-8.3.1/bin/solr-8983.pid            |  2 +-
 src/client/util/CurrentUserUtils.ts     |  2 +-
 src/client/views/search/SearchBox.scss  |  2 --
 src/client/views/search/SearchBox.tsx   | 64 ++++++++++++++++++---------------
 src/client/views/search/SearchItem.scss | 10 +++---
 src/client/views/search/SearchItem.tsx  | 20 ++++-------
 src/server/websocket.ts                 |  5 ---
 7 files changed, 48 insertions(+), 57 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 6642ad1da..4d042afa2 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-2696
+1018
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 40e5a3451..abbcd9352 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -560,7 +560,7 @@ export class CurrentUserUtils {
             doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({
                 _width: 50, _height: 25, title: "Search", _fontSize: 10,
                 letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ title: "search stack", })) as any as Doc,
+                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ title: "sidebar search stack", })) as any as Doc,
                 searchFileTypes: new List<string>([DocumentType.RTF, DocumentType.IMG, DocumentType.PDF, DocumentType.VID, DocumentType.WEB, DocumentType.SCRIPTING]),
                 targetContainer: new PrefetchProxy(sidebarContainer) as any as Doc,
                 lockedPosition: true,
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index 1e71f8cb0..cd64d71ff 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -83,8 +83,6 @@
     .no-result {
         width: 500px;
         background: $light-color-secondary;
-        border-color: $intermediate-color;
-        border-bottom-style: solid;
         padding: 10px;
         height: 50px;
         text-transform: uppercase;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 1d03e78a9..30d4fd5aa 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -45,12 +45,9 @@ library.add(faTimes);
 export const searchSchema = createSchema({
     id: "string",
     Document: Doc,
-    sideBar: "boolean",
     searchQuery: "string",
 });
 
-//add back filterquery
-
 export enum Keys {
     TITLE = "title",
     AUTHOR = "author",
@@ -190,7 +187,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
+            if (this._icons!==this._allIcons){
             runInAction(()=>{this.expandedBucket=false});
+            }
             this.submitSearch();
         }
     }
@@ -651,7 +650,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         this.getResults(StrCast(this.layoutDoc._searchString));
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
-                            if (StrCast(result[0].type)!=="search"){
+                            if (!this.blockedTypes.includes(StrCast(result[0].type))){
 
                             if(this.new_buckets[StrCast(result[0].type)]===undefined){
                                 this.new_buckets[StrCast(result[0].type)]=1;
@@ -660,13 +659,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
                             }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            
-                            result[0].query=StrCast(this.layoutDoc._searchString);
-                            //Make alias
                             let lines = new List<string>(result[2]);
                             result[0].lines=lines
                             result[0].highlighting=highlights.join(", ");
-
                             this._visibleDocuments[i] = result[0];
                             result[0].targetDoc=result[0];
 
@@ -678,7 +673,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     else {
                         result = this._results[i];
                         if (result) {
-                            if (StrCast(result[0].type)!=="search"){
+                            if (!this.blockedTypes.includes(StrCast(result[0].type))){
                             if(this.new_buckets[StrCast(result[0].type)]===undefined){
                                 this.new_buckets[StrCast(result[0].type)]=1;
                             }
@@ -686,7 +681,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
                             }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            result[0].query=StrCast(this.layoutDoc._searchString);
                             result[0].lines=new List<string>(result[2]);
                             result[0].highlighting=highlights.join(", ");
                             if(i<this._visibleDocuments.length){
@@ -703,22 +697,24 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this._numTotalResults>3 && this.expandedBucket===false){
         this.makenewbuckets();
         for (let i = 0; i < this._numTotalResults; i++) {
-            console.log(this._isSearch[i],this._isSorted[i]);
+            let result = this._results[i];
+            if (!this.blockedTypes.includes(StrCast(result[0].type))){
             if (this._isSearch[i] === "search" && (this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
-                let result = this._results[i];
+                console.log(StrCast(result[0].type));
                 if (StrCast(result[0].type)=== this.firststring && this.bucketcount[1]<3){
                     Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
                     this.bucketcount[1]+=1;
+                    console.log("1 count")
                 }
-                else if (StrCast(result[0].type)=== this.secondstring && this.bucketcount[1]<3){
+                else if (StrCast(result[0].type)=== this.secondstring && this.bucketcount[2]<3){
                     Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
                     this.bucketcount[2]+=1;
+                    console.log("2 count")
                 }
                 else if (this.bucketcount[0]<3){
                     //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
                     //this.bucketcount[0]+=1;
                     const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                    result[0].query=StrCast(this.layoutDoc._searchString);
                     result[0].lines=new List<string>(result[2]);
                     result[0].highlighting=highlights.join(", ");
                     result[0].targetDoc=result[0];
@@ -727,17 +723,18 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 this._isSorted[i]="sorted"; 
             }
         }
+        }
         console.log(this.bucketcount[0]);
         console.log(this.bucketcount[1]);
         console.log(this.bucketcount[2]);
         if (this.buckets![0]){
-        this.buckets![0]._height = this.bucketcount[0]*53 + 21;
+        this.buckets![0]._height = this.bucketcount[0]*55 + 25;
         }
         if (this.buckets![1]){
-        this.buckets![1]._height = this.bucketcount[1]*53 + 21;
+        this.buckets![1]._height = this.bucketcount[1]*55 + 25;
         }
         if (this.buckets![2]){  
-        this.buckets![2]._height = this.bucketcount[2]*53 + 21;
+        this.buckets![2]._height = this.bucketcount[2]*55 + 25;
         }
 
         // if (this.bucketcount[0]===0){
@@ -749,14 +746,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 for (let i = 0; i < this._numTotalResults; i++) {
                     if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
                         let result = this._results[i];
+                        if (!this.blockedTypes.includes(StrCast(result[0].type))){
+
                         const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                        result[0].query=StrCast(this.layoutDoc._searchString);
                         result[0].lines=new List<string>(result[2]);
                         result[0].highlighting=highlights.join(", ");
                         result[0].targetDoc=result[0];
                         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                     }
                 }
+                }
             }
 
         if (this._maxSearchIndex >= this._numTotalResults) {
@@ -766,6 +765,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
+    
+    blockedTypes:string[]= ["preselement","docholder","collection","search","searchitem", "script", "fonticonbox", "button", "label"];
+    blockedFields: string[]= ["layout"];
 
     @computed
     get resFull() { return this._numTotalResults <= 8; }
@@ -900,9 +902,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @computed get docButtons() {
         const nodeBtns = this.props.Document.nodeButtons;
         let width = () => NumCast(this.props.Document._width);
-        if (this.rootDoc.sideBar===true){
+        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
             width = MainView.Instance.flyoutWidthFunc;
-        }
+
+        // }   
         if (nodeBtns instanceof Doc) {
             return <div id="hi" style={{height:"100px",}}>
                 <DocumentView
@@ -938,9 +941,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @computed get keyButtons() {
         const nodeBtns = this.props.Document.keyButtons;
         let width = () => NumCast(this.props.Document._width);
-        if (this.rootDoc.sideBar===true){
+        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
             width = MainView.Instance.flyoutWidthFunc;
-        }
+        // }
         if (nodeBtns instanceof Doc) {
             return <div id="hi" style={{height:"35px",}}>
                 <DocumentView
@@ -976,9 +979,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @computed get defaultButtons() {
         const defBtns = this.props.Document.defaultButtons;
         let width = () => NumCast(this.props.Document._width);
-        if (this.rootDoc.sideBar===true){
+        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
             width = MainView.Instance.flyoutWidthFunc;
-        }
+        // }
         if (defBtns instanceof Doc) {
             return <div id="hi" style={{height:"35px",}}>
                 <DocumentView
@@ -1122,13 +1125,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
     addDocument = (doc: Doc) => {
-        const newPinDoc = Doc.MakeAlias(doc);
-        newPinDoc.presentationTargetDoc = doc;
-        return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
+        return null;
     }
     //Make id layour document
     render() {
-        this.props.Document._gridGap=5;
+        if (this.expandedBucket  === true){
+            this.props.Document._gridGap=5;
+        }
+        else {
+            this.props.Document._gridGap=10;
+        }
         this.props.Document._searchDoc=true;
 
         return (
@@ -1160,7 +1166,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         moveDocument={returnFalse}
                         NativeHeight={()=>400}
                         childLayoutTemplate={this.childLayoutTemplate}
-                        addDocument={this.addDocument}
+                        addDocument={undefined}
                         removeDocument={returnFalse}
                         focus={this.selectElement}
                         ScreenToLocalTransform={Transform.Identity} />
diff --git a/src/client/views/search/SearchItem.scss b/src/client/views/search/SearchItem.scss
index 9996e0a50..5ce022d41 100644
--- a/src/client/views/search/SearchItem.scss
+++ b/src/client/views/search/SearchItem.scss
@@ -11,15 +11,15 @@
 .searchItem-overview .searchItem {
     width: 100%;
     background: $light-color-secondary;
-    border-color: $intermediate-color;
-    border-bottom-style: solid;
-    padding: 10px;
-    min-height: 50px;
+    padding: 8px;
+    min-height: 46px;
+    height:46px;
     max-height: 150px;
     height: auto;
     z-index: 0;
     display: flex;
     overflow: visible;
+    box-shadow: rgb(156, 147, 150) 0.2vw 0.2vw 0.8vw;
 
     .searchItem-body {
         display: flex;
@@ -146,7 +146,7 @@
 }
 
 .searchBox-placeholder {
-    min-height: 50px;
+    min-height: 46px;
     margin-left: 150px;
     width: calc(100% - 150px);
     text-transform: uppercase;
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 97ca0ee69..9d5d64dca 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -336,12 +336,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
     }
 
-    addDocument = (doc: Doc) => {
-        const newPinDoc = Doc.MakeAlias(doc);
-        newPinDoc.presentationTargetDoc = doc;
-        return Doc.AddDocToList(this.dataDoc, this.fieldKey, newPinDoc);
-    }
-
     newsearch(){
        runInAction(()=>{
         if (StrCast(this.rootDoc.bucketfield)!=="results"){
@@ -362,9 +356,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             this.props.Document._height=this.targetDoc._height;
 
             return <div>
-            <div className="bucket-title">
-                {StrCast(this.rootDoc.bucketfield)==="results"? null:StrCast(this.rootDoc.bucketfield)}
-            </div>
             <CollectionView {...this.props}
             Document={this.props.Document}
             PanelHeight={this.panelHeight}
@@ -372,11 +363,11 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             onClick={undefined}
             moveDocument={returnFalse}
             childLayoutTemplate={this.childLayoutTemplate}
-            addDocument={this.addDocument}
+            addDocument={undefined}
             removeDocument={returnFalse}
             focus={this.selectElement}
             ScreenToLocalTransform={this.getTransform} />
-            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, fontFamily:"Arial, sans-serif"}}>See all {StrCast(this.rootDoc.bucketfield)}...
+            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, marginBottom:-2, paddingTop:2,fontFamily:"Arial, sans-serif"}}>See all {StrCast(this.rootDoc.bucketfield)}...
             </button>
             </div>
         }
@@ -385,9 +376,10 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
                     <div className="searchItem-title-container">
-                        <div className="searchItem-title">{StrCast(this.targetDoc.title)}</div>
-                        <div className="searchItem-highlighting">{StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : Cast(this.targetDoc.lines, listSpec("string"))!.length ? Cast(this.targetDoc.lines, listSpec("string"))![0] : ""}</div>
-                        {Cast(this.targetDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">{l}</div>)}
+                        <div className="searchItem-title" style={{height:"10px", overflow:"hidden", textOverflow:"ellipsis"}}>{StrCast(this.targetDoc.title)}</div>
+                        <div className="searchItem-highlighting">
+                        {StrCast(this.targetDoc.highlighting).length ? "Matched fields:" + StrCast(this.targetDoc.highlighting) : Cast(this.targetDoc.lines, listSpec("string"))!.length ? Cast(this.targetDoc.lines, listSpec("string"))![0] : ""}</div>
+                        {/* {Cast(this.targetDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">{l}</div>)} */}
                     </div>
                 </div>
                 <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
diff --git a/src/server/websocket.ts b/src/server/websocket.ts
index 87af5fa06..19c98454c 100644
--- a/src/server/websocket.ts
+++ b/src/server/websocket.ts
@@ -236,7 +236,6 @@ export namespace WebSocket {
     };
 
     function ToSearchTerm(val: any): { suffix: string, value: any } | undefined {
-        // console.log(val);
 
         if (val === null || val === undefined) {
             return;
@@ -258,7 +257,6 @@ export namespace WebSocket {
             suffix = suffix[0];
 
         }
-        // console.log(suffix);
         return { suffix, value: val };
     }
 
@@ -273,9 +271,7 @@ export namespace WebSocket {
         if (!docfield) {
             return;
         }
-        //console.log(diff);
         const update: any = { id: diff.id };
-        console.log(update);
         let dynfield = false;
         for (let key in docfield) {
             if (!key.startsWith("fields.")) continue;
@@ -295,7 +291,6 @@ export namespace WebSocket {
                     update[key] = { set: value };
                 }
                 update[key + suffix] = { set: value };
-                console.log(update);
             }
         }
         if (dynfield) {
-- 
cgit v1.2.3-70-g09d2


From 52f88acb3141e15b1063f489273d94d98447c87a Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 9 Jun 2020 19:27:47 -0400
Subject: more bugfixing'

---
 src/client/util/CurrentUserUtils.ts    |  5 ++---
 src/client/util/SearchUtil.ts          |  2 --
 src/client/views/search/SearchBox.tsx  | 26 +++++++++++++++++++-------
 src/client/views/search/SearchItem.tsx | 10 ++++++++++
 4 files changed, 31 insertions(+), 12 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index abbcd9352..9e19962f8 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -43,7 +43,7 @@ export class CurrentUserUtils {
         if (doc["template-button-query"] === undefined) {
             const queryTemplate = Docs.Create.MulticolumnDocument(
                 [
-                    Docs.Create.SearchDocument({ title: "query", _height: 200 }),
+                    Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, title: "query", _height: 200 }),
                     Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true })
                 ],
                 { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, hideFilterView: true }
@@ -342,7 +342,6 @@ export class CurrentUserUtils {
             { title: "Drag a document previewer", label: "Prev", icon: "expand", click: 'openOnRight(getCopy(this.dragFactory, true))', drag: 'getCopy(this.dragFactory,true)', dragFactory: doc.emptyDocHolder as Doc },
             { title: "Toggle a Calculator REPL", label: "repl", icon: "calculator", click: 'addOverlayWindow("ScriptingRepl", { x: 300, y: 100, width: 200, height: 200, title: "Scripting REPL" })' },
             { title: "Connect a Google Account", label: "Google Account", icon: "external-link-alt", click: 'GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken(true)' },
-            { title: "query", icon: "bolt", label: "Col", ignoreClick: true, drag: 'Docs.Create.SearchDocument({ _width: 200, title: "an image of a cat" })' },
         ];
 
     }
@@ -560,7 +559,7 @@ export class CurrentUserUtils {
             doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({
                 _width: 50, _height: 25, title: "Search", _fontSize: 10,
                 letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ title: "sidebar search stack", })) as any as Doc,
+                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({_viewType: CollectionViewType.Stacking, title: "sidebar search stack", })) as any as Doc,
                 searchFileTypes: new List<string>([DocumentType.RTF, DocumentType.IMG, DocumentType.PDF, DocumentType.VID, DocumentType.WEB, DocumentType.SCRIPTING]),
                 targetContainer: new PrefetchProxy(sidebarContainer) as any as Doc,
                 lockedPosition: true,
diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index ef6665c43..e4c4f5fb7 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -38,7 +38,6 @@ export namespace SearchUtil {
     export async function Search(query: string, returnDocs: boolean, options: SearchParams = {}) {
         query = query || "*"; //If we just have a filter query, search for * as the query
         const rpquery = Utils.prepend("/dashsearch");
-        console.log({ qs: { ...options, q: query } });
         const gotten = await rp.get(rpquery, { qs: { ...options, q: query } });
         const result: IdSearchResult = gotten.startsWith("<") ? { ids: [], docs: [], numFound: 0, lines: [] } : JSON.parse(gotten);
         if (!returnDocs) {
@@ -132,7 +131,6 @@ export namespace SearchUtil {
         });
         const result: IdSearchResult = JSON.parse(response);
         const { ids, numFound, highlighting } = result;
-        //console.log(ids.length);
         const docMap = await DocServer.GetRefFields(ids);
         const docs: Doc[] = [];
         for (const id of ids) {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 30d4fd5aa..5ec911221 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -119,9 +119,18 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (!_scriptingGlobals.hasOwnProperty("updateIcon")){
             Scripting.addGlobal(this.updateIcon);
         }
+        if (!_scriptingGlobals.hasOwnProperty("updateTitleStatus")){
+            Scripting.addGlobal(this.updateTitleStatus);
+        }
+        if (!_scriptingGlobals.hasOwnProperty("updateAuthorStatus")){
+            Scripting.addGlobal(this.updateAuthorStatus);
+        }
+        if (!_scriptingGlobals.hasOwnProperty("updateDeletedStatus")){
+            Scripting.addGlobal(this.updateDeletedStatus);
+        }
+
 
         this.resultsScrolled = this.resultsScrolled.bind(this);
-        this.rootDoc._viewType = CollectionViewType.Stacking;
 
        new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", 
        backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
@@ -612,6 +621,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             this._visibleElements = [<div className="no-result">No Search Results</div>];
             //this._visibleDocuments= Docs.Create.
+            let noResult= Docs.Create.TextDocument("",{title:"noResult"})
+            noResult.targetDoc=noResult;
+            noResult.isBucket =false;
+            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, noResult);
             return;
         }
 
@@ -893,7 +906,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     updateAuthorStatus() { this._authorFieldStatus = !this._authorFieldStatus; }
 
     @action.bound
-    updateDataStatus() { this._deletedDocsStatus = !this._deletedDocsStatus; }
+    updateDeletedStatus() { this._deletedDocsStatus = !this._deletedDocsStatus; }
 
     addButtonDoc = (doc: Doc) => Doc.AddDocToList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
     remButtonDoc = (doc: Doc) => Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
@@ -1079,10 +1092,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
             _fontSize: 7,
         }))as any as Doc;
-        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
-        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript(`handleNodeChange()`)});
-        doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("this.updateTitleStatus")});
-
+        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("updateTitleStatus(self)")});
+        doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript("updateDeletedStatus(self)")});
+        doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("updateAuthorStatus(self)")});
+        
         let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
 
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
@@ -1175,7 +1188,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     height: this.resFull ? "auto" : this.resultHeight,
                     overflow: "visibile" // this.resFull ? "auto" : "visible"
                 }} ref={this._resultsRef}>
-                    {this._visibleElements.length}           
                 </div>
             </div>
         );
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 9d5d64dca..74750a40c 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -371,6 +371,16 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             </button>
             </div>
         }
+        else if (this.targetDoc.isBucket === false){
+            this.props.Document._chromeStatus='disabled';
+            return      <div className="searchItem">
+                <div className="searchItem-body" >
+                <div className="searchItem-title-container">
+                <div className="searchItem-title" style={{height:"10px", overflow:"hidden", textOverflow:"ellipsis"}}>No Search Results</div>
+                </div>
+                </div>
+            </div>
+        }
         else {
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div className="searchItem" onPointerDown={this.nextHighlight} onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
-- 
cgit v1.2.3-70-g09d2


From fb5291760d908fe54ec0134cbe3868d666b02b19 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 15 Jun 2020 20:49:10 -0400
Subject: bugfixing with expading search terms within a bucket

---
 .../views/nodes/formattedText/FormattedTextBox.tsx | 10 ++--
 src/client/views/pdf/PDFViewer.tsx                 | 18 +++++--
 src/client/views/search/SearchBox.tsx              | 32 +++++-------
 src/client/views/search/SearchItem.tsx             | 60 +++++++++++++++++-----
 4 files changed, 77 insertions(+), 43 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index aad4e82b5..dff42bcb1 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -273,7 +273,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
             this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
             let index = this._searchIndex;
-            console.log(index);
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
             Doc.GetProto(this.dataDoc).length=length;
@@ -295,7 +294,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
             this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
             let index = this._searchIndex;
-            console.log(index);
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
             Doc.GetProto(this.dataDoc).length=length;
@@ -702,12 +700,12 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
 
         this.setupEditor(this.config, this.props.fieldKey);
 
-        this._disposers.search = reaction(() => this.rootDoc.searchMatch,
-            search => search ? this.highlightSearchTerms([Doc.SearchQuery()]) : this.unhighlightSearchTerms(),
-            { fireImmediately: true });
-        this._disposers.search2 = reaction(() => this.rootDoc.searchMatch2,
+        this._disposers.search = reaction(() => this.rootDoc.searchMatch2,
             search => search ? this.highlightSearchTerms2([Doc.SearchQuery()]) : this.unhighlightSearchTerms(),
             { fireImmediately: true });
+        this._disposers.search2 = reaction(() => this.rootDoc.searchMatch,
+            search => search ? this.highlightSearchTerms([Doc.SearchQuery()]) : this.unhighlightSearchTerms(),
+            { fireImmediately: true });
 
         this._disposers.record = reaction(() => this._recording,
             () => {
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 882e48de7..f23923279 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -107,6 +107,7 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
     private _scrollTopReactionDisposer?: IReactionDisposer;
     private _filterReactionDisposer?: IReactionDisposer;
     private _searchReactionDisposer?: IReactionDisposer;
+    private _searchReactionDisposer2?: IReactionDisposer;
     private _viewer: React.RefObject<HTMLDivElement> = React.createRef();
     private _mainCont: React.RefObject<HTMLDivElement> = React.createRef();
     private _selectionText: string = "";
@@ -144,6 +145,17 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
         runInAction(() => this._showWaiting = this._showCover = true);
         this.props.startupLive && this.setupPdfJsViewer();
         this._searchReactionDisposer = reaction(() => this.Document.searchMatch, search => {
+            if (search) {
+                this.search(Doc.SearchQuery(), false);
+                this._lastSearch = Doc.SearchQuery();
+            }
+            else {
+                setTimeout(() => this._lastSearch === "mxytzlaf" && this.search("mxytzlaf", true), 200); // bcz: how do we clear search highlights?
+                this._lastSearch && (this._lastSearch = "mxytzlaf");
+            }
+        }, { fireImmediately: true });
+
+        this._searchReactionDisposer2 = reaction(() => this.Document.searchMatch2, search => {
             if (search) {
                 this.search(Doc.SearchQuery(), true);
                 this._lastSearch = Doc.SearchQuery();
@@ -325,7 +337,10 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
     }
     @action
     prevAnnotation = () => {
+        console.log(this.Index);
         this.Index = Math.max(this.Index - 1, 0);
+        console.log(this.Index);
+        console.log(this.allAnnotations);
         this.scrollToAnnotation(this.allAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y))[this.Index]);
     }
 
@@ -335,7 +350,6 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
         this.scrollToAnnotation(this.allAnnotations.sort((a, b) => NumCast(a.y) - NumCast(b.y))[this.Index]);
         this.Document.searchIndex = this.Index;
         this.Document.length=this.allAnnotations.length;
-        console.log(this.Index);
 
     }
 
@@ -403,7 +417,6 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
                 phraseSearch: true,
                 query: searchString
             });
-            console.log(this.Index);
             this.Document.searchIndex = this.Index;
             this.Document.length=this.allAnnotations.length;
         }
@@ -419,7 +432,6 @@ export class PDFViewer extends ViewBoxAnnotatableComponent<IViewerProps, PdfDocu
             };
             this._mainCont.current.addEventListener("pagesloaded", executeFind);
             this._mainCont.current.addEventListener("pagerendered", executeFind);
-            console.log(this.Index);
             this.Document.searchIndex = this.Index;
             this.Document.length=this.allAnnotations.length;
         }
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 5ec911221..596a0cac7 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -376,7 +376,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (reset){
             this.layoutDoc._searchString="";
         }
-        console.log(this.layoutDoc._searchString);  
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.buckets=[];
         this.new_buckets={};
@@ -430,7 +429,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
 
         let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket`});
-        bucket.targetDoc = bucket;      
         bucket._viewType === CollectionViewType.Stacking;
         bucket._height=185;
         bucket.bucketfield = "results";
@@ -443,7 +441,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.firststring });
         firstbucket._height=185;
 
-        firstbucket.targetDoc = firstbucket;      
         firstbucket._viewType === CollectionViewType.Stacking;
         firstbucket.bucketfield = this.firststring;
         firstbucket.isBucket=true;
@@ -456,7 +453,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this.secondstring!==""){
         let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
         secondbucket._height=185;
-        secondbucket.targetDoc = secondbucket;      
         secondbucket._viewType === CollectionViewType.Stacking;
         secondbucket.bucketfield = this.secondstring;
         secondbucket.isBucket=true;
@@ -622,7 +618,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._visibleElements = [<div className="no-result">No Search Results</div>];
             //this._visibleDocuments= Docs.Create.
             let noResult= Docs.Create.TextDocument("",{title:"noResult"})
-            noResult.targetDoc=noResult;
             noResult.isBucket =false;
             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, noResult);
             return;
@@ -673,10 +668,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
-                            result[0].lines=lines
+                            result[0].lines=lines;
                             result[0].highlighting=highlights.join(", ");
                             this._visibleDocuments[i] = result[0];
-                            result[0].targetDoc=result[0];
 
                             this._isSearch[i] = "search";
                         }
@@ -694,11 +688,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
                             }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            result[0].lines=new List<string>(result[2]);
+
+                            let lines = new List<string>(result[2]);
+
+                            result[0].lines= lines;
                             result[0].highlighting=highlights.join(", ");
                             if(i<this._visibleDocuments.length){
                             this._visibleDocuments[i]=result[0];
-                            result[0].targetDoc=result[0];
                             this._isSearch[i] = "search";
                             }
                             }
@@ -713,33 +709,30 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             let result = this._results[i];
             if (!this.blockedTypes.includes(StrCast(result[0].type))){
             if (this._isSearch[i] === "search" && (this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
-                console.log(StrCast(result[0].type));
                 if (StrCast(result[0].type)=== this.firststring && this.bucketcount[1]<3){
+                    result[0].parent= this.buckets![1];
                     Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
                     this.bucketcount[1]+=1;
-                    console.log("1 count")
                 }
                 else if (StrCast(result[0].type)=== this.secondstring && this.bucketcount[2]<3){
+                    result[0].parent= this.buckets![2];
                     Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
                     this.bucketcount[2]+=1;
-                    console.log("2 count")
                 }
                 else if (this.bucketcount[0]<3){
                     //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
                     //this.bucketcount[0]+=1;
                     const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                    result[0].lines=new List<string>(result[2]);
+                    let lines = new List<string>(result[2]);
+                    result[0].lines= lines;
                     result[0].highlighting=highlights.join(", ");
-                    result[0].targetDoc=result[0];
                     Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                 }
                 this._isSorted[i]="sorted"; 
             }
         }
         }
-        console.log(this.bucketcount[0]);
-        console.log(this.bucketcount[1]);
-        console.log(this.bucketcount[2]);
+
         if (this.buckets![0]){
         this.buckets![0]._height = this.bucketcount[0]*55 + 25;
         }
@@ -760,11 +753,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
                         let result = this._results[i];
                         if (!this.blockedTypes.includes(StrCast(result[0].type))){
-
                         const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                        result[0].lines=new List<string>(result[2]);
+                        let lines = new List<string>(result[2]);
+                        result[0].lines= lines;
                         result[0].highlighting=highlights.join(", ");
-                        result[0].targetDoc=result[0];
                         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                     }
                 }
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 63baf625e..c1fd2d0b8 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -174,16 +174,40 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     @computed get query() { return StrCast(this.lookupField("query")); }
 
+    private _oldHeight: number = 46;
+
     componentDidMount() {
+        let parent: Doc |undefined = undefined;
+        let height = 0;
+        if (this.rootDoc.parent){
+            parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
+            height=(NumCast(parent._height));
+        }
 
         this._reactionDisposer = reaction(
             () => this.rootDoc.searchIndex,
             search => {console.log(NumCast(search));this.searchPos=NumCast(search) },{ fireImmediately: true }
         );
-
         this._reactionDisposer2 = reaction(
             () => this._useIcons,
-            el=> {console.log("YUH"); 
+            el=> { 
+                if (this.rootDoc.parent){
+                    parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
+                    height=(NumCast(parent._height));
+                };
+                console.log(height);
+                console.log(this._oldHeight);
+            setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null;
+                parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null;
+                this._mainRef.current?.getBoundingClientRect()?  this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null;
+                // this._oldHeight 55? this._oldHeight =55:null;
+            }, 1);
+        }
+        );
+
+        this._reactionDisposer3 = reaction(
+            () => this._displayLines,
+            el=> { 
             setTimeout(() =>(this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null), 1);
         }
         );
@@ -195,6 +219,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         this.rootDoc.searchMatch = undefined;
         this._reactionDisposer && this._reactionDisposer();
         this._reactionDisposer2 && this._reactionDisposer2();
+        this._reactionDisposer3 && this._reactionDisposer3();
 
     }
 
@@ -203,6 +228,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     private _reactionDisposer?: IReactionDisposer;
     private _reactionDisposer2?: IReactionDisposer;
+    private _reactionDisposer3?: IReactionDisposer;
+
 
     
     @computed get highlightPos(){return NumCast(this.rootDoc.searchIndex)}
@@ -371,7 +398,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     }
 
     @computed get searchElementDoc() { return this.rootDoc; }
-    @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
+    // @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
 
     @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
     childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined;
@@ -398,23 +425,20 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     
     @action
     returnLines(){
+        if ((Cast(this.rootDoc.lines, listSpec("string")))!.length>1){
         if (!this._displayLines) {
-            return <div style={{height:50, width: 10}}
+            console.log(Cast(this.rootDoc.lines, listSpec("string")));
+            return <div style={{width: 10}}
             onPointerDown={action(() => {
                 this._displayLines = !this._displayLines;
                 //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
             })}
             //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))}
              >
-            {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div id={i.toString()} className="searchItem-highlighting">`${l}`</div>)}
+            {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div style={{overflow:"visible"}}id={i.toString()} className="searchItem-highlighting">{l}</div>)}
             </div>;;
         }
-        else {
-        return <button style={{padding:2}} onClick={action(() => { this._displayLines = false; 
-        })} >
-            <FontAwesomeIcon icon="arrow-up" size="sm" />
-        </button>;
-        }
+    }
     }
     
     //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); 
@@ -423,14 +447,21 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     returnButtons(){
         return <div>
-            {this.returnLines()}
+        <div> 
+        {this.rootDoc!.type === DocumentType.PDF? <button style={{padding:2}} onClick={action(() => { this._displayLines = false; 
+        })} >
+            <FontAwesomeIcon icon="arrow-up" size="sm" />
+        </button>: null}
             {`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`}
              <button onClick={this.nextHighlight} style={{padding:2}}>
                         <FontAwesomeIcon icon="arrow-up" size="sm"  /> 
                         </button>
                         <button onClick={this.nextHighlight2} style={{padding:2}}>                    
                         <FontAwesomeIcon icon="arrow-down" size="sm"  />
-                        </button>
+                        </button></div>
+                        <div style={{background: "lightgrey"}}>
+            {this.returnLines()}
+        </div>
         </div>
     }
 
@@ -472,6 +503,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             </div>
         }
         else {
+            console.log(this.rootDoc.highlighting); 
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div ref={this._mainRef} className="searchItem"  onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
@@ -480,7 +512,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                         <div className="searchItem-highlighting">
                         {this.rootDoc.highlighting? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "":null}</div>
                         <div className={`icon-${this._displayLines ? "q" : "a"}`}>
-                        {NumCast(this.rootDoc.length) > 1? this.returnButtons(): null} 
+                        {NumCast(this.rootDoc.length) > 1 ?this.returnButtons(): null} 
                         </div>
                         </div>
                 </div>
-- 
cgit v1.2.3-70-g09d2


From da8b3384142b8b0714fb7fc35a5ca4a48ed94ed3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 16 Jun 2020 14:19:53 -0400
Subject: reset

---
 solr-8.3.1/bin/solr-8983.pid           | 2 +-
 src/client/views/search/SearchBox.tsx  | 5 ++++-
 src/client/views/search/SearchItem.tsx | 1 -
 3 files changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 4d042afa2..98861a8e1 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-1018
+49593
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 596a0cac7..afc3e7c8b 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -668,6 +668,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
+                            result[0]._height=46;
                             result[0].lines=lines;
                             result[0].highlighting=highlights.join(", ");
                             this._visibleDocuments[i] = result[0];
@@ -690,7 +691,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
 
                             let lines = new List<string>(result[2]);
-
+                            result[0]._height=46;
                             result[0].lines= lines;
                             result[0].highlighting=highlights.join(", ");
                             if(i<this._visibleDocuments.length){
@@ -724,6 +725,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     //this.bucketcount[0]+=1;
                     const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                     let lines = new List<string>(result[2]);
+                    result[0]._height=46;
                     result[0].lines= lines;
                     result[0].highlighting=highlights.join(", ");
                     Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
@@ -755,6 +757,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (!this.blockedTypes.includes(StrCast(result[0].type))){
                         const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                         let lines = new List<string>(result[2]);
+                        result[0]._height=46;
                         result[0].lines= lines;
                         result[0].highlighting=highlights.join(", ");
                         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 0c4ddf038..69a2c16cf 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -516,7 +516,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             </div>
         }
         else {
-            console.log(this.rootDoc.highlighting); 
         return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
             <div ref={this._mainRef} className="searchItem"  onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
                 <div className="searchItem-body" onClick={this.onClick}>
-- 
cgit v1.2.3-70-g09d2


From 80383a3705fdf330a41b8c4d9cc43a49f9e19f22 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 16 Jun 2020 15:39:06 -0400
Subject: test

---
 solr-8.3.1/bin/solr-8983.pid           |  2 +-
 src/client/views/search/SearchBox.tsx  | 64 ++++++++++++++++++++++++++++------
 src/client/views/search/SearchItem.tsx |  3 +-
 3 files changed, 56 insertions(+), 13 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 98861a8e1..6a21a128a 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-49593
+918
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index afc3e7c8b..dd9789a45 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -785,29 +785,48 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     //if true, any keywords can be used. if false, all keywords are required.
     @action.bound
-    handleWordQueryChange = () => {
+    handleWordQueryChange =  async() => {
         this._basicWordStatus = !this._basicWordStatus;
+        if (this._basicWordStatus) {
+            let doc = await Cast(this.props.Document.keywords, Doc)
+            doc!.backgroundColor= "grey";
+
+        }
+        else {
+            let doc = await Cast(this.props.Document.keywords, Doc)
+            doc!.backgroundColor= "black";
+        }
     }
 
     @action.bound
-    handleNodeChange = () => {
+    handleNodeChange = async () => {
         this._nodeStatus = !this._nodeStatus;
+
         if (this._nodeStatus) {
             this.expandSection(`node${this.props.Document[Id]}`);
+            let doc = await Cast(this.props.Document.nodes, Doc)
+            doc!.backgroundColor= "grey";
+
         }
         else {
             this.collapseSection(`node${this.props.Document[Id]}`);
+            let doc = await Cast(this.props.Document.nodes, Doc)
+            doc!.backgroundColor= "black";
         }
     }
 
     @action.bound
-    handleKeyChange = () => {
+    handleKeyChange = async () => {
         this._keyStatus = !this._keyStatus;
         if (this._keyStatus) {
             this.expandSection(`key${this.props.Document[Id]}`);
+            let doc = await Cast(this.props.Document.keys, Doc)
+            doc!.backgroundColor= "grey";
         }
         else {
             this.collapseSection(`key${this.props.Document[Id]}`);
+            let doc = await Cast(this.props.Document.keys, Doc)
+            doc!.backgroundColor= "black";
         }
     }
 
@@ -895,13 +914,40 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
     @action.bound
-    updateTitleStatus() { this._titleFieldStatus = !this._titleFieldStatus; }
+    updateTitleStatus= async () =>{ this._titleFieldStatus = !this._titleFieldStatus; 
+        if (this._titleFieldStatus){
+            let doc = await Cast(this.props.Document.title, Doc)
+            doc!.backgroundColor= "grey";
+        }
+        else{
+            let doc = await Cast(this.props.Document.title, Doc)
+            doc!.backgroundColor= "black";
+        }
+    }
 
     @action.bound
-    updateAuthorStatus() { this._authorFieldStatus = !this._authorFieldStatus; }
+    updateAuthorStatus=async () => { this._authorFieldStatus = !this._authorFieldStatus; 
+    if (this._authorFieldStatus){
+        let doc = await Cast(this.props.Document.author, Doc)
+        doc!.backgroundColor= "grey";
+    }
+    else{
+        let doc = await Cast(this.props.Document.author, Doc)
+        doc!.backgroundColor= "black";
+    }
+    }
 
     @action.bound
-    updateDeletedStatus() { this._deletedDocsStatus = !this._deletedDocsStatus; }
+    updateDeletedStatus=async() =>{ this._deletedDocsStatus = !this._deletedDocsStatus; 
+        if (this._deletedDocsStatus){
+            let doc = await Cast(this.props.Document.deleted, Doc)
+            doc!.backgroundColor= "grey";
+        }
+        else{
+            let doc = await Cast(this.props.Document.deleted, Doc)
+            doc!.backgroundColor= "black";
+        }
+    }
 
     addButtonDoc = (doc: Doc) => Doc.AddDocToList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
     remButtonDoc = (doc: Doc) => Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
@@ -1087,10 +1133,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             borderRounding: "16px", border:"1px solid grey", color:"white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
             _fontSize: 7,
         }))as any as Doc;
-        doc.title=button({ title: "Title", onClick:ScriptField.MakeScript("updateTitleStatus(self)")});
+        doc.title=button({ backgroundColor:"grey", title: "Title", onClick:ScriptField.MakeScript("updateTitleStatus(self)")});
         doc.deleted=button({ title: "Deleted", onClick:ScriptField.MakeScript("updateDeletedStatus(self)")});
-        doc.author = button({ title: "Author", onClick:ScriptField.MakeScript("updateAuthorStatus(self)")});
-        
+        doc.author = button({ backgroundColor:"grey", title: "Author", onClick:ScriptField.MakeScript("updateAuthorStatus(self)")});
         let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
 
         const dragCreators = Docs.Create.MasonryDocument(buttons, {
@@ -1156,7 +1201,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         style={{ width: this._searchbarOpen ? "500px" : "100px" }} />
                     <button className="searchBox-barChild searchBox-filter" style={{transform:"none"}} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
                 </div>
-
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults >0 ? {overflow:"visible"} : {overflow:"hidden"}}>
                     <div id={`filterhead2${this.props.Document[Id]}`} className="filter-header"  >
                         {this.defaultButtons}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 69a2c16cf..425e53510 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -57,8 +57,6 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
     constructor(props: SearchItemProps) {
         super(props);
         this.fetchDocuments();
-        
-        
     }
 
     async fetchDocuments() {
@@ -152,6 +150,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         super(props);
         this.rootDoc._viewType= CollectionViewType.Stacking;
         this.rootDoc._viewType = CollectionViewType.Stacking;
+        this.props.Document._height=46;
         if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
             Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
             // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
-- 
cgit v1.2.3-70-g09d2


From 0e0f65e53d4660aeb959b142e77b49094a3c173c Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 17 Jun 2020 16:25:30 -0400
Subject: web doc in search

---
 src/client/views/search/SearchBox.tsx  | 22 +++++++++++++++++-----
 src/client/views/search/SearchItem.tsx | 25 +++++++++++++++++++++----
 2 files changed, 38 insertions(+), 9 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index dd9789a45..8ca3c8e95 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -460,6 +460,20 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this.buckets!.push(secondbucket);
         this.bucketcount[2]=0;
         }
+
+        let webbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+        webbucket._height=185;
+        webbucket._viewType === CollectionViewType.Stacking;
+        webbucket.bucketfield = "webs";
+        webbucket.isBucket=true;
+        const textDoc = Docs.Create.WebDocument(`https://bing.com/search?q=${this.layoutDoc._searchString}`, {
+                    _width: 200,  _nativeHeight: 962, _nativeWidth: 800, isAnnotating: false,
+                    title: "bing", UseCors: true
+                });
+        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, webbucket);
+        Doc.AddDocToList(webbucket, this.props.fieldKey, textDoc);
+
+
     }
 
     @observable buckets:Doc[]|undefined;
@@ -574,7 +588,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             basicWordStatus: this._basicWordStatus,
             icons: this._icons,
         }
-        return Docs.Create.SearchDocument({ _autoHeight: true, title: StrCast(this.layoutDoc._searchString), filterQuery: filter, searchQuery: StrCast(this.layoutDoc._searchString) });
+        return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking , title: StrCast(this.layoutDoc._searchString), filterQuery: filter, searchQuery: StrCast(this.layoutDoc._searchString) });
     }
 
     @action.bound
@@ -730,6 +744,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     result[0].highlighting=highlights.join(", ");
                     Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                 }
+    
                 this._isSorted[i]="sorted"; 
             }
         }
@@ -744,10 +759,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this.buckets![2]){  
         this.buckets![2]._height = this.bucketcount[2]*55 + 25;
         }
-
-        // if (this.bucketcount[0]===0){
-        //     Doc.RemoveDocFromList(this.dataDoc, this.props.fieldKey, this.buckets![0]);
-        //     }
         }
             
         else {
@@ -836,6 +847,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this._filterOpen) {
             this.expandSection(`filterhead${this.props.Document[Id]}`);
             document.getElementById(`filterhead${this.props.Document[Id]}`)!.style.padding = "5";
+            console.log(this.props.Document[Id])
         }
         else {
             this.collapseSection(`filterhead${this.props.Document[Id]}`);
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 425e53510..8bbc3180c 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -148,8 +148,7 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     constructor(props:any){
         super(props);
-        this.rootDoc._viewType= CollectionViewType.Stacking;
-        this.rootDoc._viewType = CollectionViewType.Stacking;
+        //this.rootDoc._viewType= CollectionViewType.Stacking;
         this.props.Document._height=46;
         if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
             Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
@@ -483,6 +482,24 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     render() {
         const doc1 = Cast(this.rootDoc!.anchor1, Doc);
         const doc2 = Cast(this.rootDoc!.anchor2, Doc);
+        if (StrCast(this.rootDoc.bucketfield)==="webs"){
+            this.props.Document._viewType=CollectionViewType.Stacking;  
+            this.props.Document._chromeStatus='disabled';
+            this.props.Document._height=this.rootDoc._height;
+            return <div>
+            <CollectionView {...this.props}
+            Document={this.props.Document}
+            PanelHeight={this.panelHeight}
+            whenActiveChanged={emptyFunction}
+            onClick={undefined}
+            moveDocument={returnFalse}
+            childLayoutTemplate={undefined}
+            addDocument={undefined}
+            removeDocument={returnFalse}
+            focus={this.selectElement}
+            ScreenToLocalTransform={this.getTransform} />
+            </div>
+        }
         if (this.rootDoc.isBucket === true){
             this.props.Document._viewType=CollectionViewType.Stacking;  
             this.props.Document._chromeStatus='disabled';
@@ -532,10 +549,10 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
                         <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
                     </div>
                 </div>
-                <div className="searchItem-context" title="Drag as document">
+                {/* <div className="searchItem-context" title="Drag as document">
                     {(doc1 instanceof Doc && doc2 instanceof Doc) && this.rootDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
                         this.contextButton}
-                </div>
+                </div> */}
             </div>
         </div>;
         }
-- 
cgit v1.2.3-70-g09d2


From e23cb36795dd490730f1ff5c06081ce777133433 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 18 Jun 2020 16:09:50 -0400
Subject: refactored bucket algorithm to run much much faster

---
 src/client/views/search/SearchBox.tsx  | 161 ++++++++++++++++-----------------
 src/client/views/search/SearchItem.tsx |  13 +--
 2 files changed, 83 insertions(+), 91 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 8ca3c8e95..746f32237 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -268,15 +268,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     filterDocsByType(docs: Doc[]) {
-        if (this._icons.length === this._allIcons.length) {
-            return docs;
-        }
         const finalDocs: Doc[] = [];
+        const blockedTypes:string[]= ["preselement","docholder","collection","search","searchitem", "script", "fonticonbox", "button", "label"];
         docs.forEach(doc => {
             const layoutresult = Cast(doc.type, "string");
+            if (layoutresult && !blockedTypes.includes(layoutresult)){
             if (layoutresult && this._icons.includes(layoutresult)) {
                 finalDocs.push(doc);
             }
+        }
         });
         return finalDocs;
     }
@@ -408,6 +408,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable bucketcount:number[]=[];
 
     @action private makenewbuckets(){
+        console.log("new");
         let highcount=0;
         let secondcount=0;
         this.firststring="";
@@ -499,6 +500,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     private NumResults = 25;
     private lockPromise?: Promise<void>;
     getResults = async (query: string) => {
+        console.log("Get");
         if (this.lockPromise) {
             await this.lockPromise;
         }
@@ -517,12 +519,25 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     const highlights: typeof res.highlighting = {};
                     docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
                     const filteredDocs = this.filterDocsByType(docs);
+                    
                     runInAction(() => {
-                        filteredDocs.forEach(doc => {
+                        filteredDocs.forEach((doc,i) => {
                             const index = this._resultsSet.get(doc);
                             const highlight = highlights[doc[Id]];
                             const line = lines.get(doc[Id]) || [];
                             const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
+                            if (this.findCommonElements(hlights)){
+                            }
+                            else{
+                                const layoutresult = Cast(doc.type, "string");
+                                if (layoutresult){
+                                if(this.new_buckets[layoutresult]===undefined){
+                                    this.new_buckets[layoutresult]=1;
+                                }
+                                else {
+                                    this.new_buckets[layoutresult]=this.new_buckets[layoutresult]+1;
+                                }
+                            }
                             if (index === undefined) {
                                 this._resultsSet.set(doc, this._results.length);
                                 this._results.push([doc, hlights, line]);
@@ -530,6 +545,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this._results[index][1].push(...hlights);
                                 this._results[index][2].push(...line);
                             }
+                        }
                         });
                     });
 
@@ -539,8 +555,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
                 await this._curRequest;
             }
+            if (this._numTotalResults>3 && this.expandedBucket===false){
+            this.makenewbuckets();
+            }
             this.resultsScrolled();
-
             res();
         });
         return this.lockPromise;
@@ -652,8 +670,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._isSorted = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
 
         }
-
-
         for (let i = 0; i < this._numTotalResults; i++) {
             //if the index is out of the window then put a placeholder in
             //should ones that have already been found get set to placeholders?
@@ -666,44 +682,50 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
             else {
                 if (this._isSearch[i] !== "search") {
-
                     let result: [Doc, string[], string[]] | undefined = undefined;
                     if (i >= this._results.length) {
                         this.getResults(StrCast(this.layoutDoc._searchString));
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
-                            if (!this.blockedTypes.includes(StrCast(result[0].type))){
-
-                            if(this.new_buckets[StrCast(result[0].type)]===undefined){
-                                this.new_buckets[StrCast(result[0].type)]=1;
-                            }
-                            else { 
-                                this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
-                            }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
                             result[0]._height=46;
                             result[0].lines=lines;
                             result[0].highlighting=highlights.join(", ");
                             this._visibleDocuments[i] = result[0];
-
-                            this._isSearch[i] = "search";
-                        }
-                        }
-
+                            this._isSearch[i] = "search";           
+                            if (this._numTotalResults>3 && this.expandedBucket===false){
+                                let doctype = StrCast(result[0].type);
+                                console.log(doctype);
+                                if (doctype=== this.firststring){
+                                if (this.bucketcount[1]<3){
+                                result[0].parent= this.buckets![1];
+                                Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
+                                this.bucketcount[1]+=1;
+                                }
+                                }
+                                else if (doctype=== this.secondstring){
+                                if (this.bucketcount[2]<3){
+                                result[0].parent= this.buckets![2];
+                                Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
+                                this.bucketcount[2]+=1;
+                                }
+                                }
+                                else if (this.bucketcount[0]<3){
+                                //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
+                                //this.bucketcount[0]+=1;
+                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                                }    
+                            }
+                            else {
+                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                            }
+                    }
                     }
                     else {
                         result = this._results[i];
                         if (result) {
-                            if (!this.blockedTypes.includes(StrCast(result[0].type))){
-                            if(this.new_buckets[StrCast(result[0].type)]===undefined){
-                                this.new_buckets[StrCast(result[0].type)]=1;
-                            }
-                            else { 
-                                this.new_buckets[StrCast(result[0].type)]=this.new_buckets[StrCast(result[0].type)]+1;
-                            }
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-
                             let lines = new List<string>(result[2]);
                             result[0]._height=46;
                             result[0].lines= lines;
@@ -711,45 +733,38 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             if(i<this._visibleDocuments.length){
                             this._visibleDocuments[i]=result[0];
                             this._isSearch[i] = "search";
+                            if (this._numTotalResults>3 && this.expandedBucket===false){
+
+                                if (StrCast(result[0].type)=== this.firststring){
+                                if (this.bucketcount[1]<3){
+                                result[0].parent= this.buckets![1];
+                                Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
+                                this.bucketcount[1]+=1;
+                                }
+                                }
+                                else if (StrCast(result[0].type)=== this.secondstring){
+                                if (this.bucketcount[2]<3){
+                                result[0].parent= this.buckets![2];
+                                Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
+                                this.bucketcount[2]+=1;
+                                }
+                                }
+                                else if (this.bucketcount[0]<3){
+                                //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
+                                //this.bucketcount[0]+=1;
+                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                                }    
                             }
+                            else {
+                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                             }
                         }
+                        }
                     }
                 }
             }
         }
         if (this._numTotalResults>3 && this.expandedBucket===false){
-        this.makenewbuckets();
-        for (let i = 0; i < this._numTotalResults; i++) {
-            let result = this._results[i];
-            if (!this.blockedTypes.includes(StrCast(result[0].type))){
-            if (this._isSearch[i] === "search" && (this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
-                if (StrCast(result[0].type)=== this.firststring && this.bucketcount[1]<3){
-                    result[0].parent= this.buckets![1];
-                    Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
-                    this.bucketcount[1]+=1;
-                }
-                else if (StrCast(result[0].type)=== this.secondstring && this.bucketcount[2]<3){
-                    result[0].parent= this.buckets![2];
-                    Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
-                    this.bucketcount[2]+=1;
-                }
-                else if (this.bucketcount[0]<3){
-                    //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
-                    //this.bucketcount[0]+=1;
-                    const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                    let lines = new List<string>(result[2]);
-                    result[0]._height=46;
-                    result[0].lines= lines;
-                    result[0].highlighting=highlights.join(", ");
-                    Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                }
-    
-                this._isSorted[i]="sorted"; 
-            }
-        }
-        }
-
         if (this.buckets![0]){
         this.buckets![0]._height = this.bucketcount[0]*55 + 25;
         }
@@ -759,24 +774,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this.buckets![2]){  
         this.buckets![2]._height = this.bucketcount[2]*55 + 25;
         }
-        }
-            
-        else {
-                for (let i = 0; i < this._numTotalResults; i++) {
-                    if ((this._isSorted[i]===undefined ||this._isSorted[i]==="placeholder" )) {
-                        let result = this._results[i];
-                        if (!this.blockedTypes.includes(StrCast(result[0].type))){
-                        const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                        let lines = new List<string>(result[2]);
-                        result[0]._height=46;
-                        result[0].lines= lines;
-                        result[0].highlighting=highlights.join(", ");
-                        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                    }
-                }
-                }
-            }
-
+    }
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
             this._visibleDocuments.length = this._results.length;
@@ -784,10 +782,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
+    findCommonElements(arr2:string[]) { 
+        let arr1= ["layout", "data"];
+        return arr1.some(item => arr2.includes(item)) 
+    } 
     
-    blockedTypes:string[]= ["preselement","docholder","collection","search","searchitem", "script", "fonticonbox", "button", "label"];
-    blockedFields: string[]= ["layout"];
-
     @computed
     get resFull() { return this._numTotalResults <= 8; }
 
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 8bbc3180c..356100a90 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -184,10 +184,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
             }
         }
 
-        this._reactionDisposer = reaction(
-            () => this.rootDoc.searchIndex,
-            search => {console.log(NumCast(search));this.searchPos=NumCast(search) },{ fireImmediately: true }
-        );
         this._reactionDisposer2 = reaction(
             () => this._useIcons,
             el=> { 
@@ -224,16 +220,13 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     }
     componentWillUnmount() {
         this.rootDoc.searchMatch = undefined;
-        this._reactionDisposer && this._reactionDisposer();
         this._reactionDisposer2 && this._reactionDisposer2();
         this._reactionDisposer3 && this._reactionDisposer3();
 
     }
 
     
-    @observable searchPos: number|undefined =0;
 
-    private _reactionDisposer?: IReactionDisposer;
     private _reactionDisposer2?: IReactionDisposer;
     private _reactionDisposer3?: IReactionDisposer;
 
@@ -311,8 +304,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         this.rootDoc!.searchMatch = false;
         setTimeout(() => this.rootDoc!.searchMatch = true, 0);
         this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex);
-
-        this.searchPos=NumCast(this.rootDoc!.searchIndex);
         this.length=NumCast(this.rootDoc!.length);
     }
 
@@ -327,7 +318,6 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         setTimeout(() => this.rootDoc!.searchMatch2 = true, 0);
         this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex);
 
-        this.searchPos=NumCast(this.rootDoc!.searchIndex);
         this.length=NumCast(this.rootDoc!.length);
     }
 
@@ -428,6 +418,9 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)];
         SearchBox.Instance._icons=SearchBox.Instance._icons;
         }
+        else{
+            SearchBox.Instance._icons=SearchBox.Instance._allIcons;
+        }
         SearchBox.Instance.expandedBucket= true;
         SearchBox.Instance.submitSearch();
        }) 
-- 
cgit v1.2.3-70-g09d2


From a8d9fb68b14a5c89a3186e49ff28bbfa2cd9978e Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 24 Jun 2020 19:18:28 -0400
Subject: refreshing searches and prelimianray looks at searaching within
 collections

---
 src/client/views/search/SearchBox.tsx | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 8449f514a..37d358b02 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -258,6 +258,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this._collectionStatus) {
             query = this.addCollectionFilter(query);
             query = query.replace(/\s+/g, ' ').trim();
+            console.log(query)
+
         }
         return query;
     }
@@ -283,6 +285,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     addCollectionFilter(query: string): string {
         const collections: Doc[] = this.getCurCollections();
+        
+        console.log(collections);
         const oldWords = query.split(" ");
 
         const collectionString: string[] = [];
@@ -308,7 +312,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     getCurCollections(): Doc[] {
         const selectedDocs: DocumentView[] = SelectionManager.SelectedDocuments();
         const collections: Doc[] = [];
-
+        console.log(selectedDocs);
         selectedDocs.forEach(async element => {
             const layout: string = StrCast(element.props.Document.layout);
             //checks if selected view (element) is a collection. if it is, adds to list to search through
@@ -387,6 +391,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._isSorted=[];
         this._visibleElements = [];
         this._visibleDocuments = [];
+        console.log(this._timeout);
+        
+        if (this._timeout){clearTimeout(this._timeout); this._timeout=undefined};
+        this._timeout= setTimeout(()=>{
+            console.log("Resubmitting search");
+            this.submitSearch();
+        }, 10000);
+
         if (query !== "") {
             this._endIndex = 12;
             this._maxSearchIndex = 0;
@@ -401,6 +413,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             });
         }
     }
+    @observable _timeout:any=undefined;
     
     @observable firststring: string = "";
     @observable secondstring: string = "";
@@ -796,8 +809,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     //if true, any keywords can be used. if false, all keywords are required.
     @action.bound
     handleWordQueryChange =  async() => {
-        this._basicWordStatus = !this._basicWordStatus;
-        if (this._basicWordStatus) {
+        this._collectionStatus = !this._collectionStatus;
+        if (this._collectionStatus) {
             let doc = await Cast(this.props.Document.keywords, Doc)
             doc!.backgroundColor= "grey";
 
@@ -1207,6 +1220,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
         return (
             <div style={{pointerEvents:"all"}}className="searchBox-container">
+
                 <div className="searchBox-bar">
                     <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
-- 
cgit v1.2.3-70-g09d2


From 7a291cbffb9e609633759cfff8b459e1a32b4fc3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 25 Jun 2020 17:23:43 -0400
Subject: bugfixing search, refreshing docs, ghost buckets, etc.

---
 src/client/documents/Documents.ts                  |  1 -
 src/client/util/CurrentUserUtils.ts                |  6 ++--
 .../views/nodes/formattedText/FormattedTextBox.tsx | 15 ++++++----
 src/client/views/search/SearchBox.tsx              | 35 ++++++++++++++--------
 4 files changed, 35 insertions(+), 22 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index c32d187a0..ebdae1ce5 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -181,7 +181,6 @@ export interface DocumentOptions {
     flexDirection?: "unset" | "row" | "column" | "row-reverse" | "column-reverse";
     selectedIndex?: number;
     syntaxColor?: string; // can be applied to text for syntax highlighting all matches in the text
-    searchText?: string, //for searchbox
     searchQuery?: string, // for quersyBox
     filterQuery?: filterData,
     linearViewIsExpanded?: boolean; // is linear view expanded
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index a7cb29815..0e0942496 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -42,10 +42,10 @@ export class CurrentUserUtils {
         if (doc["template-button-query"] === undefined) {
             const queryTemplate = Docs.Create.MulticolumnDocument(
                 [
-                    Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, title: "query", _height: 200 }),
+                    Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: "query", _height: 200 }),
                     Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true })
                 ],
-                { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, hideFilterView: true }
+                { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3,  _yMargin: 3, hideFilterView: true }
             );
             queryTemplate.isTemplateDoc = makeTemplate(queryTemplate);
             doc["template-button-query"] = CurrentUserUtils.ficon({
@@ -628,7 +628,7 @@ export class CurrentUserUtils {
             doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({
                 _width: 50, _height: 25, title: "Search", _fontSize: 10,
                 letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({_viewType: CollectionViewType.Stacking, title: "sidebar search stack", })) as any as Doc,
+                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Stacking, title: "sidebar search stack", })) as any as Doc,
                 searchFileTypes: new List<string>([DocumentType.RTF, DocumentType.IMG, DocumentType.PDF, DocumentType.VID, DocumentType.WEB, DocumentType.SCRIPTING]),
                 targetContainer: new PrefetchProxy(sidebarContainer) as any as Doc,
                 lockedPosition: true,
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 6b522f6d1..ca7db2cd4 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -261,20 +261,23 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             let tr = this._editorView.state.tr;
             const flattened: TextSelection[] = [];
             res.map(r => r.map(h => flattened.push(h)));
+
+            
+            const lastSel = Math.min(flattened.length - 1, this._searchIndex);
+            flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
+            this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
+            this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
+            
+            console.log(this._searchIndex, length);
             if (this._searchIndex>1){
                 this._searchIndex+=-2;
             }
             else if (this._searchIndex===1){
                 this._searchIndex=length-1;
             }
-            else if (this._searchIndex===0){
+            else if (this._searchIndex===0 && length!==1){
                 this._searchIndex=length-2;
             }
-            
-            const lastSel = Math.min(flattened.length - 1, this._searchIndex);
-            flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
-            this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
-            this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
             let index = this._searchIndex;
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 37d358b02..d1e1818c2 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -315,6 +315,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         console.log(selectedDocs);
         selectedDocs.forEach(async element => {
             const layout: string = StrCast(element.props.Document.layout);
+            console.log(layout);
             //checks if selected view (element) is a collection. if it is, adds to list to search through
             if (layout.indexOf("Collection") > -1) {
                 //makes sure collections aren't added more than once
@@ -391,13 +392,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._isSorted=[];
         this._visibleElements = [];
         this._visibleDocuments = [];
-        console.log(this._timeout);
-        
-        if (this._timeout){clearTimeout(this._timeout); this._timeout=undefined};
-        this._timeout= setTimeout(()=>{
-            console.log("Resubmitting search");
-            this.submitSearch();
-        }, 10000);
+        if (StrCast(this.props.Document.searchQuery)){
+            if (this._timeout){clearTimeout(this._timeout); this._timeout=undefined};
+            this._timeout= setTimeout(()=>{
+                console.log("Resubmitting search");
+                this.submitSearch();
+            }, 60000);
+            }
 
         if (query !== "") {
             this._endIndex = 12;
@@ -442,7 +443,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
         }
 
-        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: `default bucket`});
+        let bucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true,title: `default bucket`});
         bucket._viewType === CollectionViewType.Stacking;
         bucket._height=185;
         bucket.bucketfield = "results";
@@ -452,7 +453,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this.bucketcount[0]=0;
         
         if (this.firststring!==""){
-        let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.firststring });
+        let firstbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.firststring });
         firstbucket._height=185;
 
         firstbucket._viewType === CollectionViewType.Stacking;
@@ -465,7 +466,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
 
         if (this.secondstring!==""){
-        let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+        let secondbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.secondstring });
         secondbucket._height=185;
         secondbucket._viewType === CollectionViewType.Stacking;
         secondbucket.bucketfield = this.secondstring;
@@ -475,21 +476,30 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this.bucketcount[2]=0;
         }
 
-        let webbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking,title: this.secondstring });
+        let webbucket = Docs.Create.StackingDocument([],{ _viewType:CollectionViewType.Stacking, childDropAction: "alias", ignoreClick: true, lockedPosition: true, title: this.secondstring });
         webbucket._height=185;
         webbucket._viewType === CollectionViewType.Stacking;
         webbucket.bucketfield = "webs";
         webbucket.isBucket=true;
+        let old = Cast(this.props.Document.webbucket,Doc) as Doc;
+        let old2=Cast(this.props.Document.bing,Doc) as Doc;
+        if (old){
+            console.log("Cleanup");
+            Doc.RemoveDocFromList(old, this.props.fieldKey,old2);
+        }
         const textDoc = Docs.Create.WebDocument(`https://bing.com/search?q=${this.layoutDoc._searchString}`, {
                     _width: 200,  _nativeHeight: 962, _nativeWidth: 800, isAnnotating: false,
                     title: "bing", UseCors: true
                 });
+        this.props.Document.bing=textDoc;
+        this.props.Document.webbucket = webbucket;
         Doc.AddDocToList(this.dataDoc, this.props.fieldKey, webbucket);
         Doc.AddDocToList(webbucket, this.props.fieldKey, textDoc);
 
 
     }
 
+
     @observable buckets:Doc[]|undefined;
 
     getAllResults = async (query: string) => {
@@ -539,6 +549,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlight = highlights[doc[Id]];
                             const line = lines.get(doc[Id]) || [];
                             const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
+                            doc? console.log(Cast(doc.context, Doc)) : null;
                             if (this.findCommonElements(hlights)){
                             }
                             else{
@@ -619,7 +630,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             basicWordStatus: this._basicWordStatus,
             icons: this._icons,
         }
-        return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking , title: StrCast(this.layoutDoc._searchString), filterQuery: filter, searchQuery: StrCast(this.layoutDoc._searchString) });
+        return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking , title: StrCast(this.layoutDoc._searchString), searchQuery: StrCast(this.layoutDoc._searchString) });
     }
 
     @action.bound
-- 
cgit v1.2.3-70-g09d2


From 195dde9364bf7b294d74b95e70c8c9a9dd19f891 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Fri, 3 Jul 2020 16:06:07 -0400
Subject: search works with schema, fixed sorting...stil a lot of bugs

---
 src/client/util/CurrentUserUtils.ts                |   4 +-
 .../views/collections/CollectionSchemaView.scss    |   2 +-
 .../views/collections/CollectionSchemaView.tsx     |   4 +
 src/client/views/collections/SchemaTable.tsx       |  14 +-
 src/client/views/search/SearchBox.tsx              | 172 +++------------------
 5 files changed, 35 insertions(+), 161 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 276ad4c90..c152a4a64 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -42,7 +42,7 @@ export class CurrentUserUtils {
         if (doc["template-button-query"] === undefined) {
             const queryTemplate = Docs.Create.MulticolumnDocument(
                 [
-                    Docs.Create.SearchDocument({ _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: "query", _height: 200 }),
+                    Docs.Create.SearchDocument({ _viewType: CollectionViewType.Schema, ignoreClick: true, forceActive: true, lockedPosition: true, title: "query", _height: 200 }),
                     Docs.Create.FreeformDocument([], { title: "data", _height: 100, _LODdisable: true })
                 ],
                 { _width: 400, _height: 300, title: "queryView", _chromeStatus: "disabled", _xMargin: 3, _yMargin: 3, hideFilterView: true }
@@ -631,7 +631,7 @@ export class CurrentUserUtils {
             doc["tabs-button-search"] = new PrefetchProxy(Docs.Create.ButtonDocument({
                 _width: 50, _height: 25, title: "Search", _fontSize: 10,
                 letterSpacing: "0px", textTransform: "unset", borderRounding: "5px 5px 0px 0px", boxShadow: "3px 3px 0px rgb(34, 34, 34)",
-                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Stacking, title: "sidebar search stack", })) as any as Doc,
+                sourcePanel: new PrefetchProxy(Docs.Create.SearchDocument({ ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc,
                 searchFileTypes: new List<string>([DocumentType.RTF, DocumentType.IMG, DocumentType.PDF, DocumentType.VID, DocumentType.WEB, DocumentType.SCRIPTING]),
                 targetContainer: new PrefetchProxy(sidebarContainer) as any as Doc,
                 lockedPosition: true,
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index 5226a60f1..688099b6c 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -6,7 +6,7 @@
     border-style: solid;
     border-radius: $border-radius;
     box-sizing: border-box;
-    position: absolute;
+    position: relative;
     top: 0;
     width: 100%;
     height: 100%;
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 9722f8f26..688313951 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -170,6 +170,10 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
     @action
     setColumnSort = (columnField: SchemaHeaderField, descending: boolean | undefined) => {
         const columns = this.columns;
+        columns.forEach(col => {
+            col.setDesc(undefined);
+        })
+
         const index = columns.findIndex(c => c.heading === columnField.heading);
         const column = columns[index];
         column.setDesc(descending);
diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx
index 695965cb4..5a73e7501 100644
--- a/src/client/views/collections/SchemaTable.tsx
+++ b/src/client/views/collections/SchemaTable.tsx
@@ -128,7 +128,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
     }
     @computed get sorted(): SortingRule[] {
         return this.props.columns.reduce((sorted, shf) => {
-            shf.desc && sorted.push({ id: shf.heading, desc: shf.desc });
+            shf.desc !== undefined && sorted.push({ id: shf.heading, desc: shf.desc });
             return sorted;
         }, [] as SortingRule[]);
     }
@@ -209,7 +209,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
                 }}>
                 {col.heading}</div>;
 
-            const sortIcon = col.desc === undefined ? "circle" : col.desc === true ? "caret-down" : "caret-up";
+            const sortIcon = col.desc === undefined ? "caret-right" : col.desc === true ? "caret-down" : "caret-up";
 
             const header =
                 <div //className="collectionSchemaView-header"
@@ -217,7 +217,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
                     className="collectionSchemaView-menuOptions-wrapper"
                     style={{
                         background: col.color, padding: "2px",
-                        display: "flex"
+                        display: "flex", cursor: "default"
                     }}>
                     <FontAwesomeIcon icon={icon} size="lg" style={{ display: "inline", paddingLeft: "7px" }} />
                     {/* <div className="keys-dropdown"
@@ -225,13 +225,13 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
                     {keysDropdown}
                     {/* </div> */}
                     <div onClick={e => this.changeSorting(col)}
-                        style={{ paddingRight: "6px", display: "inline", zIndex: 1, background: "inherit" }}>
-                        <FontAwesomeIcon icon={sortIcon} size="sm" />
+                        style={{ width: 21, padding: 1, display: "inline", zIndex: 1, background: "inherit" }}>
+                        <FontAwesomeIcon icon={sortIcon} size="lg" />
                     </div>
-                    <div onClick={e => this.props.openHeader(col, e.clientX, e.clientY)}
+                    {/* <div onClick={e => this.props.openHeader(col, e.clientX, e.clientY)}
                         style={{ float: "right", paddingRight: "6px", zIndex: 1, background: "inherit" }}>
                         <FontAwesomeIcon icon={"compass"} size="sm" />
-                    </div>
+                    </div> */}
                 </div>;
 
             return {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 5960a0502..d51d1bf0c 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -132,21 +132,21 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
         this.resultsScrolled = this.resultsScrolled.bind(this);
 
-        new PrefetchProxy(Docs.Create.SearchItemBoxDocument({
-            title: "search item template",
-            backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data"
-        }));
-
-
-        if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
-            Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
-            // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
-            // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
-            // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
-            // stored on each pres element.  
-            (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
-                { field: "string", data: Doc.name, container: Doc.name });
-        }
+        // new PrefetchProxy(Docs.Create.SearchItemBoxDocument({
+        //     title: "search item template",
+        //     backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data"
+        // }));
+
+
+        // if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
+        //     Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
+        //     // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
+        //     // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
+        //     // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
+        //     // stored on each pres element.  
+        //     (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
+        //         { field: "string", data: Doc.name, container: Doc.name });
+        // }
     }
     @observable setupButtons = false;
     componentDidMount = () => {
@@ -422,86 +422,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable secondstring: string = "";
 
     @observable bucketcount: number[] = [];
-
-    @action private makenewbuckets() {
-        console.log("new");
-        let highcount = 0;
-        let secondcount = 0;
-        this.firststring = "";
-        this.secondstring = "";
-        this.buckets = [];
-        this.bucketcount = [];
-        this.dataDoc[this.fieldKey] = new List<Doc>([]);
-        for (var key in this.new_buckets) {
-            if (this.new_buckets[key] > highcount) {
-                secondcount === highcount;
-                this.secondstring = this.firststring;
-                highcount = this.new_buckets[key];
-                this.firststring = key;
-            }
-            else if (this.new_buckets[key] > secondcount) {
-                secondcount = this.new_buckets[key];
-                this.secondstring = key;
-            }
-        }
-
-        let bucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: `default bucket` });
-        bucket._viewType === CollectionViewType.Stacking;
-        bucket._height = 185;
-        bucket.bucketfield = "results";
-        bucket.isBucket = true;
-        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, bucket);
-        this.buckets!.push(bucket);
-        this.bucketcount[0] = 0;
-
-        if (this.firststring !== "") {
-            let firstbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.firststring });
-            firstbucket._height = 185;
-
-            firstbucket._viewType === CollectionViewType.Stacking;
-            firstbucket.bucketfield = this.firststring;
-            firstbucket.isBucket = true;
-            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, firstbucket);
-            this.buckets!.push(firstbucket);
-            this.bucketcount[1] = 0;
-
-        }
-
-        if (this.secondstring !== "") {
-            let secondbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, ignoreClick: true, forceActive: true, lockedPosition: true, title: this.secondstring });
-            secondbucket._height = 185;
-            secondbucket._viewType === CollectionViewType.Stacking;
-            secondbucket.bucketfield = this.secondstring;
-            secondbucket.isBucket = true;
-            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, secondbucket);
-            this.buckets!.push(secondbucket);
-            this.bucketcount[2] = 0;
-        }
-
-        let webbucket = Docs.Create.StackingDocument([], { _viewType: CollectionViewType.Stacking, childDropAction: "alias", ignoreClick: true, lockedPosition: true, title: this.secondstring });
-        webbucket._height = 185;
-        webbucket._viewType === CollectionViewType.Stacking;
-        webbucket.bucketfield = "webs";
-        webbucket.isBucket = true;
-        let old = Cast(this.props.Document.webbucket, Doc) as Doc;
-        let old2 = Cast(this.props.Document.bing, Doc) as Doc;
-        if (old) {
-            console.log("Cleanup");
-            Doc.RemoveDocFromList(old, this.props.fieldKey, old2);
-        }
-        const textDoc = Docs.Create.WebDocument(`https://bing.com/search?q=${this.layoutDoc._searchString}`, {
-            _width: 200, _nativeHeight: 962, _nativeWidth: 800, isAnnotating: false,
-            title: "bing", UseCors: true
-        });
-        this.props.Document.bing = textDoc;
-        this.props.Document.webbucket = webbucket;
-        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, webbucket);
-        Doc.AddDocToList(webbucket, this.props.fieldKey, textDoc);
-
-
-    }
-
-
     @observable buckets: Doc[] | undefined;
 
     getAllResults = async (query: string) => {
@@ -521,7 +441,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     getDataStatus() { return this._deletedDocsStatus; }
 
-
     private NumResults = 25;
     private lockPromise?: Promise<void>;
     getResults = async (query: string) => {
@@ -581,9 +500,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
                 await this._curRequest;
             }
-            if (this._numTotalResults > 3 && this.expandedBucket === false) {
-                this.makenewbuckets();
-            }
+
             this.resultsScrolled();
             res();
         });
@@ -632,7 +549,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             basicWordStatus: this._basicWordStatus,
             icons: this._icons,
         }
-        return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Stacking, title: StrCast(this.layoutDoc._searchString), searchQuery: StrCast(this.layoutDoc._searchString) });
+        return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Schema, title: StrCast(this.layoutDoc._searchString), searchQuery: StrCast(this.layoutDoc._searchString) });
     }
 
     @action.bound
@@ -759,48 +676,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             if (i < this._visibleDocuments.length) {
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
-                                if (this._numTotalResults > 3 && this.expandedBucket === false) {
-
-                                    if (StrCast(result[0].type) === this.firststring) {
-                                        if (this.bucketcount[1] < 3) {
-                                            result[0].parent = this.buckets![1];
-                                            Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
-                                            this.bucketcount[1] += 1;
-                                        }
-                                    }
-                                    else if (StrCast(result[0].type) === this.secondstring) {
-                                        if (this.bucketcount[2] < 3) {
-                                            result[0].parent = this.buckets![2];
-                                            Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
-                                            this.bucketcount[2] += 1;
-                                        }
-                                    }
-                                    else if (this.bucketcount[0] < 3) {
-                                        //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
-                                        //this.bucketcount[0]+=1;
-                                        Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                                    }
-                                }
-                                else {
-                                    Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                                }
+                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+
                             }
                         }
                     }
                 }
             }
         }
-        if (this._numTotalResults > 3 && this.expandedBucket === false) {
-            if (this.buckets![0]) {
-                this.buckets![0]._height = this.bucketcount[0] * 55 + 25;
-            }
-            if (this.buckets![1]) {
-                this.buckets![1]._height = this.bucketcount[1] * 55 + 25;
-            }
-            if (this.buckets![2]) {
-                this.buckets![2]._height = this.bucketcount[2] * 55 + 25;
-            }
-        }
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
             this._visibleDocuments.length = this._results.length;
@@ -1214,12 +1097,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
 
-    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined;
     getTransform = () => {
         return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
     }
     panelHeight = () => {
-        return this.props.PanelHeight() - 50;
+        return this.props.PanelHeight();
     }
     selectElement = (doc: Doc) => {
         //this.gotoDocument(this.childDocs.indexOf(doc), NumCasst(this.layoutDoc._itemIndex));
@@ -1230,17 +1112,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     //Make id layour document
     render() {
-        if (this.expandedBucket === true) {
-            this.props.Document._gridGap = 5;
-        }
-        else {
-            this.props.Document._gridGap = 10;
-        }
         this.props.Document._searchDoc = true;
-
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
-
                 <div className="searchBox-bar">
                     <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
@@ -1263,11 +1137,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 </div>
                 <CollectionView {...this.props}
                     Document={this.props.Document}
-                    PanelHeight={this.panelHeight}
                     moveDocument={returnFalse}
-                    NativeHeight={() => 400}
-                    childLayoutTemplate={this.childLayoutTemplate}
-                    addDocument={undefined}
                     removeDocument={returnFalse}
                     focus={this.selectElement}
                     ScreenToLocalTransform={Transform.Identity} />
@@ -1284,7 +1154,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
 Scripting.addGlobal(function lookupSearchBoxField(container: Doc, field: string, data: Doc) {
     // if (field === 'indexInPres') return DocListCast(container[StrCast(container.presentationFieldKey)]).indexOf(data);
-    // if (field === 'presCollapsedHeight') return container._viewType === CollectionViewType.Stacking ? 50 : 46;
+    // if (field === 'presCollapsedHeight') return container._viewType === CollectionViewType.Schema ? 50 : 46;
     // if (field === 'presStatus') return container.presStatus;
     // if (field === '_itemIndex') return container._itemIndex;
     if (field == "query") return container._searchString;
-- 
cgit v1.2.3-70-g09d2


From 825bf223add7652860cc8cc95f48d183da2d0eb3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 7 Jul 2020 22:01:36 -0400
Subject: ui changes from sally and new collumns on search

---
 solr-8.3.1/bin/solr-8983.pid                           |  2 +-
 src/client/views/collections/CollectionSchemaView.scss |  3 +--
 src/client/views/collections/CollectionSchemaView.tsx  |  1 -
 src/client/views/collections/SchemaTable.tsx           |  8 +++++---
 src/client/views/search/SearchBox.tsx                  | 11 +++++++++++
 5 files changed, 18 insertions(+), 7 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 3acca38af..7fb11c5fd 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-1221
+1426
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index f844cf8bf..83fe54c82 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -25,7 +25,7 @@
     .collectionSchemaView-tableContainer {
         width: 100%;
         height: 100%;
-        overflow: scroll;
+        overflow: auto;
     }
 
     .collectionSchemaView-dividerDragger {
@@ -522,7 +522,6 @@ button.add-column {
 .collectionSchemaView-table {
     width: 100%;
     height: 100%;
-    overflow: visible;
 }
 
 .reactTable-sub {
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index fde3993f9..50eea5059 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -628,7 +628,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
                 {({ measureRef }) => <div ref={measureRef}> {menuContent} </div>}
             </Measure>
         </div>;
-
         return <div className="collectionSchemaView-container"
             style={{
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx
index 878cc6f6d..e9f7e3c68 100644
--- a/src/client/views/collections/SchemaTable.tsx
+++ b/src/client/views/collections/SchemaTable.tsx
@@ -451,9 +451,10 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
         //@ts-ignore
         expandedRowsList.forEach(row => expanded[row] = true);
         const rerender = [...this.textWrappedRows]; // TODO: get component to rerender on text wrap change without needign to console.log :((((
-
+        let overflow = "auto";
+        StrCast(this.props.Document.type) === "search" ? overflow = "overlay" : "auto";
         return <ReactTable
-            style={{ position: "relative" }}
+            style={{ position: "relative", overflow: overflow }}
             data={children}
             page={0}
             pageSize={children.length}
@@ -576,7 +577,8 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
         return <div className="collectionSchemaView-table" onPointerDown={this.props.onPointerDown} onWheel={e => this.props.active(true) && e.stopPropagation()}
             onDrop={e => this.props.onDrop(e, {})} onContextMenu={this.onContextMenu} >
             {this.reactTable}
-            <div className="collectionSchemaView-addRow" onClick={() => this.createRow()}>+ new</div>
+            {StrCast(this.props.Document.type) !== "search" ? <div className="collectionSchemaView-addRow" onClick={() => this.createRow()}>+ new</div>
+                : undefined}
             {!this._showDoc ? (null) :
                 <div className="collectionSchemaView-documentPreview" //onClick={() => { this.onOpenClick(); }}
                     style={{
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index d51d1bf0c..04a233809 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -38,6 +38,7 @@ import { makeInterface, createSchema } from '../../../fields/Schema';
 import { listSpec } from '../../../fields/Schema';
 import * as _ from "lodash";
 import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
+import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
 
 
 library.add(faTimes);
@@ -635,6 +636,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0]._height = 46;
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
+                            let headers: string[];
+                            //Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).forEach((item) => headers.push(item.heading));
+                            //this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
+                            let schemaheaders: SchemaHeaderField[] = [];
+                            //highlights.forEach((item) => headers.includes(item) ? undefined : schemaheaders.push(new SchemaHeaderField(`New field ${index ? "(" + index + ")" : ""}`, "#f1efeb")))
+                            highlights.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
+
+                            this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
+
+
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
                             if (this._numTotalResults > 3 && this.expandedBucket === false) {
-- 
cgit v1.2.3-70-g09d2


From 20bf67a41b16dd4df42e7dfc93e9acc38e910d29 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 8 Jul 2020 15:00:17 -0400
Subject: new columns on search and beginning to add highlights

---
 src/client/views/search/SearchBox.tsx | 54 +++++++++++------------------------
 1 file changed, 16 insertions(+), 38 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 04a233809..f120a408e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -590,6 +590,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const endIndex = 30;
         this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
+        let headers = new Set<string>();
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             this._visibleElements = [<div className="no-result">No Search Results</div>];
             //this._visibleDocuments= Docs.Create.
@@ -636,44 +637,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             result[0]._height = 46;
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
-                            let headers: string[];
-                            //Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).forEach((item) => headers.push(item.heading));
-                            //this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
-                            let schemaheaders: SchemaHeaderField[] = [];
-                            //highlights.forEach((item) => headers.includes(item) ? undefined : schemaheaders.push(new SchemaHeaderField(`New field ${index ? "(" + index + ")" : ""}`, "#f1efeb")))
-                            highlights.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
-
-                            this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
-
-
+                            highlights.forEach((item) => headers.add(item));
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
-                            if (this._numTotalResults > 3 && this.expandedBucket === false) {
-                                let doctype = StrCast(result[0].type);
-                                console.log(doctype);
-                                if (doctype === this.firststring) {
-                                    if (this.bucketcount[1] < 3) {
-                                        result[0].parent = this.buckets![1];
-                                        Doc.AddDocToList(this.buckets![1], this.props.fieldKey, result[0]);
-                                        this.bucketcount[1] += 1;
-                                    }
-                                }
-                                else if (doctype === this.secondstring) {
-                                    if (this.bucketcount[2] < 3) {
-                                        result[0].parent = this.buckets![2];
-                                        Doc.AddDocToList(this.buckets![2], this.props.fieldKey, result[0]);
-                                        this.bucketcount[2] += 1;
-                                    }
-                                }
-                                else if (this.bucketcount[0] < 3) {
-                                    //Doc.AddDocToList(this.buckets![0], this.props.fieldKey, result[0]);
-                                    //this.bucketcount[0]+=1;
-                                    Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                                }
-                            }
-                            else {
-                                Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                            }
+                            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                         }
                     }
                     else {
@@ -681,12 +648,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
+                            highlights.forEach((item) => headers.add(item));
                             result[0]._height = 46;
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
                             if (i < this._visibleDocuments.length) {
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
+                                console.log("WHYYYY");
                                 Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
 
                             }
@@ -695,6 +664,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
+
+        this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
+        let schemaheaders: SchemaHeaderField[] = [];
+        this.headerscale = headers.size;
+        headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
+        this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
             this._visibleDocuments.length = this._results.length;
@@ -702,6 +677,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
+    @observable headerscale: number = 0;
+
     findCommonElements(arr2: string[]) {
         let arr1 = ["layout", "data"];
         return arr1.some(item => arr2.includes(item))
@@ -1146,12 +1123,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         {this.keyButtons}
                     </div>
                 </div>
-                <CollectionView {...this.props}
+                {this.headerscale > 0 ? <CollectionView {...this.props}
                     Document={this.props.Document}
                     moveDocument={returnFalse}
                     removeDocument={returnFalse}
                     focus={this.selectElement}
-                    ScreenToLocalTransform={Transform.Identity} />
+                    ScreenToLocalTransform={Transform.Identity} /> : undefined}
+
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
                     height: this.resFull ? "auto" : this.resultHeight,
-- 
cgit v1.2.3-70-g09d2


From 2f3543eb4484205667bd2a248ef991147815f5a8 Mon Sep 17 00:00:00 2001
From: andy temp <andytemp@Kates-MacBook-Pro.local>
Date: Mon, 20 Jul 2020 11:50:15 -0400
Subject: bugfixes for highlighting

---
 package-lock.json                                  | 53 ++++++++++++--------
 package.json                                       |  2 +-
 solr-8.3.1/bin/solr-8983.pid                       |  2 +-
 src/client/views/EditableView.tsx                  | 29 +++++++----
 .../views/collections/CollectionSchemaCells.tsx    | 58 ++++++++++++++--------
 src/client/views/search/SearchBox.scss             | 10 ++--
 src/client/views/search/SearchBox.tsx              |  6 +--
 7 files changed, 99 insertions(+), 61 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/package-lock.json b/package-lock.json
index f03a39df0..7f512519d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -946,15 +946,6 @@
                 "@types/prosemirror-transform": "*"
             }
         },
-        "@types/puppeteer": {
-            "version": "2.1.1",
-            "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-2.1.1.tgz",
-            "integrity": "sha512-FqPZvUtnpTGrqbHvPUn76pvVcBPEVEqZftrdOjr6YRkaaxkjKQ8dQLNaQBjER7Lvd1Q6+0R0XR+N3tYGWBSzNw==",
-            "dev": true,
-            "requires": {
-                "@types/node": "*"
-            }
-        },
         "@types/qs": {
             "version": "6.9.1",
             "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.1.tgz",
@@ -2966,7 +2957,8 @@
                         },
                         "ansi-regex": {
                             "version": "2.1.1",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "aproba": {
                             "version": "1.2.0",
@@ -2984,11 +2976,13 @@
                         },
                         "balanced-match": {
                             "version": "1.0.0",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "brace-expansion": {
                             "version": "1.1.11",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "balanced-match": "^1.0.0",
                                 "concat-map": "0.0.1"
@@ -3001,15 +2995,18 @@
                         },
                         "code-point-at": {
                             "version": "1.1.0",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "concat-map": {
                             "version": "0.0.1",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "console-control-strings": {
                             "version": "1.1.0",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "core-util-is": {
                             "version": "1.0.2",
@@ -3112,7 +3109,8 @@
                         },
                         "inherits": {
                             "version": "2.0.4",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "ini": {
                             "version": "1.3.5",
@@ -3122,6 +3120,7 @@
                         "is-fullwidth-code-point": {
                             "version": "1.0.0",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "number-is-nan": "^1.0.0"
                             }
@@ -3134,17 +3133,20 @@
                         "minimatch": {
                             "version": "3.0.4",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "brace-expansion": "^1.1.7"
                             }
                         },
                         "minimist": {
                             "version": "1.2.5",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "minipass": {
                             "version": "2.9.0",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "safe-buffer": "^5.1.2",
                                 "yallist": "^3.0.0"
@@ -3161,6 +3163,7 @@
                         "mkdirp": {
                             "version": "0.5.3",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "minimist": "^1.2.5"
                             }
@@ -3216,7 +3219,8 @@
                         },
                         "npm-normalize-package-bin": {
                             "version": "1.0.1",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "npm-packlist": {
                             "version": "1.4.8",
@@ -3241,7 +3245,8 @@
                         },
                         "number-is-nan": {
                             "version": "1.0.1",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "object-assign": {
                             "version": "4.1.1",
@@ -3251,6 +3256,7 @@
                         "once": {
                             "version": "1.4.0",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "wrappy": "1"
                             }
@@ -3319,7 +3325,8 @@
                         },
                         "safe-buffer": {
                             "version": "5.1.2",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "safer-buffer": {
                             "version": "2.1.2",
@@ -3349,6 +3356,7 @@
                         "string-width": {
                             "version": "1.0.2",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "code-point-at": "^1.0.0",
                                 "is-fullwidth-code-point": "^1.0.0",
@@ -3366,6 +3374,7 @@
                         "strip-ansi": {
                             "version": "3.0.1",
                             "bundled": true,
+                            "optional": true,
                             "requires": {
                                 "ansi-regex": "^2.0.0"
                             }
@@ -3404,11 +3413,13 @@
                         },
                         "wrappy": {
                             "version": "1.0.2",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         },
                         "yallist": {
                             "version": "3.1.1",
-                            "bundled": true
+                            "bundled": true,
+                            "optional": true
                         }
                     }
                 }
diff --git a/package.json b/package.json
index bd8d005ee..0b0afd338 100644
--- a/package.json
+++ b/package.json
@@ -244,4 +244,4 @@
         "xoauth2": "^1.2.0",
         "xregexp": "^4.3.0"
     }
-}
\ No newline at end of file
+}
diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index 984a455bd..c38baeeb6 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-11092
+3436
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index f5a9716cd..4c2d2f0a9 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -57,7 +57,7 @@ export interface EditableProps {
     highlight?: boolean;
     positions?: number[];
     search?: string;
-    bing?: () => string;
+    bing?: () => string|undefined;
 }
 
 /**
@@ -189,24 +189,35 @@ export class EditableView extends React.Component<EditableProps> {
 
     returnHighlights() {
         let results = [];
-        let length = this.props.search!.length + 1;
-        let contents = "";
-        contents = this.props.bing!();
+        let contents = this.props.bing!();
+
+        if (contents!== undefined){
+        if (this.props.positions!==undefined){
+        let positions = this.props.positions;
+        let length = this.props.search!.length;
         console.log(contents);
+        console.log(this.props.contents?.valueOf());
         // contents = String(this.props.contents.valueOf());
+
         results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(0, this.props.positions![0]) : this.props.placeholder?.valueOf()}</span>);
-        this.props.positions?.forEach((num, cur) => {
+        positions.forEach((num, cur) => {
             results.push(<span style={{ backgroundColor: "#FFFF00", fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}</span>);
             let end = 0;
-            cur === this.props.positions!.length - 1 ? end = contents.length - 1 : end = this.props.positions![cur + 1];
-            results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num + length - 1, end) : this.props.placeholder?.valueOf()}</span>);
+            console.log
+            cur === positions.length-1? end = contents.length: end = positions[cur + 1];
+            results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}</span>);
         }
         )
-
+    }
         return results;
+}
+else{
+    return <span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{this.props.contents ? this.props.contents?.valueOf() : this.props.placeholder?.valueOf()}</span>;
+}
     }
 
     render() {
+        console.log(this.props.highlight === undefined);
         if (this._editing && this.props.GetValue() !== undefined) {
             return this.props.sizeToContent ?
                 <div style={{ display: "grid", minWidth: 100 }}>
@@ -220,7 +231,7 @@ export class EditableView extends React.Component<EditableProps> {
                     ref={this._ref}
                     style={{ display: this.props.display, minHeight: "20px", height: `${this.props.height ? this.props.height : "auto"}`, maxHeight: `${this.props.maxHeight}` }}
                     onClick={this.onClick} placeholder={this.props.placeholder}>
-                    {this.props.highlight === undefined ? <span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{this.props.contents ? this.props.contents?.valueOf() : this.props.placeholder?.valueOf()}</span>
+                    {this.props.highlight === undefined || this.props.positions===undefined || this.props.bing===undefined? <span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{this.props.contents ? this.props.contents?.valueOf() : this.props.placeholder?.valueOf()}</span>
                         : this.returnHighlights()}
                 </div>
             );
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 6fc0026e5..b1c3705ca 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -248,28 +248,36 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         if (StrCast(this.props.Document._searchString) !== "") {
             console.log(StrCast(this.props.Document._searchString));
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
-            // if (cfield[Text]!==undefined){
-
-            // }
-            console.log(cfield?.valueOf());
-            let term = StrCast(cfield);
-            console.log(term);
+            let term = "";
+            if (cfield!==undefined){
+                if (cfield.Text!==undefined){
+                    term = cfield.Text;
+                }
+                else if (StrCast(cfield)){
+                    term= StrCast(cfield);
+                }
+                else {
+                    term = String(NumCast(cfield));
+                }
+            }
             let search = StrCast(this.props.Document._searchString)
             let start = term.indexOf(search) as number;
+            console.log(start);
             let tally = 0;
+            if (start!==-1){
             positions.push(start);
+            }
             while (start < contents.length && start !== -1) {
                 term = term.slice(start + search.length + 1);
                 tally += start + search.length + 1;
                 start = term.indexOf(search);
                 positions.push(tally + start);
             }
-            console.log(positions);
             if (positions.length > 1) {
                 positions.pop();
             }
         }
-
+        console.log(positions.length);
         return (
             <div className="collectionSchemaView-cellContainer" style={{ cursor: fieldIsDoc ? "grab" : "auto" }} ref={dragRef} onPointerDown={this.onPointerDown} onPointerEnter={onPointerEnter} onPointerLeave={onPointerLeave}>
                 <div className={className} ref={this._focusRef} onPointerDown={onItemDown} tabIndex={-1}>
@@ -287,23 +295,29 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                             maxHeight={Number(MAX_ROW_HEIGHT)}
                             placeholder={"enter value"}
                             bing={() => {
-                                console.log("FLAMINGO");
-                                if (type === "number" && (contents === 0 || contents === "0")) {
-                                    return "0";
-                                } else {
+                                // if (type === "number" && (contents === 0 || contents === "0")) {
+                                //     return "0";
+                                // } else {
                                     const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
                                     console.log(cfield);
-                                    // if (type === "number") {
-                                    return StrCast(cfield);
-                                    // }
-                                    // return cfield;
-                                    // const cscript = cfield instanceof ComputedField ? cfield.script.originalScript : undefined;
-                                    // const cfinalScript = cscript?.split("return")[cscript.split("return").length - 1];
-                                    // const val = cscript !== undefined ? (cfinalScript?.endsWith(";") ? `:=${cfinalScript?.substring(0, cfinalScript.length - 2)}` : cfinalScript) :
-                                    //     Field.IsField(cfield) ? Field.toScriptString(cfield) : "";
-                                    // return val;
-
+                                    if (cfield!==undefined){
+                                    if (cfield.Text!==undefined){
+                                        console.log
+                                        return(cfield.Text)
+                                    }
+                                    else if (StrCast(cfield)){
+                                        console.log("strcast");
+                                        return StrCast(cfield);
+                                    }
+                                    else {
+                                        console.log("numcast");
+                                        return String(NumCast(cfield));
+                                    }
                                 }
+                                    // console.log(cfield.Text);
+                                    // console.log(StrCast(cfield));
+                                    // return StrCast(cfield);
+                                // }
 
                             }}
                             GetValue={() => {
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index cd64d71ff..4d057f782 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -19,8 +19,7 @@
     display: flex;
     justify-content: flex-end;
     align-items: center;
-    padding-left: 2px;
-
+    background-color: black;
     .searchBox-barChild {
 
         &.searchBox-collection {
@@ -30,17 +29,20 @@
         }
 
         &.searchBox-input {
+            margin:5px;
+            border-radius:20px;
+            border:black;    
             display: block;
             width: 130px;
             -webkit-transition: width 0.4s;
             transition: width 0.4s;
             align-self: stretch;
-
+            outline:none;
         }
 
         .searchBox-input:focus {
             width: 500px;
-            outline: 3px solid lightblue;
+            outline:none;
         }
 
         &.searchBox-filter {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index f120a408e..884aa6a68 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1104,13 +1104,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
                 <div className="searchBox-bar">
-                    <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
+                    {/* <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
-                    </span>
+                    </span> */}
                     <input value={StrCast(this.layoutDoc._searchString)} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
                         style={{ width: this._searchbarOpen ? "500px" : "100px" }} />
-                    <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button>
+                    {/* <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button> */}
                 </div>
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults > 0 ? { overflow: "visible" } : { overflow: "hidden" }}>
                     <div id={`filterhead2${this.props.Document[Id]}`} className="filter-header"  >
-- 
cgit v1.2.3-70-g09d2


From fd741cddf64fe1b068b7a1de5bc3840798afe75d Mon Sep 17 00:00:00 2001
From: andy temp <andytemp@Kates-MBP.fios-router.home>
Date: Wed, 22 Jul 2020 14:42:32 -0400
Subject: search results open and close as panel under bar

---
 src/client/util/CurrentUserUtils.ts                |  2 +-
 .../views/collections/CollectionSchemaView.tsx     |  2 +-
 src/client/views/collections/CollectionView.tsx    |  2 +-
 src/client/views/nodes/FieldView.tsx               |  2 ++
 src/client/views/search/SearchBox.scss             |  2 +-
 src/client/views/search/SearchBox.tsx              | 28 ++++++++++++++++++----
 6 files changed, 29 insertions(+), 9 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 582cc2d5c..f16ef399c 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -658,7 +658,7 @@ export class CurrentUserUtils {
         const libraryBtn = CurrentUserUtils.setupLibraryPanel(doc, sidebarContainer);
         const searchBtn = CurrentUserUtils.setupSearchBtnPanel(doc, sidebarContainer);
         if (doc["search-panel"] === undefined) {
-            doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({ ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc;
+            doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc;
     }
         // Finally, setup the list of buttons to display in the sidebar
         if (doc["tabs-buttons"] === undefined) {
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 50eea5059..be4f7c888 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -631,7 +631,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
         return <div className="collectionSchemaView-container"
             style={{
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
-                width: this.props.PanelWidth() || "100%", height: this.props.PanelHeight() || "100%"
+                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight()  || "100%", top: this.props.PanelPosition === "absolute" ? 32 : 0, position: this.props.PanelPosition || "relative",
             }}  >
             <div className="collectionSchemaView-tableContainer"
                 style={{ width: `calc(100% - ${this.previewWidth()}px)` }}
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 43bfbc913..0178cc2e9 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -554,7 +554,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
         return (<div className={"collectionView"} onContextMenu={this.onContextMenu}
             style={{ pointerEvents: this.props.Document.isBackground ? "none" : undefined, boxShadow }}>
             {this.showIsTagged()}
-            <div className="collectionView-facetCont" style={{ width: `calc(100% - ${this.facetWidth()}px)` }}>
+            <div className="collectionView-facetCont" style={{ display: this.props.PanelPosition==="absolute"? "flex" : "", justifyContent: this.props.PanelPosition==="absolute"? "center" : "", width: `calc(100% - ${this.facetWidth()}px)` }}>
                 {this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
             </div>
             {this.lightbox(DocListCast(this.props.Document[this.props.fieldKey]).filter(d => d.type === DocumentType.IMG).map(d =>
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 3aabd5d6b..8b83a29b2 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -48,10 +48,12 @@ export interface FieldViewProps {
     ignoreAutoHeight?: boolean;
     PanelWidth: () => number;
     PanelHeight: () => number;
+    PanelPosition: string;
     NativeHeight: () => number;
     NativeWidth: () => number;
     setVideoBox?: (player: VideoBox) => void;
     ContentScaling: () => number;
+
     ChromeHeight?: () => number;
     childLayoutTemplate?: () => Opt<Doc>;
     highlighting?: string[];
diff --git a/src/client/views/search/SearchBox.scss b/src/client/views/search/SearchBox.scss
index 4d057f782..8cd2f00b4 100644
--- a/src/client/views/search/SearchBox.scss
+++ b/src/client/views/search/SearchBox.scss
@@ -17,7 +17,7 @@
 .searchBox-bar {
     height: 32px;
     display: flex;
-    justify-content: flex-end;
+    justify-content: center;
     align-items: center;
     background-color: black;
     .searchBox-barChild {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 884aa6a68..21f476ea4 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -199,13 +199,26 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
-            if (this._icons !== this._allIcons) {
-                runInAction(() => { this.expandedBucket = false });
+            // if (this._icons !== this._allIcons) {
+            //     runInAction(() => { this.expandedBucket = false });
+            // }
+            console.log(StrCast(this.layoutDoc._searchString));
+            if (StrCast(this.layoutDoc._searchString)!==""){
+                console.log("OPEN");
+                runInAction(()=>{this.open=true});
+            }
+            else {
+                console.log("CLOSE");
+                runInAction(()=>{this.open=false});
+
             }
             this.submitSearch();
         }
     }
 
+    @observable open: boolean = false;
+
+
     public static async convertDataUri(imageUri: string, returnedFilename: string) {
         try {
             const posting = Utils.prepend("/uploadURI");
@@ -377,7 +390,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     get fieldFiltersApplied() { return !(this._authorFieldStatus && this._titleFieldStatus); }
 
 
-    @observable expandedBucket: boolean = false;
     @action
     submitSearch = async (reset?: boolean) => {
         this.checkIcons();
@@ -1109,7 +1121,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     </span> */}
                     <input value={StrCast(this.layoutDoc._searchString)} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
-                        style={{ width: this._searchbarOpen ? "500px" : "100px" }} />
+                        style={{ width: this._searchbarOpen ? "200px" : "200px" }} />
                     {/* <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button> */}
                 </div>
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults > 0 ? { overflow: "visible" } : { overflow: "hidden" }}>
@@ -1123,12 +1135,18 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         {this.keyButtons}
                     </div>
                 </div>
+                <div style={{zIndex:2000}}>
                 {this.headerscale > 0 ? <CollectionView {...this.props}
                     Document={this.props.Document}
                     moveDocument={returnFalse}
                     removeDocument={returnFalse}
+                    PanelHeight={this.open===true?()=>200 :()=>0}
+                    PanelWidth={this.open===true? ()=>600 : ()=>0}
+                    PanelPosition={"absolute"}
                     focus={this.selectElement}
-                    ScreenToLocalTransform={Transform.Identity} /> : undefined}
+                    ScreenToLocalTransform={Transform.Identity}
+                     /> : undefined}
+                     </div>
 
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
-- 
cgit v1.2.3-70-g09d2


From d4ff3975ee3b72a7869535bf8d9fc78039203aed Mon Sep 17 00:00:00 2001
From: andy temp <andytemp@Kates-MBP.fios-router.home>
Date: Wed, 22 Jul 2020 22:39:44 -0400
Subject: search

---
 src/client/util/CurrentUserUtils.ts                |  2 +-
 src/client/views/EditableView.tsx                  |  5 +-
 src/client/views/MainView.tsx                      | 14 ++++
 .../views/collections/CollectionSchemaCells.tsx    | 10 +--
 .../views/collections/CollectionSchemaHeaders.tsx  | 42 +++++++++-
 .../views/collections/CollectionSchemaView.tsx     |  5 +-
 src/client/views/collections/SchemaTable.tsx       |  6 +-
 src/client/views/nodes/FieldView.tsx               |  4 +-
 src/client/views/search/SearchBox.tsx              | 91 +++++++++++++++++-----
 9 files changed, 135 insertions(+), 44 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index f16ef399c..c7cdf8545 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -658,7 +658,7 @@ export class CurrentUserUtils {
         const libraryBtn = CurrentUserUtils.setupLibraryPanel(doc, sidebarContainer);
         const searchBtn = CurrentUserUtils.setupSearchBtnPanel(doc, sidebarContainer);
         if (doc["search-panel"] === undefined) {
-            doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, title: "sidebar search stack", })) as any as Doc;
+            doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({_width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, _chromeStatus: "disabled", title: "sidebar search stack", })) as any as Doc;
     }
         // Finally, setup the list of buttons to display in the sidebar
         if (doc["tabs-buttons"] === undefined) {
diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index 4c2d2f0a9..b78ed6fee 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -195,15 +195,13 @@ export class EditableView extends React.Component<EditableProps> {
         if (this.props.positions!==undefined){
         let positions = this.props.positions;
         let length = this.props.search!.length;
-        console.log(contents);
-        console.log(this.props.contents?.valueOf());
+
         // contents = String(this.props.contents.valueOf());
 
         results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(0, this.props.positions![0]) : this.props.placeholder?.valueOf()}</span>);
         positions.forEach((num, cur) => {
             results.push(<span style={{ backgroundColor: "#FFFF00", fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}</span>);
             let end = 0;
-            console.log
             cur === positions.length-1? end = contents.length: end = positions[cur + 1];
             results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}</span>);
         }
@@ -217,7 +215,6 @@ else{
     }
 
     render() {
-        console.log(this.props.highlight === undefined);
         if (this._editing && this.props.GetValue() !== undefined) {
             return this.props.sizeToContent ?
                 <div style={{ display: "grid", minWidth: 100 }}>
diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index c65c90afb..fce3707a7 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -156,10 +156,24 @@ export class MainView extends React.Component {
         const targets = document.elementsFromPoint(e.x, e.y);
         if (targets && targets.length && targets[0].className.toString().indexOf("contextMenu") === -1) {
             ContextMenu.Instance.closeMenu();
+            //SearchBox.Instance.closeSearch();
         }
         if (targets && (targets.length && targets[0].className.toString() !== "timeline-menu-desc" && targets[0].className.toString() !== "timeline-menu-item" && targets[0].className.toString() !== "timeline-menu-input")) {
             TimelineMenu.Instance.closeMenu();
         }
+        if (targets && targets.length && SearchBox.Instance._searchbarOpen){
+            let check = false;
+            targets.forEach((thing)=>{
+            if (thing.className.toString()==="collectionSchemaView-table" || thing.className.toString()==="beta") {
+                check=true;
+            }
+        });
+        if (check===false){
+            SearchBox.Instance.closeSearch();
+        }
+    }
+
+
     });
 
     globalPointerUp = () => this.isPointerDown = false;
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index b1c3705ca..11f0edf23 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -246,7 +246,6 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         trace();
         let positions = [];
         if (StrCast(this.props.Document._searchString) !== "") {
-            console.log(StrCast(this.props.Document._searchString));
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
             let term = "";
             if (cfield!==undefined){
@@ -262,7 +261,6 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             }
             let search = StrCast(this.props.Document._searchString)
             let start = term.indexOf(search) as number;
-            console.log(start);
             let tally = 0;
             if (start!==-1){
             positions.push(start);
@@ -277,7 +275,6 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                 positions.pop();
             }
         }
-        console.log(positions.length);
         return (
             <div className="collectionSchemaView-cellContainer" style={{ cursor: fieldIsDoc ? "grab" : "auto" }} ref={dragRef} onPointerDown={this.onPointerDown} onPointerEnter={onPointerEnter} onPointerLeave={onPointerLeave}>
                 <div className={className} ref={this._focusRef} onPointerDown={onItemDown} tabIndex={-1}>
@@ -299,18 +296,14 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                                 //     return "0";
                                 // } else {
                                     const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
-                                    console.log(cfield);
                                     if (cfield!==undefined){
                                     if (cfield.Text!==undefined){
-                                        console.log
-                                        return(cfield.Text)
+                                        return(cfield.Text);
                                     }
                                     else if (StrCast(cfield)){
-                                        console.log("strcast");
                                         return StrCast(cfield);
                                     }
                                     else {
-                                        console.log("numcast");
                                         return String(NumCast(cfield));
                                     }
                                 }
@@ -325,7 +318,6 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                                     return "0";
                                 } else {
                                     const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
-                                    console.log(cfield);
                                     if (type === "number") {
                                         return StrCast(cfield);
                                     }
diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx
index 4a9bd4aa6..ec8605215 100644
--- a/src/client/views/collections/CollectionSchemaHeaders.tsx
+++ b/src/client/views/collections/CollectionSchemaHeaders.tsx
@@ -9,6 +9,8 @@ import { ColumnType } from "./CollectionSchemaView";
 import { faFile } from "@fortawesome/free-regular-svg-icons";
 import { SchemaHeaderField, PastelSchemaPalette } from "../../../fields/SchemaHeaderField";
 import { undoBatch } from "../../util/UndoManager";
+import { Doc } from "../../../fields/Doc";
+import { StrCast } from "../../../fields/Types";
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
 export const Flyout = higflyout.default;
@@ -291,6 +293,7 @@ export interface KeysDropdownProps {
     onSelect: (oldKey: string, newKey: string, addnew: boolean, filter?: string) => void;
     setIsEditing: (isEditing: boolean) => void;
     width?: string;
+    docs?: Doc[];
 }
 @observer
 export class KeysDropdown extends React.Component<KeysDropdownProps> {
@@ -309,7 +312,6 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
         if (key.slice(0, this._key.length) === this._key && this._key !== key) {
             let filter = key.slice(this._key.length - key.length);
             this.props.onSelect(this._key, this._key, this.props.addNew, filter);
-            console.log("YEE");
         }
         else {
             this.props.onSelect(this._key, key, this.props.addNew);
@@ -319,6 +321,13 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
         }
     }
 
+    @action
+    onSelect2 = (key: string): void => {
+        this._searchTerm=this._searchTerm.slice(0,this._key.length) +key;
+        this._isOpen = false;
+
+    }
+
     @undoBatch
     onKeyDown = (e: React.KeyboardEvent): void => {
         //if (this._key !==)
@@ -394,7 +403,35 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
         return options;
     }
 
+    renderFilterOptions = (): JSX.Element[] | JSX.Element => {
+        console.log("HEHEHE")
+        if (!this._isOpen) return <></>;
+
+        const keyOptions:string[]=[];
+        console.log(this._searchTerm.slice(this._key.length))
+        let temp = this._searchTerm.slice(this._key.length);
+        this.props.docs?.forEach((doc)=>{
+            let key = StrCast(doc[this._key]);
+            if (keyOptions.includes(key)===false && key.includes(temp)){
+            keyOptions.push(key);
+            }
+        });
+
+
+        const options = keyOptions.map(key => {
+            return <div key={key} className="key-option" style={{
+                border: "1px solid lightgray",
+                width: this.props.width, maxWidth: this.props.width, overflowX: "hidden"
+            }}
+                onPointerDown={e => e.stopPropagation()} onClick={() => { this.onSelect2(key);  }}>{key}</div>;
+        });
+
+        return options;
+    }
+
+
     render() {
+        console.log(this.props.docs);
         return (
             <div className="keys-dropdown" style={{ zIndex: 10, width: this.props.width, maxWidth: this.props.width }}>
                 {this._key === this._searchTerm.slice(0, this._key.length) ?
@@ -414,7 +451,8 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
                     width: this.props.width, maxWidth: this.props.width,
                 }}
                     onPointerEnter={this.onPointerEnter} onPointerLeave={this.onPointerOut}>
-                    {this.renderOptions()}
+                    {this._key === this._searchTerm.slice(0, this._key.length) ?
+                    this.renderFilterOptions():this.renderOptions()}
                 </div>
             </div >
         );
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index be4f7c888..0b3d8e20d 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -609,7 +609,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
 
 
     onKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
-        console.log("yeet2");
     }
     render() {
         TraceMobx();
@@ -631,10 +630,10 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
         return <div className="collectionSchemaView-container"
             style={{
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
-                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight()  || "100%", top: this.props.PanelPosition === "absolute" ? 32 : 0, position: this.props.PanelPosition || "relative",
+                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight()  || "100%", top: this.props.PanelPosition === "absolute" ? 52 : 0, position: this.props.PanelPosition || "relative",
             }}  >
             <div className="collectionSchemaView-tableContainer"
-                style={{ width: `calc(100% - ${this.previewWidth()}px)` }}
+                style={{ backgroundColor:"white", width: `calc(100% - ${this.previewWidth()}px)` }}
                 onKeyPress={this.onKeyPress}
                 onPointerDown={this.onPointerDown}
                 onWheel={e => this.props.active(true) && e.stopPropagation()}
diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx
index 2b60bef1b..c820cb661 100644
--- a/src/client/views/collections/SchemaTable.tsx
+++ b/src/client/views/collections/SchemaTable.tsx
@@ -189,7 +189,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
                 addNew={false}
                 onSelect={this.props.changeColumns}
                 setIsEditing={this.props.setHeaderIsEditing}
-
+                docs={this.props.childDocs}
                 // try commenting this out
                 width={"100%"}
             />;
@@ -451,10 +451,8 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
         //@ts-ignore
         expandedRowsList.forEach(row => expanded[row] = true);
         const rerender = [...this.textWrappedRows]; // TODO: get component to rerender on text wrap change without needign to console.log :((((
-        let overflow = "auto";
-        StrCast(this.props.Document.type) === "search" ? overflow = "overlay" : "auto";
         return <ReactTable
-            style={{ position: "relative", overflow: overflow }}
+            style={{ position: "relative" }}
             data={children}
             page={0}
             pageSize={children.length}
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 8b83a29b2..732a254fe 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -46,8 +46,8 @@ export interface FieldViewProps {
     dontRegisterView?: boolean;
     focus: (doc: Doc) => void;
     ignoreAutoHeight?: boolean;
-    PanelWidth: () => number;
-    PanelHeight: () => number;
+    PanelWidth: () => number|string;
+    PanelHeight: () => number|string;
     PanelPosition: string;
     NativeHeight: () => number;
     NativeWidth: () => number;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 21f476ea4..ee85375e3 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -73,7 +73,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @computed get _searchString() { return this.layoutDoc.searchQuery; }
     @computed set _searchString(value) { this.layoutDoc.searchQuery = (value); }
     @observable private _resultsOpen: boolean = false;
-    @observable private _searchbarOpen: boolean = false;
+    @observable _searchbarOpen: boolean = false;
     @observable private _results: [Doc, string[], string[]][] = [];
     @observable private _openNoResults: boolean = false;
     @observable private _visibleElements: JSX.Element[] = [];
@@ -183,10 +183,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @action
     getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc)
 
+
+    @observable newsearchstring: string ="";
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
-        this.layoutDoc._searchString = e.target.value;
-
+        //this.layoutDoc._searchString = e.target.value;
+        this.newsearchstring= e.target.value;
+        if (e.target.value===""){
+            console.log("CLOSE");
+            runInAction(()=>{this.open=false});
+        }
         this._openNoResults = false;
         this._results = [];
         this._resultsSet.clear();
@@ -199,10 +205,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
+            console.log(this.newsearchstring)
+            this.layoutDoc._searchString=this.newsearchstring;
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
             // }
-            console.log(StrCast(this.layoutDoc._searchString));
             if (StrCast(this.layoutDoc._searchString)!==""){
                 console.log("OPEN");
                 runInAction(()=>{this.open=true});
@@ -392,11 +399,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async (reset?: boolean) => {
+        
         this.checkIcons();
         if (reset) {
             this.layoutDoc._searchString = "";
         }
+        this.noresults= false;
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
+        this.headercount=0;
+        this.children=0;
         this.buckets = [];
         this.new_buckets = {};
         const query = StrCast(this.layoutDoc._searchString);
@@ -519,7 +530,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         });
         return this.lockPromise;
     }
-
+    @observable noresults = false;
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
         const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
@@ -591,6 +602,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._curRequest = undefined;
     }
 
+    @observable children: number =0;
     @action
     resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
         if (!this._resultsRef.current) return;
@@ -604,11 +616,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._endIndex = 30;
         let headers = new Set<string>();
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
-            this._visibleElements = [<div className="no-result">No Search Results</div>];
-            //this._visibleDocuments= Docs.Create.
-            let noResult = Docs.Create.TextDocument("", { title: "noResult" })
-            noResult.isBucket = false;
-            Doc.AddDocToList(this.dataDoc, this.props.fieldKey, noResult);
+            this.noresults=true;
             return;
         }
 
@@ -653,6 +661,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                            this.children ++;
                         }
                     }
                     else {
@@ -669,6 +678,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this._isSearch[i] = "search";
                                 console.log("WHYYYY");
                                 Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
+                                this.children ++;
 
                             }
                         }
@@ -681,6 +691,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         let schemaheaders: SchemaHeaderField[] = [];
         this.headerscale = headers.size;
         headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
+        this.headercount= schemaheaders.length;
         this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
@@ -688,7 +699,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._isSearch.length = this._results.length;
         }
     }
-
+    @observable headercount:number=0;
     @observable headerscale: number = 0;
 
     findCommonElements(arr2: string[]) {
@@ -1112,16 +1123,24 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
     //Make id layour document
     render() {
+        this.props.Document._chromeStatus === "disabled";
         this.props.Document._searchDoc = true;
+        //let length = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
+        let length = this.headercount;
+        length > 3 ? length = 650 : length = length * 205 + 51;
+        let height = this.children;
+        height > 8 ? height = 31+31*8: height = 31*height+ 31; 
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
                 <div className="searchBox-bar">
                     {/* <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
                     </span> */}
-                    <input value={StrCast(this.layoutDoc._searchString)} onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
+                    <div style={{position:"absolute", left:15}}>{Doc.CurrentUserEmail}</div>
+                    <FontAwesomeIcon icon={"search"} size="lg" style={{ position:"relative", left:24, padding:1 }} />
+                    <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
-                        style={{ width: this._searchbarOpen ? "200px" : "200px" }} />
+                        style={{ paddingLeft:23, width: this._searchbarOpen ? "200px" : "200px" }} />
                     {/* <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button> */}
                 </div>
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults > 0 ? { overflow: "visible" } : { overflow: "hidden" }}>
@@ -1135,18 +1154,52 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         {this.keyButtons}
                     </div>
                 </div>
-                <div style={{zIndex:2000}}>
-                {this.headerscale > 0 ? <CollectionView {...this.props}
+                <div style={{ zIndex:2000}}>
+                {this._searchbarOpen === true ? 
+                <div style={{display:"flex", justifyContent:"center",}}>
+                <div style={{width: this.headercount>0?length: 251,
+                height: 25,
+                borderColor: "#9c9396",
+                border: "1px solid",
+                borderRadius:"0.3em",
+                borderBottom:this.open===false?"1px solid":"none",
+                position: "absolute",
+                background: "rgb(241, 239, 235)",
+                top:29}}>                 
+                    <form className="beta" style={{justifyContent:"space-evenly", display:"flex"}}><label>
+      <input
+        type="radio"
+      />
+      Current collection 
+    </label>
+    <label>
+      <input
+        type="radio"
+      />
+      Workspace
+    </label>
+    <label>
+      <input
+        type="radio"
+      />
+      Database
+    </label></form>           
+                </div>
+
+                {this.noresults===false? <div style={{display:this.open===true? "contents":"none"}}> <CollectionView {...this.props}
                     Document={this.props.Document}
                     moveDocument={returnFalse}
                     removeDocument={returnFalse}
-                    PanelHeight={this.open===true?()=>200 :()=>0}
-                    PanelWidth={this.open===true? ()=>600 : ()=>0}
+                    PanelHeight={this.open===true?()=> height:()=>0}
+                    PanelWidth={this.open===true? ()=>length : ()=>0}
                     PanelPosition={"absolute"}
                     focus={this.selectElement}
                     ScreenToLocalTransform={Transform.Identity}
-                     /> : undefined}
-                     </div>
+                     /></div>: <div style={{display:"flex",justifyContent:"center"}}><div style={{height:200, top:29, width:250, position:"absolute", backgroundColor:"white", display:"flex", justifyContent:"center", alignItems    :"center", border: "black 1px solid", }}>
+                     <div>No search results :(</div>
+                     </div></div>}
+                     </div>: undefined}
+                </div>
 
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
                     display: this._resultsOpen ? "flex" : "none",
-- 
cgit v1.2.3-70-g09d2


From 383351a022ff7b20a46a2d492d04ac350b1f2eb3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Sun, 26 Jul 2020 18:30:47 -0400
Subject: searching within collections : )

---
 .../views/collections/CollectionSchemaHeaders.tsx  |  15 +-
 src/client/views/search/SearchBox.tsx              | 182 +++++++++++++--------
 2 files changed, 118 insertions(+), 79 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx
index ec8605215..0ee225407 100644
--- a/src/client/views/collections/CollectionSchemaHeaders.tsx
+++ b/src/client/views/collections/CollectionSchemaHeaders.tsx
@@ -323,7 +323,7 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
 
     @action
     onSelect2 = (key: string): void => {
-        this._searchTerm=this._searchTerm.slice(0,this._key.length) +key;
+        this._searchTerm = this._searchTerm.slice(0, this._key.length) + key;
         this._isOpen = false;
 
     }
@@ -404,16 +404,15 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
     }
 
     renderFilterOptions = (): JSX.Element[] | JSX.Element => {
-        console.log("HEHEHE")
         if (!this._isOpen) return <></>;
 
-        const keyOptions:string[]=[];
+        const keyOptions: string[] = [];
         console.log(this._searchTerm.slice(this._key.length))
         let temp = this._searchTerm.slice(this._key.length);
-        this.props.docs?.forEach((doc)=>{
+        this.props.docs?.forEach((doc) => {
             let key = StrCast(doc[this._key]);
-            if (keyOptions.includes(key)===false && key.includes(temp)){
-            keyOptions.push(key);
+            if (keyOptions.includes(key) === false && key.includes(temp)) {
+                keyOptions.push(key);
             }
         });
 
@@ -423,7 +422,7 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
                 border: "1px solid lightgray",
                 width: this.props.width, maxWidth: this.props.width, overflowX: "hidden"
             }}
-                onPointerDown={e => e.stopPropagation()} onClick={() => { this.onSelect2(key);  }}>{key}</div>;
+                onPointerDown={e => e.stopPropagation()} onClick={() => { this.onSelect2(key); }}>{key}</div>;
         });
 
         return options;
@@ -452,7 +451,7 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
                 }}
                     onPointerEnter={this.onPointerEnter} onPointerLeave={this.onPointerOut}>
                     {this._key === this._searchTerm.slice(0, this._key.length) ?
-                    this.renderFilterOptions():this.renderOptions()}
+                        this.renderFilterOptions() : this.renderOptions()}
                 </div>
             </div >
         );
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index ee85375e3..ee2dab2f6 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -5,7 +5,7 @@ import { action, computed, observable, runInAction, IReactionDisposer, reaction
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import * as rp from 'request-promise';
-import { Doc } from '../../../fields/Doc';
+import { Doc, DocListCast } from '../../../fields/Doc';
 import { Id } from '../../../fields/FieldSymbols';
 import { Cast, NumCast, StrCast } from '../../../fields/Types';
 import { Utils, returnTrue, emptyFunction, returnFalse, emptyPath, returnOne, returnEmptyString, returnEmptyFilter } from '../../../Utils';
@@ -24,7 +24,7 @@ import { CollectionLinearView } from '../collections/CollectionLinearView';
 import { CurrentUserUtils } from '../../util/CurrentUserUtils';
 
 import { CollectionDockingView } from '../collections/CollectionDockingView';
-import { ScriptField } from '../../../fields/ScriptField';
+import { ScriptField, ComputedField } from '../../../fields/ScriptField';
 import { PrefetchProxy } from '../../../fields/Proxy';
 import { List } from '../../../fields/List';
 import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
@@ -184,14 +184,14 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc)
 
 
-    @observable newsearchstring: string ="";
+    @observable newsearchstring: string = "";
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         //this.layoutDoc._searchString = e.target.value;
-        this.newsearchstring= e.target.value;
-        if (e.target.value===""){
+        this.newsearchstring = e.target.value;
+        if (e.target.value === "") {
             console.log("CLOSE");
-            runInAction(()=>{this.open=false});
+            runInAction(() => { this.open = false });
         }
         this._openNoResults = false;
         this._results = [];
@@ -206,17 +206,17 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
             console.log(this.newsearchstring)
-            this.layoutDoc._searchString=this.newsearchstring;
+            this.layoutDoc._searchString = this.newsearchstring;
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
             // }
-            if (StrCast(this.layoutDoc._searchString)!==""){
+            if (StrCast(this.layoutDoc._searchString) !== "") {
                 console.log("OPEN");
-                runInAction(()=>{this.open=true});
+                runInAction(() => { this.open = true });
             }
             else {
                 console.log("CLOSE");
-                runInAction(()=>{this.open=false});
+                runInAction(() => { this.open = false });
 
             }
             this.submitSearch();
@@ -335,10 +335,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     getCurCollections(): Doc[] {
         const selectedDocs: DocumentView[] = SelectionManager.SelectedDocuments();
         const collections: Doc[] = [];
-        console.log(selectedDocs);
         selectedDocs.forEach(async element => {
             const layout: string = StrCast(element.props.Document.layout);
-            console.log(layout);
+
+            console.log(DocListCast(element.dataDoc[Doc.LayoutFieldKey(element.dataDoc)]));
+            console.log(DocListCast(element.dataDoc[Doc.LayoutFieldKey(element.dataDoc)]).length);
+
             //checks if selected view (element) is a collection. if it is, adds to list to search through
             if (layout.indexOf("Collection") > -1) {
                 //makes sure collections aren't added more than once
@@ -356,6 +358,34 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
 
+
+    searchCollection(query: string) {
+
+        const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
+        if (selectedCollection !== undefined) {
+            let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
+            let found: [Doc, string[], string[]][] = [];
+            docs.forEach((d) => {
+                let hlights: string[] = [];
+                const protos = Doc.GetAllPrototypes(d);
+                let proto = protos[protos.length - 2];
+                Object.keys(proto).forEach(key => {
+                    if (StrCast(d[key]).includes(query)) {
+                        console.log(key, d[key]);
+                        hlights.push(key);
+                    }
+                });
+                if (hlights.length > 0) {
+                    found.push([d, hlights, []]);
+                };
+            });
+            console.log(found);
+            this._results = found;
+            this._numTotalResults = found.length;
+        }
+
+    }
+
     applyBasicFieldFilters(query: string) {
         let finalQuery = "";
 
@@ -399,15 +429,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async (reset?: boolean) => {
-        
+
         this.checkIcons();
         if (reset) {
             this.layoutDoc._searchString = "";
         }
-        this.noresults= false;
+        this.noresults = false;
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
-        this.headercount=0;
-        this.children=0;
+        this.headercount = 0;
+        this.children = 0;
         this.buckets = [];
         this.new_buckets = {};
         const query = StrCast(this.layoutDoc._searchString);
@@ -422,7 +452,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined };
             this._timeout = setTimeout(() => {
                 console.log("Resubmitting search");
-                this.submitSearch();
+
             }, 60000);
         }
 
@@ -430,7 +460,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._endIndex = 12;
             this._maxSearchIndex = 0;
             this._numTotalResults = -1;
-            await this.getResults(query);
+            this.scale === true ? await this.getResults(query) : this.searchCollection(query);
             runInAction(() => {
                 this._resultsOpen = true;
                 this._searchbarOpen = true;
@@ -440,6 +470,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             });
         }
     }
+
+    @observable scale = false;
+
     @observable _timeout: any = undefined;
 
     @observable firststring: string = "";
@@ -494,6 +527,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlight = highlights[doc[Id]];
                             const line = lines.get(doc[Id]) || [];
                             const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
+                            console.log(hlights);
                             doc ? console.log(Cast(doc.context, Doc)) : null;
                             if (this.findCommonElements(hlights)) {
                             }
@@ -602,7 +636,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._curRequest = undefined;
     }
 
-    @observable children: number =0;
+    @observable children: number = 0;
     @action
     resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
         if (!this._resultsRef.current) return;
@@ -616,7 +650,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._endIndex = 30;
         let headers = new Set<string>();
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
-            this.noresults=true;
+            console.log("TRU");
+            this.noresults = true;
             return;
         }
 
@@ -660,8 +695,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             highlights.forEach((item) => headers.add(item));
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
+                            console.log(result[0]);
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                            this.children ++;
+                            this.children++;
                         }
                     }
                     else {
@@ -677,8 +713,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
                                 console.log("WHYYYY");
+                                console.log(result[0]);
+
                                 Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
-                                this.children ++;
+                                this.children++;
 
                             }
                         }
@@ -691,7 +729,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         let schemaheaders: SchemaHeaderField[] = [];
         this.headerscale = headers.size;
         headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
-        this.headercount= schemaheaders.length;
+        this.headercount = schemaheaders.length;
         this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
         if (this._maxSearchIndex >= this._numTotalResults) {
             this._visibleElements.length = this._results.length;
@@ -699,7 +737,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._isSearch.length = this._results.length;
         }
     }
-    @observable headercount:number=0;
+    @observable headercount: number = 0;
     @observable headerscale: number = 0;
 
     findCommonElements(arr2: string[]) {
@@ -1125,22 +1163,22 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     render() {
         this.props.Document._chromeStatus === "disabled";
         this.props.Document._searchDoc = true;
-        //let length = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
-        let length = this.headercount;
+        let length = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
+        //let length = this.headercount;
         length > 3 ? length = 650 : length = length * 205 + 51;
         let height = this.children;
-        height > 8 ? height = 31+31*8: height = 31*height+ 31; 
+        height > 8 ? height = 31 + 31 * 8 : height = 31 * height + 31;
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
                 <div className="searchBox-bar">
                     {/* <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
                         <FontAwesomeIcon icon="object-group" size="lg" />
                     </span> */}
-                    <div style={{position:"absolute", left:15}}>{Doc.CurrentUserEmail}</div>
-                    <FontAwesomeIcon icon={"search"} size="lg" style={{ position:"relative", left:24, padding:1 }} />
+                    <div style={{ position: "absolute", left: 15 }}>{Doc.CurrentUserEmail}</div>
+                    <FontAwesomeIcon icon={"search"} size="lg" style={{ position: "relative", left: 24, padding: 1 }} />
                     <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
-                        style={{ paddingLeft:23, width: this._searchbarOpen ? "200px" : "200px" }} />
+                        style={{ paddingLeft: 23, width: this._searchbarOpen ? "200px" : "200px" }} />
                     {/* <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button> */}
                 </div>
                 <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults > 0 ? { overflow: "visible" } : { overflow: "hidden" }}>
@@ -1154,51 +1192,53 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         {this.keyButtons}
                     </div>
                 </div>
-                <div style={{ zIndex:2000}}>
-                {this._searchbarOpen === true ? 
-                <div style={{display:"flex", justifyContent:"center",}}>
-                <div style={{width: this.headercount>0?length: 251,
-                height: 25,
-                borderColor: "#9c9396",
-                border: "1px solid",
-                borderRadius:"0.3em",
-                borderBottom:this.open===false?"1px solid":"none",
-                position: "absolute",
-                background: "rgb(241, 239, 235)",
-                top:29}}>                 
-                    <form className="beta" style={{justifyContent:"space-evenly", display:"flex"}}><label>
-      <input
-        type="radio"
-      />
-      Current collection 
+                <div style={{ zIndex: 2000 }}>
+                    {this._searchbarOpen === true ?
+                        <div style={{ display: "flex", justifyContent: "center", }}>
+                            <div style={{
+                                width: this.headercount > 0 ? length : 251,
+                                height: 25,
+                                borderColor: "#9c9396",
+                                border: "1px solid",
+                                borderRadius: "0.3em",
+                                borderBottom: this.open === false ? "1px solid" : "none",
+                                position: "absolute",
+                                background: "rgb(241, 239, 235)",
+                                top: 29
+                            }}>
+                                <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}><label>
+                                    <input
+                                        type="radio"
+                                    />
+      Current collection
     </label>
-    <label>
-      <input
-        type="radio"
-      />
+                                    <label>
+                                        <input
+                                            type="radio"
+                                        />
       Workspace
     </label>
-    <label>
-      <input
-        type="radio"
-      />
+                                    <label>
+                                        <input
+                                            type="radio"
+                                        />
       Database
-    </label></form>           
-                </div>
-
-                {this.noresults===false? <div style={{display:this.open===true? "contents":"none"}}> <CollectionView {...this.props}
-                    Document={this.props.Document}
-                    moveDocument={returnFalse}
-                    removeDocument={returnFalse}
-                    PanelHeight={this.open===true?()=> height:()=>0}
-                    PanelWidth={this.open===true? ()=>length : ()=>0}
-                    PanelPosition={"absolute"}
-                    focus={this.selectElement}
-                    ScreenToLocalTransform={Transform.Identity}
-                     /></div>: <div style={{display:"flex",justifyContent:"center"}}><div style={{height:200, top:29, width:250, position:"absolute", backgroundColor:"white", display:"flex", justifyContent:"center", alignItems    :"center", border: "black 1px solid", }}>
-                     <div>No search results :(</div>
-                     </div></div>}
-                     </div>: undefined}
+    </label></form>
+                            </div>
+
+                            {this.noresults === false ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
+                                Document={this.props.Document}
+                                moveDocument={returnFalse}
+                                removeDocument={returnFalse}
+                                PanelHeight={this.open === true ? () => height : () => 0}
+                                PanelWidth={this.open === true ? () => length : () => 0}
+                                PanelPosition={"absolute"}
+                                focus={this.selectElement}
+                                ScreenToLocalTransform={Transform.Identity}
+                            /></div> : <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 29, width: 250, position: "absolute", backgroundColor: "white", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
+                                <div>No search results :(</div>
+                            </div></div>}
+                        </div> : undefined}
                 </div>
 
                 <div className="searchBox-results" onScroll={this.resultsScrolled} style={{
-- 
cgit v1.2.3-70-g09d2


From 1217790e3a5314d5a50899c6423337ad9325fc52 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Sun, 26 Jul 2020 19:16:44 -0400
Subject:  better radio buttons

---
 src/client/views/search/SearchBox.tsx | 48 +++++++++++++++++------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index ee2dab2f6..0daebf0cf 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -383,6 +383,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._results = found;
             this._numTotalResults = found.length;
         }
+        else {
+            this.noresults = "No collection selected :(";
+        }
 
     }
 
@@ -434,7 +437,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (reset) {
             this.layoutDoc._searchString = "";
         }
-        this.noresults = false;
+        this.noresults = "";
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.headercount = 0;
         this.children = 0;
@@ -564,7 +567,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         });
         return this.lockPromise;
     }
-    @observable noresults = false;
+    @observable noresults = "";
     collectionRef = React.createRef<HTMLSpanElement>();
     startDragCollection = async () => {
         const res = await this.getAllResults(this.getFinalQuery(StrCast(this.layoutDoc._searchString)));
@@ -650,8 +653,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._endIndex = 30;
         let headers = new Set<string>();
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
-            console.log("TRU");
-            this.noresults = true;
+            if (this.noresults === "") {
+                this.noresults = "No search results :(";
+            }
             return;
         }
 
@@ -1206,27 +1210,23 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 background: "rgb(241, 239, 235)",
                                 top: 29
                             }}>
-                                <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}><label>
-                                    <input
-                                        type="radio"
-                                    />
-      Current collection
-    </label>
-                                    <label>
-                                        <input
-                                            type="radio"
-                                        />
-      Workspace
-    </label>
-                                    <label>
-                                        <input
-                                            type="radio"
-                                        />
-      Database
-    </label></form>
+                                <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
+                                    <div className="radio" style={{ margin: 0 }}>
+                                        <label style={{ fontSize: 12, marginTop: 6 }} >
+                                            <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                        Current collection
+                                    </label>
+                                    </div>
+                                    <div className="radio" style={{ margin: 0 }}>
+                                        <label style={{ fontSize: 12, marginTop: 6 }} >
+                                            <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                            Database
+                                    </label>
+                                    </div>
+                                </form>
                             </div>
 
-                            {this.noresults === false ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
+                            {this.noresults === "" ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
                                 Document={this.props.Document}
                                 moveDocument={returnFalse}
                                 removeDocument={returnFalse}
@@ -1236,7 +1236,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 focus={this.selectElement}
                                 ScreenToLocalTransform={Transform.Identity}
                             /></div> : <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 29, width: 250, position: "absolute", backgroundColor: "white", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
-                                <div>No search results :(</div>
+                                <div>{this.noresults}</div>
                             </div></div>}
                         </div> : undefined}
                 </div>
-- 
cgit v1.2.3-70-g09d2


From 61f7e5f47a02c004982640270feb8176e9407eb5 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 27 Jul 2020 17:33:01 -0400
Subject: filtering in search bar

---
 .../views/collections/CollectionSchemaView.tsx     |   5 +-
 src/client/views/search/SearchBox.tsx              | 110 ++++++++++++++++++---
 2 files changed, 98 insertions(+), 17 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 0b3d8e20d..4ecc7ba60 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -315,7 +315,6 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
     @undoBatch
     @action
     changeColumns = (oldKey: string, newKey: string, addNew: boolean, filter?: string) => {
-        console.log("COL");
         const columns = this.columns;
         if (columns === undefined) {
             this.columns = new List<SchemaHeaderField>([new SchemaHeaderField(newKey, "f1efeb")]);
@@ -630,10 +629,10 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
         return <div className="collectionSchemaView-container"
             style={{
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
-                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight()  || "100%", top: this.props.PanelPosition === "absolute" ? 52 : 0, position: this.props.PanelPosition || "relative",
+                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight() || "100%", top: this.props.PanelPosition === "absolute" ? 52 : 0, position: this.props.PanelPosition || "relative",
             }}  >
             <div className="collectionSchemaView-tableContainer"
-                style={{ backgroundColor:"white", width: `calc(100% - ${this.previewWidth()}px)` }}
+                style={{ backgroundColor: "white", width: `calc(100% - ${this.previewWidth()}px)` }}
                 onKeyPress={this.onKeyPress}
                 onPointerDown={this.onPointerDown}
                 onWheel={e => this.props.active(true) && e.stopPropagation()}
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 0daebf0cf..7601ea12e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -39,6 +39,7 @@ import { listSpec } from '../../../fields/Schema';
 import * as _ from "lodash";
 import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
 import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
+import { indexOf } from 'lodash';
 
 
 library.add(faTimes);
@@ -187,8 +188,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable newsearchstring: string = "";
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
-        //this.layoutDoc._searchString = e.target.value;
+        this.layoutDoc._searchString = e.target.value;
+        console.log(e.target.value);
         this.newsearchstring = e.target.value;
+
+        if (this.filter === true) {
+            runInAction(() => { this.open = false });
+            this.submitFilter();
+        }
+
+
         if (e.target.value === "") {
             console.log("CLOSE");
             runInAction(() => { this.open = false });
@@ -205,7 +214,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
-            console.log(this.newsearchstring)
             this.layoutDoc._searchString = this.newsearchstring;
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
@@ -219,7 +227,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 runInAction(() => { this.open = false });
 
             }
-            this.submitSearch();
+            if (this.filter === false) {
+                this.submitSearch();
+            }
+
         }
     }
 
@@ -430,6 +441,52 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     get fieldFiltersApplied() { return !(this._authorFieldStatus && this._titleFieldStatus); }
 
 
+    @action
+    submitFilter() {
+        let searchString = StrCast(this.layoutDoc._searchString);
+        if (searchString.includes(":") === false) {
+            return
+        }
+        let key = searchString.slice(0, searchString.indexOf(":"));
+        console.log(key);
+        console.log(searchString);
+        let values = searchString.slice(searchString.indexOf(":") + 1, searchString.length);
+        console.log(values);
+
+        const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
+        if (selectedCollection !== undefined) {
+            let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
+            let found: [Doc, string[], string[]][] = [];
+            Doc.setDocFilter(selectedCollection.props.Document, key, values, "match");
+            // docs.forEach((d) => {
+            //     let hlights: string[] = [];
+            //     const protos = Doc.GetAllPrototypes(d);
+            //     let proto = protos[protos.length - 2];
+            //     Object.keys(proto).forEach(key => {
+            //         console.log(key);
+            //         console.log(StrCast(this.layoutDoc._searchString));
+            //         Doc.setDocFilter(selectedCollection.props.Document, key, StrCast(this.layoutDoc._searchString), "match");
+
+            //         // if (StrCast(d[key]).includes(query)) {
+            //         //     console.log(key, d[key]);
+            //         //     hlights.push(key);
+            //         // }
+            //     });
+            //     // if (hlights.length > 0) {
+            //     //     found.push([d, hlights, []]);
+            //     // };
+            // });
+            // console.log(found);
+            // this._results = found;
+            // this._numTotalResults = found.length;
+        }
+        else {
+            this.noresults = "No collection selected :(";
+        }
+
+        //Doc.setDocFilter(this.props.Document, newKey, filter, "match");
+    }
+
     @action
     submitSearch = async (reset?: boolean) => {
 
@@ -474,7 +531,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
-    @observable scale = false;
+    @observable scale = true;
 
     @observable _timeout: any = undefined;
 
@@ -1163,6 +1220,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     addDocument = (doc: Doc) => {
         return null;
     }
+
+    @observable filter = false;
+
     //Make id layour document
     render() {
         this.props.Document._chromeStatus === "disabled";
@@ -1200,7 +1260,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     {this._searchbarOpen === true ?
                         <div style={{ display: "flex", justifyContent: "center", }}>
                             <div style={{
-                                width: this.headercount > 0 ? length : 251,
+                                width: this.headercount > 0 ? length : 253,
                                 height: 25,
                                 borderColor: "#9c9396",
                                 border: "1px solid",
@@ -1211,21 +1271,43 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 top: 29
                             }}>
                                 <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
-                                    <div className="radio" style={{ margin: 0 }}>
-                                        <label style={{ fontSize: 12, marginTop: 6 }} >
-                                            <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                    <div className="checkbox" style={{ margin: 0 }}>
+                                        <label style={{ fontSize: 12, marginTop: 6 }}>
+                                            <input style={{ marginLeft: -16, marginTop: -1 }} checked={this.filter === true} onChange={() => { runInAction(() => { this.filter = !this.filter }) }} type="checkbox"></input>
+                                            Filter
+                                        </label>
+                                    </div>
+                                    {this.filter === true ? <div style={{ display: "contents" }}>
+                                        <div className="radio" style={{ margin: 0 }}>
+                                            <label style={{ fontSize: 12, marginTop: 6 }} >
+                                                <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
                                         Current collection
                                     </label>
-                                    </div>
-                                    <div className="radio" style={{ margin: 0 }}>
-                                        <label style={{ fontSize: 12, marginTop: 6 }} >
-                                            <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
-                                            Database
+                                        </div>
+                                        <div className="radio" style={{ margin: 0 }}>
+                                            <label style={{ fontSize: 12, marginTop: 6 }} >
+                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                            Workspace
                                     </label>
+                                        </div>
                                     </div>
+                                        : <div style={{ display: "contents" }}>
+                                            <div className="radio" style={{ margin: 0 }}>
+                                                <label style={{ fontSize: 12, marginTop: 6 }} >
+                                                    <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                Current collection
+                            </label>
+                                            </div>
+                                            <div className="radio" style={{ margin: 0 }}>
+                                                <label style={{ fontSize: 12, marginTop: 6 }} >
+                                                    <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                    Database
+                            </label>
+                                            </div>
+                                        </div>
+                                    }
                                 </form>
                             </div>
-
                             {this.noresults === "" ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
                                 Document={this.props.Document}
                                 moveDocument={returnFalse}
-- 
cgit v1.2.3-70-g09d2


From a0f266b7dd7946a12be0d17b523b0a45570c80a6 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 28 Jul 2020 17:03:53 -0400
Subject: filter and other small features

---
 .../views/collections/CollectionSchemaView.scss    |   1 -
 .../views/collections/CollectionSchemaView.tsx     |   1 +
 src/client/views/nodes/FieldView.tsx               |   5 +-
 src/client/views/search/SearchBox.tsx              | 194 +++------------------
 4 files changed, 28 insertions(+), 173 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index 83fe54c82..93878d799 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -25,7 +25,6 @@
     .collectionSchemaView-tableContainer {
         width: 100%;
         height: 100%;
-        overflow: auto;
     }
 
     .collectionSchemaView-dividerDragger {
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 4ecc7ba60..d3c975e5d 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -628,6 +628,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
         </div>;
         return <div className="collectionSchemaView-container"
             style={{
+                overflow: this.props.overflow === true ? "auto" : undefined,
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
                 width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight() || "100%", top: this.props.PanelPosition === "absolute" ? 52 : 0, position: this.props.PanelPosition || "relative",
             }}  >
diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 732a254fe..c9fc99a31 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -46,9 +46,10 @@ export interface FieldViewProps {
     dontRegisterView?: boolean;
     focus: (doc: Doc) => void;
     ignoreAutoHeight?: boolean;
-    PanelWidth: () => number|string;
-    PanelHeight: () => number|string;
+    PanelWidth: () => number | string;
+    PanelHeight: () => number | string;
     PanelPosition: string;
+    overflow?: boolean;
     NativeHeight: () => number;
     NativeWidth: () => number;
     setVideoBox?: (player: VideoBox) => void;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 7601ea12e..73932896b 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -452,39 +452,22 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         console.log(searchString);
         let values = searchString.slice(searchString.indexOf(":") + 1, searchString.length);
         console.log(values);
-
-        const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
-        if (selectedCollection !== undefined) {
-            let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
-            let found: [Doc, string[], string[]][] = [];
-            Doc.setDocFilter(selectedCollection.props.Document, key, values, "match");
-            // docs.forEach((d) => {
-            //     let hlights: string[] = [];
-            //     const protos = Doc.GetAllPrototypes(d);
-            //     let proto = protos[protos.length - 2];
-            //     Object.keys(proto).forEach(key => {
-            //         console.log(key);
-            //         console.log(StrCast(this.layoutDoc._searchString));
-            //         Doc.setDocFilter(selectedCollection.props.Document, key, StrCast(this.layoutDoc._searchString), "match");
-
-            //         // if (StrCast(d[key]).includes(query)) {
-            //         //     console.log(key, d[key]);
-            //         //     hlights.push(key);
-            //         // }
-            //     });
-            //     // if (hlights.length > 0) {
-            //     //     found.push([d, hlights, []]);
-            //     // };
-            // });
-            // console.log(found);
-            // this._results = found;
-            // this._numTotalResults = found.length;
+        let doc = undefined;
+        if (this.scale === false) {
+            doc = SelectionManager.SelectedDocuments()[0].props.Document;
+        }
+        console.log(this.scale);
+        if (this.scale === true) {
+            doc = Cast(Doc.UserDoc().myWorkspaces, Doc) as Doc;
+            doc = DocListCast(doc.data)[0];
+        }
+        if (doc !== undefined) {
+            console.log(StrCast(doc.title));
+            Doc.setDocFilter(doc, key, values, "match");
         }
         else {
             this.noresults = "No collection selected :(";
         }
-
-        //Doc.setDocFilter(this.props.Document, newKey, filter, "match");
     }
 
     @action
@@ -512,7 +495,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined };
             this._timeout = setTimeout(() => {
                 console.log("Resubmitting search");
-
             }, 60000);
         }
 
@@ -708,7 +690,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const endIndex = 30;
         this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
-        let headers = new Set<string>();
+        let headers = new Set<string>(["title", "author", "creationDate"]);
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             if (this.noresults === "") {
                 this.noresults = "No search results :(";
@@ -986,125 +968,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     remButtonDoc = (doc: Doc) => Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
     moveButtonDoc = (doc: Doc, targetCollection: Doc | undefined, addDocument: (document: Doc) => boolean) => this.remButtonDoc(doc) && addDocument(doc);
 
-    @computed get docButtons() {
-        const nodeBtns = this.props.Document.nodeButtons;
-        let width = () => NumCast(this.props.Document._width);
-        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
-        width = MainView.Instance.flyoutWidthFunc;
-
-        // }   
-        if (nodeBtns instanceof Doc) {
-            return <div id="hi" style={{ height: "100px", }}>
-                <DocumentView
-                    docFilters={returnEmptyFilter}
-                    Document={nodeBtns}
-                    DataDoc={undefined}
-                    LibraryPath={emptyPath}
-                    addDocument={undefined}
-                    addDocTab={returnFalse}
-                    rootSelected={returnTrue}
-                    pinToPres={emptyFunction}
-                    onClick={undefined}
-                    removeDocument={undefined}
-                    ScreenToLocalTransform={this.getTransform}
-                    ContentScaling={returnOne}
-                    PanelWidth={width}
-                    PanelHeight={() => 100}
-                    renderDepth={0}
-                    backgroundColor={returnEmptyString}
-                    focus={emptyFunction}
-                    parentActive={returnTrue}
-                    whenActiveChanged={emptyFunction}
-                    bringToFront={emptyFunction}
-                    ContainingCollectionView={undefined}
-                    ContainingCollectionDoc={undefined}
-                    NativeHeight={() => 100}
-                    NativeWidth={width}
-                />
-            </div>;
-        }
-        return (null);
-    }
-
-    @computed get keyButtons() {
-        const nodeBtns = this.props.Document.keyButtons;
-        let width = () => NumCast(this.props.Document._width);
-        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
-        width = MainView.Instance.flyoutWidthFunc;
-        // }
-        if (nodeBtns instanceof Doc) {
-            return <div id="hi" style={{ height: "35px", }}>
-                <DocumentView
-                    docFilters={returnEmptyFilter}
-                    Document={nodeBtns}
-                    DataDoc={undefined}
-                    LibraryPath={emptyPath}
-                    addDocument={undefined}
-                    addDocTab={returnFalse}
-                    rootSelected={returnTrue}
-                    pinToPres={emptyFunction}
-                    onClick={undefined}
-                    removeDocument={undefined}
-                    ScreenToLocalTransform={this.getTransform}
-                    ContentScaling={returnOne}
-                    PanelWidth={width}
-                    PanelHeight={() => 100}
-                    renderDepth={0}
-                    backgroundColor={returnEmptyString}
-                    focus={emptyFunction}
-                    parentActive={returnTrue}
-                    whenActiveChanged={emptyFunction}
-                    bringToFront={emptyFunction}
-                    ContainingCollectionView={undefined}
-                    ContainingCollectionDoc={undefined}
-                    NativeHeight={() => 100}
-                    NativeWidth={width}
-                />
-            </div>;
-        }
-        return (null);
-    }
-
-    @computed get defaultButtons() {
-        const defBtns = this.props.Document.defaultButtons;
-        let width = () => NumCast(this.props.Document._width);
-        // if (StrCast(this.props.Document.title)==="sidebar search stack"){
-        width = MainView.Instance.flyoutWidthFunc;
-        // }
-        if (defBtns instanceof Doc) {
-            return <div id="hi" style={{ height: "35px", }}>
-                <DocumentView
-                    docFilters={returnEmptyFilter}
-
-                    Document={defBtns}
-                    DataDoc={undefined}
-                    LibraryPath={emptyPath}
-                    addDocument={undefined}
-                    addDocTab={returnFalse}
-                    rootSelected={returnTrue}
-                    pinToPres={emptyFunction}
-                    onClick={undefined}
-                    removeDocument={undefined}
-                    ScreenToLocalTransform={this.getTransform}
-                    ContentScaling={returnOne}
-                    PanelWidth={width}
-                    PanelHeight={() => 100}
-                    renderDepth={0}
-                    backgroundColor={returnEmptyString}
-                    focus={emptyFunction}
-                    parentActive={returnTrue}
-                    whenActiveChanged={emptyFunction}
-                    bringToFront={emptyFunction}
-                    ContainingCollectionView={undefined}
-                    ContainingCollectionDoc={undefined}
-                    NativeHeight={() => 100}
-                    NativeWidth={width}
-                />
-            </div>;
-        }
-        return (null);
-    }
-
     @action.bound
     updateIcon = async (icon: string) => {
         if (this._icons.includes(icon)) {
@@ -1223,15 +1086,17 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @observable filter = false;
 
+
     //Make id layour document
     render() {
         this.props.Document._chromeStatus === "disabled";
         this.props.Document._searchDoc = true;
-        let length = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
-        //let length = this.headercount;
-        length > 3 ? length = 650 : length = length * 205 + 51;
-        let height = this.children;
-        height > 8 ? height = 31 + 31 * 8 : height = 31 * height + 31;
+        let cols = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
+        let length = 0;
+        cols > 5 ? length = 1076 : length = cols * 205 + 51;
+        let height = 0;
+        let rows = this.children;
+        rows > 8 ? height = 31 + 31 * 8 : height = 31 * rows + 31;
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
                 <div className="searchBox-bar">
@@ -1239,28 +1104,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         <FontAwesomeIcon icon="object-group" size="lg" />
                     </span> */}
                     <div style={{ position: "absolute", left: 15 }}>{Doc.CurrentUserEmail}</div>
-                    <FontAwesomeIcon icon={"search"} size="lg" style={{ position: "relative", left: 24, padding: 1 }} />
+                    <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg" style={{ position: "relative", left: 24, padding: 1 }} />
                     <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                         className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
                         style={{ paddingLeft: 23, width: this._searchbarOpen ? "200px" : "200px" }} />
-                    {/* <button className="searchBox-barChild searchBox-filter" style={{ transform: "none" }} title="Advanced Filtering Options" onClick={() => this.handleFilterChange()}><FontAwesomeIcon icon="ellipsis-v" color="white" /></button> */}
-                </div>
-                <div id={`filterhead${this.props.Document[Id]}`} className="filter-form" style={this._filterOpen && this._numTotalResults > 0 ? { overflow: "visible" } : { overflow: "hidden" }}>
-                    <div id={`filterhead2${this.props.Document[Id]}`} className="filter-header"  >
-                        {this.defaultButtons}
-                    </div>
-                    <div id={`node${this.props.Document[Id]}`} className="filter-body" style={this._nodeStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-                        {this.docButtons}
-                    </div>
-                    <div className="filter-key" id={`key${this.props.Document[Id]}`} style={this._keyStatus ? { borderTop: "grey 1px solid" } : { borderTop: "0px" }}>
-                        {this.keyButtons}
-                    </div>
                 </div>
                 <div style={{ zIndex: 2000 }}>
                     {this._searchbarOpen === true ?
                         <div style={{ display: "flex", justifyContent: "center", }}>
                             <div style={{
-                                width: this.headercount > 0 ? length : 253,
+                                width: cols > 0 ? length : 253,
                                 height: 25,
                                 borderColor: "#9c9396",
                                 border: "1px solid",
@@ -1315,9 +1168,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 PanelHeight={this.open === true ? () => height : () => 0}
                                 PanelWidth={this.open === true ? () => length : () => 0}
                                 PanelPosition={"absolute"}
+                                overflow={cols > 5 || rows > 8 ? true : false}
                                 focus={this.selectElement}
                                 ScreenToLocalTransform={Transform.Identity}
-                            /></div> : <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 29, width: 250, position: "absolute", backgroundColor: "white", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
+                            /></div> : <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 54, width: 250, position: "absolute", backgroundColor: "rgb(241, 239, 235)", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
                                 <div>{this.noresults}</div>
                             </div></div>}
                         </div> : undefined}
-- 
cgit v1.2.3-70-g09d2


From ea8fc6cbc6c3b976a0c345e834c6a91d338f97c5 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 28 Jul 2020 18:49:56 -0400
Subject: ui

---
 src/client/views/search/SearchBox.tsx | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 73932896b..05befc12f 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -199,6 +199,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
 
         if (e.target.value === "") {
+            this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
             console.log("CLOSE");
             runInAction(() => { this.open = false });
         }
@@ -218,7 +219,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
             // }
-            if (StrCast(this.layoutDoc._searchString) !== "") {
+            if (StrCast(this.layoutDoc._searchString) !== "" && this.filter === false) {
                 console.log("OPEN");
                 runInAction(() => { this.open = true });
             }
@@ -348,10 +349,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const collections: Doc[] = [];
         selectedDocs.forEach(async element => {
             const layout: string = StrCast(element.props.Document.layout);
-
-            console.log(DocListCast(element.dataDoc[Doc.LayoutFieldKey(element.dataDoc)]));
-            console.log(DocListCast(element.dataDoc[Doc.LayoutFieldKey(element.dataDoc)]).length);
-
             //checks if selected view (element) is a collection. if it is, adds to list to search through
             if (layout.indexOf("Collection") > -1) {
                 //makes sure collections aren't added more than once
@@ -472,7 +469,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async (reset?: boolean) => {
-
         this.checkIcons();
         if (reset) {
             this.layoutDoc._searchString = "";
@@ -682,6 +678,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @action
     resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
         if (!this._resultsRef.current) return;
+        this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
 
         const scrollY = e ? e.currentTarget.scrollTop : this._resultsRef.current ? this._resultsRef.current.scrollTop : 0;
         const itemHght = 53;
@@ -767,8 +764,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
-
-        this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
         let schemaheaders: SchemaHeaderField[] = [];
         this.headerscale = headers.size;
         headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
@@ -1126,20 +1121,28 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
                                     <div className="checkbox" style={{ margin: 0 }}>
                                         <label style={{ fontSize: 12, marginTop: 6 }}>
-                                            <input style={{ marginLeft: -16, marginTop: -1 }} checked={this.filter === true} onChange={() => { runInAction(() => { this.filter = !this.filter }) }} type="checkbox"></input>
+                                            <input style={{ marginLeft: -16, marginTop: -1 }} checked={this.filter === true} onChange={() => {
+                                                runInAction(() => {
+                                                    this.filter = !this.filter; this.filter === true ? this.open = false : undefined; this.filter === true ? this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]) : undefined;
+                                                })
+                                            }} type="checkbox"></input>
                                             Filter
                                         </label>
                                     </div>
                                     {this.filter === true ? <div style={{ display: "contents" }}>
                                         <div className="radio" style={{ margin: 0 }}>
                                             <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                                <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => {
+                                                    runInAction(() => {
+                                                        this.scale = !this.scale; this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                    })
+                                                }} />
                                         Current collection
                                     </label>
                                         </div>
                                         <div className="radio" style={{ margin: 0 }}>
                                             <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
+                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale; this.dataDoc[this.fieldKey] = new List<Doc>([]); }) }} />
                                             Workspace
                                     </label>
                                         </div>
-- 
cgit v1.2.3-70-g09d2


From 211beefca70ca5c869d6bf8a464fe41e94a7b4c3 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Thu, 30 Jul 2020 18:05:34 -0400
Subject: filtering correctly

---
 .../views/collections/CollectionSchemaView.tsx     |  10 +-
 src/client/views/collections/CollectionSubView.tsx |   9 +-
 src/client/views/search/SearchBox.tsx              | 192 +++++++--------------
 3 files changed, 77 insertions(+), 134 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index d3c975e5d..aceaa2bae 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -6,7 +6,7 @@ import { action, computed, observable, untracked } from "mobx";
 import { observer } from "mobx-react";
 import { Resize } from "react-table";
 import "react-table/react-table.css";
-import { Doc } from "../../../fields/Doc";
+import { Doc, DocCastAsync } from "../../../fields/Doc";
 import { List } from "../../../fields/List";
 import { listSpec } from "../../../fields/Schema";
 import { SchemaHeaderField, PastelSchemaPalette } from "../../../fields/SchemaHeaderField";
@@ -333,9 +333,17 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
                         console.log(newKey);
                         console.log(filter);
                         Doc.setDocFilter(this.props.Document, newKey, filter, "match");
+                        if (this.props.Document.selectedDoc !== undefined) {
+                            let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+                            Doc.setDocFilter(doc, newKey, filter, "match");
+                        }
                     }
                     else {
                         this.props.Document._docFilters = undefined;
+                        if (this.props.Document.selectedDoc !== undefined) {
+                            let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+                            doc._docFilters = undefined;
+                        }
                     }
                 }
             }
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index ed8535ecb..9dad9a056 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -1,7 +1,7 @@
 import { action, computed, IReactionDisposer, reaction } from "mobx";
 import { basename } from 'path';
 import CursorField from "../../../fields/CursorField";
-import { Doc, Opt, Field } from "../../../fields/Doc";
+import { Doc, Opt, Field, DocListCast } from "../../../fields/Doc";
 import { Id } from "../../../fields/FieldSymbols";
 import { List } from "../../../fields/List";
 import { listSpec } from "../../../fields/Schema";
@@ -130,7 +130,12 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             }
             const docs = rawdocs.filter(d => !(d instanceof Promise)).map(d => d as Doc);
             const viewSpecScript = Cast(this.props.Document.viewSpecScript, ScriptField);
-            const childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
+            let childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
+
+            const searchDocs = DocListCast(this.props.Document._searchDocs);
+            if (searchDocs !== undefined && searchDocs.length > 0) {
+                childDocs = searchDocs;
+            }
 
             const filteredDocs = docFilters.length && !this.props.dontRegisterView ? childDocs.filter(d => {
                 for (const facetKey of Object.keys(filterFacets)) {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 05befc12f..b17751d44 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -153,9 +153,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable setupButtons = false;
     componentDidMount = () => {
         if (this.setupButtons == false) {
-            this.setupDocTypeButtons();
-            this.setupKeyButtons();
-            this.setupDefaultButtons();
+
             runInAction(() => this.setupButtons == true);
         }
         if (this.inputRef.current) {
@@ -192,14 +190,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         console.log(e.target.value);
         this.newsearchstring = e.target.value;
 
-        if (this.filter === true) {
-            runInAction(() => { this.open = false });
-            this.submitFilter();
-        }
-
 
         if (e.target.value === "") {
             this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
+            if (this.currentSelectedCollection !== undefined) {
+                this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
+                this.currentSelectedCollection = undefined;
+                this.props.Document.selectedDoc = undefined;
+
+            }
             console.log("CLOSE");
             runInAction(() => { this.open = false });
         }
@@ -219,7 +218,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
             // }
-            if (StrCast(this.layoutDoc._searchString) !== "" && this.filter === false) {
+            if (StrCast(this.layoutDoc._searchString) !== "") {
                 console.log("OPEN");
                 runInAction(() => { this.open = true });
             }
@@ -228,9 +227,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 runInAction(() => { this.open = false });
 
             }
-            if (this.filter === false) {
-                this.submitSearch();
-            }
+            this.submitSearch();
+
 
         }
     }
@@ -366,13 +364,21 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     }
 
 
+    currentSelectedCollection: DocumentView | undefined = undefined;
+    docsforfilter: Doc[] = [];
 
     searchCollection(query: string) {
 
         const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
+
         if (selectedCollection !== undefined) {
+            this.currentSelectedCollection = selectedCollection;
+            if (this.filter === true) {
+                this.props.Document.selectedDoc = selectedCollection.props.Document;
+            }
             let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
             let found: [Doc, string[], string[]][] = [];
+            let docsforFilter: Doc[] = []
             docs.forEach((d) => {
                 let hlights: string[] = [];
                 const protos = Doc.GetAllPrototypes(d);
@@ -385,10 +391,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 });
                 if (hlights.length > 0) {
                     found.push([d, hlights, []]);
+                    docsforFilter.push(d);
                 };
             });
             console.log(found);
             this._results = found;
+            this.docsforfilter = docsforFilter;
+            if (this.filter === true) {
+                selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
+            }
             this._numTotalResults = found.length;
         }
         else {
@@ -437,42 +448,13 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     get fieldFiltersApplied() { return !(this._authorFieldStatus && this._titleFieldStatus); }
 
-
-    @action
-    submitFilter() {
-        let searchString = StrCast(this.layoutDoc._searchString);
-        if (searchString.includes(":") === false) {
-            return
-        }
-        let key = searchString.slice(0, searchString.indexOf(":"));
-        console.log(key);
-        console.log(searchString);
-        let values = searchString.slice(searchString.indexOf(":") + 1, searchString.length);
-        console.log(values);
-        let doc = undefined;
-        if (this.scale === false) {
-            doc = SelectionManager.SelectedDocuments()[0].props.Document;
-        }
-        console.log(this.scale);
-        if (this.scale === true) {
-            doc = Cast(Doc.UserDoc().myWorkspaces, Doc) as Doc;
-            doc = DocListCast(doc.data)[0];
-        }
-        if (doc !== undefined) {
-            console.log(StrCast(doc.title));
-            Doc.setDocFilter(doc, key, values, "match");
-        }
-        else {
-            this.noresults = "No collection selected :(";
-        }
-    }
-
     @action
     submitSearch = async (reset?: boolean) => {
         this.checkIcons();
         if (reset) {
             this.layoutDoc._searchString = "";
         }
+        this.props.Document._docFilters = undefined;
         this.noresults = "";
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.headercount = 0;
@@ -995,74 +977,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
-    setupDocTypeButtons() {
-        let doc = this.props.Document;
-        const ficon = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.FontIconDocument({
-            ...opts,
-            dropAction: "alias", removeDropProperties: new List<string>(["dropAction"]), _nativeWidth: 100, _nativeHeight: 100, _width: 100,
-            _height: 100
-        })) as any as Doc;
-        doc.Audio = ficon({ onClick: ScriptField.MakeScript(`updateIcon("audio")`), title: "music button", icon: "music" });
-        doc.Collection = ficon({ onClick: ScriptField.MakeScript(`updateIcon("collection")`), title: "col button", icon: "object-group" });
-        doc.Image = ficon({ onClick: ScriptField.MakeScript(`updateIcon("image")`), title: "image button", icon: "image" });
-        doc.Link = ficon({ onClick: ScriptField.MakeScript(`updateIcon("link")`), title: "link button", icon: "link" });
-        doc.Pdf = ficon({ onClick: ScriptField.MakeScript(`updateIcon("pdf")`), title: "pdf button", icon: "file-pdf" });
-        doc.Rtf = ficon({ onClick: ScriptField.MakeScript(`updateIcon("rtf")`), title: "text button", icon: "sticky-note" });
-        doc.Video = ficon({ onClick: ScriptField.MakeScript(`updateIcon("video")`), title: "vid button", icon: "video" });
-        doc.Web = ficon({ onClick: ScriptField.MakeScript(`updateIcon("web")`), title: "web button", icon: "globe-asia" });
-
-        let buttons = [doc.None as Doc, doc.Audio as Doc, doc.Collection as Doc,
-        doc.Image as Doc, doc.Link as Doc, doc.Pdf as Doc, doc.Rtf as Doc, doc.Video as Doc, doc.Web as Doc];
-
-        const dragCreators = Docs.Create.MasonryDocument(buttons, {
-            _width: 500, backgroundColor: "#121721", _autoHeight: true, _columnWidth: 35, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons",
-            dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), _yMargin: 5
-        });
-        doc.nodeButtons = dragCreators;
-        this.checkIcons()
-    }
-
-
-    setupKeyButtons() {
-        let doc = this.props.Document;
-        const button = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.ButtonDocument({
-            ...opts,
-            _width: 35, _height: 30,
-            borderRounding: "16px", border: "1px solid grey", color: "white", hovercolor: "rgb(170, 170, 163)", letterSpacing: "2px",
-            _fontSize: 7,
-        })) as any as Doc;
-        doc.title = button({ backgroundColor: "grey", title: "Title", onClick: ScriptField.MakeScript("updateTitleStatus(self)") });
-        doc.deleted = button({ title: "Deleted", onClick: ScriptField.MakeScript("updateDeletedStatus(self)") });
-        doc.author = button({ backgroundColor: "grey", title: "Author", onClick: ScriptField.MakeScript("updateAuthorStatus(self)") });
-        let buttons = [doc.title as Doc, doc.deleted as Doc, doc.author as Doc];
-
-        const dragCreators = Docs.Create.MasonryDocument(buttons, {
-            _width: 500, backgroundColor: "#121721", _autoHeight: true, _columnWidth: 50, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons", _yMargin: 5
-            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), 
-        });
-        doc.keyButtons = dragCreators;
-    }
-
-    setupDefaultButtons() {
-        let doc = this.props.Document;
-        const button = (opts: DocumentOptions) => new PrefetchProxy(Docs.Create.ButtonDocument({
-            ...opts,
-            _width: 35, _height: 30,
-            borderRounding: "16px", border: "1px solid grey", color: "white",
-            //hovercolor: "rgb(170, 170, 163)", 
-            letterSpacing: "2px",
-            _fontSize: 7,
-        })) as any as Doc;
-        doc.keywords = button({ title: "Keywords", onClick: ScriptField.MakeScript("handleWordQueryChange(self)") });
-        doc.keys = button({ title: "Keys", onClick: ScriptField.MakeScript(`handleKeyChange(self)`) });
-        doc.nodes = button({ title: "Nodes", onClick: ScriptField.MakeScript("handleNodeChange(self)") });
-        let buttons = [doc.keywords as Doc, doc.keys as Doc, doc.nodes as Doc];
-        const dragCreators = Docs.Create.MasonryDocument(buttons, {
-            _width: 500, backgroundColor: "#121721", _autoHeight: true, _columnWidth: 60, ignoreClick: true, lockedPosition: true, _chromeStatus: "disabled", title: "buttons", _yMargin: 5
-            //dropConverter: ScriptField.MakeScript("convertToButtons(dragData)", { dragData: DragManager.DocumentDragData.name }), 
-        });
-        doc.defaultButtons = dragCreators;
-    }
     @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
 
     getTransform = () => {
@@ -1121,20 +1035,39 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
                                     <div className="checkbox" style={{ margin: 0 }}>
                                         <label style={{ fontSize: 12, marginTop: 6 }}>
-                                            <input style={{ marginLeft: -16, marginTop: -1 }} checked={this.filter === true} onChange={() => {
+                                            <input style={{ marginLeft: -16, marginTop: -1, color: this.scale == false ? "black" : "grey" }} checked={this.filter === true} onChange={() => {
                                                 runInAction(() => {
-                                                    this.filter = !this.filter; this.filter === true ? this.open = false : undefined; this.filter === true ? this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]) : undefined;
+                                                    if (this.scale === false) {
+                                                        this.filter = !this.filter;
+                                                        if (this.filter === true && this.currentSelectedCollection !== undefined) {
+                                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
+                                                            this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
+                                                            this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
+                                                        }
+                                                        else if (this.filter === false && this.currentSelectedCollection !== undefined) {
+                                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
+                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                            this.props.Document.selectedDoc = undefined;
+                                                        }
+                                                    }
                                                 })
                                             }} type="checkbox"></input>
                                             Filter
                                         </label>
                                     </div>
-                                    {this.filter === true ? <div style={{ display: "contents" }}>
+                                    <div style={{ display: "contents" }}>
                                         <div className="radio" style={{ margin: 0 }}>
                                             <label style={{ fontSize: 12, marginTop: 6 }} >
                                                 <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => {
                                                     runInAction(() => {
-                                                        this.scale = !this.scale; this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                        this.scale = !this.scale;
+                                                        this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                        if (this.currentSelectedCollection !== undefined) {
+                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                            this.currentSelectedCollection.props.Document._searchDocs = undefined;
+                                                            this.currentSelectedCollection = undefined;
+                                                        }
+                                                        this.submitSearch();
                                                     })
                                                 }} />
                                         Current collection
@@ -1142,26 +1075,23 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                         </div>
                                         <div className="radio" style={{ margin: 0 }}>
                                             <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale; this.dataDoc[this.fieldKey] = new List<Doc>([]); }) }} />
+                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => {
+                                                    runInAction(() => {
+                                                        this.scale = !this.scale;
+                                                        this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                        this.filter = false;
+                                                        if (this.currentSelectedCollection !== undefined) {
+                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                            this.currentSelectedCollection.props.Document._searchDocs = undefined;
+                                                            this.currentSelectedCollection = undefined;
+                                                        }
+                                                        this.submitSearch();
+                                                    })
+                                                }} />
                                             Workspace
                                     </label>
                                         </div>
                                     </div>
-                                        : <div style={{ display: "contents" }}>
-                                            <div className="radio" style={{ margin: 0 }}>
-                                                <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                    <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
-                                Current collection
-                            </label>
-                                            </div>
-                                            <div className="radio" style={{ margin: 0 }}>
-                                                <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                    <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => { runInAction(() => { this.scale = !this.scale }) }} />
-                                    Database
-                            </label>
-                                            </div>
-                                        </div>
-                                    }
                                 </form>
                             </div>
                             {this.noresults === "" ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
@@ -1186,7 +1116,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     overflow: "visibile" // this.resFull ? "auto" : "visible"
                 }} ref={this._resultsRef}>
                 </div>
-            </div>
+            </div >
         );
     }
 }
-- 
cgit v1.2.3-70-g09d2


From a1950ec49c56f5f9e2612da7e60a1e2615209386 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Fri, 31 Jul 2020 18:25:39 -0400
Subject: bugfix

---
 src/client/views/DocComponent.tsx                  |  2 +
 src/client/views/GlobalKeyHandler.ts               |  2 +
 src/client/views/collections/CollectionView.tsx    |  4 +-
 .../views/nodes/formattedText/FormattedTextBox.tsx | 28 ++++-----
 src/client/views/search/SearchBox.tsx              | 69 ++++++++++++++++------
 5 files changed, 71 insertions(+), 34 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/DocComponent.tsx b/src/client/views/DocComponent.tsx
index 9b9a28f0f..106250af4 100644
--- a/src/client/views/DocComponent.tsx
+++ b/src/client/views/DocComponent.tsx
@@ -146,6 +146,8 @@ export function ViewBoxAnnotatableComponent<P extends ViewBoxAnnotatableProps, T
                     added.map(doc => doc.context = this.props.Document);
                     targetDataDoc[this.annotationKey] = new List<Doc>([...docList, ...added]);
                     targetDataDoc[this.annotationKey + "-lastModified"] = new DateField(new Date(Date.now()));
+                    targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
                 }
             }
             return true;
diff --git a/src/client/views/GlobalKeyHandler.ts b/src/client/views/GlobalKeyHandler.ts
index c85849adb..2e5c018ba 100644
--- a/src/client/views/GlobalKeyHandler.ts
+++ b/src/client/views/GlobalKeyHandler.ts
@@ -307,6 +307,8 @@ export default class KeyManager {
                             undoBatch(() => {
                                 targetDataDoc[fieldKey] = new List<Doc>([...docList, ...added]);
                                 targetDataDoc[fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
+                                targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
                             })();
                         }
                     }
diff --git a/src/client/views/collections/CollectionView.tsx b/src/client/views/collections/CollectionView.tsx
index 0178cc2e9..f9dc666d6 100644
--- a/src/client/views/collections/CollectionView.tsx
+++ b/src/client/views/collections/CollectionView.tsx
@@ -159,6 +159,8 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
                 added.map(add => Doc.AddDocToList(Cast(Doc.UserDoc().myCatalog, Doc, null), "data", add));
                 targetDataDoc[this.props.fieldKey] = new List<Doc>([...docList, ...added]);
                 targetDataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()));
+                targetDataDoc["lastModified"] = new DateField(new Date(Date.now()));
+
             }
         }
         return true;
@@ -554,7 +556,7 @@ export class CollectionView extends Touchable<FieldViewProps & CollectionViewCus
         return (<div className={"collectionView"} onContextMenu={this.onContextMenu}
             style={{ pointerEvents: this.props.Document.isBackground ? "none" : undefined, boxShadow }}>
             {this.showIsTagged()}
-            <div className="collectionView-facetCont" style={{ display: this.props.PanelPosition==="absolute"? "flex" : "", justifyContent: this.props.PanelPosition==="absolute"? "center" : "", width: `calc(100% - ${this.facetWidth()}px)` }}>
+            <div className="collectionView-facetCont" style={{ display: this.props.PanelPosition === "absolute" ? "flex" : "", justifyContent: this.props.PanelPosition === "absolute" ? "center" : "", width: `calc(100% - ${this.facetWidth()}px)` }}>
                 {this.collectionViewType !== undefined ? this.SubView(this.collectionViewType, props) : (null)}
             </div>
             {this.lightbox(DocListCast(this.props.Document[this.props.fieldKey]).filter(d => d.type === DocumentType.IMG).map(d =>
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 11f25a208..71ba51039 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -228,7 +228,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             if (!this.dataDoc[AclSym]) {
                 if (!this._applyingChange && json.replace(/"selection":.*/, "") !== curProto?.Data.replace(/"selection":.*/, "")) {
                     this._applyingChange = true;
-                    (curText !== Cast(this.dataDoc[this.fieldKey], RichTextField)?.Text) && (this.dataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now())));
+                    (curText !== Cast(this.dataDoc[this.fieldKey], RichTextField)?.Text) && (this.dataDoc[this.props.fieldKey + "-lastModified"] = new DateField(new Date(Date.now()))) && (this.dataDoc["lastModified"] = new DateField(new Date(Date.now())));
                     if ((!curTemp && !curProto) || curText || curLayout?.Data.includes("dash")) { // if no template, or there's text that didn't come from the layout template, write it to the document. (if this is driven by a template, then this overwrites the template text which is intended)
                         if (json !== curLayout?.Data) {
                             !curText && tx.storedMarks?.map(m => m.type.name === "pFontSize" && (Doc.UserDoc().fontSize = this.layoutDoc._fontSize = m.attrs.fontSize));
@@ -280,7 +280,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             this._editorView.dispatch(tr.addMark(flattened[lastSel].from, flattened[lastSel].to, link));
         }
     }
-    public highlightSearchTerms = (terms: string[])=> {
+    public highlightSearchTerms = (terms: string[]) => {
         if (this._editorView && (this._editorView as any).docView && terms.some(t => t)) {
 
             const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
@@ -291,30 +291,30 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             const flattened: TextSelection[] = [];
             res.map(r => r.map(h => flattened.push(h)));
 
-            
+
             const lastSel = Math.min(flattened.length - 1, this._searchIndex);
             flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
             this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
-            
+
             console.log(this._searchIndex, length);
-            if (this._searchIndex>1){
-                this._searchIndex+=-2;
+            if (this._searchIndex > 1) {
+                this._searchIndex += -2;
             }
-            else if (this._searchIndex===1){
-                this._searchIndex=length-1;
+            else if (this._searchIndex === 1) {
+                this._searchIndex = length - 1;
             }
-            else if (this._searchIndex===0 && length!==1){
-                this._searchIndex=length-2;
+            else if (this._searchIndex === 0 && length !== 1) {
+                this._searchIndex = length - 2;
             }
             let index = this._searchIndex;
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
-            Doc.GetProto(this.dataDoc).length=length;
+            Doc.GetProto(this.dataDoc).length = length;
         }
     }
 
-    public highlightSearchTerms2 = (terms: string[])=> {
+    public highlightSearchTerms2 = (terms: string[]) => {
         if (this._editorView && (this._editorView as any).docView && terms.some(t => t)) {
 
             const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
@@ -323,7 +323,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             let length = res[0].length;
             let tr = this._editorView.state.tr;
             const flattened: TextSelection[] = [];
-            res.map(r => r.map(h => flattened.push(h)));       
+            res.map(r => r.map(h => flattened.push(h)));
             const lastSel = Math.min(flattened.length - 1, this._searchIndex);
             flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
@@ -331,7 +331,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             let index = this._searchIndex;
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
-            Doc.GetProto(this.dataDoc).length=length;
+            Doc.GetProto(this.dataDoc).length = length;
         }
     }
 
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b17751d44..005f7d1af 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -40,6 +40,7 @@ import * as _ from "lodash";
 import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
 import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
 import { indexOf } from 'lodash';
+import { protocol } from 'socket.io-client';
 
 
 library.add(faTimes);
@@ -379,22 +380,42 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
             let found: [Doc, string[], string[]][] = [];
             let docsforFilter: Doc[] = []
-            docs.forEach((d) => {
-                let hlights: string[] = [];
-                const protos = Doc.GetAllPrototypes(d);
-                let proto = protos[protos.length - 2];
-                Object.keys(proto).forEach(key => {
-                    if (StrCast(d[key]).includes(query)) {
-                        console.log(key, d[key]);
-                        hlights.push(key);
+            let newarray: Doc[] = [];
+
+            while (docs.length > 0) {
+                console.log("iteration");
+                newarray = [];
+                docs.forEach((d) => {
+                    console.log(d);
+                    if (d.data != undefined) {
+                        let newdocs = DocListCast(d.data);
+                        newdocs.forEach((newdoc) => {
+                            console.log(newdoc);
+                            newarray.push(newdoc);
+
+                        });
                     }
+
+
+                    let hlights: string[] = [];
+
+                    const protos = Doc.GetAllPrototypes(d);
+                    let proto = protos[protos.length - 1];
+                    protos.forEach(proto => {
+                        Object.keys(proto).forEach(key => {
+                            // console.log(key, d[key]);
+                            if (StrCast(d[key]).includes(query) && !hlights.includes(key)) {
+                                hlights.push(key);
+                            }
+                        })
+                    });
+                    if (hlights.length > 0) {
+                        found.push([d, hlights, []]);
+                        docsforFilter.push(d);
+                    };
                 });
-                if (hlights.length > 0) {
-                    found.push([d, hlights, []]);
-                    docsforFilter.push(d);
-                };
-            });
-            console.log(found);
+                docs = newarray;
+            }
             this._results = found;
             this.docsforfilter = docsforFilter;
             if (this.filter === true) {
@@ -408,6 +429,20 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     }
 
+
+    documentKeys(doc: Doc) {
+        const keys: { [key: string]: boolean } = {};
+        // bcz: ugh.  this is untracked since otherwise a large collection of documents will blast the server for all their fields.
+        //  then as each document's fields come back, we update the documents _proxies.  Each time we do this, the whole schema will be
+        //  invalidated and re-rendered.   This workaround will inquire all of the document fields before the options button is clicked.
+        //  then by the time the options button is clicked, all of the fields should be in place.  If a new field is added while this menu
+        //  is displayed (unlikely) it won't show up until something else changes.
+        //TODO Types
+        Doc.GetAllPrototypes(doc).map
+            (proto => Object.keys(proto).forEach(key => keys[key] = false));
+        return Array.from(Object.keys(keys));
+    }
+
     applyBasicFieldFilters(query: string) {
         let finalQuery = "";
 
@@ -669,7 +704,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const endIndex = 30;
         this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
-        let headers = new Set<string>(["title", "author", "creationDate"]);
+        let headers = new Set<string>(["title", "author", "lastModified"]);
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             if (this.noresults === "") {
                 this.noresults = "No search results :(";
@@ -734,12 +769,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             if (i < this._visibleDocuments.length) {
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
-                                console.log("WHYYYY");
-                                console.log(result[0]);
-
                                 Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                                 this.children++;
-
                             }
                         }
                     }
-- 
cgit v1.2.3-70-g09d2


From 1eb12a6dfadf4caf3868d4d5b373859f5999214f Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Fri, 31 Jul 2020 19:35:32 -0400
Subject: bugfix

---
 src/client/util/SearchUtil.ts         | 2 +-
 src/client/views/search/SearchBox.tsx | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts
index 911340ab1..f54e13197 100644
--- a/src/client/util/SearchUtil.ts
+++ b/src/client/util/SearchUtil.ts
@@ -30,7 +30,7 @@ export namespace SearchUtil {
         rows?: number;
         fq?: string;
         allowAliases?: boolean;
-        "facet"?:string;
+        "facet"?: string;
         "facet.field"?: string;
     }
     export function Search(query: string, returnDocs: true, options?: SearchParams): Promise<DocSearchResult>;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 72cb3a04e..410e6afa5 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -746,7 +746,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
-                            result[0]._height = 46;
+                            console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
                             highlights.forEach((item) => headers.add(item));
@@ -763,7 +763,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             let lines = new List<string>(result[2]);
                             highlights.forEach((item) => headers.add(item));
-                            result[0]._height = 46;
+                            console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
                             if (i < this._visibleDocuments.length) {
-- 
cgit v1.2.3-70-g09d2


From 76b8ce516103a469d36e876ddf3dd5b53f09c734 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 3 Aug 2020 14:46:11 -0400
Subject: selecting:

---
 solr-8.3.1/bin/solr-8983.pid                       |  2 +-
 .../views/collections/CollectionSchemaCells.tsx    | 31 ++++++++++---------
 .../views/collections/CollectionSchemaHeaders.tsx  |  1 -
 src/client/views/collections/CollectionSubView.tsx |  5 ++-
 src/client/views/search/SearchBox.tsx              | 36 +++++++++++++---------
 5 files changed, 42 insertions(+), 33 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index c38baeeb6..e3e2416b2 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-3436
+7933
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index bf826857e..e50f95dca 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -247,12 +247,12 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         if (StrCast(this.props.Document._searchString) !== "") {
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
             let term = "";
-            if (cfield!==undefined){
-                if (cfield.Text!==undefined){
+            if (cfield !== undefined) {
+                if (cfield.Text !== undefined) {
                     term = cfield.Text;
                 }
-                else if (StrCast(cfield)){
-                    term= StrCast(cfield);
+                else if (StrCast(cfield)) {
+                    term = StrCast(cfield);
                 }
                 else {
                     term = String(NumCast(cfield));
@@ -261,8 +261,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             let search = StrCast(this.props.Document._searchString)
             let start = term.indexOf(search) as number;
             let tally = 0;
-            if (start!==-1){
-            positions.push(start);
+            if (start !== -1) {
+                positions.push(start);
             }
             while (start < contents.length && start !== -1) {
                 term = term.slice(start + search.length + 1);
@@ -275,7 +275,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
             }
         }
         return (
-            <div className="collectionSchemaView-cellContainer" style={{ cursor: fieldIsDoc ? "grab" : "auto" }} ref={dragRef} onPointerDown={this.onPointerDown} onPointerEnter={onPointerEnter} onPointerLeave={onPointerLeave}>
+            <div className="collectionSchemaView-cellContainer" style={{ cursor: fieldIsDoc ? "grab" : "auto" }}
+                ref={dragRef} onPointerDown={this.onPointerDown} onPointerEnter={onPointerEnter} onPointerLeave={onPointerLeave}>
                 <div className={className} ref={this._focusRef} onPointerDown={onItemDown} tabIndex={-1}>
                     <div className="collectionSchemaView-cellContents" ref={type === undefined || type === "document" ? this.dropRef : null} key={props.Document[Id]}>
                         <EditableView
@@ -294,21 +295,21 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                                 // if (type === "number" && (contents === 0 || contents === "0")) {
                                 //     return "0";
                                 // } else {
-                                    const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
-                                    if (cfield!==undefined){
-                                    if (cfield.Text!==undefined){
-                                        return(cfield.Text);
+                                const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
+                                if (cfield !== undefined) {
+                                    if (cfield.Text !== undefined) {
+                                        return (cfield.Text);
                                     }
-                                    else if (StrCast(cfield)){
+                                    else if (StrCast(cfield)) {
                                         return StrCast(cfield);
                                     }
                                     else {
                                         return String(NumCast(cfield));
                                     }
                                 }
-                                    // console.log(cfield.Text);
-                                    // console.log(StrCast(cfield));
-                                    // return StrCast(cfield);
+                                // console.log(cfield.Text);
+                                // console.log(StrCast(cfield));
+                                // return StrCast(cfield);
                                 // }
 
                             }}
diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx
index 0ee225407..a979f9838 100644
--- a/src/client/views/collections/CollectionSchemaHeaders.tsx
+++ b/src/client/views/collections/CollectionSchemaHeaders.tsx
@@ -430,7 +430,6 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
 
 
     render() {
-        console.log(this.props.docs);
         return (
             <div className="keys-dropdown" style={{ zIndex: 10, width: this.props.width, maxWidth: this.props.width }}>
                 {this._key === this._searchTerm.slice(0, this._key.length) ?
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index dacb06e5b..4463eef3e 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -130,13 +130,16 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             let childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
 
             const searchDocs = DocListCast(this.props.Document._searchDocs);
+            console.log(this.props.Document);
+            console.log(searchDocs);
             if (searchDocs !== undefined && searchDocs.length > 0) {
+                console.log("yes");
                 childDocs = searchDocs;
             }
             const docFilters = this.docFilters();
             const docRangeFilters = this.props.ignoreFields?.includes("_docRangeFilters") ? [] : Cast(this.props.Document._docRangeFilters, listSpec("string"), []);
 
-            return this.props.Document.dontRegisterView ? docs : DocUtils.FilterDocs(docs, docFilters, docRangeFilters, viewSpecScript);
+            return this.props.Document.dontRegisterView ? childDocs : DocUtils.FilterDocs(childDocs, docFilters, docRangeFilters, viewSpecScript);
         }
 
         @action
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 410e6afa5..60e935e98 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -188,11 +188,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         this.layoutDoc._searchString = e.target.value;
-        console.log(e.target.value);
         this.newsearchstring = e.target.value;
 
 
         if (e.target.value === "") {
+            console.log(this._results);
+            this._results.forEach(result => {
+                Doc.UnBrushDoc(result[0]);
+            });
+
             this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
             if (this.currentSelectedCollection !== undefined) {
                 this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
@@ -202,15 +206,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
             console.log("CLOSE");
             runInAction(() => { this.open = false });
+            this._openNoResults = false;
+            this._results = [];
+            this._resultsSet.clear();
+            this._visibleElements = [];
+            this._numTotalResults = -1;
+            this._endIndex = -1;
+            this._curRequest = undefined;
+            this._maxSearchIndex = 0;
         }
-        this._openNoResults = false;
-        this._results = [];
-        this._resultsSet.clear();
-        this._visibleElements = [];
-        this._numTotalResults = -1;
-        this._endIndex = -1;
-        this._curRequest = undefined;
-        this._maxSearchIndex = 0;
     }
 
     enter = (e: React.KeyboardEvent) => {
@@ -383,14 +387,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             let newarray: Doc[] = [];
 
             while (docs.length > 0) {
-                console.log("iteration");
                 newarray = [];
                 docs.forEach((d) => {
-                    console.log(d);
                     if (d.data != undefined) {
                         let newdocs = DocListCast(d.data);
                         newdocs.forEach((newdoc) => {
-                            console.log(newdoc);
                             newarray.push(newdoc);
 
                         });
@@ -419,6 +420,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._results = found;
             this.docsforfilter = docsforFilter;
             if (this.filter === true) {
+                console.log(docsforFilter);
                 selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
             }
             this._numTotalResults = found.length;
@@ -498,6 +500,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this.new_buckets = {};
         const query = StrCast(this.layoutDoc._searchString);
         this.getFinalQuery(query);
+        this._results.forEach(result => {
+            Doc.UnBrushDoc(result[0]);
+        });
         this._results = [];
         this._resultsSet.clear();
         this._isSearch = [];
@@ -675,7 +680,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action.bound
     closeSearch = () => {
-        this.closeResults();
+        //this.closeResults();
         this._searchbarOpen = false;
     }
 
@@ -752,7 +757,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             highlights.forEach((item) => headers.add(item));
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
-                            console.log(result[0]);
+                            Doc.BrushDoc(result[0]);
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                             this.children++;
                         }
@@ -769,6 +774,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             if (i < this._visibleDocuments.length) {
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
+                                Doc.BrushDoc(result[0]);
                                 Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                                 this.children++;
                             }
@@ -1117,7 +1123,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                                         this.submitSearch();
                                                     })
                                                 }} />
-                                            Workspace
+                                            Database
                                     </label>
                                         </div>
                                     </div>
-- 
cgit v1.2.3-70-g09d2


From e87f8f5113756b188feb3de1fc6f9697a4c91b51 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Mon, 3 Aug 2020 19:46:09 -0400
Subject: pdf search

---
 src/client/views/collections/SchemaTable.tsx | 28 +++++++++++++++++++++++++++-
 src/client/views/search/SearchBox.tsx        |  6 ++++++
 2 files changed, 33 insertions(+), 1 deletion(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx
index 5c199096e..9d02807fd 100644
--- a/src/client/views/collections/SchemaTable.tsx
+++ b/src/client/views/collections/SchemaTable.tsx
@@ -283,13 +283,39 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
             Header: <CollectionSchemaAddColumnHeader createColumn={this.createColumn} />,
             accessor: (doc: Doc) => 0,
             id: "add",
-            Cell: (rowProps: CellInfo) => <></>,
+            Cell: (rowProps: CellInfo) => <div> <button onClick={(e) => this.nextHighlight(e, this.props.Document)} style={{ padding: 2, left: 77 }}>
+                <FontAwesomeIcon icon="arrow-up" size="sm" />
+            </button>
+                <button onClick={(e) => this.nextHighlight2(e, this.props.Document)} style={{ padding: 2, left: 87 }}>
+                    <FontAwesomeIcon icon="arrow-down" size="sm" />
+                </button></div>,
             width: 28,
             resizable: false
         });
         return columns;
     }
 
+
+
+    @action
+    nextHighlight = (e: React.MouseEvent, doc: Doc) => {
+        e.preventDefault();
+        e.stopPropagation();
+
+        doc.searchMatch = false;
+        setTimeout(() => doc.searchMatch = true, 0);
+        doc.searchIndex = NumCast(doc.searchIndex);
+    }
+
+    @action
+    nextHighlight2 = (e: React.MouseEvent, doc: Doc) => {
+        e.preventDefault();
+        e.stopPropagation();
+        doc.searchMatch2 = false;
+        setTimeout(() => doc.searchMatch2 = true, 0);
+        doc.searchIndex = NumCast(doc.searchIndex);
+    }
+
     constructor(props: SchemaTableProps) {
         super(props);
         // convert old schema columns (list of strings) into new schema columns (list of schema header fields)
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 09fbe383c..de6fff5d2 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -195,6 +195,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             console.log(this._results);
             this._results.forEach(result => {
                 Doc.UnBrushDoc(result[0]);
+                result[0].searchMatch = undefined;
             });
 
             this.props.Document._schemaHeaders = new List<SchemaHeaderField>([]);
@@ -493,15 +494,18 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
         this.props.Document._docFilters = undefined;
         this.noresults = "";
+
         this.dataDoc[this.fieldKey] = new List<Doc>([]);
         this.headercount = 0;
         this.children = 0;
         this.buckets = [];
         this.new_buckets = {};
         const query = StrCast(this.layoutDoc._searchString);
+        Doc.SetSearchQuery(query);
         this.getFinalQuery(query);
         this._results.forEach(result => {
             Doc.UnBrushDoc(result[0]);
+            result[0].searchMatch = undefined;
         });
         this._results = [];
         this._resultsSet.clear();
@@ -758,6 +762,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             this._visibleDocuments[i] = result[0];
                             this._isSearch[i] = "search";
                             Doc.BrushDoc(result[0]);
+                            result[0].searchMatch = true;
                             Doc.AddDocToList(this.dataDoc, this.props.fieldKey, result[0]);
                             this.children++;
                         }
@@ -771,6 +776,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
+                            result[0].searchMatch = true;
                             if (i < this._visibleDocuments.length) {
                                 this._visibleDocuments[i] = result[0];
                                 this._isSearch[i] = "search";
-- 
cgit v1.2.3-70-g09d2


From 17cc7ae30f08e00c10398214070b5664ad221a03 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 3 Aug 2020 23:20:04 -0400
Subject: playing with new search.  added 'text' as default search field.

---
 solr-8.3.1/bin/solr                   |  0
 solr-8.3.1/bin/solr-8983.pid          |  2 +-
 src/client/views/search/SearchBox.tsx | 78 +++++++++++++----------------------
 3 files changed, 30 insertions(+), 50 deletions(-)
 mode change 100644 => 100755 solr-8.3.1/bin/solr

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/solr-8.3.1/bin/solr b/solr-8.3.1/bin/solr
old mode 100644
new mode 100755
diff --git a/solr-8.3.1/bin/solr-8983.pid b/solr-8.3.1/bin/solr-8983.pid
index e3e2416b2..efc75f3cc 100644
--- a/solr-8.3.1/bin/solr-8983.pid
+++ b/solr-8.3.1/bin/solr-8983.pid
@@ -1 +1 @@
-7933
+34698
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index de6fff5d2..bd938b75a 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1,49 +1,30 @@
-import { library } from '@fortawesome/fontawesome-svg-core';
-import { faTimes } from '@fortawesome/free-solid-svg-icons';
-import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
-import { action, computed, observable, runInAction, IReactionDisposer, reaction } from 'mobx';
+import * as _ from "lodash";
+import { action, computed, observable, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
 import * as rp from 'request-promise';
 import { Doc, DocListCast } from '../../../fields/Doc';
+import { documentSchema } from "../../../fields/documentSchemas";
 import { Id } from '../../../fields/FieldSymbols';
+import { List } from '../../../fields/List';
+import { createSchema, listSpec, makeInterface } from '../../../fields/Schema';
+import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
 import { Cast, NumCast, StrCast } from '../../../fields/Types';
-import { Utils, returnTrue, emptyFunction, returnFalse, emptyPath, returnOne, returnEmptyString, returnEmptyFilter } from '../../../Utils';
-import { Docs, DocumentOptions } from '../../documents/Documents';
-import { SetupDrag, DragManager } from '../../util/DragManager';
-import { SearchUtil } from '../../util/SearchUtil';
-import "./SearchBox.scss";
-import { SearchItem } from './SearchItem';
-import { IconBar } from './IconBar';
-import { FieldView, FieldViewProps } from '../nodes/FieldView';
+import { returnFalse, Utils } from '../../../Utils';
+import { Docs } from '../../documents/Documents';
 import { DocumentType } from "../../documents/DocumentTypes";
-import { DocumentView } from '../nodes/DocumentView';
-import { SelectionManager } from '../../util/SelectionManager';
-import { FilterQuery } from 'mongodb';
-import { CollectionLinearView } from '../collections/CollectionLinearView';
 import { CurrentUserUtils } from '../../util/CurrentUserUtils';
-
-import { CollectionDockingView } from '../collections/CollectionDockingView';
-import { ScriptField, ComputedField } from '../../../fields/ScriptField';
-import { PrefetchProxy } from '../../../fields/Proxy';
-import { List } from '../../../fields/List';
-import { faSearch, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote, faMusic, faLink, faChartBar, faGlobeAsia, faBan, faVideo, faCaretDown } from '@fortawesome/free-solid-svg-icons';
-import { Transform } from '../../util/Transform';
-import { MainView } from "../MainView";
+import { SetupDrag } from '../../util/DragManager';
 import { Scripting, _scriptingGlobals } from '../../util/Scripting';
+import { SearchUtil } from '../../util/SearchUtil';
+import { SelectionManager } from '../../util/SelectionManager';
+import { Transform } from '../../util/Transform';
 import { CollectionView, CollectionViewType } from '../collections/CollectionView';
 import { ViewBoxBaseComponent } from "../DocComponent";
-import { documentSchema } from "../../../fields/documentSchemas";
-import { makeInterface, createSchema } from '../../../fields/Schema';
-import { listSpec } from '../../../fields/Schema';
-import * as _ from "lodash";
-import { checkIfStateModificationsAreAllowed } from 'mobx/lib/internal';
-import { SchemaHeaderField } from '../../../fields/SchemaHeaderField';
-import { indexOf } from 'lodash';
-import { protocol } from 'socket.io-client';
-
-
-library.add(faTimes);
+import { DocumentView } from '../nodes/DocumentView';
+import { FieldView, FieldViewProps } from '../nodes/FieldView';
+import "./SearchBox.scss";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 
 export const searchSchema = createSchema({
     id: "string",
@@ -54,7 +35,8 @@ export const searchSchema = createSchema({
 export enum Keys {
     TITLE = "title",
     AUTHOR = "author",
-    DATA = "data"
+    DATA = "data",
+    TEXT = "text"
 }
 
 export interface filterData {
@@ -458,26 +440,24 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this._deletedDocsStatus) {
             finalQuery = finalQuery + this.basicFieldFilters(query, Keys.DATA);
         }
+        if (this._deletedDocsStatus) {
+            finalQuery = finalQuery + this.basicFieldFilters(query, Keys.TEXT);
+        }
         return finalQuery;
     }
 
     basicFieldFilters(query: string, type: string): string {
-        const oldWords = query.split(" ");
         let mod = "";
-
-        if (type === Keys.AUTHOR) {
-            mod = " author_t:";
-        } if (type === Keys.DATA) {
-            //TODO
-        } if (type === Keys.TITLE) {
-            mod = " title_t:";
+        switch (type) {
+            case Keys.AUTHOR: mod = " author_t:"; break;
+            case Keys.DATA: break; // TODO
+            case Keys.TITLE: mod = " _title_t:"; break;
+            case Keys.TEXT: mod = " text_t:"; break;
         }
 
         const newWords: string[] = [];
-        oldWords.forEach(word => {
-            const newWrd = mod + word;
-            newWords.push(newWrd);
-        });
+        const oldWords = query.split(" ");
+        oldWords.forEach(word => newWords.push(mod + word));
 
         query = newWords.join(" ");
 
@@ -713,7 +693,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const endIndex = 30;
         this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
-        let headers = new Set<string>(["title", "author", "lastModified"]);
+        let headers = new Set<string>(["title", "author", "text", "lastModified"]);
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             if (this.noresults === "") {
                 this.noresults = "No search results :(";
-- 
cgit v1.2.3-70-g09d2


From efdb0f0a04ceca49e1187ae1dda687b187b1e266 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 4 Aug 2020 10:10:30 -0400
Subject: mods to schema search layout

---
 .../views/collections/CollectionSchemaView.tsx     |   2 +-
 src/client/views/search/SearchBox.tsx              | 180 +++++++++++----------
 2 files changed, 93 insertions(+), 89 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index 869be2b03..d47d41a1e 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -631,7 +631,7 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
             style={{
                 overflow: this.props.overflow === true ? "auto" : undefined,
                 pointerEvents: !this.props.active() && !SnappingManager.GetIsDragging() ? "none" : undefined,
-                width: this.props.PanelWidth() || "100%", height: this.props.PanelPosition === "absolute" ? this.props.PanelHeight() : this.props.PanelHeight() || "100%", top: this.props.PanelPosition === "absolute" ? 52 : 0, position: this.props.PanelPosition || "relative",
+                width: this.props.PanelWidth() || "100%", height: this.props.PanelHeight() || "100%", position: "relative",
             }}  >
             <div className="collectionSchemaView-tableContainer"
                 style={{ backgroundColor: "white", width: `calc(100% - ${this.previewWidth()}px)` }}
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index bd938b75a..3b93b028e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1034,100 +1034,104 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         <FontAwesomeIcon icon="object-group" size="lg" />
                     </span> */}
                     <div style={{ position: "absolute", left: 15 }}>{Doc.CurrentUserEmail}</div>
-                    <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg" style={{ color: "black", position: "relative", left: 24, padding: 1 }} />
-                    <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
-                        className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
-                        style={{ paddingLeft: 23, color: "black", width: this._searchbarOpen ? "200px" : "200px" }} />
-                </div>
-                <div style={{ zIndex: 20000, color: "black" }}>
-                    {this._searchbarOpen === true ?
-                        <div style={{ display: "flex", justifyContent: "center", }}>
-                            <div style={{
-                                width: cols > 0 ? length : 253,
-                                height: 25,
-                                borderColor: "#9c9396",
-                                border: "1px solid",
-                                borderRadius: "0.3em",
-                                borderBottom: this.open === false ? "1px solid" : "none",
-                                position: "absolute",
-                                background: "rgb(241, 239, 235)",
-                                top: 29
-                            }}>
-                                <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
-                                    <div className="checkbox" style={{ margin: 0 }}>
-                                        <label style={{ fontSize: 12, marginTop: 6 }}>
-                                            <input style={{ marginLeft: -16, marginTop: -1, color: this.scale == false ? "black" : "grey" }} checked={this.filter === true} onChange={() => {
-                                                runInAction(() => {
-                                                    if (this.scale === false) {
-                                                        this.filter = !this.filter;
-                                                        if (this.filter === true && this.currentSelectedCollection !== undefined) {
-                                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
-                                                            this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
-                                                            this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
-                                                        }
-                                                        else if (this.filter === false && this.currentSelectedCollection !== undefined) {
-                                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
-                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
-                                                            this.props.Document.selectedDoc = undefined;
-                                                        }
+                    <div style={{ display: "flex", alignItems: "center" }}>
+                        <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg"
+                            style={{ color: "black", left: 24, padding: 1, position: "relative" }} />
+
+                        <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
+                            className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
+                            style={{ padding: 1, paddingLeft: 20, color: "black", height: 20, width: 200 }} />
+                        <div style={{
+                            height: 25,
+                            paddingLeft: "4px",
+                            paddingRight: "4px",
+                            border: "1px solid gray",
+                            borderRadius: "0.3em",
+                            borderBottom: this.open === false ? "1px solid" : "none",
+                        }}>
+                            <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
+                                <div className="checkbox" style={{ margin: 0 }}>
+                                    <label style={{ fontSize: 12, marginTop: 6 }}>
+                                        <input style={{ marginLeft: -16, marginTop: -1, color: this.scale == false ? "black" : "grey" }} checked={this.filter === true} onChange={() => {
+                                            runInAction(() => {
+                                                if (this.scale === false) {
+                                                    this.filter = !this.filter;
+                                                    if (this.filter === true && this.currentSelectedCollection !== undefined) {
+                                                        this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
+                                                        this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
+                                                        this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
                                                     }
-                                                })
-                                            }} type="checkbox"></input>
+                                                    else if (this.filter === false && this.currentSelectedCollection !== undefined) {
+                                                        this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
+                                                        this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                        this.props.Document.selectedDoc = undefined;
+                                                    }
+                                                }
+                                            })
+                                        }} type="checkbox"></input>
                                             Filter
                                         </label>
-                                    </div>
-                                    <div style={{ display: "contents" }}>
-                                        <div className="radio" style={{ margin: 0 }}>
-                                            <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => {
-                                                    runInAction(() => {
-                                                        this.scale = !this.scale;
-                                                        this.dataDoc[this.fieldKey] = new List<Doc>([]);
-                                                        if (this.currentSelectedCollection !== undefined) {
-                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
-                                                            this.currentSelectedCollection.props.Document._searchDocs = undefined;
-                                                            this.currentSelectedCollection = undefined;
-                                                        }
-                                                        this.submitSearch();
-                                                    })
-                                                }} />
-                                        Current collection
+                                </div>
+                                <div style={{ display: "contents" }}>
+                                    <div className="radio" style={{ margin: 0 }}>
+                                        <label style={{ fontSize: 12, marginTop: 6 }} >
+                                            <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => {
+                                                runInAction(() => {
+                                                    this.scale = !this.scale;
+                                                    this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                    if (this.currentSelectedCollection !== undefined) {
+                                                        this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                        this.currentSelectedCollection.props.Document._searchDocs = undefined;
+                                                        this.currentSelectedCollection = undefined;
+                                                    }
+                                                    this.submitSearch();
+                                                })
+                                            }} />
+                                        Collection
                                     </label>
-                                        </div>
-                                        <div className="radio" style={{ margin: 0 }}>
-                                            <label style={{ fontSize: 12, marginTop: 6 }} >
-                                                <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => {
-                                                    runInAction(() => {
-                                                        this.scale = !this.scale;
-                                                        this.dataDoc[this.fieldKey] = new List<Doc>([]);
-                                                        this.filter = false;
-                                                        if (this.currentSelectedCollection !== undefined) {
-                                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
-                                                            this.currentSelectedCollection.props.Document._searchDocs = undefined;
-                                                            this.currentSelectedCollection = undefined;
-                                                        }
-                                                        this.submitSearch();
-                                                    })
-                                                }} />
-                                            Database
+                                    </div>
+                                    <div className="radio" style={{ margin: 0 }}>
+                                        <label style={{ fontSize: 12, marginTop: 6 }} >
+                                            <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => {
+                                                runInAction(() => {
+                                                    this.scale = !this.scale;
+                                                    this.dataDoc[this.fieldKey] = new List<Doc>([]);
+                                                    this.filter = false;
+                                                    if (this.currentSelectedCollection !== undefined) {
+                                                        this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                                        this.currentSelectedCollection.props.Document._searchDocs = undefined;
+                                                        this.currentSelectedCollection = undefined;
+                                                    }
+                                                    this.submitSearch();
+                                                })
+                                            }} />
+                                            DB
                                     </label>
-                                        </div>
                                     </div>
-                                </form>
-                            </div>
-                            {this.noresults === "" ? <div style={{ display: this.open === true ? "contents" : "none" }}> <CollectionView {...this.props}
-                                Document={this.props.Document}
-                                moveDocument={returnFalse}
-                                removeDocument={returnFalse}
-                                PanelHeight={this.open === true ? () => height : () => 0}
-                                PanelWidth={this.open === true ? () => length : () => 0}
-                                PanelPosition={"absolute"}
-                                overflow={cols > 5 || rows > 8 ? true : false}
-                                focus={this.selectElement}
-                                ScreenToLocalTransform={Transform.Identity}
-                            /></div> : <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 54, width: 250, position: "absolute", backgroundColor: "rgb(241, 239, 235)", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
-                                <div>{this.noresults}</div>
-                            </div></div>}
+                                </div>
+                            </form>
+                        </div>
+                    </div>
+
+                </div>
+                <div style={{ zIndex: 20000, color: "black" }}>
+                    {this._searchbarOpen === true ?
+                        <div style={{ display: "flex", justifyContent: "center", }}>
+                            {this.noresults === "" ? <div style={{ display: this.open === true ? "flex" : "none", overflow: "auto", }}>
+                                <CollectionView {...this.props}
+                                    Document={this.props.Document}
+                                    moveDocument={returnFalse}
+                                    removeDocument={returnFalse}
+                                    PanelHeight={this.open === true ? () => height : () => 0}
+                                    PanelWidth={this.open === true ? () => length : () => 0}
+                                    overflow={cols > 5 || rows > 8 ? true : false}
+                                    focus={this.selectElement}
+                                    ScreenToLocalTransform={Transform.Identity}
+                                />
+                            </div> :
+                                <div style={{ display: "flex", justifyContent: "center" }}><div style={{ height: 200, top: 54, minWidth: 400, position: "absolute", backgroundColor: "rgb(241, 239, 235)", display: "flex", justifyContent: "center", alignItems: "center", border: "black 1px solid", }}>
+                                    <div>{this.noresults}</div>
+                                </div></div>}
                         </div> : undefined}
                 </div>
 
-- 
cgit v1.2.3-70-g09d2


From 58a322592f13bb37c369957b0141f53469d0d100 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 4 Aug 2020 10:59:28 -0400
Subject: moved filter to an icon

---
 src/client/util/CurrentUserUtils.ts   |  3 +++
 src/client/views/search/SearchBox.tsx | 45 ++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 25 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 048b5fe76..4b2f8d0f6 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -894,6 +894,9 @@ 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"]);
+        if (doc["search-panel"] === undefined) {
+            doc["search-panel"] = new PrefetchProxy(Docs.Create.SearchDocument({ _width: 500, _height: 400, backgroundColor: "dimGray", ignoreClick: true, childDropAction: "alias", lockedPosition: true, _viewType: CollectionViewType.Schema, _chromeStatus: "disabled", title: "sidebar search stack", })) as any as Doc;
+        }
         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.setupRightSidebar(doc);  // sets up the right sidebar collection for mobile upload documents and sharing
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 3b93b028e..2cb910f8b 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1036,11 +1036,28 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     <div style={{ position: "absolute", left: 15 }}>{Doc.CurrentUserEmail}</div>
                     <div style={{ display: "flex", alignItems: "center" }}>
                         <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg"
-                            style={{ color: "black", left: 24, padding: 1, position: "relative" }} />
-
+                            style={{ color: "black", padding: 1, left: 35, position: "relative" }} />
+
+                        <FontAwesomeIcon icon={"filter"} size="lg"
+                            style={{ right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
+                            onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
+                            onClick={action(() => {
+                                this.filter = !this.filter && !this.scale;
+                                if (this.filter === true && this.currentSelectedCollection !== undefined) {
+                                    this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
+                                    this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
+                                    this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
+                                }
+                                else if (this.filter === false && this.currentSelectedCollection !== undefined) {
+                                    this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
+                                    this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                    this.props.Document.selectedDoc = undefined;
+                                }
+                            }
+                            )} />
                         <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                             className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
-                            style={{ padding: 1, paddingLeft: 20, color: "black", height: 20, width: 200 }} />
+                            style={{ padding: 1, paddingLeft: 20, paddingRight: 20, color: "black", height: 20, width: 250 }} />
                         <div style={{
                             height: 25,
                             paddingLeft: "4px",
@@ -1050,28 +1067,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             borderBottom: this.open === false ? "1px solid" : "none",
                         }}>
                             <form className="beta" style={{ justifyContent: "space-evenly", display: "flex" }}>
-                                <div className="checkbox" style={{ margin: 0 }}>
-                                    <label style={{ fontSize: 12, marginTop: 6 }}>
-                                        <input style={{ marginLeft: -16, marginTop: -1, color: this.scale == false ? "black" : "grey" }} checked={this.filter === true} onChange={() => {
-                                            runInAction(() => {
-                                                if (this.scale === false) {
-                                                    this.filter = !this.filter;
-                                                    if (this.filter === true && this.currentSelectedCollection !== undefined) {
-                                                        this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
-                                                        this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
-                                                        this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
-                                                    }
-                                                    else if (this.filter === false && this.currentSelectedCollection !== undefined) {
-                                                        this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
-                                                        this.currentSelectedCollection.props.Document._docFilters = undefined;
-                                                        this.props.Document.selectedDoc = undefined;
-                                                    }
-                                                }
-                                            })
-                                        }} type="checkbox"></input>
-                                            Filter
-                                        </label>
-                                </div>
                                 <div style={{ display: "contents" }}>
                                     <div className="radio" style={{ margin: 0 }}>
                                         <label style={{ fontSize: 12, marginTop: 6 }} >
-- 
cgit v1.2.3-70-g09d2


From 4931f089160d6de5f34d8956c6106b6be1ec7d6f Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 4 Aug 2020 11:21:44 -0400
Subject: fixed click behavior on filter icon in search bar.

---
 src/client/views/MainView.tsx         | 2 +-
 src/client/views/search/SearchBox.tsx | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/MainView.tsx b/src/client/views/MainView.tsx
index 923036eae..c6cebc9ab 100644
--- a/src/client/views/MainView.tsx
+++ b/src/client/views/MainView.tsx
@@ -195,7 +195,7 @@ export class MainView extends React.Component {
         if (targets && targets.length && SearchBox.Instance._searchbarOpen) {
             let check = false;
             targets.forEach((thing) => {
-                if (thing.className.toString() === "collectionSchemaView-table" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") {
+                if (thing.className.toString() === "collectionSchemaView-table" || (thing as any)?.dataset["icon"] === "filter" || thing.className.toString() === "beta" || thing.className.toString() === "collectionSchemaView-menuOptions-wrapper") {
                     check = true;
                 }
             });
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 2cb910f8b..b7f7af244 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1039,7 +1039,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             style={{ color: "black", padding: 1, left: 35, position: "relative" }} />
 
                         <FontAwesomeIcon icon={"filter"} size="lg"
-                            style={{ right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
+                            style={{ cursor:"default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
                             onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
                             onClick={action(() => {
                                 this.filter = !this.filter && !this.scale;
-- 
cgit v1.2.3-70-g09d2


From a59bcec29efb9b5ea0ba8ddfb4b9977b904c10b8 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 4 Aug 2020 12:18:16 -0400
Subject: cleaning up

---
 src/client/views/nodes/FieldView.tsx   |   2 +-
 src/client/views/search/SearchBox.tsx  |   6 +-
 src/client/views/search/SearchItem.tsx | 272 +++++++++++++++++----------------
 3 files changed, 141 insertions(+), 139 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/nodes/FieldView.tsx b/src/client/views/nodes/FieldView.tsx
index 2cbfcdb0b..34b07f351 100644
--- a/src/client/views/nodes/FieldView.tsx
+++ b/src/client/views/nodes/FieldView.tsx
@@ -48,7 +48,7 @@ export interface FieldViewProps {
     ignoreAutoHeight?: boolean;
     PanelWidth: () => number;
     PanelHeight: () => number;
-    PanelPosition: string;
+    PanelPosition?: string;
     overflow?: boolean;
     NativeHeight: () => number;
     NativeWidth: () => number;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b7f7af244..b76955815 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -54,7 +54,7 @@ const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
 @observer
 export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDocument>(SearchBoxDocument) {
 
-    @computed get _searchString() { return this.layoutDoc.searchQuery; }
+    get _searchString() { return this.layoutDoc.searchQuery; }
     @computed set _searchString(value) { this.layoutDoc.searchQuery = (value); }
     @observable private _resultsOpen: boolean = false;
     @observable _searchbarOpen: boolean = false;
@@ -691,7 +691,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
         //const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this._resultsRef.current.getBoundingClientRect().height / itemHght)));
         const endIndex = 30;
-        this._endIndex = endIndex === -1 ? 12 : endIndex;
+        //this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
         let headers = new Set<string>(["title", "author", "text", "lastModified"]);
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
@@ -1039,7 +1039,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             style={{ color: "black", padding: 1, left: 35, position: "relative" }} />
 
                         <FontAwesomeIcon icon={"filter"} size="lg"
-                            style={{ cursor:"default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
+                            style={{ cursor: "default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
                             onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
                             onClick={action(() => {
                                 this.filter = !this.filter && !this.scale;
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 6b06289c4..b61ed450f 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -143,13 +143,13 @@ const SearchDocument = makeInterface(documentSchema);
 
 @observer
 export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) {
-    
+
     public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); }
 
-    constructor(props:any){
+    constructor(props: any) {
         super(props);
         //this.rootDoc._viewType= CollectionViewType.Stacking;
-        this.props.Document._height=46;
+        this.props.Document._height = 46;
         if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
             Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
             // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
@@ -175,44 +175,46 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     private _oldHeight: number = 46;
 
     componentDidMount() {
-        let parent: Doc |undefined = undefined;
+        let parent: Doc | undefined = undefined;
         let height = 0;
-        if (this.rootDoc.parent){
+        if (this.rootDoc.parent) {
             parent = Cast(this.rootDoc.parent, Doc, null);
-            if (parent!== undefined){
-            height=(NumCast(parent._height));
+            if (parent !== undefined) {
+                height = (NumCast(parent._height));
             }
         }
 
         this._reactionDisposer2 = reaction(
             () => this._useIcons,
-            el=> { 
-                if (this.rootDoc.parent){
+            el => {
+                if (this.rootDoc.parent) {
                     parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
-                    height=(NumCast(parent._height));
+                    height = (NumCast(parent._height));
                 };
                 console.log(height);
                 console.log(this._oldHeight);
-            setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null;
-                parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null;
-                this._mainRef.current?.getBoundingClientRect()?  this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null;
-                // this._oldHeight 55? this._oldHeight =55:null;
-            }, 1);
-        }
+                setTimeout(() => {
+                    this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null;
+                    parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null;
+                    this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null;
+                    // this._oldHeight 55? this._oldHeight =55:null;
+                }, 1);
+            }
         );
 
         this._reactionDisposer3 = reaction(
             () => this._displayLines,
-            el=> { 
-                if (this.rootDoc.parent){
+            el => {
+                if (this.rootDoc.parent) {
                     parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
-                    height=(NumCast(parent._height));
+                    height = (NumCast(parent._height));
                 };
-            setTimeout(() =>{this._mainRef.current?.getBoundingClientRect()? this.props.Document._height= this._mainRef.current?.getBoundingClientRect().height : null;
-                parent!==undefined? this._mainRef.current?.getBoundingClientRect()? parent._height= -this._oldHeight + height +this._mainRef.current?.getBoundingClientRect().height : null: null;
-                this._mainRef.current?.getBoundingClientRect()?  this._oldHeight= this._mainRef.current?.getBoundingClientRect().height : null;
-            }, 1);
-        }
+                setTimeout(() => {
+                    this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null;
+                    parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null;
+                    this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null;
+                }, 1);
+            }
         );
 
         Doc.SetSearchQuery(this.query);
@@ -225,14 +227,14 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
     }
 
-    
+
 
     private _reactionDisposer2?: IReactionDisposer;
     private _reactionDisposer3?: IReactionDisposer;
 
 
-    
-    @computed get highlightPos(){return NumCast(this.rootDoc.searchIndex)}
+
+    @computed get highlightPos() { return NumCast(this.rootDoc.searchIndex) }
 
     @action
     public DocumentIcon() {
@@ -286,9 +288,9 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         return <div><div onClick={action(() => { this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} >
             <FontAwesomeIcon icon={button} size="2x" />
         </div>
-        <div className="searchItem-label">{this.rootDoc.type ? this.rootDoc.type : "Other"}</div>
+            <div className="searchItem-label">{this.rootDoc.type ? this.rootDoc.type : "Other"}</div>
         </div>
-        ;
+            ;
     }
 
     collectionRef = React.createRef<HTMLDivElement>();
@@ -304,8 +306,8 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
         this.rootDoc!.searchMatch = false;
         setTimeout(() => this.rootDoc!.searchMatch = true, 0);
-        this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex);
-        this.length=NumCast(this.rootDoc!.length);
+        this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex);
+        this.length = NumCast(this.rootDoc!.length);
     }
 
     @action
@@ -317,12 +319,12 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
 
         this.rootDoc!.searchMatch2 = false;
         setTimeout(() => this.rootDoc!.searchMatch2 = true, 0);
-        this.rootDoc.searchIndex=NumCast(this.rootDoc.searchIndex);
+        this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex);
 
-        this.length=NumCast(this.rootDoc!.length);
+        this.length = NumCast(this.rootDoc!.length);
     }
 
-    @observable length:number|undefined = 0;
+    @observable length: number | undefined = 0;
 
     highlightDoc = (e: React.PointerEvent) => {
         if (this.rootDoc!.type === DocumentType.LINK) {
@@ -402,9 +404,9 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     // @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
 
     @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
-    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate: undefined;
+    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined;
     getTransform = () => {
-    return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
+        return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
     }
     panelHeight = () => {
         return this.props.PanelHeight();
@@ -413,60 +415,60 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
         //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
     }
 
-    newsearch(){
-       runInAction(()=>{
-        if (StrCast(this.rootDoc.bucketfield)!=="results"){
-        SearchBox.Instance._icons=[StrCast(this.rootDoc.bucketfield)];
-        SearchBox.Instance._icons=SearchBox.Instance._icons;
-        }
-        else{
-            SearchBox.Instance._icons=SearchBox.Instance._allIcons;
-        }
-        SearchBox.Instance.expandedBucket= true;
-        SearchBox.Instance.submitSearch();
-       }) 
+    newsearch() {
+        runInAction(() => {
+            if (StrCast(this.rootDoc.bucketfield) !== "results") {
+                SearchBox.Instance._icons = [StrCast(this.rootDoc.bucketfield)];
+                SearchBox.Instance._icons = SearchBox.Instance._icons;
+            }
+            else {
+                SearchBox.Instance._icons = SearchBox.Instance._allIcons;
+            }
+            SearchBox.Instance.submitSearch();
+        })
     }
-    
+
     @action
-    returnLines(){
-        if ((Cast(this.rootDoc.lines, listSpec("string")))!.length>1){
-        if (!this._displayLines) {
-            console.log(Cast(this.rootDoc.lines, listSpec("string")));
-            return <div style={{width: 10}}
-            onPointerDown={action(() => {
-                this._displayLines = !this._displayLines;
-                //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
-            })}
-            //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))}
-             >
-            {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div style={{overflow:"visible"}}id={i.toString()} className="searchItem-highlighting">{l}</div>)}
-            </div>;;
+    returnLines() {
+        if ((Cast(this.rootDoc.lines, listSpec("string")))!.length > 1) {
+            if (!this._displayLines) {
+                console.log(Cast(this.rootDoc.lines, listSpec("string")));
+                return <div style={{ width: 10 }}
+                    onPointerDown={action(() => {
+                        this._displayLines = !this._displayLines;
+                        //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
+                    })}
+                //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))}
+                >
+                    {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div style={{ overflow: "visible" }} id={i.toString()} className="searchItem-highlighting">{l}</div>)}
+                </div>;;
+            }
         }
     }
-    }
-    
+
     //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); 
 
     @observable _displayLines: boolean = true;
 
-    returnButtons(){
+    returnButtons() {
         return <div>
-        <div onClick={action(() => { this.rootDoc!.type === DocumentType.PDF? this._displayLines = !this._displayLines : null; 
-        })}> 
-        {this.rootDoc!.type === DocumentType.PDF?"Expand Lines": null}
-        {NumCast(this.rootDoc!.length)>1?`Instance ${NumCast(this.rootDoc.searchIndex)===0? NumCast(this.rootDoc.length):NumCast(this.rootDoc.searchIndex) } of ${NumCast(this.rootDoc.length)}`: null}
-             <button onClick={this.nextHighlight} style={{padding:2, position:"absolute", left:77}}>
-                        <FontAwesomeIcon icon="arrow-up" size="sm"  /> 
-                        </button>
-                        <button onClick={this.nextHighlight2} style={{padding:2, position:"absolute", left:87}}>                    
-                        <FontAwesomeIcon icon="arrow-down" size="sm"  />
-                        </button>
-        </div>
-        <div>
-        <div style={{background: "lightgrey"}}>
-            {this.returnLines()}
-        </div>
-        </div>
+            <div onClick={action(() => {
+                this.rootDoc!.type === DocumentType.PDF ? this._displayLines = !this._displayLines : null;
+            })}>
+                {this.rootDoc!.type === DocumentType.PDF ? "Expand Lines" : null}
+                {NumCast(this.rootDoc!.length) > 1 ? `Instance ${NumCast(this.rootDoc.searchIndex) === 0 ? NumCast(this.rootDoc.length) : NumCast(this.rootDoc.searchIndex)} of ${NumCast(this.rootDoc.length)}` : null}
+                <button onClick={this.nextHighlight} style={{ padding: 2, position: "absolute", left: 77 }}>
+                    <FontAwesomeIcon icon="arrow-up" size="sm" />
+                </button>
+                <button onClick={this.nextHighlight2} style={{ padding: 2, position: "absolute", left: 87 }}>
+                    <FontAwesomeIcon icon="arrow-down" size="sm" />
+                </button>
+            </div>
+            <div>
+                <div style={{ background: "lightgrey" }}>
+                    {this.returnLines()}
+                </div>
+            </div>
         </div>
     }
 
@@ -476,79 +478,79 @@ export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchem
     render() {
         const doc1 = Cast(this.rootDoc!.anchor1, Doc);
         const doc2 = Cast(this.rootDoc!.anchor2, Doc);
-        if (StrCast(this.rootDoc.bucketfield)==="webs"){
-            this.props.Document._viewType=CollectionViewType.Stacking;  
-            this.props.Document._chromeStatus='disabled';
-            this.props.Document._height=this.rootDoc._height;
+        if (StrCast(this.rootDoc.bucketfield) === "webs") {
+            this.props.Document._viewType = CollectionViewType.Stacking;
+            this.props.Document._chromeStatus = 'disabled';
+            this.props.Document._height = this.rootDoc._height;
             return <div>
-            <CollectionView {...this.props}
-            Document={this.props.Document}
-            PanelHeight={this.panelHeight}
-            whenActiveChanged={emptyFunction}
-            onClick={undefined}
-            moveDocument={returnFalse}
-            childLayoutTemplate={undefined}
-            addDocument={undefined}
-            removeDocument={returnFalse}
-            focus={this.selectElement}
-            ScreenToLocalTransform={this.getTransform} />
+                <CollectionView {...this.props}
+                    Document={this.props.Document}
+                    PanelHeight={this.panelHeight}
+                    whenActiveChanged={emptyFunction}
+                    onClick={undefined}
+                    moveDocument={returnFalse}
+                    childLayoutTemplate={undefined}
+                    addDocument={undefined}
+                    removeDocument={returnFalse}
+                    focus={this.selectElement}
+                    ScreenToLocalTransform={this.getTransform} />
             </div>
         }
-        if (this.rootDoc.isBucket === true){
-            this.props.Document._viewType=CollectionViewType.Stacking;  
-            this.props.Document._chromeStatus='disabled';
-            this.props.Document._height=this.rootDoc._height;
+        if (this.rootDoc.isBucket === true) {
+            this.props.Document._viewType = CollectionViewType.Stacking;
+            this.props.Document._chromeStatus = 'disabled';
+            this.props.Document._height = this.rootDoc._height;
 
             return <div>
-            <CollectionView {...this.props}
-            Document={this.props.Document}
-            PanelHeight={this.panelHeight}
-            whenActiveChanged={emptyFunction}
-            onClick={undefined}
-            moveDocument={returnFalse}
-            childLayoutTemplate={this.childLayoutTemplate}
-            addDocument={undefined}
-            removeDocument={returnFalse}
-            focus={this.selectElement}
-            ScreenToLocalTransform={this.getTransform} />
-            <button onClick={()=>this.newsearch()}className="bucket-expand" style={{transform:"none", fontSize:"100%",textTransform:"none", background: "lightgray",color: "black", bottom: 8, marginBottom:-2, paddingTop:2,fontFamily:"Arial, sans-serif"}}>See all {StrCast(this.rootDoc.bucketfield)}...
+                <CollectionView {...this.props}
+                    Document={this.props.Document}
+                    PanelHeight={this.panelHeight}
+                    whenActiveChanged={emptyFunction}
+                    onClick={undefined}
+                    moveDocument={returnFalse}
+                    childLayoutTemplate={this.childLayoutTemplate}
+                    addDocument={undefined}
+                    removeDocument={returnFalse}
+                    focus={this.selectElement}
+                    ScreenToLocalTransform={this.getTransform} />
+                <button onClick={() => this.newsearch()} className="bucket-expand" style={{ transform: "none", fontSize: "100%", textTransform: "none", background: "lightgray", color: "black", bottom: 8, marginBottom: -2, paddingTop: 2, fontFamily: "Arial, sans-serif" }}>See all {StrCast(this.rootDoc.bucketfield)}...
             </button>
             </div>
         }
-        else if (this.rootDoc.isBucket === false){
-            this.props.Document._chromeStatus='disabled';
-            return      <div className="searchItem">
+        else if (this.rootDoc.isBucket === false) {
+            this.props.Document._chromeStatus = 'disabled';
+            return <div className="searchItem">
                 <div className="searchItem-body" >
-                <div className="searchItem-title-container">
-                <div className="searchItem-title" style={{height:"10px", overflow:"hidden", textOverflow:"ellipsis"}}>No Search Results</div>
-                </div>
+                    <div className="searchItem-title-container">
+                        <div className="searchItem-title" style={{ height: "10px", overflow: "hidden", textOverflow: "ellipsis" }}>No Search Results</div>
+                    </div>
                 </div>
             </div>
         }
         else {
-        return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
-            <div ref={this._mainRef} className="searchItem"  onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
-                <div className="searchItem-body" onClick={this.onClick}>
-                    <div className="searchItem-title-container">
-                        <div className="searchItem-title" style={{height:"10px", overflow:"hidden", textOverflow:"ellipsis"}}>{StrCast(this.rootDoc.title)}</div>
-                        <div className="searchItem-highlighting">
-                        {this.rootDoc.highlighting? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "":null}</div>
-                        <div className={`icon-${this._displayLines ? "q" : "a"}`}>
-                        {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF?this.returnButtons(): null} 
+            return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
+                <div ref={this._mainRef} className="searchItem" onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
+                    <div className="searchItem-body" onClick={this.onClick}>
+                        <div className="searchItem-title-container">
+                            <div className="searchItem-title" style={{ height: "10px", overflow: "hidden", textOverflow: "ellipsis" }}>{StrCast(this.rootDoc.title)}</div>
+                            <div className="searchItem-highlighting">
+                                {this.rootDoc.highlighting ? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "" : null}</div>
+                            <div className={`icon-${this._displayLines ? "q" : "a"}`}>
+                                {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF ? this.returnButtons() : null}
+                            </div>
                         </div>
+                    </div>
+                    <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
+                        <div className={`icon-${this._useIcons ? "icons" : "live"}`}>
+                            <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
                         </div>
-                </div>
-                <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
-                    <div className={`icon-${this._useIcons ? "icons" : "live"}`}>
-                        <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
                     </div>
-                </div>
-                {/* <div className="searchItem-context" title="Drag as document">
+                    {/* <div className="searchItem-context" title="Drag as document">
                     {(doc1 instanceof Doc && doc2 instanceof Doc) && this.rootDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
                         this.contextButton}
                 </div> */}
-            </div>
-        </div>;
+                </div>
+            </div>;
         }
     }
 } 
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 840d7f00989a33dd0fd9a48a3c2076433340d3ac Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 4 Aug 2020 12:56:15 -0400
Subject: cleanup of searchbox variables.

---
 src/client/views/search/SearchBox.tsx | 34 ++++++++++++----------------------
 1 file changed, 12 insertions(+), 22 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b7f7af244..c8a1c4e8e 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -206,13 +206,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             // if (this._icons !== this._allIcons) {
             //     runInAction(() => { this.expandedBucket = false });
             // }
-            if (StrCast(this.layoutDoc._searchString) !== "") {
-                console.log("OPEN");
-                runInAction(() => { this.open = true });
+            if (StrCast(this.layoutDoc._searchString) !== "" || !this.searchFullDB) {
+                runInAction(() => this.open = true);
             }
             else {
-                console.log("CLOSE");
-                runInAction(() => { this.open = false });
+                runInAction(() => this.open = false);
 
             }
             this.submitSearch();
@@ -356,7 +354,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     docsforfilter: Doc[] = [];
 
     searchCollection(query: string) {
-
         const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
 
         if (selectedCollection !== undefined) {
@@ -373,18 +370,12 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 newarray = [];
                 docs.forEach((d) => {
                     if (d.data != undefined) {
-                        let newdocs = DocListCast(d.data);
-                        newdocs.forEach((newdoc) => {
-                            newarray.push(newdoc);
-
-                        });
+                        newarray.push(...DocListCast(d.data));
                     }
 
-
                     let hlights: string[] = [];
 
                     const protos = Doc.GetAllPrototypes(d);
-                    let proto = protos[protos.length - 1];
                     protos.forEach(proto => {
                         Object.keys(proto).forEach(key => {
                             // console.log(key, d[key]);
@@ -403,7 +394,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._results = found;
             this.docsforfilter = docsforFilter;
             if (this.filter === true) {
-                console.log(docsforFilter);
                 selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
             }
             this._numTotalResults = found.length;
@@ -504,7 +494,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             this._endIndex = 12;
             this._maxSearchIndex = 0;
             this._numTotalResults = -1;
-            this.scale === true ? await this.getResults(query) : this.searchCollection(query);
+            this.searchFullDB ? await this.getResults(query) : this.searchCollection(query);
             runInAction(() => {
                 this._resultsOpen = true;
                 this._searchbarOpen = true;
@@ -515,7 +505,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
     }
 
-    @observable scale = true;
+    @observable searchFullDB = true;
 
     @observable _timeout: any = undefined;
 
@@ -1039,10 +1029,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             style={{ color: "black", padding: 1, left: 35, position: "relative" }} />
 
                         <FontAwesomeIcon icon={"filter"} size="lg"
-                            style={{ cursor:"default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
+                            style={{ cursor: "default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
                             onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
                             onClick={action(() => {
-                                this.filter = !this.filter && !this.scale;
+                                this.filter = !this.filter && !this.searchFullDB;
                                 if (this.filter === true && this.currentSelectedCollection !== undefined) {
                                     this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
                                     this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
@@ -1070,9 +1060,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 <div style={{ display: "contents" }}>
                                     <div className="radio" style={{ margin: 0 }}>
                                         <label style={{ fontSize: 12, marginTop: 6 }} >
-                                            <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={this.scale === false} onChange={() => {
+                                            <input type="radio" style={{ marginLeft: -16, marginTop: -1 }} checked={!this.searchFullDB} onChange={() => {
                                                 runInAction(() => {
-                                                    this.scale = !this.scale;
+                                                    this.searchFullDB = !this.searchFullDB;
                                                     this.dataDoc[this.fieldKey] = new List<Doc>([]);
                                                     if (this.currentSelectedCollection !== undefined) {
                                                         this.currentSelectedCollection.props.Document._docFilters = undefined;
@@ -1087,9 +1077,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                     </div>
                                     <div className="radio" style={{ margin: 0 }}>
                                         <label style={{ fontSize: 12, marginTop: 6 }} >
-                                            <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.scale === true} onChange={() => {
+                                            <input style={{ marginLeft: -16, marginTop: -1 }} type="radio" checked={this.searchFullDB} onChange={() => {
                                                 runInAction(() => {
-                                                    this.scale = !this.scale;
+                                                    this.searchFullDB = !this.searchFullDB;
                                                     this.dataDoc[this.fieldKey] = new List<Doc>([]);
                                                     this.filter = false;
                                                     if (this.currentSelectedCollection !== undefined) {
-- 
cgit v1.2.3-70-g09d2


From 43f0db3b59366c65a4051db6b0f8b67b13f98a67 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Tue, 4 Aug 2020 15:06:30 -0400
Subject: got rid of special-case code for _searchDOc in stackingview.

---
 src/client/views/collections/CollectionStackingView.tsx | 3 +--
 src/client/views/search/SearchBox.tsx                   | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionStackingView.tsx b/src/client/views/collections/CollectionStackingView.tsx
index a8e3b2ebb..559365361 100644
--- a/src/client/views/collections/CollectionStackingView.tsx
+++ b/src/client/views/collections/CollectionStackingView.tsx
@@ -50,7 +50,6 @@ export class CollectionStackingView extends CollectionSubView(StackingDocument)
     @computed get yMargin() { return Math.max(this.layoutDoc._showTitle && !this.layoutDoc._showTitleHover ? 30 : 0, NumCast(this.layoutDoc._yMargin, 0)); } // 2 * this.gridGap)); }
     @computed get gridGap() { return NumCast(this.layoutDoc._gridGap, 10); }
     @computed get isStackingView() { return BoolCast(this.layoutDoc._columnsStack, true); }
-    @computed get searchDoc() { return BoolCast(this.props.Document._searchDoc, false); }
     @computed get numGroupColumns() { return this.isStackingView ? Math.max(1, this.Sections.size + (this.showAddAGroup ? 1 : 0)) : 1; }
     @computed get showAddAGroup() { return (this.pivotField && (this.layoutDoc._chromeStatus !== 'view-mode' && this.layoutDoc._chromeStatus !== 'disabled')); }
     @computed get columnWidth() {
@@ -78,7 +77,7 @@ export class CollectionStackingView extends CollectionSubView(StackingDocument)
             this._docXfs.push({ dxf, width, height });
             const rowSpan = Math.ceil((height() + this.gridGap) / this.gridGap);
 
-            const style = this.isStackingView ? { width: width(), marginTop: i || this.searchDoc ? this.gridGap : 0, marginBottom: this.searchDoc ? 10 : 0, height: height() } : { gridRowEnd: `span ${rowSpan}` };
+            const style = this.isStackingView ? { width: width(), marginTop: i ? this.gridGap : 0, height: height() } : { gridRowEnd: `span ${rowSpan}` };
             return <div className={`collectionStackingView-${this.isStackingView ? "columnDoc" : "masonryDoc"}`} key={d[Id]} ref={dref} style={style} >
                 {this.getDisplayDoc(d, (!d.isTemplateDoc && !d.isTemplateForField && !d.PARAMS) ? undefined : this.props.DataDoc, dxf, width)}
             </div>;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 4f9d75705..696da0c9a 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1010,7 +1010,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     //Make id layour document
     render() {
         this.props.Document._chromeStatus === "disabled";
-        this.props.Document._searchDoc = true;
         let cols = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
         let length = 0;
         cols > 5 ? length = 1076 : length = cols * 205 + 51;
-- 
cgit v1.2.3-70-g09d2


From e83fd812ed3798a7e7c22ad132a2f9e8dccaa76c Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Tue, 4 Aug 2020 22:05:30 -0400
Subject: changes

---
 src/client/documents/Documents.ts                  |  14 +-
 src/client/util/CurrentUserUtils.ts                |  12 +-
 src/client/views/SearchDocBox.tsx                  | 428 ----------------
 .../views/collections/CollectionSchemaCells.tsx    |  84 +++-
 .../views/collections/CollectionSchemaHeaders.tsx  |   8 +-
 .../views/collections/CollectionSchemaView.scss    |   2 +-
 src/client/views/collections/CollectionSubView.tsx |  53 +-
 src/client/views/collections/SchemaTable.tsx       |  47 +-
 .../collectionFreeForm/PropertiesView.tsx          |   2 +-
 src/client/views/nodes/DocumentContentsView.tsx    |   3 +-
 src/client/views/nodes/LabelBox.tsx                |   2 +-
 .../views/nodes/formattedText/FormattedTextBox.tsx |   1 -
 src/client/views/search/SearchBox.tsx              | 419 +++++-----------
 src/client/views/search/SearchItem.scss            | 186 -------
 src/client/views/search/SearchItem.tsx             | 556 ---------------------
 15 files changed, 300 insertions(+), 1517 deletions(-)
 delete mode 100644 src/client/views/SearchDocBox.tsx
 delete mode 100644 src/client/views/search/SearchItem.scss
 delete mode 100644 src/client/views/search/SearchItem.tsx

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index e6eaaad60..b809a73b7 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -22,8 +22,7 @@ import { LinkManager } from "../util/LinkManager";
 import { Scripting } from "../util/Scripting";
 import { UndoManager } from "../util/UndoManager";
 import { DocumentType } from "./DocumentTypes";
-import { SearchItem } from "../views/search/SearchItem";
-import { SearchBox, filterData } from "../views/search/SearchBox";
+import { SearchBox } from "../views/search/SearchBox";
 import { CollectionDockingView } from "../views/collections/CollectionDockingView";
 import { CollectionView, CollectionViewType } from "../views/collections/CollectionView";
 import { ContextMenu } from "../views/ContextMenu";
@@ -48,7 +47,6 @@ import { VideoBox } from "../views/nodes/VideoBox";
 import { WebBox } from "../views/nodes/WebBox";
 import { PresElementBox } from "../views/presentationview/PresElementBox";
 import { DashWebRTCVideo } from "../views/webcam/DashWebRTCVideo";
-import { DocumentType } from "./DocumentTypes";
 import { Networking } from "../Network";
 import { Upload } from "../../server/SharedMediaTypes";
 const path = require('path');
@@ -191,8 +189,7 @@ export interface DocumentOptions {
     flexDirection?: "unset" | "row" | "column" | "row-reverse" | "column-reverse";
     selectedIndex?: number;
     syntaxColor?: string; // can be applied to text for syntax highlighting all matches in the text
-    searchQuery?: string, // for quersyBox
-    filterQuery?: filterData,
+    searchQuery?: string; // for quersyBox
     linearViewIsExpanded?: boolean; // is linear view expanded
     border?: string; //for searchbox
     hovercolor?: string;
@@ -316,9 +313,6 @@ export namespace Docs {
             [DocumentType.PRESELEMENT, {
                 layout: { view: PresElementBox, dataField: defaultDataKey }
             }],
-            [DocumentType.SEARCHITEM, {
-                layout: { view: SearchItem, dataField: defaultDataKey }
-            }],
             [DocumentType.INK, {
                 layout: { view: InkingStroke, dataField: defaultDataKey },
                 options: { backgroundColor: "transparent" }
@@ -803,10 +797,6 @@ export namespace Docs {
             return InstanceFromProto(Prototypes.get(DocumentType.PRESELEMENT), undefined, { ...(options || {}) });
         }
 
-        export function SearchItemBoxDocument(options?: DocumentOptions) {
-            return InstanceFromProto(Prototypes.get(DocumentType.SEARCHITEM), undefined, { ...(options || {}) });
-        }
-
         export function DockDocument(documents: Array<Doc>, config: string, options: DocumentOptions, id?: string) {
             const inst = InstanceFromProto(Prototypes.get(DocumentType.COL), new List(documents), { ...options, _viewType: CollectionViewType.Docking, dockingConfig: config }, id);
             Doc.GetProto(inst).data = new List<Doc>(documents);
diff --git a/src/client/util/CurrentUserUtils.ts b/src/client/util/CurrentUserUtils.ts
index 84cd4823b..cd8c09a0e 100644
--- a/src/client/util/CurrentUserUtils.ts
+++ b/src/client/util/CurrentUserUtils.ts
@@ -543,7 +543,7 @@ export class CurrentUserUtils {
                     btn.color = "white";
                     btn._backgroundColor = "";
                 }));
-            })
+            });
         });
         return doc.menuStack as Doc;
     }
@@ -761,16 +761,6 @@ export class CurrentUserUtils {
         }
     }
 
-    static setupSidebarContainer(doc: Doc) {
-        if (doc["sidebar"] === undefined) {
-            const sidebarContainer = new Doc();
-            sidebarContainer._chromeStatus = "disabled";
-            sidebarContainer.onClick = ScriptField.MakeScript("freezeSidebar()");
-            doc["sidebar"] = new PrefetchProxy(sidebarContainer);
-        }
-        return doc["sidebar"] as Doc;
-    }
-
     // setup the list of sidebar mode buttons which determine what is displayed in the sidebar
     static async setupSidebarButtons(doc: Doc) {
         await CurrentUserUtils.setupToolsBtnPanel(doc);
diff --git a/src/client/views/SearchDocBox.tsx b/src/client/views/SearchDocBox.tsx
deleted file mode 100644
index 084f952a3..000000000
--- a/src/client/views/SearchDocBox.tsx
+++ /dev/null
@@ -1,428 +0,0 @@
-import { library } from "@fortawesome/fontawesome-svg-core";
-import { faBullseye, faLink } from "@fortawesome/free-solid-svg-icons";
-import { action, computed, observable, runInAction } from "mobx";
-import { observer } from "mobx-react";
-//import "./SearchBoxDoc.scss";
-import { Doc, DocListCast } from "../../fields/Doc";
-import { Id } from "../../fields/FieldSymbols";
-import { BoolCast, Cast, NumCast, StrCast } from "../../fields/Types";
-import { returnFalse, returnZero } from "../../Utils";
-import { Docs } from "../documents/Documents";
-import { SearchUtil } from "../util/SearchUtil";
-import { EditableView } from "./EditableView";
-import { ContentFittingDocumentView } from "./nodes/ContentFittingDocumentView";
-import { FieldView, FieldViewProps } from "./nodes/FieldView";
-import { FilterBox } from "./search/FilterBox";
-import { SearchItem } from "./search/SearchItem";
-import React = require("react");
-
-export interface RecProps {
-    documents: { preview: Doc, similarity: number }[];
-    node: Doc;
-
-}
-
-library.add(faBullseye, faLink);
-export const keyPlaceholder = "Query";
-
-@observer
-export class SearchDocBox extends React.Component<FieldViewProps> {
-
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchDocBox, fieldKey); }
-
-    // @observable private _display: boolean = false;
-    @observable private _pageX: number = 0;
-    @observable private _pageY: number = 0;
-    @observable private _width: number = 0;
-    @observable private _height: number = 0;
-    @observable.shallow private _docViews: JSX.Element[] = [];
-    // @observable private _documents: { preview: Doc, score: number }[] = [];
-    private previewDocs: Doc[] = [];
-
-    constructor(props: FieldViewProps) {
-        super(props);
-        this.editingMetadata = this.editingMetadata || false;
-        //SearchBox.Instance = this;
-        this.resultsScrolled = this.resultsScrolled.bind(this);
-    }
-
-
-    @computed
-    private get editingMetadata() {
-        return BoolCast(this.props.Document.editingMetadata);
-    }
-
-    private set editingMetadata(value: boolean) {
-        this.props.Document.editingMetadata = value;
-    }
-
-    static readonly buffer = 20;
-
-    componentDidMount() {
-        runInAction(() => {
-            this.query = StrCast(this.props.Document.searchText);
-            this.content = (Docs.Create.TreeDocument(DocListCast(Doc.GetProto(this.props.Document).data), { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs:` + this.query }));
-
-        });
-        if (this.inputRef.current) {
-            this.inputRef.current.focus();
-            runInAction(() => {
-                this._searchbarOpen = true;
-            });
-        }
-    }
-
-    @observable
-    private content: Doc | undefined;
-
-    @action
-    updateKey = async (newKey: string) => {
-        this.query = newKey;
-        if (newKey.length > 1) {
-            const newdocs = await this.getAllResults(this.query);
-            const things = newdocs.docs;
-            runInAction(() => {
-                this.content = Docs.Create.TreeDocument(things, { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs:` + this.query });
-            });
-        }
-
-
-        //this.keyRef.current && this.keyRef.current.setIsFocused(false);
-        //this.query.length === 0 && (this.query = keyPlaceholder);
-        return true;
-    }
-
-    @computed
-    public get query() {
-        return StrCast(this.props.Document.query);
-    }
-
-    public set query(value: string) {
-        this.props.Document.query = value;
-    }
-
-    @observable private _searchString: string = "";
-    @observable private _resultsOpen: boolean = false;
-    @observable private _searchbarOpen: boolean = false;
-    @observable private _results: [Doc, string[], string[]][] = [];
-    private _resultsSet = new Map<Doc, number>();
-    @observable private _openNoResults: boolean = false;
-    @observable private _visibleElements: JSX.Element[] = [];
-
-    private resultsRef = React.createRef<HTMLDivElement>();
-    public inputRef = React.createRef<HTMLInputElement>();
-
-    private _isSearch: ("search" | "placeholder" | undefined)[] = [];
-    private _numTotalResults = -1;
-    private _endIndex = -1;
-
-
-    private _maxSearchIndex: number = 0;
-    private _curRequest?: Promise<any> = undefined;
-
-    @action
-    getViews = async (doc: Doc) => {
-        const results = await SearchUtil.GetViewsOfDocument(doc);
-        let toReturn: Doc[] = [];
-        await runInAction(() => {
-            toReturn = results;
-        });
-        return toReturn;
-    }
-
-    @action.bound
-    onChange(e: React.ChangeEvent<HTMLInputElement>) {
-        this._searchString = e.target.value;
-
-        this._openNoResults = false;
-        this._results = [];
-        this._resultsSet.clear();
-        this._visibleElements = [];
-        this._numTotalResults = -1;
-        this._endIndex = -1;
-        this._curRequest = undefined;
-        this._maxSearchIndex = 0;
-    }
-
-    enter = async (e: React.KeyboardEvent) => {
-        if (e.key === "Enter") {
-            const newdocs = await this.getAllResults(this.query);
-            this.content = Docs.Create.TreeDocument(newdocs.docs, { _width: 200, _height: 400, _chromeStatus: "disabled", title: `Search Docs: "Results"` });
-        }
-    }
-
-
-    @action
-    submitSearch = async () => {
-        let query = this._searchString;
-        query = FilterBox.Instance.getFinalQuery(query);
-        this._results = [];
-        this._resultsSet.clear();
-        this._isSearch = [];
-        this._visibleElements = [];
-        FilterBox.Instance.closeFilter();
-
-        //if there is no query there should be no result
-        if (query === "") {
-            return;
-        }
-        else {
-            this._endIndex = 12;
-            this._maxSearchIndex = 0;
-            this._numTotalResults = -1;
-            await this.getResults(query);
-        }
-
-        runInAction(() => {
-            this._resultsOpen = true;
-            this._searchbarOpen = true;
-            this._openNoResults = true;
-            this.resultsScrolled();
-        });
-    }
-
-    getAllResults = async (query: string) => {
-        return SearchUtil.Search(query, true, { fq: this.filterQuery, start: 0, rows: 10000000 });
-    }
-
-    private get filterQuery() {
-        const types = FilterBox.Instance.filterTypes;
-        const includeDeleted = FilterBox.Instance.getDataStatus();
-        return "NOT baseProto_b:true" + (includeDeleted ? "" : " AND NOT deleted_b:true") + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}" OR type_t:"extension"`).join(" ")})` : "");
-    }
-
-
-    private NumResults = 25;
-    private lockPromise?: Promise<void>;
-    getResults = async (query: string) => {
-        if (this.lockPromise) {
-            await this.lockPromise;
-        }
-        this.lockPromise = new Promise(async res => {
-            while (this._results.length <= this._endIndex && (this._numTotalResults === -1 || this._maxSearchIndex < this._numTotalResults)) {
-                this._curRequest = SearchUtil.Search(query, true, { fq: this.filterQuery, start: this._maxSearchIndex, rows: this.NumResults, hl: true, "hl.fl": "*" }).then(action(async (res: SearchUtil.DocSearchResult) => {
-
-                    // happens at the beginning
-                    if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
-                        this._numTotalResults = res.numFound;
-                    }
-
-                    const highlighting = res.highlighting || {};
-                    const highlightList = res.docs.map(doc => highlighting[doc[Id]]);
-                    const lines = new Map<string, string[]>();
-                    res.docs.map((doc, i) => lines.set(doc[Id], res.lines[i]));
-                    const docs = await Promise.all(res.docs.map(async doc => (await Cast(doc.extendsDoc, Doc)) || doc));
-                    const highlights: typeof res.highlighting = {};
-                    docs.forEach((doc, index) => highlights[doc[Id]] = highlightList[index]);
-                    const filteredDocs = FilterBox.Instance.filterDocsByType(docs);
-                    runInAction(() => {
-                        // this._results.push(...filteredDocs);
-                        filteredDocs.forEach(doc => {
-                            const index = this._resultsSet.get(doc);
-                            const highlight = highlights[doc[Id]];
-                            const line = lines.get(doc[Id]) || [];
-                            const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
-                            if (index === undefined) {
-                                this._resultsSet.set(doc, this._results.length);
-                                this._results.push([doc, hlights, line]);
-                            } else {
-                                this._results[index][1].push(...hlights);
-                                this._results[index][2].push(...line);
-                            }
-                        });
-                    });
-
-                    this._curRequest = undefined;
-                }));
-                this._maxSearchIndex += this.NumResults;
-
-                await this._curRequest;
-            }
-            this.resultsScrolled();
-            res();
-        });
-        return this.lockPromise;
-    }
-
-    collectionRef = React.createRef<HTMLSpanElement>();
-    startDragCollection = async () => {
-        const res = await this.getAllResults(FilterBox.Instance.getFinalQuery(this._searchString));
-        const filtered = FilterBox.Instance.filterDocsByType(res.docs);
-        const docs = filtered.map(doc => {
-            const isProto = Doc.GetT(doc, "isPrototype", "boolean", true);
-            if (isProto) {
-                return Doc.MakeDelegate(doc);
-            } else {
-                return Doc.MakeAlias(doc);
-            }
-        });
-        let x = 0;
-        let y = 0;
-        for (const doc of docs.map(d => Doc.Layout(d))) {
-            doc.x = x;
-            doc.y = y;
-            const size = 200;
-            const aspect = NumCast(doc._nativeHeight) / NumCast(doc._nativeWidth, 1);
-            if (aspect > 1) {
-                doc._height = size;
-                doc._width = size / aspect;
-            } else if (aspect > 0) {
-                doc._width = size;
-                doc._height = size * aspect;
-            } else {
-                doc._width = size;
-                doc._height = size;
-            }
-            x += 250;
-            if (x > 1000) {
-                x = 0;
-                y += 300;
-            }
-        }
-        //return Docs.Create.TreeDocument(docs, { _width: 200, _height: 400, backgroundColor: "grey", title: `Search Docs: "${this._searchString}"` });
-        return Docs.Create.QueryDocument({ _width: 200, _height: 400, searchText: this._searchString, title: `Query Docs: "${this._searchString}"` });
-    }
-
-    @action.bound
-    openSearch(e: React.SyntheticEvent) {
-        e.stopPropagation();
-        this._openNoResults = false;
-        FilterBox.Instance.closeFilter();
-        this._resultsOpen = true;
-        this._searchbarOpen = true;
-        FilterBox.Instance._pointerTime = e.timeStamp;
-    }
-
-    @action.bound
-    closeSearch = () => {
-        FilterBox.Instance.closeFilter();
-        this.closeResults();
-        this._searchbarOpen = false;
-    }
-
-    @action.bound
-    closeResults() {
-        this._resultsOpen = false;
-        this._results = [];
-        this._resultsSet.clear();
-        this._visibleElements = [];
-        this._numTotalResults = -1;
-        this._endIndex = -1;
-        this._curRequest = undefined;
-    }
-
-    @action
-    resultsScrolled = (e?: React.UIEvent<HTMLDivElement>) => {
-        if (!this.resultsRef.current) return;
-        const scrollY = e ? e.currentTarget.scrollTop : this.resultsRef.current ? this.resultsRef.current.scrollTop : 0;
-        const itemHght = 53;
-        const startIndex = Math.floor(Math.max(0, scrollY / itemHght));
-        const endIndex = Math.ceil(Math.min(this._numTotalResults - 1, startIndex + (this.resultsRef.current.getBoundingClientRect().height / itemHght)));
-
-        this._endIndex = endIndex === -1 ? 12 : endIndex;
-
-        if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
-            this._visibleElements = [<div className="no-result">No Search Results</div>];
-            return;
-        }
-
-        if (this._numTotalResults <= this._maxSearchIndex) {
-            this._numTotalResults = this._results.length;
-        }
-
-        // only hit right at the beginning
-        // visibleElements is all of the elements (even the ones you can't see)
-        else if (this._visibleElements.length !== this._numTotalResults) {
-            // undefined until a searchitem is put in there
-            this._visibleElements = Array<JSX.Element>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-            // indicates if things are placeholders
-            this._isSearch = Array<undefined>(this._numTotalResults === -1 ? 0 : this._numTotalResults);
-        }
-
-        for (let i = 0; i < this._numTotalResults; i++) {
-            //if the index is out of the window then put a placeholder in
-            //should ones that have already been found get set to placeholders?
-            if (i < startIndex || i > endIndex) {
-                if (this._isSearch[i] !== "placeholder") {
-                    this._isSearch[i] = "placeholder";
-                    this._visibleElements[i] = <div className="searchBox-placeholder" key={`searchBox-placeholder-${i}`}>Loading...</div>;
-                }
-            }
-            else {
-                if (this._isSearch[i] !== "search") {
-                    let result: [Doc, string[], string[]] | undefined = undefined;
-                    if (i >= this._results.length) {
-                        this.getResults(this._searchString);
-                        if (i < this._results.length) result = this._results[i];
-                        if (result) {
-                            const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
-                            this._isSearch[i] = "search";
-                        }
-                    }
-                    else {
-                        result = this._results[i];
-                        if (result) {
-                            const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            this._visibleElements[i] = <SearchItem doc={result[0]} query={this._searchString} key={result[0][Id]} lines={result[2]} highlighting={highlights} />;
-                            this._isSearch[i] = "search";
-                        }
-                    }
-                }
-            }
-        }
-        if (this._maxSearchIndex >= this._numTotalResults) {
-            this._visibleElements.length = this._results.length;
-            this._isSearch.length = this._results.length;
-        }
-    }
-
-    @computed
-    get resFull() { return this._numTotalResults <= 8; }
-
-    @computed
-    get resultHeight() { return this._numTotalResults * 70; }
-
-    render() {
-        const isEditing = this.editingMetadata;
-        return !this.content ? (null) : (
-            <div style={{ pointerEvents: "all" }}>
-                <ContentFittingDocumentView {...this.props}
-                    Document={this.content}
-                    rootSelected={returnFalse}
-                    bringToFront={returnFalse}
-                    ContainingCollectionDoc={undefined}
-                    ContainingCollectionView={undefined}
-                    NativeWidth={returnZero}
-                    NativeHeight={returnZero}
-                    parentActive={this.props.active}
-                    ScreenToLocalTransform={this.props.ScreenToLocalTransform}>
-                </ContentFittingDocumentView>
-                <div
-                    style={{
-                        position: "absolute",
-                        right: 0,
-                        width: 20,
-                        height: 20,
-                        background: "black",
-                        pointerEvents: "all",
-                        opacity: 1,
-                        transition: "0.4s opacity ease",
-                        zIndex: 99,
-                        top: 0,
-                    }}
-                    title={"Add Metadata"}
-                    onClick={action(() => this.editingMetadata = !this.editingMetadata)}
-                />
-                <div className="editableclass" onKeyPress={this.enter} style={{ opacity: isEditing ? 1 : 0, pointerEvents: isEditing ? "auto" : "none", transition: "0.4s opacity ease", position: "absolute", top: 0, left: 0, height: 20, width: "-webkit-fill-available" }}>
-                    <EditableView
-                        contents={this.query}
-                        SetValue={this.updateKey}
-                        GetValue={() => ""}
-                    />
-                </div>
-            </div >
-        );
-    }
-
-}
\ No newline at end of file
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index ecd20eb06..6e19bb029 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -242,7 +242,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         //     </div>
         // );   
         trace();
-        let positions = [];
+        const positions = [];
         if (StrCast(this.props.Document._searchString) !== "") {
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
             let term = "";
@@ -257,7 +257,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                     term = String(NumCast(cfield));
                 }
             }
-            let search = StrCast(this.props.Document._searchString)
+            let search = StrCast(this.props.Document._searchString);
             let start = term.indexOf(search) as number;
             let tally = 0;
             if (start !== -1) {
@@ -873,3 +873,83 @@ export class CollectionSchemaCheckboxCell extends CollectionSchemaCell {
         );
     }
 }
+
+
+@observer
+export class CollectionSchemaButtons extends CollectionSchemaCell {
+
+    render() {
+        // const reference = React.createRef<HTMLDivElement>();
+        // const onItemDown = (e: React.PointerEvent) => {
+        //     (!this.props.CollectionView || !this.props.CollectionView.props.isSelected() ? undefined :
+        //         SetupDrag(reference, () => this._document, this.props.moveDocument, this.props.Document.schemaDoc ? "copy" : undefined)(e));
+        // };
+        let doc = this.props.rowProps.original;
+        let buttons = <div style={{
+            paddingTop: 8,
+            paddingLeft: 3,
+        }}><button onClick={() => {
+            console.log(doc);
+            console.log(doc.searchMatch);
+            doc.searchMatch = false;
+            console.log(doc.searchMatch);
+            setTimeout(() => doc.searchMatch = true, 0);
+            console.log(doc.searchMatch);
+            doc.searchIndex = NumCast(doc.searchIndex);
+        }} style={{ padding: 2, left: 77 }}>
+                <FontAwesomeIcon icon="arrow-up" size="sm" />
+            </button>
+            <button onClick={() => {
+                {
+                    console.log(doc);
+                    console.log(doc.searchMatch2);
+                    doc.searchMatch2 = false;
+                    console.log(doc.searchMatch2);
+                    setTimeout(() => doc.searchMatch2 = true, 0);
+                    console.log(doc.searchMatch2);
+                    doc.searchIndex = NumCast(doc.searchIndex);
+                }
+            }} style={{ padding: 2 }}>
+                <FontAwesomeIcon icon="arrow-down" size="sm" />
+            </button></div>;
+        const type = StrCast(doc.type);
+        console.log(StrCast(doc.type));
+        if (type === "pdf") {
+            buttons = <div><button
+                style={{
+                    position: "relative",
+                    height: 30,
+                    width: 28,
+                    left: 1,
+                }}
+
+                onClick={() => {
+                    console.log(doc);
+                    console.log(doc.searchMatch);
+                    doc.searchMatch = false;
+                    console.log(doc.searchMatch);
+                    setTimeout(() => doc.searchMatch = true, 0);
+                    console.log(doc.searchMatch);
+                    doc.searchIndex = NumCast(doc.searchIndex);
+                }}>
+                <FontAwesomeIcon icon="arrow-down" size="sm" />
+            </button></div >
+        }
+        else if (type !== "rtf") {
+            console.log("sad");
+            buttons = undefined;
+        }
+
+        if (BoolCast(this.props.Document._searchDoc) === true) {
+
+        }
+        else {
+            buttons = undefined;
+        }
+
+        return (
+            <div> {buttons}</div>
+        );
+    }
+}
+
diff --git a/src/client/views/collections/CollectionSchemaHeaders.tsx b/src/client/views/collections/CollectionSchemaHeaders.tsx
index 5d7ab2c61..e65adcf76 100644
--- a/src/client/views/collections/CollectionSchemaHeaders.tsx
+++ b/src/client/views/collections/CollectionSchemaHeaders.tsx
@@ -302,7 +302,7 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
     @action
     onSelect = (key: string): void => {
         if (key.slice(0, this._key.length) === this._key && this._key !== key) {
-            let filter = key.slice(this._key.length - key.length);
+            const filter = key.slice(this._key.length - key.length);
             this.props.onSelect(this._key, this._key, this.props.addNew, filter);
         }
         else {
@@ -395,12 +395,10 @@ export class KeysDropdown extends React.Component<KeysDropdownProps> {
 
     renderFilterOptions = (): JSX.Element[] | JSX.Element => {
         if (!this._isOpen) return <></>;
-
         const keyOptions: string[] = [];
-        console.log(this._searchTerm.slice(this._key.length))
-        let temp = this._searchTerm.slice(this._key.length);
+        const temp = this._searchTerm.slice(this._key.length);
         this.props.docs?.forEach((doc) => {
-            let key = StrCast(doc[this._key]);
+            const key = StrCast(doc[this._key]);
             if (keyOptions.includes(key) === false && key.includes(temp)) {
                 keyOptions.push(key);
             }
diff --git a/src/client/views/collections/CollectionSchemaView.scss b/src/client/views/collections/CollectionSchemaView.scss
index 93878d799..2dcd6d6c0 100644
--- a/src/client/views/collections/CollectionSchemaView.scss
+++ b/src/client/views/collections/CollectionSchemaView.scss
@@ -93,7 +93,7 @@
     }
 
     .rt-tbody {
-        width: calc(100% - 2px);
+        width: 100%;
         direction: rtl;
         overflow: visible;
     }
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 88241f519..bf3129a8a 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -130,9 +130,60 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
             let childDocs = viewSpecScript ? docs.filter(d => viewSpecScript.script.run({ doc: d }, console.log).result) : docs;
 
             const searchDocs = DocListCast(this.props.Document._searchDocs);
+            // if (searchDocs !== undefined && searchDocs.length > 0) {
+            //     let newdocs: Doc[] = [];
+            //     childDocs.forEach((el) => {
+            //         searchDocs.includes(el) ? newdocs.push(el) : undefined;
+            //     });
+            //     childDocs = newdocs;
+            // }
+
+            let docsforFilter: Doc[] = childDocs;
             if (searchDocs !== undefined && searchDocs.length > 0) {
-                childDocs = searchDocs;
+                docsforFilter = [];
+                // let newdocs: Doc[] = [];
+                // let newarray: Doc[] = [];
+                //while (childDocs.length > 0) {
+                //newarray = [];
+                childDocs.forEach((d) => {
+                    if (d.data !== undefined) {
+                        console.log(d);
+                        let newdocs = DocListCast(d.data);
+                        if (newdocs.length > 0) {
+                            let vibecheck = false;
+
+                            let newarray: Doc[] = [];
+
+                            while (newdocs.length > 0) {
+                                newarray = [];
+                                newdocs.forEach((t) => {
+                                    if (d.data !== undefined) {
+                                        let newdocs = DocListCast(t.data);
+                                        newdocs.forEach((newdoc) => {
+                                            newarray.push(newdoc);
+                                        });
+                                    }
+                                    if (searchDocs.includes(t)) {
+                                        vibecheck = true;
+                                    }
+                                });
+                                newdocs = newarray;
+                            }
+                            if (vibecheck === true) {
+                                docsforFilter.push(d);
+                            }
+                        }
+                    }
+                    if (searchDocs.includes(d)) {
+                        docsforFilter.push(d);
+                    }
+                });
+                //childDocs = newarray;
+                //}
             }
+            childDocs = docsforFilter;
+
+
             const docFilters = this.docFilters();
             const docRangeFilters = this.props.ignoreFields?.includes("_docRangeFilters") ? [] : Cast(this.props.Document._docRangeFilters, listSpec("string"), []);
 
diff --git a/src/client/views/collections/SchemaTable.tsx b/src/client/views/collections/SchemaTable.tsx
index 9d02807fd..8b7717ad1 100644
--- a/src/client/views/collections/SchemaTable.tsx
+++ b/src/client/views/collections/SchemaTable.tsx
@@ -19,7 +19,7 @@ import { undoBatch } from "../../util/UndoManager";
 import { COLLECTION_BORDER_WIDTH } from '../../views/globalCssVariables.scss';
 import { ContextMenu } from "../ContextMenu";
 import '../DocumentDecorations.scss';
-import { CellProps, CollectionSchemaCell, CollectionSchemaCheckboxCell, CollectionSchemaDocCell, CollectionSchemaNumberCell, CollectionSchemaStringCell, CollectionSchemaImageCell, CollectionSchemaListCell, CollectionSchemaDateCell } from "./CollectionSchemaCells";
+import { CellProps, CollectionSchemaCell, CollectionSchemaCheckboxCell, CollectionSchemaDocCell, CollectionSchemaNumberCell, CollectionSchemaStringCell, CollectionSchemaImageCell, CollectionSchemaListCell, CollectionSchemaDateCell, CollectionSchemaButtons } from "./CollectionSchemaCells";
 import { CollectionSchemaAddColumnHeader, KeysDropdown } from "./CollectionSchemaHeaders";
 import { MovableColumn, MovableRow } from "./CollectionSchemaMovableTableHOC";
 import "./CollectionSchemaView.scss";
@@ -160,7 +160,7 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
         const focusedCol = this._focusedCell.col;
         const isEditable = !this.props.headerIsEditing;
 
-        if (this.childDocs.reduce((found, doc) => found || doc.type === "collection", false)) {
+        if (this.childDocs.reduce((found, doc) => found || doc.type === "nnnnn", false)) {
             columns.push(
                 {
                     expander: true,
@@ -283,12 +283,34 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
             Header: <CollectionSchemaAddColumnHeader createColumn={this.createColumn} />,
             accessor: (doc: Doc) => 0,
             id: "add",
-            Cell: (rowProps: CellInfo) => <div> <button onClick={(e) => this.nextHighlight(e, this.props.Document)} style={{ padding: 2, left: 77 }}>
-                <FontAwesomeIcon icon="arrow-up" size="sm" />
-            </button>
-                <button onClick={(e) => this.nextHighlight2(e, this.props.Document)} style={{ padding: 2, left: 87 }}>
-                    <FontAwesomeIcon icon="arrow-down" size="sm" />
-                </button></div>,
+            Cell: (rowProps: CellInfo) => {
+                const rowIndex = rowProps.index;
+                const columnIndex = this.props.columns.map(c => c.heading).indexOf(rowProps.column.id!);
+                const isFocused = focusedRow === rowIndex && focusedCol === columnIndex && tableIsFocused;
+                const props: CellProps = {
+                    row: rowIndex,
+                    col: columnIndex,
+                    rowProps: rowProps,
+                    isFocused: isFocused,
+                    changeFocusedCellByIndex: this.changeFocusedCellByIndex,
+                    CollectionView: this.props.CollectionView,
+                    ContainingCollection: this.props.ContainingCollectionView,
+                    Document: this.props.Document,
+                    fieldKey: this.props.fieldKey,
+                    renderDepth: this.props.renderDepth,
+                    addDocTab: this.props.addDocTab,
+                    pinToPres: this.props.pinToPres,
+                    moveDocument: this.props.moveDocument,
+                    setIsEditing: this.setCellIsEditing,
+                    isEditable: isEditable,
+                    setPreviewDoc: this.props.setPreviewDoc,
+                    setComputed: this.setComputed,
+                    getField: this.getField,
+                    showDoc: this.showDoc,
+                };
+
+                return <CollectionSchemaButtons {...props} />;
+            },
             width: 28,
             resizable: false
         });
@@ -301,16 +323,17 @@ export class SchemaTable extends React.Component<SchemaTableProps> {
     nextHighlight = (e: React.MouseEvent, doc: Doc) => {
         e.preventDefault();
         e.stopPropagation();
-
         doc.searchMatch = false;
+        console.log(doc.searchMatch);
         setTimeout(() => doc.searchMatch = true, 0);
+        console.log(doc.searchMatch);
+
         doc.searchIndex = NumCast(doc.searchIndex);
     }
 
     @action
-    nextHighlight2 = (e: React.MouseEvent, doc: Doc) => {
-        e.preventDefault();
-        e.stopPropagation();
+    nextHighlight2 = (doc: Doc) => {
+
         doc.searchMatch2 = false;
         setTimeout(() => doc.searchMatch2 = true, 0);
         doc.searchIndex = NumCast(doc.searchIndex);
diff --git a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
index f5e0cd077..031dbf884 100644
--- a/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
+++ b/src/client/views/collections/collectionFreeForm/PropertiesView.tsx
@@ -539,7 +539,7 @@ export class PropertiesView extends React.Component<PropertiesViewProps> {
 
     getField(key: string) {
         //if (this.selectedDoc) {
-        return Field.toString(this.selectedDoc[key] as Field);
+        return Field.toString(this.selectedDoc![key] as Field);
         // } else {
         //     return undefined as Opt<string>;
         // }
diff --git a/src/client/views/nodes/DocumentContentsView.tsx b/src/client/views/nodes/DocumentContentsView.tsx
index c724ba50b..1282bbee5 100644
--- a/src/client/views/nodes/DocumentContentsView.tsx
+++ b/src/client/views/nodes/DocumentContentsView.tsx
@@ -25,7 +25,6 @@ import { KeyValueBox } from "./KeyValueBox";
 import { PDFBox } from "./PDFBox";
 import { PresBox } from "./PresBox";
 import { SearchBox } from "../search/SearchBox";
-import { SearchItem } from "../search/SearchItem"
 import { ColorBox } from "./ColorBox";
 import { DashWebRTCVideo } from "../webcam/DashWebRTCVideo";
 import { LinkAnchorBox } from "./LinkAnchorBox";
@@ -192,7 +191,7 @@ export class DocumentContentsView extends React.Component<DocumentViewProps & {
                 components={{
                     FormattedTextBox, ImageBox, DirectoryImportBox, FontIconBox, LabelBox, SliderBox, FieldView,
                     CollectionFreeFormView, CollectionDockingView, CollectionSchemaView, CollectionView, WebBox, KeyValueBox,
-                    PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, SearchBox, SearchItem,
+                    PDFBox, VideoBox, AudioBox, PresBox, YoutubeBox, PresElementBox, SearchBox,
                     ColorBox, DashWebRTCVideo, LinkAnchorBox, InkingStroke, DocHolderBox, LinkBox, ScriptingBox,
                     ScreenshotBox, HTMLtag, ComparisonBox
                 }}
diff --git a/src/client/views/nodes/LabelBox.tsx b/src/client/views/nodes/LabelBox.tsx
index 302d66cc5..10a164158 100644
--- a/src/client/views/nodes/LabelBox.tsx
+++ b/src/client/views/nodes/LabelBox.tsx
@@ -70,7 +70,7 @@ export class LabelBox extends ViewBoxBaseComponent<FieldViewProps, LabelDocument
         const missingParams = params?.filter(p => !this.paramsDoc[p]);
         params?.map(p => DocListCast(this.paramsDoc[p])); // bcz: really hacky form of prefetching ... 
         return (
-            <div className="labelBox-outerDiv" onClick={() => runInAction(() => { this.clicked = !this.clicked; this.clicked ? this.backColor = StrCast(this.layoutDoc.hovercolor) : this.backColor = "unset" })} onMouseLeave={() => runInAction(() => { !this.clicked ? this.backColor = "unset" : null })}
+            <div className="labelBox-outerDiv" onClick={() => runInAction(() => { this.clicked = !this.clicked; this.clicked ? this.backColor = StrCast(this.layoutDoc.hovercolor) : this.backColor = "unset"; })} onMouseLeave={() => runInAction(() => { !this.clicked ? this.backColor = "unset" : null; })}
                 onMouseOver={() => runInAction(() => { this.backColor = StrCast(this.layoutDoc.hovercolor); })} ref={this.createDropTarget} onContextMenu={this.specificContextMenu}
                 style={{ boxShadow: this.layoutDoc.opacity ? StrCast(this.layoutDoc.boxShadow) : "" }}>
                 <div className="labelBox-mainButton" style={{
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index 79cf5c5fd..b21596493 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -309,7 +309,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
             this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
 
-            console.log(this._searchIndex, length);
             if (this._searchIndex > 1) {
                 this._searchIndex += -2;
             }
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index b76955815..acdd8d047 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -39,14 +39,6 @@ export enum Keys {
     TEXT = "text"
 }
 
-export interface filterData {
-    deletedDocsStatus: boolean;
-    authorFieldStatus: boolean;
-    titleFieldStatus: boolean;
-    basicWordStatus: boolean;
-    icons: string[];
-}
-
 type SearchBoxDocument = makeInterface<[typeof documentSchema, typeof searchSchema]>;
 const SearchBoxDocument = makeInterface(documentSchema, searchSchema);
 
@@ -89,55 +81,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable private newAssign: boolean = true;
 
     constructor(props: any) {
-
         super(props);
         SearchBox.Instance = this;
-        if (!_scriptingGlobals.hasOwnProperty("handleNodeChange")) {
-            Scripting.addGlobal(this.handleNodeChange);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("handleKeyChange")) {
-            Scripting.addGlobal(this.handleKeyChange);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("handleWordQueryChange")) {
-            Scripting.addGlobal(this.handleWordQueryChange);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("updateIcon")) {
-            Scripting.addGlobal(this.updateIcon);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("updateTitleStatus")) {
-            Scripting.addGlobal(this.updateTitleStatus);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("updateAuthorStatus")) {
-            Scripting.addGlobal(this.updateAuthorStatus);
-        }
-        if (!_scriptingGlobals.hasOwnProperty("updateDeletedStatus")) {
-            Scripting.addGlobal(this.updateDeletedStatus);
-        }
-
-
         this.resultsScrolled = this.resultsScrolled.bind(this);
 
-        // new PrefetchProxy(Docs.Create.SearchItemBoxDocument({
-        //     title: "search item template",
-        //     backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data"
-        // }));
-
-
-        // if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
-        //     Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
-        //     // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
-        //     // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
-        //     // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
-        //     // stored on each pres element.  
-        //     (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
-        //         { field: "string", data: Doc.name, container: Doc.name });
-        // }
     }
     @observable setupButtons = false;
     componentDidMount = () => {
-        if (this.setupButtons == false) {
+        if (this.setupButtons === false) {
 
-            runInAction(() => this.setupButtons == true);
+            runInAction(() => this.setupButtons = true);
         }
         if (this.inputRef.current) {
             this.inputRef.current.focus();
@@ -163,7 +116,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
 
     @action
-    getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc)
+    getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc);
 
 
     @observable newsearchstring: string = "";
@@ -203,9 +156,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     enter = (e: React.KeyboardEvent) => {
         if (e.key === "Enter") {
             this.layoutDoc._searchString = this.newsearchstring;
-            // if (this._icons !== this._allIcons) {
-            //     runInAction(() => { this.expandedBucket = false });
-            // }
+
             if (StrCast(this.layoutDoc._searchString) !== "") {
                 console.log("OPEN");
                 runInAction(() => { this.open = true });
@@ -213,11 +164,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             else {
                 console.log("CLOSE");
                 runInAction(() => { this.open = false });
-
             }
             this.submitSearch();
-
-
         }
     }
 
@@ -365,46 +313,58 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 this.props.Document.selectedDoc = selectedCollection.props.Document;
             }
             let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
-            let found: [Doc, string[], string[]][] = [];
-            let docsforFilter: Doc[] = []
+            const found: [Doc, string[], string[]][] = [];
+            const docsforFilter: Doc[] = []
             let newarray: Doc[] = [];
 
             while (docs.length > 0) {
                 newarray = [];
                 docs.forEach((d) => {
-                    if (d.data != undefined) {
+                    if (d.data !== undefined) {
                         let newdocs = DocListCast(d.data);
                         newdocs.forEach((newdoc) => {
                             newarray.push(newdoc);
 
                         });
                     }
-
-
-                    let hlights: string[] = [];
-
+                    const hlights: string[] = [];
                     const protos = Doc.GetAllPrototypes(d);
-                    let proto = protos[protos.length - 1];
                     protos.forEach(proto => {
                         Object.keys(proto).forEach(key => {
-                            // console.log(key, d[key]);
                             if (StrCast(d[key]).includes(query) && !hlights.includes(key)) {
                                 hlights.push(key);
                             }
-                        })
+                        });
                     });
                     if (hlights.length > 0) {
                         found.push([d, hlights, []]);
                         docsforFilter.push(d);
-                    };
+                    }
                 });
                 docs = newarray;
             }
             this._results = found;
             this.docsforfilter = docsforFilter;
             if (this.filter === true) {
-                console.log(docsforFilter);
                 selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
+                docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
+                while (docs.length > 0) {
+                    console.log("HIT");
+                    newarray = [];
+                    docs.forEach((d) => {
+                        if (d.data !== undefined) {
+                            console.log(d._searchDocs);
+                            d._searchDocs = new List<Doc>(docsforFilter);
+                            console.log(d);
+                            console.log(d._searchDocs);
+                            let newdocs = DocListCast(d.data);
+                            newdocs.forEach((newdoc) => {
+                                newarray.push(newdoc);
+                            });
+                        }
+                    });
+                    docs = newarray;
+                }
             }
             this._numTotalResults = found.length;
         }
@@ -468,7 +428,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @action
     submitSearch = async (reset?: boolean) => {
-        this.checkIcons();
         if (reset) {
             this.layoutDoc._searchString = "";
         }
@@ -644,13 +603,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 y += 300;
             }
         }
-        const filter: filterData = {
-            deletedDocsStatus: this._deletedDocsStatus,
-            authorFieldStatus: this._authorFieldStatus,
-            titleFieldStatus: this._titleFieldStatus,
-            basicWordStatus: this._basicWordStatus,
-            icons: this._icons,
-        }
         return Docs.Create.SearchDocument({ _autoHeight: true, _viewType: CollectionViewType.Schema, title: StrCast(this.layoutDoc._searchString), searchQuery: StrCast(this.layoutDoc._searchString) });
     }
 
@@ -693,7 +645,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         const endIndex = 30;
         //this._endIndex = endIndex === -1 ? 12 : endIndex;
         this._endIndex = 30;
-        let headers = new Set<string>(["title", "author", "text", "lastModified"]);
+        const headers = new Set<string>(["title", "author", "lastModified", "text"]);
         if ((this._numTotalResults === 0 || this._results.length === 0) && this._openNoResults) {
             if (this.noresults === "") {
                 this.noresults = "No search results :(";
@@ -734,7 +686,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (i < this._results.length) result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            let lines = new List<string>(result[2]);
+                            const lines = new List<string>(result[2]);
                             console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
@@ -751,7 +703,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         result = this._results[i];
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
-                            let lines = new List<string>(result[2]);
+                            const lines = new List<string>(result[2]);
                             highlights.forEach((item) => headers.add(item));
                             console.log(lines);
                             result[0].lines = lines;
@@ -769,9 +721,9 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 }
             }
         }
-        let schemaheaders: SchemaHeaderField[] = [];
+        const schemaheaders: SchemaHeaderField[] = [];
         this.headerscale = headers.size;
-        headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")))
+        headers.forEach((item) => schemaheaders.push(new SchemaHeaderField(item, "#f1efeb")));
         this.headercount = schemaheaders.length;
         this.props.Document._schemaHeaders = new List<SchemaHeaderField>(schemaheaders);
         if (this._maxSearchIndex >= this._numTotalResults) {
@@ -784,8 +736,8 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @observable headerscale: number = 0;
 
     findCommonElements(arr2: string[]) {
-        let arr1 = ["layout", "data"];
-        return arr1.some(item => arr2.includes(item))
+        const arr1 = ["layout", "data"];
+        return arr1.some(item => arr2.includes(item));
     }
 
     @computed
@@ -794,210 +746,10 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
     @computed
     get resultHeight() { return this._numTotalResults * 70; }
 
-    //if true, any keywords can be used. if false, all keywords are required.
-    @action.bound
-    handleWordQueryChange = async () => {
-        this._collectionStatus = !this._collectionStatus;
-        if (this._collectionStatus) {
-            let doc = await Cast(this.props.Document.keywords, Doc)
-            doc!.backgroundColor = "grey";
-
-        }
-        else {
-            let doc = await Cast(this.props.Document.keywords, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
-    @action.bound
-    handleNodeChange = async () => {
-        this._nodeStatus = !this._nodeStatus;
-
-        if (this._nodeStatus) {
-            this.expandSection(`node${this.props.Document[Id]}`);
-            let doc = await Cast(this.props.Document.nodes, Doc)
-            doc!.backgroundColor = "grey";
-
-        }
-        else {
-            this.collapseSection(`node${this.props.Document[Id]}`);
-            let doc = await Cast(this.props.Document.nodes, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
-    @action.bound
-    handleKeyChange = async () => {
-        this._keyStatus = !this._keyStatus;
-        if (this._keyStatus) {
-            this.expandSection(`key${this.props.Document[Id]}`);
-            let doc = await Cast(this.props.Document.keys, Doc)
-            doc!.backgroundColor = "grey";
-        }
-        else {
-            this.collapseSection(`key${this.props.Document[Id]}`);
-            let doc = await Cast(this.props.Document.keys, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
-    @action.bound
-    handleFilterChange = () => {
-        this._filterOpen = !this._filterOpen;
-        if (this._filterOpen) {
-            this.expandSection(`filterhead${this.props.Document[Id]}`);
-            document.getElementById(`filterhead${this.props.Document[Id]}`)!.style.padding = "5";
-            console.log(this.props.Document[Id])
-        }
-        else {
-            this.collapseSection(`filterhead${this.props.Document[Id]}`);
-
-
-        }
-    }
-
-    @computed
-    get menuHeight() {
-        return document.getElementById("hi")?.clientHeight;
-    }
-
-
-    collapseSection(thing: string) {
-        const id = this.props.Document[Id];
-        const element = document.getElementById(thing)!;
-        // get the height of the element's inner content, regardless of its actual size
-        const sectionHeight = element.scrollHeight;
-
-        // temporarily disable all css transitions
-        const elementTransition = element.style.transition;
-        element.style.transition = '';
-
-        // on the next frame (as soon as the previous style change has taken effect),
-        // explicitly set the element's height to its current pixel height, so we 
-        // aren't transitioning out of 'auto'
-        requestAnimationFrame(function () {
-            element.style.height = sectionHeight + 'px';
-            element.style.transition = elementTransition;
-
-            // on the next frame (as soon as the previous style change has taken effect),
-            // have the element transition to height: 0
-            requestAnimationFrame(function () {
-                element.style.height = 0 + 'px';
-                thing === `filterhead${id}` ? document.getElementById(`filterhead${id}`)!.style.padding = "0" : null;
-            });
-        });
-
-        // mark the section as "currently collapsed"
-        element.setAttribute('data-collapsed', 'true');
-    }
-
-    expandSection(thing: string) {
-        const element = document.getElementById(thing)!;
-        // get the height of the element's inner content, regardless of its actual size
-        const sectionHeight = element.scrollHeight;
-
-        // have the element transition to the height of its inner content
-        element.style.height = sectionHeight + 'px';
-
-        // when the next css transition finishes (which should be the one we just triggered)
-        element.addEventListener('transitionend', function handler(e) {
-            // remove this event listener so it only gets triggered once
-            element.removeEventListener('transitionend', handler);
-
-            // remove "height" from the element's inline styles, so it can return to its initial value
-            element.style.height = "auto";
-            //element.style.height = undefined;
-        });
-
-        // mark the section as "currently not collapsed"
-        element.setAttribute('data-collapsed', 'false');
-
-    }
-
-    autoset(thing: string) {
-        const element = document.getElementById(thing)!;
-        element.removeEventListener('transitionend', function (e) { });
-
-        // remove "height" from the element's inline styles, so it can return to its initial value
-        element.style.height = "auto";
-        //element.style.height = undefined;
-    }
-
-    @action.bound
-    updateTitleStatus = async () => {
-        this._titleFieldStatus = !this._titleFieldStatus;
-        if (this._titleFieldStatus) {
-            let doc = await Cast(this.props.Document.title, Doc)
-            doc!.backgroundColor = "grey";
-        }
-        else {
-            let doc = await Cast(this.props.Document.title, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
-    @action.bound
-    updateAuthorStatus = async () => {
-        this._authorFieldStatus = !this._authorFieldStatus;
-        if (this._authorFieldStatus) {
-            let doc = await Cast(this.props.Document.author, Doc)
-            doc!.backgroundColor = "grey";
-        }
-        else {
-            let doc = await Cast(this.props.Document.author, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
-    @action.bound
-    updateDeletedStatus = async () => {
-        this._deletedDocsStatus = !this._deletedDocsStatus;
-        if (this._deletedDocsStatus) {
-            let doc = await Cast(this.props.Document.deleted, Doc)
-            doc!.backgroundColor = "grey";
-        }
-        else {
-            let doc = await Cast(this.props.Document.deleted, Doc)
-            doc!.backgroundColor = "black";
-        }
-    }
-
     addButtonDoc = (doc: Doc) => Doc.AddDocToList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
     remButtonDoc = (doc: Doc) => Doc.RemoveDocFromList(CurrentUserUtils.UserDocument.expandingButtons as Doc, "data", doc);
     moveButtonDoc = (doc: Doc, targetCollection: Doc | undefined, addDocument: (document: Doc) => boolean) => this.remButtonDoc(doc) && addDocument(doc);
 
-    @action.bound
-    updateIcon = async (icon: string) => {
-        if (this._icons.includes(icon)) {
-            _.pull(this._icons, icon);
-            let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
-            console.log(cap);
-            let doc = await Cast(this.props.Document[cap], Doc)
-            doc!.backgroundColor = "black";
-        }
-        else {
-            this._icons.push(icon);
-            let cap = icon.charAt(0).toUpperCase() + icon.slice(1)
-            let doc = await Cast(this.props.Document[cap], Doc)
-            doc!.backgroundColor = "grey";
-        }
-    }
-
-    @action.bound
-    checkIcons = async () => {
-        for (let i = 0; i < this._allIcons.length; i++) {
-
-            let cap = this._allIcons[i].charAt(0).toUpperCase() + this._allIcons[i].slice(1)
-            let doc = await Cast(this.props.Document[cap], Doc)
-            if (this._icons.includes(this._allIcons[i])) {
-                doc!.backgroundColor = "grey";
-            }
-            else {
-                doc!.backgroundColor = "black";
-            }
-        }
-    }
-
     @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
 
     getTransform = () => {
@@ -1016,16 +768,15 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     @observable filter = false;
 
-
     //Make id layour document
     render() {
         this.props.Document._chromeStatus === "disabled";
         this.props.Document._searchDoc = true;
-        let cols = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
+        const cols = Cast(this.props.Document._schemaHeaders, listSpec(SchemaHeaderField), []).length;
         let length = 0;
         cols > 5 ? length = 1076 : length = cols * 205 + 51;
         let height = 0;
-        let rows = this.children;
+        const rows = this.children;
         rows > 8 ? height = 31 + 31 * 8 : height = 31 * rows + 31;
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
@@ -1045,10 +796,52 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                 this.filter = !this.filter && !this.scale;
                                 if (this.filter === true && this.currentSelectedCollection !== undefined) {
                                     this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
+                                    let newarray: Doc[] = [];
+                                    let docs: Doc[] = [];
+                                    docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
+                                    while (docs.length > 0) {
+                                        console.log("HIT");
+                                        newarray = [];
+                                        docs.forEach((d) => {
+                                            if (d.data !== undefined) {
+                                                console.log(d._searchDocs);
+                                                d._searchDocs = new List<Doc>(this.docsforfilter);
+                                                console.log(d);
+                                                console.log(d._searchDocs);
+                                                let newdocs = DocListCast(d.data);
+                                                newdocs.forEach((newdoc) => {
+                                                    newarray.push(newdoc);
+                                                });
+                                            }
+                                        });
+                                        docs = newarray;
+                                    }
+
                                     this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
                                     this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
                                 }
                                 else if (this.filter === false && this.currentSelectedCollection !== undefined) {
+                                    let newarray: Doc[] = [];
+                                    let docs: Doc[] = [];
+                                    docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
+                                    while (docs.length > 0) {
+                                        console.log("HIT");
+                                        newarray = [];
+                                        docs.forEach((d) => {
+                                            if (d.data !== undefined) {
+                                                console.log(d._searchDocs);
+                                                d._searchDocs = new List<Doc>();
+                                                console.log(d);
+                                                console.log(d._searchDocs);
+                                                let newdocs = DocListCast(d.data);
+                                                newdocs.forEach((newdoc) => {
+                                                    newarray.push(newdoc);
+                                                });
+                                            }
+                                        });
+                                        docs = newarray;
+                                    }
+
                                     this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
                                     this.currentSelectedCollection.props.Document._docFilters = undefined;
                                     this.props.Document.selectedDoc = undefined;
@@ -1075,12 +868,32 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                                     this.scale = !this.scale;
                                                     this.dataDoc[this.fieldKey] = new List<Doc>([]);
                                                     if (this.currentSelectedCollection !== undefined) {
+                                                        let newarray: Doc[] = [];
+                                                        let docs: Doc[] = [];
+                                                        docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
+                                                        while (docs.length > 0) {
+                                                            console.log("HIT");
+                                                            newarray = [];
+                                                            docs.forEach((d) => {
+                                                                if (d.data !== undefined) {
+                                                                    console.log(d._searchDocs);
+                                                                    d._searchDocs = new List<Doc>();
+                                                                    console.log(d);
+                                                                    console.log(d._searchDocs);
+                                                                    let newdocs = DocListCast(d.data);
+                                                                    newdocs.forEach((newdoc) => {
+                                                                        newarray.push(newdoc);
+                                                                    });
+                                                                }
+                                                            });
+                                                            docs = newarray;
+                                                        }
                                                         this.currentSelectedCollection.props.Document._docFilters = undefined;
                                                         this.currentSelectedCollection.props.Document._searchDocs = undefined;
                                                         this.currentSelectedCollection = undefined;
                                                     }
                                                     this.submitSearch();
-                                                })
+                                                });
                                             }} />
                                         Collection
                                     </label>
@@ -1093,12 +906,32 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                                     this.dataDoc[this.fieldKey] = new List<Doc>([]);
                                                     this.filter = false;
                                                     if (this.currentSelectedCollection !== undefined) {
+                                                        let newarray: Doc[] = [];
+                                                        let docs: Doc[] = [];
+                                                        docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
+                                                        while (docs.length > 0) {
+                                                            console.log("HIT");
+                                                            newarray = [];
+                                                            docs.forEach((d) => {
+                                                                if (d.data !== undefined) {
+                                                                    console.log(d._searchDocs);
+                                                                    d._searchDocs = new List<Doc>();
+                                                                    console.log(d);
+                                                                    console.log(d._searchDocs);
+                                                                    let newdocs = DocListCast(d.data);
+                                                                    newdocs.forEach((newdoc) => {
+                                                                        newarray.push(newdoc);
+                                                                    });
+                                                                }
+                                                            });
+                                                            docs = newarray;
+                                                        }
                                                         this.currentSelectedCollection.props.Document._docFilters = undefined;
                                                         this.currentSelectedCollection.props.Document._searchDocs = undefined;
                                                         this.currentSelectedCollection = undefined;
                                                     }
                                                     this.submitSearch();
-                                                })
+                                                });
                                             }} />
                                             DB
                                     </label>
@@ -1140,13 +973,3 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         );
     }
 }
-
-Scripting.addGlobal(function lookupSearchBoxField(container: Doc, field: string, data: Doc) {
-    // if (field === 'indexInPres') return DocListCast(container[StrCast(container.presentationFieldKey)]).indexOf(data);
-    // if (field === 'presCollapsedHeight') return container._viewType === CollectionViewType.Schema ? 50 : 46;
-    // if (field === 'presStatus') return container.presStatus;
-    // if (field === '_itemIndex') return container._itemIndex;
-    if (field == "query") return container._searchString;
-    return undefined;
-});
-
diff --git a/src/client/views/search/SearchItem.scss b/src/client/views/search/SearchItem.scss
deleted file mode 100644
index 5ce022d41..000000000
--- a/src/client/views/search/SearchItem.scss
+++ /dev/null
@@ -1,186 +0,0 @@
-@import "../globalCssVariables";
-
-.searchItem-overview {
-    display: flex;
-    flex-direction: reverse;
-    justify-content: flex-end;
-    z-index: 0;
-}
-
-.searchBox-placeholder,
-.searchItem-overview .searchItem {
-    width: 100%;
-    background: $light-color-secondary;
-    padding: 8px;
-    min-height: 46px;
-    height:46px;
-    max-height: 150px;
-    height: auto;
-    z-index: 0;
-    display: flex;
-    overflow: visible;
-    box-shadow: rgb(156, 147, 150) 0.2vw 0.2vw 0.8vw;
-
-    .searchItem-body {
-        display: flex;
-        flex-direction: row;
-        width: 100%;
-
-        .searchItem-title-container {
-            width: 100%;
-            overflow: hidden;
-
-            .searchItem-title {
-                text-transform: uppercase;
-                text-align: left;
-                width: 100%;
-                font-weight: bold;
-            }
-        }
-
-        .searchItem-info {
-            display: flex;
-            justify-content: flex-end;
-
-            .icon-icons {
-                width: 50px
-            }
-
-            .icon-live {
-                width: 175px;
-                height: 0px;
-            }
-
-            .icon-icons {
-                height:auto;
-            }
-            .icon-icons,
-            .icon-live {
-                margin: auto;
-                overflow: visible;
-
-                .searchItem-type {
-                    display: inline-block;
-                    width: 100%;
-                    position: absolute;
-                    justify-content: center;
-                    align-items: center;
-                    position: relative;
-                    margin-right: 5px;
-                }
-
-                .pdfBox-cont {
-                    overflow: hidden;
-
-                    img {
-                        width: 100% !important;
-                        height: auto !important;
-                    }
-                }
-
-                .searchItem-type:hover+.searchItem-label {
-                    opacity: 1;
-                }
-
-                .searchItem-label {
-                    font-size: 10;
-                    position: relative;
-                    right: 0px;
-                    text-transform: capitalize;
-                    opacity: 0;
-                    -webkit-transition: opacity 0.2s ease-in-out;
-                    -moz-transition: opacity 0.2s ease-in-out;
-                    -o-transition: opacity 0.2s ease-in-out;
-                    transition: opacity 0.2s ease-in-out;
-                }
-            }
-
-            .icon-live:hover {
-                .pdfBox-cont {
-                    img {
-                        width: 100% !important;
-                    }
-                }
-            }
-        }
-
-        .searchItem-info:hover {
-            width: 60%;
-        }
-    }
-}
-
-.searchItem:hover~.searchBox-instances,
-.searchBox-instances:hover,
-.searchBox-instances:active {
-    opacity: 1;
-    background: $lighter-alt-accent;
-}
-
-.searchItem:hover {
-    transition: all 0.2s;
-    background: $lighter-alt-accent;
-}
-
-.searchItem-highlighting {
-    overflow: hidden;
-    text-overflow: ellipsis;
-    white-space: pre;
-}
-
-.searchBox-instances {
-    opacity: 1;
-    width:40px;
-    height:40px;
-    background: gray;
-    transition: all 0.2s ease;
-    color: black;
-    overflow: hidden;
-    right:-100;
-    display:inline-block;
-}
-
-
-.searchItem-overview:hover {
-    z-index: 1;
-}
-
-.searchBox-placeholder {
-    min-height: 46px;
-    margin-left: 150px;
-    width: calc(100% - 150px);
-    text-transform: uppercase;
-    text-align: left;
-    font-weight: bold;
-}
-
-.collection {
-    display: flex;
-}
-
-.collection-item {
-    width: 35px;
-}
-
-.bucket-title{
-    width:auto;
-    padding: 5px;
-    height: auto;
-    top: -18;
-    z-index: 55;
-    position: absolute;
-}
-
-.bucket-expand{
-    bottom: 0;
-    position: absolute;
-    width: 100%;
-    height: 15;
-    transform:none;
-    .bucket-expand:hover{
-        transform:none;
-    }
-    button:hover{
-        transform:none;
-    }
-}
\ No newline at end of file
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
deleted file mode 100644
index b61ed450f..000000000
--- a/src/client/views/search/SearchItem.tsx
+++ /dev/null
@@ -1,556 +0,0 @@
-import React = require("react");
-import { library } from '@fortawesome/fontawesome-svg-core';
-import { faCaretUp, faChartBar, faFile, faFilePdf, faFilm, faFingerprint, faGlobeAsia, faImage, faLink, faMusic, faObjectGroup, faStickyNote } from '@fortawesome/free-solid-svg-icons';
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { action, computed, observable, runInAction, IReactionDisposer, reaction } from "mobx";
-import { observer } from "mobx-react";
-import { Doc, DocCastAsync } from "../../../fields/Doc";
-import { Id } from "../../../fields/FieldSymbols";
-import { Cast, NumCast, StrCast } from "../../../fields/Types";
-import { emptyFunction, emptyPath, returnFalse, Utils, returnTrue, returnOne, returnZero, returnEmptyString, returnEmptyFilter } from "../../../Utils";
-import { DocumentType } from "../../documents/DocumentTypes";
-import { DocumentManager } from "../../util/DocumentManager";
-import { DragManager, SetupDrag } from "../../util/DragManager";
-import { SearchUtil } from "../../util/SearchUtil";
-import { Transform } from "../../util/Transform";
-import { SEARCH_THUMBNAIL_SIZE } from "../../views/globalCssVariables.scss";
-import { CollectionDockingView } from "../collections/CollectionDockingView";
-import { CollectionViewType, CollectionView } from "../collections/CollectionView";
-import { ParentDocSelector } from "../collections/ParentDocumentSelector";
-import { ContextMenu } from "../ContextMenu";
-import { ContentFittingDocumentView } from "../nodes/ContentFittingDocumentView";
-import { SearchBox } from "./SearchBox";
-import "./SearchItem.scss";
-import "./SelectorContextMenu.scss";
-import { FieldViewProps, FieldView } from "../nodes/FieldView";
-import { ViewBoxBaseComponent } from "../DocComponent";
-import { makeInterface, createSchema, listSpec } from "../../../fields/Schema";
-import { documentSchema } from "../../../fields/documentSchemas";
-import { PrefetchProxy } from "../../../fields/Proxy";
-import { Docs } from "../../documents/Documents";
-import { ScriptField } from "../../../fields/ScriptField";
-import { CollectionStackingView } from "../collections/CollectionStackingView";
-
-export interface SearchItemProps {
-    doc: Doc;
-    query: string;
-    highlighting: string[];
-    lines: string[];
-}
-
-library.add(faCaretUp);
-library.add(faObjectGroup);
-library.add(faStickyNote);
-library.add(faFile);
-library.add(faFilePdf);
-library.add(faFilm);
-library.add(faMusic);
-library.add(faLink);
-library.add(faChartBar);
-library.add(faGlobeAsia, faFingerprint);
-
-@observer
-export class SelectorContextMenu extends React.Component<SearchItemProps> {
-    @observable private _docs: { col: Doc, target: Doc }[] = [];
-    @observable private _otherDocs: { col: Doc, target: Doc }[] = [];
-
-    constructor(props: SearchItemProps) {
-        super(props);
-        this.fetchDocuments();
-    }
-
-    async fetchDocuments() {
-        const aliases = (await SearchUtil.GetViewsOfDocument(this.props.doc)).filter(doc => doc !== this.props.doc);
-        const { docs } = await SearchUtil.Search("", true, { fq: `data_l:"${this.props.doc[Id]}"` });
-        const map: Map<Doc, Doc> = new Map;
-        const allDocs = await Promise.all(aliases.map(doc => SearchUtil.Search("", true, { fq: `data_l:"${doc[Id]}"` }).then(result => result.docs)));
-        allDocs.forEach((docs, index) => docs.forEach(doc => map.set(doc, aliases[index])));
-        docs.forEach(doc => map.delete(doc));
-        runInAction(() => {
-            this._docs = docs.filter(doc => !Doc.AreProtosEqual(doc, CollectionDockingView.Instance.props.Document)).map(doc => ({ col: doc, target: this.props.doc }));
-            this._otherDocs = Array.from(map.entries()).filter(entry => !Doc.AreProtosEqual(entry[0], CollectionDockingView.Instance.props.Document)).map(([col, target]) => ({ col, target }));
-
-        });
-    }
-
-    getOnClick({ col, target }: { col: Doc, target: Doc }) {
-        return () => {
-            col = Doc.IsPrototype(col) ? Doc.MakeDelegate(col) : col;
-            if (col._viewType === CollectionViewType.Freeform) {
-                const newPanX = NumCast(target.x) + NumCast(target._width) / 2;
-                const newPanY = NumCast(target.y) + NumCast(target._height) / 2;
-                col._panX = newPanX;
-                col._panY = newPanY;
-            }
-            CollectionDockingView.AddRightSplit(col);
-        };
-    }
-    render() {
-        return (
-            <div className="parents">
-                <p className="contexts">Contexts:</p>
-                {[...this._docs, ...this._otherDocs].map(doc => {
-                    const item = React.createRef<HTMLDivElement>();
-                    return <div className="collection" key={doc.col[Id] + doc.target[Id]} ref={item}>
-                        <div className="collection-item" onPointerDown={
-                            SetupDrag(item, () => doc.col, undefined, undefined, () => SearchBox.Instance.closeSearch())}>
-                            <FontAwesomeIcon icon={faStickyNote} />
-                        </div>
-                        <a onClick={this.getOnClick(doc)}>{doc.col.title}</a>
-                    </div>;
-                })}
-            </div>
-        );
-    }
-}
-
-export interface LinkMenuProps {
-    doc1: Doc;
-    doc2: Doc;
-}
-
-@observer
-export class LinkContextMenu extends React.Component<LinkMenuProps> {
-
-    highlightDoc = (doc: Doc) => () => Doc.BrushDoc(doc);
-
-    unHighlightDoc = (doc: Doc) => () => Doc.UnBrushDoc(doc);
-
-    getOnClick = (col: Doc) => () => CollectionDockingView.AddRightSplit(col);
-
-    render() {
-        return (
-            <div className="parents">
-                <p className="contexts">Anchors:</p>
-                <div className="collection"><a onMouseEnter={this.highlightDoc(this.props.doc1)} onMouseLeave={this.unHighlightDoc(this.props.doc1)} onClick={this.getOnClick(this.props.doc1)}>Doc 1: {this.props.doc2.title}</a></div>
-                <div><a onMouseEnter={this.highlightDoc(this.props.doc2)} onMouseLeave={this.unHighlightDoc(this.props.doc2)} onClick={this.getOnClick(this.props.doc2)}>Doc 2: {this.props.doc1.title}</a></div>
-            </div>
-        );
-    }
-
-}
-
-
-type SearchSchema = makeInterface<[typeof documentSchema]>;
-
-export const SearchSchema = createSchema({
-    targetDoc: Doc,
-});
-
-const SearchDocument = makeInterface(documentSchema);
-
-
-
-@observer
-export class SearchItem extends ViewBoxBaseComponent<FieldViewProps, SearchSchema>(SearchDocument) {
-
-    public static LayoutString(fieldKey: string) { return FieldView.LayoutString(SearchItem, fieldKey); }
-
-    constructor(props: any) {
-        super(props);
-        //this.rootDoc._viewType= CollectionViewType.Stacking;
-        this.props.Document._height = 46;
-        if (!this.searchItemTemplate) { // create exactly one presElmentBox template to use by any and all presentations.
-            Doc.UserDoc().searchItemTemplate = new PrefetchProxy(Docs.Create.SearchItemBoxDocument({ title: "search item template", backgroundColor: "transparent", _xMargin: 5, _height: 46, isTemplateDoc: true, isTemplateForField: "data" }));
-            // this script will be called by each presElement to get rendering-specific info that the PresBox knows about but which isn't written to the PresElement
-            // this is a design choice -- we could write this data to the presElements which would require a reaction to keep it up to date, and it would prevent
-            // the preselement docs from being part of multiple presentations since they would all have the same field, or we'd have to keep per-presentation data
-            // stored on each pres element.  
-            (this.searchItemTemplate as Doc).lookupField = ScriptField.MakeFunction("lookupSearchBoxField(container, field, data)",
-                { field: "string", data: Doc.name, container: Doc.name });
-        }
-
-    }
-
-    @observable _selected: boolean = false;
-
-    onClick = () => {
-        DocumentManager.Instance.jumpToDocument(this.rootDoc, false);
-    }
-    @observable _useIcons = true;
-    @observable _displayDim = 50;
-
-    @computed get query() { return StrCast(this.lookupField("query")); }
-
-    private _oldHeight: number = 46;
-
-    componentDidMount() {
-        let parent: Doc | undefined = undefined;
-        let height = 0;
-        if (this.rootDoc.parent) {
-            parent = Cast(this.rootDoc.parent, Doc, null);
-            if (parent !== undefined) {
-                height = (NumCast(parent._height));
-            }
-        }
-
-        this._reactionDisposer2 = reaction(
-            () => this._useIcons,
-            el => {
-                if (this.rootDoc.parent) {
-                    parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
-                    height = (NumCast(parent._height));
-                };
-                console.log(height);
-                console.log(this._oldHeight);
-                setTimeout(() => {
-                    this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null;
-                    parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null;
-                    this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null;
-                    // this._oldHeight 55? this._oldHeight =55:null;
-                }, 1);
-            }
-        );
-
-        this._reactionDisposer3 = reaction(
-            () => this._displayLines,
-            el => {
-                if (this.rootDoc.parent) {
-                    parent = Cast(this.rootDoc.parent, Doc, null) as Doc;
-                    height = (NumCast(parent._height));
-                };
-                setTimeout(() => {
-                    this._mainRef.current?.getBoundingClientRect() ? this.props.Document._height = this._mainRef.current?.getBoundingClientRect().height : null;
-                    parent !== undefined ? this._mainRef.current?.getBoundingClientRect() ? parent._height = -this._oldHeight + height + this._mainRef.current?.getBoundingClientRect().height : null : null;
-                    this._mainRef.current?.getBoundingClientRect() ? this._oldHeight = this._mainRef.current?.getBoundingClientRect().height : null;
-                }, 1);
-            }
-        );
-
-        Doc.SetSearchQuery(this.query);
-        this.rootDoc.searchMatch = true;
-    }
-    componentWillUnmount() {
-        this.rootDoc.searchMatch = undefined;
-        this._reactionDisposer2 && this._reactionDisposer2();
-        this._reactionDisposer3 && this._reactionDisposer3();
-
-    }
-
-
-
-    private _reactionDisposer2?: IReactionDisposer;
-    private _reactionDisposer3?: IReactionDisposer;
-
-
-
-    @computed get highlightPos() { return NumCast(this.rootDoc.searchIndex) }
-
-    @action
-    public DocumentIcon() {
-        const layoutresult = StrCast(this.rootDoc.type);
-        if (!this._useIcons) {
-            const returnXDimension = () => this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
-            const returnYDimension = () => this._displayDim;
-            const docview = <div
-                onPointerDown={action(() => {
-                    this._useIcons = !this._useIcons;
-                    this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
-                })}
-                onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} >
-                <ContentFittingDocumentView
-                    Document={this.rootDoc}
-                    LibraryPath={emptyPath}
-                    rootSelected={returnFalse}
-                    fitToBox={StrCast(this.rootDoc.type).indexOf(DocumentType.COL) !== -1}
-                    addDocument={returnFalse}
-                    removeDocument={returnFalse}
-                    addDocTab={returnFalse}
-                    pinToPres={returnFalse}
-                    docFilters={returnEmptyFilter}
-                    ContainingCollectionDoc={undefined}
-                    ContainingCollectionView={undefined}
-                    ScreenToLocalTransform={Transform.Identity}
-                    renderDepth={1}
-                    PanelWidth={returnXDimension}
-                    PanelHeight={returnYDimension}
-                    NativeWidth={returnZero}
-                    NativeHeight={returnZero}
-                    focus={emptyFunction}
-                    moveDocument={returnFalse}
-                    parentActive={returnFalse}
-                    whenActiveChanged={returnFalse}
-                    bringToFront={returnFalse}
-                    ContentScaling={returnOne}
-                />
-            </div>;
-            return docview;
-        }
-        const button = layoutresult.indexOf(DocumentType.PDF) !== -1 ? faFilePdf :
-            layoutresult.indexOf(DocumentType.IMG) !== -1 ? faImage :
-                layoutresult.indexOf(DocumentType.RTF) !== -1 ? faStickyNote :
-                    layoutresult.indexOf(DocumentType.VID) !== -1 ? faFilm :
-                        layoutresult.indexOf(DocumentType.COL) !== -1 ? faObjectGroup :
-                            layoutresult.indexOf(DocumentType.AUDIO) !== -1 ? faMusic :
-                                layoutresult.indexOf(DocumentType.LINK) !== -1 ? faLink :
-                                    layoutresult.indexOf(DocumentType.WEB) !== -1 ? faGlobeAsia :
-                                        faCaretUp;
-        return <div><div onClick={action(() => { this._useIcons = false; this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); })} >
-            <FontAwesomeIcon icon={button} size="2x" />
-        </div>
-            <div className="searchItem-label">{this.rootDoc.type ? this.rootDoc.type : "Other"}</div>
-        </div>
-            ;
-    }
-
-    collectionRef = React.createRef<HTMLDivElement>();
-
-    @action
-    pointerDown = (e: React.PointerEvent) => { e.preventDefault(); e.button === 0 && SearchBox.Instance.openSearch(e); }
-
-    @action
-    nextHighlight = (e: React.MouseEvent) => {
-        e.preventDefault();
-        e.stopPropagation();
-        //e.button === 0 && SearchBox.Instance.openSearch(e);
-
-        this.rootDoc!.searchMatch = false;
-        setTimeout(() => this.rootDoc!.searchMatch = true, 0);
-        this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex);
-        this.length = NumCast(this.rootDoc!.length);
-    }
-
-    @action
-    nextHighlight2 = (e: React.MouseEvent) => {
-        e.preventDefault();
-        e.stopPropagation();
-
-        //e.button === 0 && SearchBox.Instance.openSearch(e);
-
-        this.rootDoc!.searchMatch2 = false;
-        setTimeout(() => this.rootDoc!.searchMatch2 = true, 0);
-        this.rootDoc.searchIndex = NumCast(this.rootDoc.searchIndex);
-
-        this.length = NumCast(this.rootDoc!.length);
-    }
-
-    @observable length: number | undefined = 0;
-
-    highlightDoc = (e: React.PointerEvent) => {
-        if (this.rootDoc!.type === DocumentType.LINK) {
-            if (this.rootDoc!.anchor1 && this.rootDoc!.anchor2) {
-
-                const doc1 = Cast(this.rootDoc!.anchor1, Doc, null);
-                const doc2 = Cast(this.rootDoc!.anchor2, Doc, null);
-                Doc.BrushDoc(doc1);
-                Doc.BrushDoc(doc2);
-            }
-        } else {
-            Doc.BrushDoc(this.rootDoc!);
-        }
-        e.stopPropagation();
-    }
-
-    unHighlightDoc = (e: React.PointerEvent) => {
-        if (this.rootDoc!.type === DocumentType.LINK) {
-            if (this.rootDoc!.anchor1 && this.rootDoc!.anchor2) {
-
-                const doc1 = Cast(this.rootDoc!.anchor1, Doc, null);
-                const doc2 = Cast(this.rootDoc!.anchor2, Doc, null);
-                Doc.UnBrushDoc(doc1);
-                Doc.UnBrushDoc(doc2);
-            }
-        } else {
-            Doc.UnBrushDoc(this.rootDoc!);
-        }
-    }
-
-    onContextMenu = (e: React.MouseEvent) => {
-        e.preventDefault();
-        e.stopPropagation();
-        ContextMenu.Instance.clearItems();
-        ContextMenu.Instance.addItem({
-            description: "Copy ID", event: () => {
-                Utils.CopyText(StrCast(this.rootDoc[Id]));
-            },
-            icon: "fingerprint"
-        });
-        ContextMenu.Instance.displayMenu(e.clientX, e.clientY);
-    }
-
-    _downX = 0;
-    _downY = 0;
-    _target: any;
-    onPointerDown = (e: React.PointerEvent<HTMLDivElement>) => {
-        this._downX = e.clientX;
-        this._downY = e.clientY;
-        e.stopPropagation();
-        this._target = e.currentTarget;
-        document.removeEventListener("pointermove", this.onPointerMoved);
-        document.removeEventListener("pointerup", this.onPointerUp);
-        document.addEventListener("pointermove", this.onPointerMoved);
-        document.addEventListener("pointerup", this.onPointerUp);
-    }
-    onPointerMoved = (e: PointerEvent) => {
-        if (Math.abs(e.clientX - this._downX) > Utils.DRAG_THRESHOLD ||
-            Math.abs(e.clientY - this._downY) > Utils.DRAG_THRESHOLD) {
-            document.removeEventListener("pointermove", this.onPointerMoved);
-            document.removeEventListener("pointerup", this.onPointerUp);
-            const doc = Doc.IsPrototype(this.rootDoc) ? Doc.MakeDelegate(this.rootDoc) : this.rootDoc;
-            DragManager.StartDocumentDrag([this._target], new DragManager.DocumentDragData([doc]), e.clientX, e.clientY);
-        }
-    }
-    onPointerUp = (e: PointerEvent) => {
-        document.removeEventListener("pointermove", this.onPointerMoved);
-        document.removeEventListener("pointerup", this.onPointerUp);
-    }
-
-    @computed
-    get contextButton() {
-        return <ParentDocSelector Document={this.rootDoc} addDocTab={(doc, where) => CollectionDockingView.AddRightSplit(doc)} />;
-    }
-
-    @computed get searchElementDoc() { return this.rootDoc; }
-    // @computed get targetDoc() { return this.searchElementDoc?.targetDoc as Doc; }
-
-    @computed get searchItemTemplate() { return Cast(Doc.UserDoc().searchItemTemplate, Doc, null); }
-    childLayoutTemplate = () => this.layoutDoc._viewType === CollectionViewType.Stacking ? this.searchItemTemplate : undefined;
-    getTransform = () => {
-        return this.props.ScreenToLocalTransform().translate(-5, -65);// listBox padding-left and pres-box-cont minHeight
-    }
-    panelHeight = () => {
-        return this.props.PanelHeight();
-    }
-    selectElement = (doc: Doc) => {
-        //this.gotoDocument(this.childDocs.indexOf(doc), NumCast(this.layoutDoc._itemIndex));
-    }
-
-    newsearch() {
-        runInAction(() => {
-            if (StrCast(this.rootDoc.bucketfield) !== "results") {
-                SearchBox.Instance._icons = [StrCast(this.rootDoc.bucketfield)];
-                SearchBox.Instance._icons = SearchBox.Instance._icons;
-            }
-            else {
-                SearchBox.Instance._icons = SearchBox.Instance._allIcons;
-            }
-            SearchBox.Instance.submitSearch();
-        })
-    }
-
-    @action
-    returnLines() {
-        if ((Cast(this.rootDoc.lines, listSpec("string")))!.length > 1) {
-            if (!this._displayLines) {
-                console.log(Cast(this.rootDoc.lines, listSpec("string")));
-                return <div style={{ width: 10 }}
-                    onPointerDown={action(() => {
-                        this._displayLines = !this._displayLines;
-                        //this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE);
-                    })}
-                //onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))}
-                >
-                    {Cast(this.rootDoc.lines, listSpec("string"))!.filter((m, i) => i).map((l, i) => <div style={{ overflow: "visible" }} id={i.toString()} className="searchItem-highlighting">{l}</div>)}
-                </div>;;
-            }
-        }
-    }
-
-    //this._displayDim = Number(SEARCH_THUMBNAIL_SIZE); 
-
-    @observable _displayLines: boolean = true;
-
-    returnButtons() {
-        return <div>
-            <div onClick={action(() => {
-                this.rootDoc!.type === DocumentType.PDF ? this._displayLines = !this._displayLines : null;
-            })}>
-                {this.rootDoc!.type === DocumentType.PDF ? "Expand Lines" : null}
-                {NumCast(this.rootDoc!.length) > 1 ? `Instance ${NumCast(this.rootDoc.searchIndex) === 0 ? NumCast(this.rootDoc.length) : NumCast(this.rootDoc.searchIndex)} of ${NumCast(this.rootDoc.length)}` : null}
-                <button onClick={this.nextHighlight} style={{ padding: 2, position: "absolute", left: 77 }}>
-                    <FontAwesomeIcon icon="arrow-up" size="sm" />
-                </button>
-                <button onClick={this.nextHighlight2} style={{ padding: 2, position: "absolute", left: 87 }}>
-                    <FontAwesomeIcon icon="arrow-down" size="sm" />
-                </button>
-            </div>
-            <div>
-                <div style={{ background: "lightgrey" }}>
-                    {this.returnLines()}
-                </div>
-            </div>
-        </div>
-    }
-
-    private _mainRef: React.RefObject<HTMLDivElement> = React.createRef();
-
-
-    render() {
-        const doc1 = Cast(this.rootDoc!.anchor1, Doc);
-        const doc2 = Cast(this.rootDoc!.anchor2, Doc);
-        if (StrCast(this.rootDoc.bucketfield) === "webs") {
-            this.props.Document._viewType = CollectionViewType.Stacking;
-            this.props.Document._chromeStatus = 'disabled';
-            this.props.Document._height = this.rootDoc._height;
-            return <div>
-                <CollectionView {...this.props}
-                    Document={this.props.Document}
-                    PanelHeight={this.panelHeight}
-                    whenActiveChanged={emptyFunction}
-                    onClick={undefined}
-                    moveDocument={returnFalse}
-                    childLayoutTemplate={undefined}
-                    addDocument={undefined}
-                    removeDocument={returnFalse}
-                    focus={this.selectElement}
-                    ScreenToLocalTransform={this.getTransform} />
-            </div>
-        }
-        if (this.rootDoc.isBucket === true) {
-            this.props.Document._viewType = CollectionViewType.Stacking;
-            this.props.Document._chromeStatus = 'disabled';
-            this.props.Document._height = this.rootDoc._height;
-
-            return <div>
-                <CollectionView {...this.props}
-                    Document={this.props.Document}
-                    PanelHeight={this.panelHeight}
-                    whenActiveChanged={emptyFunction}
-                    onClick={undefined}
-                    moveDocument={returnFalse}
-                    childLayoutTemplate={this.childLayoutTemplate}
-                    addDocument={undefined}
-                    removeDocument={returnFalse}
-                    focus={this.selectElement}
-                    ScreenToLocalTransform={this.getTransform} />
-                <button onClick={() => this.newsearch()} className="bucket-expand" style={{ transform: "none", fontSize: "100%", textTransform: "none", background: "lightgray", color: "black", bottom: 8, marginBottom: -2, paddingTop: 2, fontFamily: "Arial, sans-serif" }}>See all {StrCast(this.rootDoc.bucketfield)}...
-            </button>
-            </div>
-        }
-        else if (this.rootDoc.isBucket === false) {
-            this.props.Document._chromeStatus = 'disabled';
-            return <div className="searchItem">
-                <div className="searchItem-body" >
-                    <div className="searchItem-title-container">
-                        <div className="searchItem-title" style={{ height: "10px", overflow: "hidden", textOverflow: "ellipsis" }}>No Search Results</div>
-                    </div>
-                </div>
-            </div>
-        }
-        else {
-            return <div className="searchItem-overview" onPointerDown={this.pointerDown} onContextMenu={this.onContextMenu}>
-                <div ref={this._mainRef} className="searchItem" onPointerEnter={this.highlightDoc} onPointerLeave={this.unHighlightDoc}>
-                    <div className="searchItem-body" onClick={this.onClick}>
-                        <div className="searchItem-title-container">
-                            <div className="searchItem-title" style={{ height: "10px", overflow: "hidden", textOverflow: "ellipsis" }}>{StrCast(this.rootDoc.title)}</div>
-                            <div className="searchItem-highlighting">
-                                {this.rootDoc.highlighting ? StrCast(this.rootDoc.highlighting).length ? "Matched fields:" + StrCast(this.rootDoc.highlighting) : Cast(this.rootDoc.lines, listSpec("string"))!.length ? Cast(this.rootDoc.lines, listSpec("string"))![0] : "" : null}</div>
-                            <div className={`icon-${this._displayLines ? "q" : "a"}`}>
-                                {NumCast(this.rootDoc.length) > 1 || this.rootDoc!.type === DocumentType.PDF ? this.returnButtons() : null}
-                            </div>
-                        </div>
-                    </div>
-                    <div className="searchItem-info" style={{ width: this._useIcons ? "30px" : "100%" }}>
-                        <div className={`icon-${this._useIcons ? "icons" : "live"}`}>
-                            <div className="searchItem-type" title="Click to Preview" onPointerDown={this.onPointerDown}>{this.DocumentIcon()}</div>
-                        </div>
-                    </div>
-                    {/* <div className="searchItem-context" title="Drag as document">
-                    {(doc1 instanceof Doc && doc2 instanceof Doc) && this.rootDoc!.type === DocumentType.LINK ? <LinkContextMenu doc1={doc1} doc2={doc2} /> :
-                        this.contextButton}
-                </div> */}
-                </div>
-            </div>;
-        }
-    }
-} 
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From 8c7196ca1eda1f89bbac3e2f24219df739978776 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 5 Aug 2020 00:07:59 -0400
Subject: lint

---
 src/client/views/EditableView.tsx                  | 12 ++---
 .../views/collections/CollectionSchemaCells.tsx    | 25 ++--------
 .../views/collections/CollectionSchemaView.tsx     |  4 +-
 src/client/views/collections/CollectionSubView.tsx |  2 +-
 .../views/nodes/formattedText/FormattedTextBox.tsx |  8 ++--
 src/client/views/search/SearchBox.tsx              | 56 +++++-----------------
 6 files changed, 31 insertions(+), 76 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/EditableView.tsx b/src/client/views/EditableView.tsx
index a98ef97ea..a5628d5ee 100644
--- a/src/client/views/EditableView.tsx
+++ b/src/client/views/EditableView.tsx
@@ -187,13 +187,13 @@ export class EditableView extends React.Component<EditableProps> {
     }
 
     returnHighlights() {
-        let results = [];
-        let contents = this.props.bing!();
+        const results = [];
+        const contents = this.props.bing!();
 
         if (contents !== undefined) {
             if (this.props.positions !== undefined) {
-                let positions = this.props.positions;
-                let length = this.props.search!.length;
+                const positions = this.props.positions;
+                const length = this.props.search!.length;
 
                 // contents = String(this.props.contents.valueOf());
 
@@ -201,10 +201,10 @@ export class EditableView extends React.Component<EditableProps> {
                 positions.forEach((num, cur) => {
                     results.push(<span style={{ backgroundColor: "#FFFF00", fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num, num + length) : this.props.placeholder?.valueOf()}</span>);
                     let end = 0;
-                    cur === positions.length - 1 ? end = contents.length : end = positions[cur + 1];
+                    cur === positions.length - 1 ? end = contents!.length : end = positions[cur + 1];
                     results.push(<span style={{ fontStyle: this.props.fontStyle, fontSize: this.props.fontSize, color: this.props.contents ? "black" : "grey" }}>{contents ? contents.slice(num + length, end) : this.props.placeholder?.valueOf()}</span>);
                 }
-                )
+                );
             }
             return results;
         }
diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index b02b4c86a..7a80f4484 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -241,7 +241,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         //         <FontAwesomeIcon icon="expand" size="sm" />
         //     </div>
         // );   
-        let positions = [];
+        const positions = [];
         if (StrCast(this.props.Document._searchString) !== "") {
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
             let term = "";
@@ -256,8 +256,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                     term = String(NumCast(cfield));
                 }
             }
-            let search = StrCast(this.props.Document._searchString);
-            let start = term.indexOf(search) as number;
+            const search = StrCast(this.props.Document._searchString);
+            let start = term.indexOf(search);
             let tally = 0;
             if (start !== -1) {
                 positions.push(start);
@@ -883,36 +883,27 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
         //     (!this.props.CollectionView || !this.props.CollectionView.props.isSelected() ? undefined :
         //         SetupDrag(reference, () => this._document, this.props.moveDocument, this.props.Document.schemaDoc ? "copy" : undefined)(e));
         // };
-        let doc = this.props.rowProps.original;
+        const doc = this.props.rowProps.original;
         let buttons = <div style={{
             paddingTop: 8,
             paddingLeft: 3,
         }}><button onClick={() => {
-            console.log(doc);
-            console.log(doc.searchMatch);
             doc.searchMatch = false;
-            console.log(doc.searchMatch);
             setTimeout(() => doc.searchMatch = true, 0);
-            console.log(doc.searchMatch);
             doc.searchIndex = NumCast(doc.searchIndex);
         }} style={{ padding: 2, left: 77 }}>
                 <FontAwesomeIcon icon="arrow-up" size="sm" />
             </button>
             <button onClick={() => {
                 {
-                    console.log(doc);
-                    console.log(doc.searchMatch2);
                     doc.searchMatch2 = false;
-                    console.log(doc.searchMatch2);
                     setTimeout(() => doc.searchMatch2 = true, 0);
-                    console.log(doc.searchMatch2);
                     doc.searchIndex = NumCast(doc.searchIndex);
                 }
             }} style={{ padding: 2 }}>
                 <FontAwesomeIcon icon="arrow-down" size="sm" />
             </button></div>;
         const type = StrCast(doc.type);
-        console.log(StrCast(doc.type));
         if (type === "pdf") {
             buttons = <div><button
                 style={{
@@ -923,19 +914,14 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
                 }}
 
                 onClick={() => {
-                    console.log(doc);
-                    console.log(doc.searchMatch);
                     doc.searchMatch = false;
-                    console.log(doc.searchMatch);
                     setTimeout(() => doc.searchMatch = true, 0);
-                    console.log(doc.searchMatch);
                     doc.searchIndex = NumCast(doc.searchIndex);
                 }}>
                 <FontAwesomeIcon icon="arrow-down" size="sm" />
-            </button></div >
+            </button></div >;
         }
         else if (type !== "rtf") {
-            console.log("sad");
             buttons = undefined;
         }
 
@@ -945,7 +931,6 @@ export class CollectionSchemaButtons extends CollectionSchemaCell {
         else {
             buttons = undefined;
         }
-
         return (
             <div> {buttons}</div>
         );
diff --git a/src/client/views/collections/CollectionSchemaView.tsx b/src/client/views/collections/CollectionSchemaView.tsx
index d47d41a1e..a003de0d3 100644
--- a/src/client/views/collections/CollectionSchemaView.tsx
+++ b/src/client/views/collections/CollectionSchemaView.tsx
@@ -329,14 +329,14 @@ export class CollectionSchemaView extends CollectionSubView(doc => doc) {
                     if (filter) {
                         Doc.setDocFilter(this.props.Document, newKey, filter, "match");
                         if (this.props.Document.selectedDoc !== undefined) {
-                            let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+                            const doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
                             Doc.setDocFilter(doc, newKey, filter, "match");
                         }
                     }
                     else {
                         this.props.Document._docFilters = undefined;
                         if (this.props.Document.selectedDoc !== undefined) {
-                            let doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
+                            const doc = Cast(this.props.Document.selectedDoc, Doc) as Doc;
                             doc._docFilters = undefined;
                         }
                     }
diff --git a/src/client/views/collections/CollectionSubView.tsx b/src/client/views/collections/CollectionSubView.tsx
index 888f0b9e9..b896518ed 100644
--- a/src/client/views/collections/CollectionSubView.tsx
+++ b/src/client/views/collections/CollectionSubView.tsx
@@ -159,7 +159,7 @@ export function CollectionSubView<T, X>(schemaCtor: (doc: Doc) => T, moreProps?:
                                 newarray = [];
                                 newdocs.forEach((t) => {
                                     if (d.data !== undefined) {
-                                        let newdocs = DocListCast(t.data);
+                                        const newdocs = DocListCast(t.data);
                                         newdocs.forEach((newdoc) => {
                                             newarray.push(newdoc);
                                         });
diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
index b21596493..ab29f6889 100644
--- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx
+++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx
@@ -298,7 +298,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
             const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true });
             const res = terms.filter(t => t).map(term => this.findInNode(this._editorView!, this._editorView!.state.doc, term));
-            let length = res[0].length;
+            const length = res[0].length;
             let tr = this._editorView.state.tr;
             const flattened: TextSelection[] = [];
             res.map(r => r.map(h => flattened.push(h)));
@@ -318,7 +318,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             else if (this._searchIndex === 0 && length !== 1) {
                 this._searchIndex = length - 2;
             }
-            let index = this._searchIndex;
+            const index = this._searchIndex;
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
             Doc.GetProto(this.dataDoc).length = length;
@@ -331,7 +331,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             const mark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight);
             const activeMark = this._editorView.state.schema.mark(this._editorView.state.schema.marks.search_highlight, { selected: true });
             const res = terms.filter(t => t).map(term => this.findInNode(this._editorView!, this._editorView!.state.doc, term));
-            let length = res[0].length;
+            const length = res[0].length;
             let tr = this._editorView.state.tr;
             const flattened: TextSelection[] = [];
             res.map(r => r.map(h => flattened.push(h)));
@@ -339,7 +339,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<(FieldViewProp
             flattened.forEach((h: TextSelection, ind: number) => tr = tr.addMark(h.from, h.to, ind === lastSel ? activeMark : mark));
             this._searchIndex = ++this._searchIndex > flattened.length - 1 ? 0 : this._searchIndex;
             this._editorView.dispatch(tr.setSelection(new TextSelection(tr.doc.resolve(flattened[lastSel].from), tr.doc.resolve(flattened[lastSel].to))).scrollIntoView());
-            let index = this._searchIndex;
+            const index = this._searchIndex;
 
             Doc.GetProto(this.dataDoc).searchIndex = index;
             Doc.GetProto(this.dataDoc).length = length;
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 001792f41..097e6c4d9 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -94,7 +94,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         }
         if (this.inputRef.current) {
             this.inputRef.current.focus();
-            runInAction(() => { this._searchbarOpen = true });
+            runInAction(() => { this._searchbarOpen = true; });
         }
         if (this.rootDoc.searchQuery && this.newAssign) {
             const sq = this.rootDoc.searchQuery;
@@ -112,11 +112,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 this.submitSearch();
             });
         }
-    };
+    }
 
 
     @action
-    getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc);
+    getViews = (doc: Doc) => SearchUtil.GetViewsOfDocument(doc)
 
 
     @observable newsearchstring: string = "";
@@ -127,7 +127,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
 
         if (e.target.value === "") {
-            console.log(this._results);
             this._results.forEach(result => {
                 Doc.UnBrushDoc(result[0]);
                 result[0].searchMatch = undefined;
@@ -140,8 +139,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 this.props.Document.selectedDoc = undefined;
 
             }
-            console.log("CLOSE");
-            runInAction(() => { this.open = false });
+            runInAction(() => { this.open = false; });
             this._openNoResults = false;
             this._results = [];
             this._resultsSet.clear();
@@ -226,7 +224,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         if (this._collectionStatus) {
             query = this.addCollectionFilter(query);
             query = query.replace(/\s+/g, ' ').trim();
-            console.log(query)
 
         }
         return query;
@@ -253,8 +250,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     addCollectionFilter(query: string): string {
         const collections: Doc[] = this.getCurCollections();
-
-        console.log(collections);
         const oldWords = query.split(" ");
 
         const collectionString: string[] = [];
@@ -312,18 +307,16 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
             }
             let docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
             const found: [Doc, string[], string[]][] = [];
-            const docsforFilter: Doc[] = []
+            const docsforFilter: Doc[] = [];
             let newarray: Doc[] = [];
 
             while (docs.length > 0) {
                 newarray = [];
                 docs.forEach((d) => {
-                    if (d.data != undefined) {
+                    if (d.data !== undefined) {
                         newarray.push(...DocListCast(d.data));
                     }
-
-                    let hlights: string[] = [];
-
+                    const hlights: string[] = [];
                     const protos = Doc.GetAllPrototypes(d);
                     protos.forEach(proto => {
                         Object.keys(proto).forEach(key => {
@@ -345,15 +338,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                 selectedCollection.props.Document._searchDocs = new List<Doc>(docsforFilter);
                 docs = DocListCast(selectedCollection.dataDoc[Doc.LayoutFieldKey(selectedCollection.dataDoc)]);
                 while (docs.length > 0) {
-                    console.log("HIT");
                     newarray = [];
                     docs.forEach((d) => {
                         if (d.data !== undefined) {
-                            console.log(d._searchDocs);
                             d._searchDocs = new List<Doc>(docsforFilter);
-                            console.log(d);
-                            console.log(d._searchDocs);
-                            let newdocs = DocListCast(d.data);
+                            const newdocs = DocListCast(d.data);
                             newdocs.forEach((newdoc) => {
                                 newarray.push(newdoc);
                             });
@@ -449,7 +438,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         this._visibleElements = [];
         this._visibleDocuments = [];
         if (StrCast(this.props.Document.searchQuery)) {
-            if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined };
+            if (this._timeout) { clearTimeout(this._timeout); this._timeout = undefined; }
             this._timeout = setTimeout(() => {
                 console.log("Resubmitting search");
             }, 60000);
@@ -526,7 +515,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlight = highlights[doc[Id]];
                             const line = lines.get(doc[Id]) || [];
                             const hlights = highlight ? Object.keys(highlight).map(key => key.substring(0, key.length - 2)) : [];
-                            console.log(hlights);
                             doc ? console.log(Cast(doc.context, Doc)) : null;
                             if (this.findCommonElements(hlights)) {
                             }
@@ -683,7 +671,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         if (result) {
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             const lines = new List<string>(result[2]);
-                            console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
                             highlights.forEach((item) => headers.add(item));
@@ -701,7 +688,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                             const highlights = Array.from([...Array.from(new Set(result[1]).values())]);
                             const lines = new List<string>(result[2]);
                             highlights.forEach((item) => headers.add(item));
-                            console.log(lines);
                             result[0].lines = lines;
                             result[0].highlighting = highlights.join(", ");
                             result[0].searchMatch = true;
@@ -796,15 +782,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                     let docs: Doc[] = [];
                                     docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
                                     while (docs.length > 0) {
-                                        console.log("HIT");
                                         newarray = [];
                                         docs.forEach((d) => {
                                             if (d.data !== undefined) {
-                                                console.log(d._searchDocs);
                                                 d._searchDocs = new List<Doc>(this.docsforfilter);
-                                                console.log(d);
-                                                console.log(d._searchDocs);
-                                                let newdocs = DocListCast(d.data);
+                                                const newdocs = DocListCast(d.data);
                                                 newdocs.forEach((newdoc) => {
                                                     newarray.push(newdoc);
                                                 });
@@ -821,15 +803,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                     let docs: Doc[] = [];
                                     docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
                                     while (docs.length > 0) {
-                                        console.log("HIT");
                                         newarray = [];
                                         docs.forEach((d) => {
                                             if (d.data !== undefined) {
-                                                console.log(d._searchDocs);
                                                 d._searchDocs = new List<Doc>();
-                                                console.log(d);
-                                                console.log(d._searchDocs);
-                                                let newdocs = DocListCast(d.data);
+                                                const newdocs = DocListCast(d.data);
                                                 newdocs.forEach((newdoc) => {
                                                     newarray.push(newdoc);
                                                 });
@@ -868,15 +846,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                                         let docs: Doc[] = [];
                                                         docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
                                                         while (docs.length > 0) {
-                                                            console.log("HIT");
                                                             newarray = [];
                                                             docs.forEach((d) => {
                                                                 if (d.data !== undefined) {
-                                                                    console.log(d._searchDocs);
                                                                     d._searchDocs = new List<Doc>();
-                                                                    console.log(d);
-                                                                    console.log(d._searchDocs);
-                                                                    let newdocs = DocListCast(d.data);
+                                                                    const newdocs = DocListCast(d.data);
                                                                     newdocs.forEach((newdoc) => {
                                                                         newarray.push(newdoc);
                                                                     });
@@ -906,15 +880,11 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                                                         let docs: Doc[] = [];
                                                         docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
                                                         while (docs.length > 0) {
-                                                            console.log("HIT");
                                                             newarray = [];
                                                             docs.forEach((d) => {
                                                                 if (d.data !== undefined) {
-                                                                    console.log(d._searchDocs);
                                                                     d._searchDocs = new List<Doc>();
-                                                                    console.log(d);
-                                                                    console.log(d._searchDocs);
-                                                                    let newdocs = DocListCast(d.data);
+                                                                    const newdocs = DocListCast(d.data);
                                                                     newdocs.forEach((newdoc) => {
                                                                         newarray.push(newdoc);
                                                                     });
-- 
cgit v1.2.3-70-g09d2


From 217bb86beceed8f48ffe81cea0dbc578cb57a431 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 5 Aug 2020 10:31:11 -0400
Subject: fixed some warnings/errors.  added tooltip for filter icon.

---
 .../apis/HypothesisAuthenticationManager.tsx       |  2 +-
 src/client/views/PropertiesButtons.tsx             | 28 +++----
 src/client/views/collections/CollectionMenu.tsx    | 48 ++++++------
 .../collectionGrid/CollectionGridView.tsx          |  2 +-
 src/client/views/nodes/WebBox.tsx                  |  2 +-
 src/client/views/search/SearchBox.tsx              | 85 +++++++++-------------
 src/server/websocket.ts                            |  3 +-
 7 files changed, 77 insertions(+), 93 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/apis/HypothesisAuthenticationManager.tsx b/src/client/apis/HypothesisAuthenticationManager.tsx
index c3e8d2fff..bc95b5f9a 100644
--- a/src/client/apis/HypothesisAuthenticationManager.tsx
+++ b/src/client/apis/HypothesisAuthenticationManager.tsx
@@ -18,7 +18,7 @@ export default class HypothesisAuthenticationManager extends React.Component<{}>
     @observable private showPasteTargetState = false;
     @observable private success: Opt<boolean> = undefined;
     @observable private displayLauncher = true;
-    @observable private credentials: string;
+    @observable private credentials: string = "";
     private disposer: Opt<IReactionDisposer>;
 
     private set isOpen(value: boolean) {
diff --git a/src/client/views/PropertiesButtons.tsx b/src/client/views/PropertiesButtons.tsx
index d46c03470..033bd7791 100644
--- a/src/client/views/PropertiesButtons.tsx
+++ b/src/client/views/PropertiesButtons.tsx
@@ -28,7 +28,6 @@ import { GooglePhotos } from '../apis/google_docs/GooglePhotosClientUtils';
 import { ImageField } from '../../fields/URLField';
 import { undoBatch, UndoManager } from '../util/UndoManager';
 import { DocumentType } from '../documents/DocumentTypes';
-import { CollectionFreeFormView } from './collections/collectionFreeForm/CollectionFreeFormView';
 import { InkField } from '../../fields/InkField';
 const higflyout = require("@hig/flyout");
 export const { anchorPoints } = higflyout;
@@ -128,18 +127,19 @@ export class PropertiesButtons extends React.Component<{}, {}> {
         const targetDoc = this.selectedDoc;
         const published = targetDoc && Doc.GetProto(targetDoc)[GoogleRef] !== undefined;
         const animation = this.isAnimatingPulse ? "shadow-pulse 1s linear infinite" : "none";
-        return !targetDoc ? (null) : <Tooltip title={<><div className="dash-tooltip">{`${published ? "Push" : "Publish"} to Google Docs`}</div></>}>
-            <div
-                className="propertiesButtons-linker"
-                style={{ animation }}
-                onClick={async () => {
-                    await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
-                    !published && runInAction(() => this.isAnimatingPulse = true);
-                    PropertiesButtons.hasPushedHack = false;
-                    targetDoc[Pushes] = NumCast(targetDoc[Pushes]) + 1;
-                }}>
-                <FontAwesomeIcon className="documentdecorations-icon" icon={published ? (this.pushIcon as any) : cloud} size={published ? "sm" : "xs"} />
-            </div></Tooltip>;
+        return !targetDoc ? (null) :
+            <Tooltip title={<><div className="dash-tooltip">{`${published ? "Push" : "Publish"} to Google Docs`}</div></>}>
+                <div className="propertiesButtons-linker"
+                    style={{ animation }}
+                    onClick={async () => {
+                        await GoogleAuthenticationManager.Instance.fetchOrGenerateAccessToken();
+                        !published && runInAction(() => this.isAnimatingPulse = true);
+                        PropertiesButtons.hasPushedHack = false;
+                        targetDoc[Pushes] = NumCast(targetDoc[Pushes]) + 1;
+                    }}>
+                    <FontAwesomeIcon className="documentdecorations-icon" icon={published ? (this.pushIcon as any) : cloud} size={published ? "sm" : "xs"} />
+                </div>
+            </Tooltip>;
     }
 
     @computed
@@ -377,7 +377,7 @@ export class PropertiesButtons extends React.Component<{}, {}> {
     @computed
     get onClickButton() {
         if (this.selectedDoc) {
-            return <Tooltip title={<><div className="dash-tooltip">Choose onClick behavior</div></>}>
+            return <Tooltip title={<div className="dash-tooltip">Choose onClick behavior</div>}>
                 <div className="propertiesButtons-linkFlyout">
                     <Flyout anchorPoint={anchorPoints.LEFT_TOP}
                         content={this.onClickFlyout}>
diff --git a/src/client/views/collections/CollectionMenu.tsx b/src/client/views/collections/CollectionMenu.tsx
index a7d2c07fa..4eb0088f6 100644
--- a/src/client/views/collections/CollectionMenu.tsx
+++ b/src/client/views/collections/CollectionMenu.tsx
@@ -1,37 +1,35 @@
 import React = require("react");
+import { IconProp } from '@fortawesome/fontawesome-svg-core';
 import { FontAwesomeIcon, FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
-import { action, computed, observable, reaction, runInAction, Lambda } from "mobx";
+import { Tooltip } from "@material-ui/core";
+import { action, computed, Lambda, observable, reaction, runInAction } from "mobx";
 import { observer } from "mobx-react";
-import { Doc, DocListCast, Opt, Field } from "../../../fields/Doc";
-import { BoolCast, Cast, StrCast, NumCast } from "../../../fields/Types";
-import AntimodeMenu from "../AntimodeMenu";
-import "./CollectionMenu.scss";
-import { undoBatch } from "../../util/UndoManager";
-import { CollectionViewType, CollectionView, COLLECTION_BORDER_WIDTH } from "./CollectionView";
-import { emptyFunction, setupMoveUpEvents, Utils } from "../../../Utils";
-import { DragManager } from "../../util/DragManager";
-import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
-import { List } from "../../../fields/List";
-import { EditableView } from "../EditableView";
+import { ColorState } from "react-color";
+import { Doc, DocListCast, Opt } from "../../../fields/Doc";
+import { Document } from "../../../fields/documentSchemas";
 import { Id } from "../../../fields/FieldSymbols";
-import { listSpec } from "../../../fields/Schema";
-import FormatShapePane from "./collectionFreeForm/FormatShapePane";
-import { ActiveFillColor, SetActiveInkWidth, ActiveInkColor, SetActiveBezierApprox, SetActiveArrowEnd, SetActiveArrowStart, SetActiveFillColor, SetActiveInkColor } from "../InkingStroke";
-import GestureOverlay from "../GestureOverlay";
 import { InkTool } from "../../../fields/InkField";
-import { DocumentType } from "../../documents/DocumentTypes";
-import { Document } from "../../../fields/documentSchemas";
-import { SelectionManager } from "../../util/SelectionManager";
-import { DocumentView } from "../nodes/DocumentView";
-import { ColorState } from "react-color";
+import { List } from "../../../fields/List";
 import { ObjectField } from "../../../fields/ObjectField";
-import RichTextMenu from "../nodes/formattedText/RichTextMenu";
 import { RichTextField } from "../../../fields/RichTextField";
+import { listSpec } from "../../../fields/Schema";
 import { ScriptField } from "../../../fields/ScriptField";
-import { IconProp } from '@fortawesome/fontawesome-svg-core';
-import { DocUtils } from "../../documents/Documents";
-import { Tooltip } from "@material-ui/core";
+import { BoolCast, Cast, NumCast, StrCast } from "../../../fields/Types";
+import { emptyFunction, setupMoveUpEvents, Utils } from "../../../Utils";
+import { DocumentType } from "../../documents/DocumentTypes";
 import { CurrentUserUtils } from "../../util/CurrentUserUtils";
+import { DragManager } from "../../util/DragManager";
+import { SelectionManager } from "../../util/SelectionManager";
+import { undoBatch } from "../../util/UndoManager";
+import AntimodeMenu from "../AntimodeMenu";
+import { EditableView } from "../EditableView";
+import GestureOverlay from "../GestureOverlay";
+import { ActiveFillColor, ActiveInkColor, SetActiveArrowEnd, SetActiveArrowStart, SetActiveBezierApprox, SetActiveFillColor, SetActiveInkColor, SetActiveInkWidth } from "../InkingStroke";
+import { CollectionFreeFormDocumentView } from "../nodes/CollectionFreeFormDocumentView";
+import { DocumentView } from "../nodes/DocumentView";
+import RichTextMenu from "../nodes/formattedText/RichTextMenu";
+import "./CollectionMenu.scss";
+import { CollectionViewType, COLLECTION_BORDER_WIDTH } from "./CollectionView";
 
 @observer
 export default class CollectionMenu extends AntimodeMenu {
diff --git a/src/client/views/collections/collectionGrid/CollectionGridView.tsx b/src/client/views/collections/collectionGrid/CollectionGridView.tsx
index 21f77e47b..e6ac7021a 100644
--- a/src/client/views/collections/collectionGrid/CollectionGridView.tsx
+++ b/src/client/views/collections/collectionGrid/CollectionGridView.tsx
@@ -240,7 +240,7 @@ export class CollectionGridView extends CollectionSubView(GridSchema) {
                 w: Math.min(w, this.numCols), // reduces width if greater than numCols
                 static: BoolCast(this.childLayoutPairs.find(({ layout }) => layout[Id] === i)?.layout.lockedPosition, false) // checks if the lock position item has been selected in the context menu
             })) :
-            this.savedLayoutList.map((layout, index) => Object.assign(layout, this.unflexedPosition(index)));
+            this.savedLayoutList.map((layout, index) => { Object.assign(layout, this.unflexedPosition(index)); return layout; });
     }
 
     /**
diff --git a/src/client/views/nodes/WebBox.tsx b/src/client/views/nodes/WebBox.tsx
index 646a94aa7..3283f568a 100644
--- a/src/client/views/nodes/WebBox.tsx
+++ b/src/client/views/nodes/WebBox.tsx
@@ -536,7 +536,7 @@ export class WebBox extends ViewBoxAnnotatableComponent<FieldViewProps, WebDocum
     highlight = (color: string) => {
         // creates annotation documents for current highlights
         const effectiveAcl = GetEffectiveAcl(this.props.Document);
-        const annotationDoc = [AclAddonly, AclEdit, AclAdmin].includes(effectiveAcl) && this.makeAnnotationDocument(color);
+        const annotationDoc = [AclAddonly, AclEdit, AclAdmin].includes(effectiveAcl) ? this.makeAnnotationDocument(color) : undefined;
         annotationDoc && this.addDocument?.(annotationDoc);
         return annotationDoc ?? undefined;
     }
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 097e6c4d9..812658b32 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -1,4 +1,5 @@
-import * as _ from "lodash";
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { Tooltip } from '@material-ui/core';
 import { action, computed, observable, runInAction } from 'mobx';
 import { observer } from 'mobx-react';
 import * as React from 'react';
@@ -15,7 +16,6 @@ import { Docs } from '../../documents/Documents';
 import { DocumentType } from "../../documents/DocumentTypes";
 import { CurrentUserUtils } from '../../util/CurrentUserUtils';
 import { SetupDrag } from '../../util/DragManager';
-import { Scripting, _scriptingGlobals } from '../../util/Scripting';
 import { SearchUtil } from '../../util/SearchUtil';
 import { SelectionManager } from '../../util/SelectionManager';
 import { Transform } from '../../util/Transform';
@@ -24,7 +24,6 @@ import { ViewBoxBaseComponent } from "../DocComponent";
 import { DocumentView } from '../nodes/DocumentView';
 import { FieldView, FieldViewProps } from '../nodes/FieldView';
 import "./SearchBox.scss";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
 
 export const searchSchema = createSchema({
     id: "string",
@@ -771,57 +770,43 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                         <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg"
                             style={{ color: "black", padding: 1, left: 35, position: "relative" }} />
 
-                        <FontAwesomeIcon icon={"filter"} size="lg"
-                            style={{ cursor: "default", right: 20, padding: 1, left: 250, position: "relative", backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
-                            onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
-                            onClick={action(() => {
-                                this.filter = !this.filter && !this.searchFullDB;
-                                if (this.filter === true && this.currentSelectedCollection !== undefined) {
-                                    this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
-                                    let newarray: Doc[] = [];
-                                    let docs: Doc[] = [];
-                                    docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
-                                    while (docs.length > 0) {
-                                        newarray = [];
-                                        docs.forEach((d) => {
-                                            if (d.data !== undefined) {
-                                                d._searchDocs = new List<Doc>(this.docsforfilter);
-                                                const newdocs = DocListCast(d.data);
-                                                newdocs.forEach((newdoc) => {
-                                                    newarray.push(newdoc);
+                        <div style={{ cursor: "default", left: 250, position: "relative", }}>
+                            <Tooltip title={<div className="dash-tooltip" >only display documents matching search</div>} ><div>
+                                <FontAwesomeIcon icon={"filter"} size="lg"
+                                    style={{ padding: 1, backgroundColor: this.filter ? "white" : "lightgray", color: this.filter ? "black" : "white" }}
+                                    onPointerDown={e => { e.stopPropagation(); SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined); }}
+                                    onClick={action(() => {
+                                        const dofilter = (currentSelectedCollection: DocumentView) => {
+                                            let docs = DocListCast(currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(currentSelectedCollection.dataDoc)]);
+                                            while (docs.length > 0) {
+                                                const newarray: Doc[] = [];
+                                                docs.filter(d => d.data !== undefined).forEach((d) => {
+                                                    d._searchDocs = new List<Doc>(this.docsforfilter);
+                                                    newarray.push(...DocListCast(d.data));
                                                 });
+                                                docs = newarray;
                                             }
-                                        });
-                                        docs = newarray;
-                                    }
+                                        };
+                                        this.filter = !this.filter && !this.searchFullDB;
+                                        if (this.filter === true && this.currentSelectedCollection !== undefined) {
+                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>(this.docsforfilter);
 
-                                    this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
-                                    this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
-                                }
-                                else if (this.filter === false && this.currentSelectedCollection !== undefined) {
-                                    let newarray: Doc[] = [];
-                                    let docs: Doc[] = [];
-                                    docs = DocListCast(this.currentSelectedCollection.dataDoc[Doc.LayoutFieldKey(this.currentSelectedCollection.dataDoc)]);
-                                    while (docs.length > 0) {
-                                        newarray = [];
-                                        docs.forEach((d) => {
-                                            if (d.data !== undefined) {
-                                                d._searchDocs = new List<Doc>();
-                                                const newdocs = DocListCast(d.data);
-                                                newdocs.forEach((newdoc) => {
-                                                    newarray.push(newdoc);
-                                                });
-                                            }
-                                        });
-                                        docs = newarray;
-                                    }
+                                            dofilter(this.currentSelectedCollection);
 
-                                    this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
-                                    this.currentSelectedCollection.props.Document._docFilters = undefined;
-                                    this.props.Document.selectedDoc = undefined;
-                                }
-                            }
-                            )} />
+                                            this.currentSelectedCollection.props.Document._docFilters = new List<string>(Cast(this.props.Document._docFilters, listSpec("string"), []));
+                                            this.props.Document.selectedDoc = this.currentSelectedCollection.props.Document;
+                                        }
+                                        else if (this.filter === false && this.currentSelectedCollection !== undefined) {
+
+                                            dofilter(this.currentSelectedCollection);
+
+                                            this.currentSelectedCollection.props.Document._searchDocs = new List<Doc>([]);
+                                            this.currentSelectedCollection.props.Document._docFilters = undefined;
+                                            this.props.Document.selectedDoc = undefined;
+                                        }
+                                    }
+                                    )} />
+                            </div></Tooltip></div>
                         <input value={this.newsearchstring} autoComplete="off" onChange={this.onChange} type="text" placeholder="Search..." id="search-input" ref={this.inputRef}
                             className="searchBox-barChild searchBox-input" onPointerDown={this.openSearch} onKeyPress={this.enter} onFocus={this.openSearch}
                             style={{ padding: 1, paddingLeft: 20, paddingRight: 20, color: "black", height: 20, width: 250 }} />
diff --git a/src/server/websocket.ts b/src/server/websocket.ts
index 2c8ec090a..24371a997 100644
--- a/src/server/websocket.ts
+++ b/src/server/websocket.ts
@@ -16,6 +16,7 @@ import { DocumentsCollection } from "./IDatabase";
 import { Diff, GestureContent, MessageStore, MobileDocumentUploadContent, MobileInkOverlayContent, Transferable, Types, UpdateMobileInkOverlayPositionContent, YoutubeQueryInput, YoutubeQueryTypes } from "./Message";
 import { Search } from "./Search";
 import { resolvedPorts } from './server_Initialization';
+import { Opt } from "../fields/Doc";
 
 export namespace WebSocket {
 
@@ -31,7 +32,7 @@ export namespace WebSocket {
             if (socketPort) {
                 resolvedPorts.socket = Number(socketPort);
             }
-            let socketEndpoint: Server;
+            let socketEndpoint: Opt<Server>;
             await new Promise<void>(resolve => socketEndpoint = createServer(SSL.Credentials, app).listen(resolvedPorts.socket, resolve));
             io = sio(socketEndpoint!, SSL.Credentials as any);
         } else {
-- 
cgit v1.2.3-70-g09d2


From dbfcc51bb77f67ec0b86b0301699f2577b0341e0 Mon Sep 17 00:00:00 2001
From: Andy Rickert <andrew_rickert@brown.edu>
Date: Wed, 5 Aug 2020 12:37:33 -0400
Subject: highlighting case sensitive'

---
 src/client/views/collections/CollectionSchemaCells.tsx | 5 +++--
 src/client/views/search/SearchBox.tsx                  | 7 ++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

(limited to 'src/client/views/search/SearchBox.tsx')

diff --git a/src/client/views/collections/CollectionSchemaCells.tsx b/src/client/views/collections/CollectionSchemaCells.tsx
index 98b7b7739..f627faa63 100644
--- a/src/client/views/collections/CollectionSchemaCells.tsx
+++ b/src/client/views/collections/CollectionSchemaCells.tsx
@@ -243,7 +243,7 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
         //     </div>
         // );   
         const positions = [];
-        if (StrCast(this.props.Document._searchString) !== "") {
+        if (StrCast(this.props.Document._searchString).toLowerCase() !== "") {
             const cfield = ComputedField.WithoutComputed(() => FieldValue(props.Document[props.fieldKey]));
             let term = "";
             if (cfield !== undefined) {
@@ -257,7 +257,8 @@ export class CollectionSchemaCell extends React.Component<CellProps> {
                     term = String(NumCast(cfield));
                 }
             }
-            const search = StrCast(this.props.Document._searchString);
+            term = term.toLowerCase();
+            const search = StrCast(this.props.Document._searchString).toLowerCase();
             let start = term.indexOf(search);
             let tally = 0;
             if (start !== -1) {
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 097e6c4d9..113e5f6ca 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -299,7 +299,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
 
     searchCollection(query: string) {
         const selectedCollection: DocumentView = SelectionManager.SelectedDocuments()[0];
-
+        query = query.toLowerCase();
         if (selectedCollection !== undefined) {
             this.currentSelectedCollection = selectedCollection;
             if (this.filter === true) {
@@ -320,7 +320,7 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
                     const protos = Doc.GetAllPrototypes(d);
                     protos.forEach(proto => {
                         Object.keys(proto).forEach(key => {
-                            if (StrCast(d[key]).includes(query) && !hlights.includes(key)) {
+                            if (StrCast(d[key]).toLowerCase().includes(query) && !hlights.includes(key)) {
                                 hlights.push(key);
                             }
                         });
@@ -763,9 +763,6 @@ export class SearchBox extends ViewBoxBaseComponent<FieldViewProps, SearchBoxDoc
         return (
             <div style={{ pointerEvents: "all" }} className="searchBox-container">
                 <div className="searchBox-bar">
-                    {/* <span className="searchBox-barChild searchBox-collection" onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} ref={this.collectionRef} title="Drag Results as Collection">
-                        <FontAwesomeIcon icon="object-group" size="lg" />
-                    </span> */}
                     <div style={{ position: "absolute", left: 15 }}>{Doc.CurrentUserEmail}</div>
                     <div style={{ display: "flex", alignItems: "center" }}>
                         <FontAwesomeIcon onPointerDown={SetupDrag(this.collectionRef, () => StrCast(this.layoutDoc._searchString) ? this.startDragCollection() : undefined)} icon={"search"} size="lg"
-- 
cgit v1.2.3-70-g09d2

