From 39bb878a32821d2e14110f4158471890234f4769 Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Mon, 29 Apr 2019 19:52:35 -0400
Subject: search UI

---
 src/client/views/SearchBox.tsx | 89 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 89 insertions(+)
 create mode 100644 src/client/views/SearchBox.tsx

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
new file mode 100644
index 000000000..7f388719d
--- /dev/null
+++ b/src/client/views/SearchBox.tsx
@@ -0,0 +1,89 @@
+import * as React from 'react';
+import { observer } from 'mobx-react';
+import { observable, action } from 'mobx';
+import { Utils } from '../../Utils';
+import { MessageStore } from '../../server/Message';
+import { Server } from '../Server';
+import "./SearchBox.scss";
+import { faSearch } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { actionFieldDecorator } from 'mobx/lib/internal';
+
+library.add(faSearch);
+
+@observer
+export class SearchBox extends React.Component {
+    @observable
+    searchString: string = "";
+
+    @observable private _open: boolean = false;
+
+    @action.bound
+    onChange(e: React.ChangeEvent<HTMLInputElement>) {
+        this.searchString = e.target.value;
+
+    }
+
+    submitSearch = () => {
+        Utils.EmitCallback(Server.Socket, MessageStore.SearchFor, this.searchString, (results: string[]) => {
+            for (const result of results) {
+                console.log(result);
+                Utils.GetQueryVariable()
+            }
+        });
+    }
+
+    @action
+    handleClick = (e: Event): void => {
+        var className = (e.target as any).className;
+        var id = (e.target as any).id;
+        console.log(id);
+        //let imgPrev = document.getElementById("img_preview");
+        console.log(className);
+        if (className !== "filter-button" && className !== "filter-form") {
+            console.log("false");
+            this._open = false;
+        }
+
+    }
+
+    componentWillMount() {
+        document.addEventListener('mousedown', this.handleClick, false);
+    }
+
+    componentWillUnmount() {
+        document.removeEventListener('mousedown', this.handleClick, false);
+    }
+
+    @action
+    toggleDisplay = () => {
+        this._open = !this._open;
+    }
+
+    render() {
+        return (
+            <div id="outer">
+                <div className="searchBox" id="outer">
+                    {/* <input value={this.searchString} onChange={this.onChange} />
+                <button onClick={this.submitSearch} /> */}
+
+                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" />
+                    {/* {this._items.filter(prop => prop.description.toLowerCase().indexOf(this._searchString.toLowerCase()) !== -1).
+                    map(prop => <ContextMenuItem {...prop} key={prop.description} />)} */}
+
+                    <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
+                    <div className="submit-search" ><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
+                </div>
+                <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
+                    <div className="filter-form" id="header">Filter Search Results</div>
+                    <div className="filter-form" id="option">
+                        filter by collection, key, type of node
+                    </div>
+
+                </div>
+            </div>
+
+        );
+    }
+}
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From b269ce7d85a9b83280d2b5b23299aa16e6cc5a92 Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 30 Apr 2019 19:59:38 -0400
Subject: confused but still goin

---
 src/client/views/SearchBox.tsx                                    | 2 +-
 .../collections/collectionFreeForm/CollectionFreeFormView.tsx     | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 7f388719d..7ceaf1da6 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -29,7 +29,7 @@ export class SearchBox extends React.Component {
         Utils.EmitCallback(Server.Socket, MessageStore.SearchFor, this.searchString, (results: string[]) => {
             for (const result of results) {
                 console.log(result);
-                Utils.GetQueryVariable()
+                //Utils.GetQueryVariable();
             }
         });
     }
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index 8647ded8a..08c28e76f 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -48,9 +48,13 @@ export class CollectionFreeFormView extends CollectionSubView {
         this.addDocument(newBox, false);
     }
 
-    public addDocument = (newBox: Document, allowDuplicates: boolean) => this.props.addDocument(this.bringToFront(newBox), false);
+    public addDocument = (newBox: Document, allowDuplicates: boolean) => {
+        this.props.addDocument(newBox, false);
+        this.bringToFront(newBox);
+        return true;
+    }
 
-    public selectDocuments = (docs: Document[]) => {
+    private selectDocuments = (docs: Document[]) => {
         SelectionManager.DeselectAll;
         docs.map(doc => DocumentManager.Instance.getDocumentView(doc)).filter(dv => dv).map(dv =>
             SelectionManager.SelectDoc(dv!, true));
-- 
cgit v1.2.3-70-g09d2


From eed0866d6148dfdb29c3f87b42afe365231f258c Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 30 Apr 2019 21:47:03 -0400
Subject: i am CONFUSED

---
 src/client/views/SearchBox.tsx | 31 ++++++++++++++++++++++++-------
 src/server/Search.ts           |  2 ++
 2 files changed, 26 insertions(+), 7 deletions(-)

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 7ceaf1da6..0670360a2 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -9,6 +9,10 @@ import { faSearch } from '@fortawesome/free-solid-svg-icons';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { library } from '@fortawesome/fontawesome-svg-core';
 import { actionFieldDecorator } from 'mobx/lib/internal';
+// const app = express();
+// import * as express from 'express';
+import { Search } from '../../server/Search';
+
 
 library.add(faSearch);
 
@@ -26,12 +30,25 @@ export class SearchBox extends React.Component {
     }
 
     submitSearch = () => {
-        Utils.EmitCallback(Server.Socket, MessageStore.SearchFor, this.searchString, (results: string[]) => {
-            for (const result of results) {
-                console.log(result);
-                //Utils.GetQueryVariable();
-            }
-        });
+        // Utils.EmitCallback(Server.Socket, MessageStore.SearchFor, this.searchString, (results: string[]) => {
+        //     for (const result of results) {
+        //         console.log(result);
+        //         //Utils.GetQueryVariable();
+        //     }
+        // });
+
+        let query = this.searchString;
+        console.log(query);
+        //something bad is happening here
+        let results = Search.Instance.search(query);
+        console.log(results);
+
+        // app.get("/search", async (req, res) => {
+        //     //let query = req.query.query || "hello";
+        //     let query = this.searchString;
+        //     let results = await Search.Instance.search(query);
+        //     res.send(results);
+        // });
     }
 
     @action
@@ -73,7 +90,7 @@ export class SearchBox extends React.Component {
                     map(prop => <ContextMenuItem {...prop} key={prop.description} />)} */}
 
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
-                    <div className="submit-search" ><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
+                    <div className="submit-search" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
                 </div>
                 <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
                     <div className="filter-form" id="header">Filter Search Results</div>
diff --git a/src/server/Search.ts b/src/server/Search.ts
index 7d8602346..8ae996e9e 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -13,6 +13,8 @@ export class Search {
     }
 
     public async search(query: string) {
+        console.log("____________________________");
+        console.log(query);
         const searchResults = JSON.parse(await rp.get(this.url + "dash/select", {
             qs: {
                 q: query
-- 
cgit v1.2.3-70-g09d2


From 364396d9062381d72c618c5b9931267c6cc55c97 Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Mon, 6 May 2019 19:37:37 -0400
Subject: things happening

---
 src/client/views/SearchBox.tsx  | 87 +++++++++++++++++++++++++++++------------
 src/client/views/SearchItem.tsx | 34 ++++++++++++++++
 2 files changed, 95 insertions(+), 26 deletions(-)
 create mode 100644 src/client/views/SearchItem.tsx

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 0670360a2..2fd809d9e 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -12,6 +12,9 @@ import { actionFieldDecorator } from 'mobx/lib/internal';
 // const app = express();
 // import * as express from 'express';
 import { Search } from '../../server/Search';
+import * as rp from 'request-promise';
+import { Document } from '../../fields/Document';
+import { SearchItem } from './SearchItem';
 
 
 library.add(faSearch);
@@ -23,43 +26,74 @@ export class SearchBox extends React.Component {
 
     @observable private _open: boolean = false;
 
+    @observable
+    private _results: any;
+
+    constructor(props: any) {
+        super(props);
+        let searchInput = document.getElementById("input");
+        if (searchInput) {
+            searchInput.addEventListener("keydown", this.onKeyPress)
+        }
+    }
+
+    //this is not working?????
+    @action
+    onKeyPress = (e: KeyboardEvent) => {
+        console.log('things happening')
+        //Number 13 is the "Enter" key on the keyboard
+        if (e.keyCode === 13) {
+            console.log("happi")
+            // Cancel the default action, if needed
+            e.preventDefault();
+            // Trigger the button element with a click
+            let btn = document.getElementById("submit");
+            if (btn) {
+                console.log("yesyesyes")
+                btn.click();
+            }
+        }
+    }
+
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         this.searchString = e.target.value;
+    };
 
-    }
-
-    submitSearch = () => {
-        // Utils.EmitCallback(Server.Socket, MessageStore.SearchFor, this.searchString, (results: string[]) => {
-        //     for (const result of results) {
-        //         console.log(result);
-        //         //Utils.GetQueryVariable();
-        //     }
-        // });
+    submitSearch = async () => {
 
         let query = this.searchString;
-        console.log(query);
-        //something bad is happening here
-        let results = Search.Instance.search(query);
-        console.log(results);
-
-        // app.get("/search", async (req, res) => {
-        //     //let query = req.query.query || "hello";
-        //     let query = this.searchString;
-        //     let results = await Search.Instance.search(query);
-        //     res.send(results);
-        // });
+
+        let response = await rp.get('http://localhost:1050/search', {
+            qs: {
+                query
+            }
+        });
+
+        let results = JSON.parse(response);
+
+        this._results = results;
+
+        let doc = await Server.GetField(this._results[1]);
+        if (doc instanceof Document) {
+            console.log("doc");
+            console.log(doc.Title);
+        }
+
+        // console.log("results")
+        // console.log(results);
+        // console.log("type")
+        // console.log(results.type)
+        console.log(this._results);
+
+
     }
 
     @action
     handleClick = (e: Event): void => {
         var className = (e.target as any).className;
         var id = (e.target as any).id;
-        console.log(id);
-        //let imgPrev = document.getElementById("img_preview");
-        console.log(className);
         if (className !== "filter-button" && className !== "filter-form") {
-            console.log("false");
             this._open = false;
         }
 
@@ -85,12 +119,13 @@ export class SearchBox extends React.Component {
                     {/* <input value={this.searchString} onChange={this.onChange} />
                 <button onClick={this.submitSearch} /> */}
 
-                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" />
+                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" />
                     {/* {this._items.filter(prop => prop.description.toLowerCase().indexOf(this._searchString.toLowerCase()) !== -1).
                     map(prop => <ContextMenuItem {...prop} key={prop.description} />)} */}
+                    {/* {this._results.map(doc => <SearchItem {...doc} key={doc.Title} />)} */}
 
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
-                    <div className="submit-search" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
+                    <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
                 </div>
                 <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
                     <div className="filter-form" id="header">Filter Search Results</div>
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx
new file mode 100644
index 000000000..f030e011b
--- /dev/null
+++ b/src/client/views/SearchItem.tsx
@@ -0,0 +1,34 @@
+import React = require("react");
+import { Document } from "../../fields/Document";
+
+export interface SearchProps {
+    doc: Document;
+    //description: string;
+    //event: (e: React.MouseEvent<HTMLDivElement>) => void;
+}
+
+// export interface SubmenuProps {
+//     description: string;
+//     subitems: ContextMenuProps[];
+// }
+
+// export interface ContextMenuItemProps {
+//     type: ContextMenuProps | SubmenuProps;
+// }
+
+
+
+export class SearchItem extends React.Component<SearchProps> {
+
+    onClick = () => {
+        console.log("clicked search item");
+    };
+
+    render() {
+        return (
+            <div className="search-item" onClick={this.onClick}>
+                <div className="search-title">{this.props.doc.Title}</div>
+            </div>
+        );
+    }
+}
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2


From c3e613aebc056fd75bb1a5b3ac95f2367532b098 Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 7 May 2019 13:11:13 -0400
Subject: type issues??

---
 src/client/views/SearchBox.tsx  | 87 ++++++++++++++++++++++++++---------------
 src/client/views/SearchItem.tsx |  2 +-
 2 files changed, 56 insertions(+), 33 deletions(-)

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 2fd809d9e..eb3cd56fd 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -15,6 +15,7 @@ import { Search } from '../../server/Search';
 import * as rp from 'request-promise';
 import { Document } from '../../fields/Document';
 import { SearchItem } from './SearchItem';
+import { isString } from 'util';
 
 
 library.add(faSearch);
@@ -26,40 +27,41 @@ export class SearchBox extends React.Component {
 
     @observable private _open: boolean = false;
 
-    @observable
-    private _results: any;
-
-    constructor(props: any) {
-        super(props);
-        let searchInput = document.getElementById("input");
-        if (searchInput) {
-            searchInput.addEventListener("keydown", this.onKeyPress)
-        }
-    }
-
-    //this is not working?????
-    @action
-    onKeyPress = (e: KeyboardEvent) => {
-        console.log('things happening')
-        //Number 13 is the "Enter" key on the keyboard
-        if (e.keyCode === 13) {
-            console.log("happi")
-            // Cancel the default action, if needed
-            e.preventDefault();
-            // Trigger the button element with a click
-            let btn = document.getElementById("submit");
-            if (btn) {
-                console.log("yesyesyes")
-                btn.click();
-            }
-        }
-    }
+    //@observable
+    private _results: Document[] = [];
+
+    // constructor(props: any) {
+    //     super(props);
+    //     let searchInput = document.getElementById("input");
+    //     if (searchInput) {
+    //         // searchInput.addEventListener("keydown", this.onKeyPress)
+    //     }
+    // }
+
+    // //this is not working?????
+    // @action
+    // onKeyPress = (e: KeyboardEvent) => {
+    //     console.log('things happening')
+    //     //Number 13 is the "Enter" key on the keyboard
+    //     if (e.keyCode === 13) {
+    //         console.log("happi")
+    //         // Cancel the default action, if needed
+    //         e.preventDefault();
+    //         // Trigger the button element with a click
+    //         let btn = document.getElementById("submit");
+    //         if (btn) {
+    //             console.log("yesyesyes")
+    //             btn.click();
+    //         }
+    //     }
+    // }
 
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         this.searchString = e.target.value;
-    };
+    }
 
+    //@action
     submitSearch = async () => {
 
         let query = this.searchString;
@@ -74,17 +76,38 @@ export class SearchBox extends React.Component {
 
         this._results = results;
 
-        let doc = await Server.GetField(this._results[1]);
+        let doc = await Server.GetField(results[1]);
         if (doc instanceof Document) {
             console.log("doc");
             console.log(doc.Title);
         }
 
+        // weird things happening
         // console.log("results")
         // console.log(results);
         // console.log("type")
         // console.log(results.type)
-        console.log(this._results);
+        let temp: string = this._results[1].Id;
+        // console.log(this._results)
+        // console.log(this._results[1])
+
+        console.log(this._results[1].constructor.name)
+
+        if (this._results[1] instanceof Document) {
+            console.log("is a doc")
+        }
+
+        if (this._results[1]) {
+            console.log("is a string")
+        }
+
+        console.log(temp);
+        let doc2 = await Server.GetField(temp);
+        console.log(doc2);
+        if (doc2 instanceof Document) {
+            console.log("doc2");
+            console.log(doc2.Title);
+        }
 
 
     }
@@ -122,7 +145,7 @@ export class SearchBox extends React.Component {
                     <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" />
                     {/* {this._items.filter(prop => prop.description.toLowerCase().indexOf(this._searchString.toLowerCase()) !== -1).
                     map(prop => <ContextMenuItem {...prop} key={prop.description} />)} */}
-                    {/* {this._results.map(doc => <SearchItem {...doc} key={doc.Title} />)} */}
+                    {this._results.map(doc => <SearchItem {...doc} key={doc.Title} />)}
 
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
                     <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx
index f030e011b..c8fd6457b 100644
--- a/src/client/views/SearchItem.tsx
+++ b/src/client/views/SearchItem.tsx
@@ -22,7 +22,7 @@ export class SearchItem extends React.Component<SearchProps> {
 
     onClick = () => {
         console.log("clicked search item");
-    };
+    }
 
     render() {
         return (
-- 
cgit v1.2.3-70-g09d2


From 96d9bd38cb3ae6d59945d15071e1b346e4d0a8e2 Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 7 May 2019 14:38:23 -0400
Subject: hacky way of getting search to work

---
 src/client/views/SearchBox.scss | 52 ++++++++++++++++++++++++++++++++---------
 src/client/views/SearchBox.tsx  | 52 +++++++++++------------------------------
 2 files changed, 55 insertions(+), 49 deletions(-)

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

diff --git a/src/client/views/SearchBox.scss b/src/client/views/SearchBox.scss
index 92363e681..1aad13b2e 100644
--- a/src/client/views/SearchBox.scss
+++ b/src/client/views/SearchBox.scss
@@ -8,18 +8,7 @@
     transition: width 0.4s ease-in-out;
     align-items: center;
 
-    .submit-search {
-        text-align: right;
-        color: $dark-color;
-        -webkit-transition: right 0.4s;
-        transition: right 0.4s;
-    }
 
-    .submit-search:hover {
-        color: $main-accent;
-        transform: scale(1.05);
-        cursor: pointer;
-    }
 
     input[type=text] {
         width: 130px;
@@ -38,6 +27,19 @@
         position: absolute;
         right: 30px;
     }
+
+    .submit-search {
+        text-align: right;
+        color: $dark-color;
+        -webkit-transition: right 0.4s;
+        transition: right 0.4s;
+    }
+
+    .submit-search:hover {
+        color: $main-accent;
+        transform: scale(1.05);
+        cursor: pointer;
+    }
 }
 
 .filter-form {
@@ -60,4 +62,32 @@
 
 #option {
     height: 20px;
+}
+
+.search-item {
+    width: 500px;
+    height: 50px;
+    background: $light-color-secondary;
+    display: flex;
+    justify-content: left;
+    align-items: center;
+    transition: all 0.1s;
+    border-width: 0.11px;
+    border-style: none;
+    border-color: $intermediate-color;
+    border-bottom-style: solid;
+    padding: 10px;
+    white-space: nowrap;
+    font-size: 13px;
+}
+
+.search-item:hover {
+    transition: all 0.1s;
+    background: $lighter-alt-accent;
+}
+
+.search-title {
+    text-transform: uppercase;
+    text-align: left;
+    width: 8vw;
 }
\ No newline at end of file
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index eb3cd56fd..eecd9c8bb 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -74,42 +74,19 @@ export class SearchBox extends React.Component {
 
         let results = JSON.parse(response);
 
-        this._results = results;
-
-        let doc = await Server.GetField(results[1]);
-        if (doc instanceof Document) {
-            console.log("doc");
-            console.log(doc.Title);
-        }
-
-        // weird things happening
-        // console.log("results")
-        // console.log(results);
-        // console.log("type")
-        // console.log(results.type)
-        let temp: string = this._results[1].Id;
-        // console.log(this._results)
-        // console.log(this._results[1])
-
-        console.log(this._results[1].constructor.name)
-
-        if (this._results[1] instanceof Document) {
-            console.log("is a doc")
-        }
-
-        if (this._results[1]) {
-            console.log("is a string")
-        }
-
-        console.log(temp);
-        let doc2 = await Server.GetField(temp);
-        console.log(doc2);
-        if (doc2 instanceof Document) {
-            console.log("doc2");
-            console.log(doc2.Title);
-        }
+        //gets json result into a list of documents that can be used
+        this.getResults(results);
 
+    }
 
+    getResults = async (res: string[]) => {
+        let doc;
+        res.map(async result => {
+            doc = await Server.GetField(result);
+            if (doc instanceof Document) {
+                this._results.push(doc);
+            }
+        });
     }
 
     @action
@@ -143,10 +120,9 @@ export class SearchBox extends React.Component {
                 <button onClick={this.submitSearch} /> */}
 
                     <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" />
-                    {/* {this._items.filter(prop => prop.description.toLowerCase().indexOf(this._searchString.toLowerCase()) !== -1).
-                    map(prop => <ContextMenuItem {...prop} key={prop.description} />)} */}
-                    {this._results.map(doc => <SearchItem {...doc} key={doc.Title} />)}
-
+                    <div style={this._open ? { display: "flex" } : { display: "none" }}>
+                        {this._results.map(result => <SearchItem doc={result} key={result.Id} />)}
+                    </div>
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
                     <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
                 </div>
-- 
cgit v1.2.3-70-g09d2


From 500f75d10f82db4717cba968577f9421d901a17c Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 7 May 2019 15:51:00 -0400
Subject: things showing up

---
 src/client/views/SearchBox.tsx | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index eecd9c8bb..0760578a8 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -1,6 +1,6 @@
 import * as React from 'react';
 import { observer } from 'mobx-react';
-import { observable, action } from 'mobx';
+import { observable, action, runInAction } from 'mobx';
 import { Utils } from '../../Utils';
 import { MessageStore } from '../../server/Message';
 import { Server } from '../Server';
@@ -8,7 +8,6 @@ import "./SearchBox.scss";
 import { faSearch } from '@fortawesome/free-solid-svg-icons';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { library } from '@fortawesome/fontawesome-svg-core';
-import { actionFieldDecorator } from 'mobx/lib/internal';
 // const app = express();
 // import * as express from 'express';
 import { Search } from '../../server/Search';
@@ -26,8 +25,9 @@ export class SearchBox extends React.Component {
     searchString: string = "";
 
     @observable private _open: boolean = false;
+    @observable private _resultsOpen: boolean = false;
 
-    //@observable
+    @observable
     private _results: Document[] = [];
 
     // constructor(props: any) {
@@ -61,7 +61,7 @@ export class SearchBox extends React.Component {
         this.searchString = e.target.value;
     }
 
-    //@action
+    @action
     submitSearch = async () => {
 
         let query = this.searchString;
@@ -71,20 +71,20 @@ export class SearchBox extends React.Component {
                 query
             }
         });
-
         let results = JSON.parse(response);
 
         //gets json result into a list of documents that can be used
         this.getResults(results);
 
+        runInAction(() => { this._resultsOpen = true; });
     }
 
+    @action
     getResults = async (res: string[]) => {
-        let doc;
         res.map(async result => {
-            doc = await Server.GetField(result);
+            const doc = await Server.GetField(result);
             if (doc instanceof Document) {
-                this._results.push(doc);
+                runInAction(() => this._results.push(doc));
             }
         });
     }
@@ -120,7 +120,7 @@ export class SearchBox extends React.Component {
                 <button onClick={this.submitSearch} /> */}
 
                     <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" />
-                    <div style={this._open ? { display: "flex" } : { display: "none" }}>
+                    <div style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
                         {this._results.map(result => <SearchItem doc={result} key={result.Id} />)}
                     </div>
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
-- 
cgit v1.2.3-70-g09d2


From 93d2214b84eaef61c9a9f980d24b5c1addbd67dc Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 7 May 2019 16:26:51 -0400
Subject: things working

---
 src/client/views/SearchBox.scss |  6 ++++++
 src/client/views/SearchBox.tsx  | 46 ++++++++++++-----------------------------
 src/client/views/SearchItem.tsx |  2 +-
 3 files changed, 20 insertions(+), 34 deletions(-)

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

diff --git a/src/client/views/SearchBox.scss b/src/client/views/SearchBox.scss
index 1aad13b2e..f4fc0029e 100644
--- a/src/client/views/SearchBox.scss
+++ b/src/client/views/SearchBox.scss
@@ -64,6 +64,12 @@
     height: 20px;
 }
 
+.results {
+    top: 300px;
+    display: flex;
+    flex-direction: column;
+}
+
 .search-item {
     width: 500px;
     height: 50px;
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 0760578a8..ff215efab 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -15,6 +15,7 @@ import * as rp from 'request-promise';
 import { Document } from '../../fields/Document';
 import { SearchItem } from './SearchItem';
 import { isString } from 'util';
+import { constant } from 'async';
 
 
 library.add(faSearch);
@@ -30,40 +31,15 @@ export class SearchBox extends React.Component {
     @observable
     private _results: Document[] = [];
 
-    // constructor(props: any) {
-    //     super(props);
-    //     let searchInput = document.getElementById("input");
-    //     if (searchInput) {
-    //         // searchInput.addEventListener("keydown", this.onKeyPress)
-    //     }
-    // }
-
-    // //this is not working?????
-    // @action
-    // onKeyPress = (e: KeyboardEvent) => {
-    //     console.log('things happening')
-    //     //Number 13 is the "Enter" key on the keyboard
-    //     if (e.keyCode === 13) {
-    //         console.log("happi")
-    //         // Cancel the default action, if needed
-    //         e.preventDefault();
-    //         // Trigger the button element with a click
-    //         let btn = document.getElementById("submit");
-    //         if (btn) {
-    //             console.log("yesyesyes")
-    //             btn.click();
-    //         }
-    //     }
-    // }
-
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         this.searchString = e.target.value;
+        console.log(this.searchString)
     }
 
     @action
     submitSearch = async () => {
-
+        runInAction(() => this._results = []);
         let query = this.searchString;
 
         let response = await rp.get('http://localhost:1050/search', {
@@ -112,19 +88,23 @@ export class SearchBox extends React.Component {
         this._open = !this._open;
     }
 
+    enter = (e: React.KeyboardEvent<HTMLInputElement>) => {
+        if (e.key === "Enter") {
+            this.submitSearch();
+        }
+    }
+
     render() {
         return (
             <div id="outer">
                 <div className="searchBox" id="outer">
-                    {/* <input value={this.searchString} onChange={this.onChange} />
-                <button onClick={this.submitSearch} /> */}
 
-                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" />
-                    <div style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
-                        {this._results.map(result => <SearchItem doc={result} key={result.Id} />)}
-                    </div>
+                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" onKeyPress={this.enter} />
                     <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
                     <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
+                    <div className="results" style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
+                        {this._results.map(result => <SearchItem doc={result} key={result.Id} />)}
+                    </div>
                 </div>
                 <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
                     <div className="filter-form" id="header">Filter Search Results</div>
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx
index c8fd6457b..6021c0736 100644
--- a/src/client/views/SearchItem.tsx
+++ b/src/client/views/SearchItem.tsx
@@ -21,7 +21,7 @@ export interface SearchProps {
 export class SearchItem extends React.Component<SearchProps> {
 
     onClick = () => {
-        console.log("clicked search item");
+        console.log("document clicked: ", this.props.doc);
     }
 
     render() {
-- 
cgit v1.2.3-70-g09d2


From 11ab63f6c91093951fdc293c3d67e63073fb2f4c Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Tue, 7 May 2019 17:42:37 -0400
Subject: navigate to searched doc

---
 src/client/util/DocumentManager.ts | 30 +++++++++++++++++++++++++++++-
 src/client/views/Main.tsx          |  2 +-
 src/client/views/SearchBox.tsx     |  2 +-
 src/client/views/SearchItem.tsx    | 16 ++--------------
 src/client/views/nodes/LinkBox.tsx | 23 +----------------------
 5 files changed, 34 insertions(+), 39 deletions(-)

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

diff --git a/src/client/util/DocumentManager.ts b/src/client/util/DocumentManager.ts
index 69964e2c9..3151bcfb5 100644
--- a/src/client/util/DocumentManager.ts
+++ b/src/client/util/DocumentManager.ts
@@ -1,8 +1,10 @@
 import { computed, observable } from 'mobx';
 import { DocumentView } from '../views/nodes/DocumentView';
 import { Doc } from '../../new_fields/Doc';
-import { FieldValue, Cast } from '../../new_fields/Types';
+import { FieldValue, Cast, NumCast } from '../../new_fields/Types';
 import { listSpec } from '../../new_fields/Schema';
+import { undoBatch } from './UndoManager';
+import { CollectionDockingView } from '../views/collections/CollectionDockingView';
 
 
 export class DocumentManager {
@@ -87,4 +89,30 @@ export class DocumentManager {
             return pairs;
         }, [] as { a: DocumentView, b: DocumentView, l: Doc }[]);
     }
+
+    @undoBatch
+    public jumpToDocument = async (doc: Doc): Promise<void> => {
+        let docView = DocumentManager.Instance.getDocumentView(doc);
+        if (docView) {
+            docView.props.focus(docView.props.Document);
+        } else {
+            const contextDoc = await Cast(doc.annotationOn, Doc);
+            if (!contextDoc) {
+                CollectionDockingView.Instance.AddRightSplit(Doc.MakeDelegate(doc));
+            } else {
+                const page = NumCast(doc.page, undefined);
+                const curPage = NumCast(contextDoc.curPage, undefined);
+                if (page !== curPage) {
+                    contextDoc.curPage = page;
+                }
+                let contextView = DocumentManager.Instance.getDocumentView(contextDoc);
+                if (contextView) {
+                    contextDoc.panTransformType = "Ease";
+                    contextView.props.focus(contextDoc);
+                } else {
+                    CollectionDockingView.Instance.AddRightSplit(contextDoc);
+                }
+            }
+        }
+    }
 }
\ No newline at end of file
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx
index 677902c5b..c9d5c395c 100644
--- a/src/client/views/Main.tsx
+++ b/src/client/views/Main.tsx
@@ -267,7 +267,7 @@ export class Main extends React.Component {
                 <button className="toolbar-button round-button" title="Ink" onClick={() => InkingControl.Instance.toggleDisplay()}><FontAwesomeIcon icon="pen-nib" size="sm" /></button>
             </div >,
             <div className="main-searchDiv" key="search" style={{ top: '34px', right: '1px', position: 'absolute' }} > <SearchBox /> </div>,
-            <div className="main-buttonDiv" key="logout" style={{ top: '34px', right: '1px', position: 'absolute' }} ref={logoutRef}>
+            <div className="main-buttonDiv" key="logout" style={{ bottom: '0px', right: '1px', position: 'absolute' }} ref={logoutRef}>
                 <button onClick={() => request.get(DocServer.prepend(RouteStore.logout), emptyFunction)}>Log Out</button></div>
         ];
 
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index a52598f4c..827d468df 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -17,6 +17,7 @@ import { constant } from 'async';
 import { DocServer } from '../DocServer';
 import { Doc } from '../../new_fields/Doc';
 import { Id } from '../../new_fields/RefField';
+import { DocumentManager } from '../util/DocumentManager';
 
 
 library.add(faSearch);
@@ -35,7 +36,6 @@ export class SearchBox extends React.Component {
     @action.bound
     onChange(e: React.ChangeEvent<HTMLInputElement>) {
         this.searchString = e.target.value;
-        console.log(this.searchString)
     }
 
     @action
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx
index 82cb5404c..81da7ebd2 100644
--- a/src/client/views/SearchItem.tsx
+++ b/src/client/views/SearchItem.tsx
@@ -1,27 +1,15 @@
 import React = require("react");
 import { Doc } from "../../new_fields/Doc";
+import { DocumentManager } from "../util/DocumentManager";
 
 export interface SearchProps {
     doc: Doc;
-    //description: string;
-    //event: (e: React.MouseEvent<HTMLDivElement>) => void;
 }
 
-// export interface SubmenuProps {
-//     description: string;
-//     subitems: ContextMenuProps[];
-// }
-
-// export interface ContextMenuItemProps {
-//     type: ContextMenuProps | SubmenuProps;
-// }
-
-
-
 export class SearchItem extends React.Component<SearchProps> {
 
     onClick = () => {
-        console.log("document clicked: ", this.props.doc);
+        DocumentManager.Instance.jumpToDocument(this.props.doc)
     }
 
     render() {
diff --git a/src/client/views/nodes/LinkBox.tsx b/src/client/views/nodes/LinkBox.tsx
index 08cfa590b..611cb66b6 100644
--- a/src/client/views/nodes/LinkBox.tsx
+++ b/src/client/views/nodes/LinkBox.tsx
@@ -31,28 +31,7 @@ export class LinkBox extends React.Component<Props> {
     @undoBatch
     onViewButtonPressed = async (e: React.PointerEvent): Promise<void> => {
         e.stopPropagation();
-        let docView = DocumentManager.Instance.getDocumentView(this.props.pairedDoc);
-        if (docView) {
-            docView.props.focus(docView.props.Document);
-        } else {
-            const contextDoc = await Cast(this.props.pairedDoc.annotationOn, Doc);
-            if (!contextDoc) {
-                CollectionDockingView.Instance.AddRightSplit(Doc.MakeDelegate(this.props.pairedDoc));
-            } else {
-                const page = NumCast(this.props.pairedDoc.page, undefined);
-                const curPage = NumCast(contextDoc.curPage, undefined);
-                if (page !== curPage) {
-                    contextDoc.curPage = page;
-                }
-                let contextView = DocumentManager.Instance.getDocumentView(contextDoc);
-                if (contextView) {
-                    contextDoc.panTransformType = "Ease";
-                    contextView.props.focus(contextDoc);
-                } else {
-                    CollectionDockingView.Instance.AddRightSplit(contextDoc);
-                }
-            }
-        }
+        DocumentManager.Instance.jumpToDocument(this.props.pairedDoc);
     }
 
     onEditButtonPressed = (e: React.PointerEvent): void => {
-- 
cgit v1.2.3-70-g09d2


From b5fac34cf22bcb47854c00671848e25b7ee9d37f Mon Sep 17 00:00:00 2001
From: Monika Hedman <monika_hedman@brown.edu>
Date: Wed, 8 May 2019 20:38:02 -0400
Subject: issues with icon

---
 src/client/views/SearchBox.scss | 50 ++++++++++++++++++++---------------------
 src/client/views/SearchBox.tsx  | 24 +++++++++++++++-----
 src/client/views/SearchItem.tsx | 36 ++++++++++++++++++++++++++---
 3 files changed, 76 insertions(+), 34 deletions(-)

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

diff --git a/src/client/views/SearchBox.scss b/src/client/views/SearchBox.scss
index f4fc0029e..792d6dd3c 100644
--- a/src/client/views/SearchBox.scss
+++ b/src/client/views/SearchBox.scss
@@ -68,32 +68,32 @@
     top: 300px;
     display: flex;
     flex-direction: column;
-}
 
-.search-item {
-    width: 500px;
-    height: 50px;
-    background: $light-color-secondary;
-    display: flex;
-    justify-content: left;
-    align-items: center;
-    transition: all 0.1s;
-    border-width: 0.11px;
-    border-style: none;
-    border-color: $intermediate-color;
-    border-bottom-style: solid;
-    padding: 10px;
-    white-space: nowrap;
-    font-size: 13px;
-}
+    .search-item {
+        width: 500px;
+        height: 50px;
+        background: $light-color-secondary;
+        display: flex;
+        justify-content: space-between;
+        align-items: center;
+        transition: all 0.1s;
+        border-width: 0.11px;
+        border-style: none;
+        border-color: $intermediate-color;
+        border-bottom-style: solid;
+        padding: 10px;
+        white-space: nowrap;
+        font-size: 13px;
+    }
 
-.search-item:hover {
-    transition: all 0.1s;
-    background: $lighter-alt-accent;
-}
+    .search-item:hover {
+        transition: all 0.1s;
+        background: $lighter-alt-accent;
+    }
 
-.search-title {
-    text-transform: uppercase;
-    text-align: left;
-    width: 8vw;
+    .search-title {
+        text-transform: uppercase;
+        text-align: left;
+        width: 8vw;
+    }
 }
\ No newline at end of file
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 827d468df..7dd1af4e7 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -67,7 +67,7 @@ export class SearchBox extends React.Component {
     }
 
     @action
-    handleClick = (e: Event): void => {
+    handleClickFilter = (e: Event): void => {
         var className = (e.target as any).className;
         var id = (e.target as any).id;
         if (className !== "filter-button" && className !== "filter-form") {
@@ -76,16 +76,28 @@ export class SearchBox extends React.Component {
 
     }
 
+    @action
+    handleClickResults = (e: Event): void => {
+        var className = (e.target as any).className;
+        var id = (e.target as any).id;
+        if (id !== "result") {
+            this._resultsOpen = false;
+        }
+
+    }
+
     componentWillMount() {
-        document.addEventListener('mousedown', this.handleClick, false);
+        document.addEventListener('mousedown', this.handleClickFilter, false);
+        document.addEventListener('mousedown', this.handleClickResults, false);
     }
 
     componentWillUnmount() {
-        document.removeEventListener('mousedown', this.handleClick, false);
+        document.removeEventListener('mousedown', this.handleClickFilter, false);
+        document.removeEventListener('mousedown', this.handleClickResults, false);
     }
 
     @action
-    toggleDisplay = () => {
+    toggleFilterDisplay = () => {
         this._open = !this._open;
     }
 
@@ -101,9 +113,9 @@ export class SearchBox extends React.Component {
                 <div className="searchBox" id="outer">
 
                     <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" onKeyPress={this.enter} />
-                    <button className="filter-button" onClick={this.toggleDisplay}> Filter </button>
+                    <button className="filter-button" onClick={this.toggleFilterDisplay}> Filter </button>
                     <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
-                    <div className="results" style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
+                    <div className="results" id="results" style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
                         {this._results.map(result => <SearchItem doc={result} key={result[Id]} />)}
                     </div>
                 </div>
diff --git a/src/client/views/SearchItem.tsx b/src/client/views/SearchItem.tsx
index 81da7ebd2..539d6b5e5 100644
--- a/src/client/views/SearchItem.tsx
+++ b/src/client/views/SearchItem.tsx
@@ -1,21 +1,51 @@
 import React = require("react");
 import { Doc } from "../../new_fields/Doc";
 import { DocumentManager } from "../util/DocumentManager";
+import { library } from '@fortawesome/fontawesome-svg-core';
+import { faCaretUp, faFilePdf, faFilm, faImage, faObjectGroup, faStickyNote } from '@fortawesome/free-solid-svg-icons';
+import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { Cast } from "../../new_fields/Types";
+import { FieldView, FieldViewProps } from './nodes/FieldView';
+import { computed } from "mobx";
+import { IconField } from "../../new_fields/IconField";
+
 
 export interface SearchProps {
     doc: Doc;
 }
 
+library.add(faCaretUp);
+library.add(faObjectGroup);
+library.add(faStickyNote);
+library.add(faFilePdf);
+library.add(faFilm);
+
 export class SearchItem extends React.Component<SearchProps> {
 
     onClick = () => {
-        DocumentManager.Instance.jumpToDocument(this.props.doc)
+        DocumentManager.Instance.jumpToDocument(this.props.doc);
+    }
+
+    //needs help
+    // @computed get layout(): string { const field = Cast(this.props.doc[fieldKey], IconField); return field ? field.icon : "<p>Error loading icon data</p>"; }
+
+
+    public static DocumentIcon(layout: string) {
+        let button = layout.indexOf("PDFBox") !== -1 ? faFilePdf :
+            layout.indexOf("ImageBox") !== -1 ? faImage :
+                layout.indexOf("Formatted") !== -1 ? faStickyNote :
+                    layout.indexOf("Video") !== -1 ? faFilm :
+                        layout.indexOf("Collection") !== -1 ? faObjectGroup :
+                            faCaretUp;
+        return <FontAwesomeIcon icon={button} className="documentView-minimizedIcon" />;
     }
 
     render() {
         return (
-            <div className="search-item" onClick={this.onClick}>
-                <div className="search-title">{this.props.doc.title}</div>
+            <div className="search-item" id="result" onClick={this.onClick}>
+                <div className="search-title" id="result" >title: {this.props.doc.title}</div>
+                <div className="search-type" id="result" >Type: {this.props.doc.layout}</div>
+                {/* <div className="search-type" >{SearchItem.DocumentIcon(this.layout)}</div> */}
             </div>
         );
     }
-- 
cgit v1.2.3-70-g09d2


From 913244091c3ad3fefad7c9e3eeeeb432a9b3d15e Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Fri, 10 May 2019 06:39:00 -0400
Subject: Refactored SearchBox Made DragManager able to handle async functions
 Cleaned up some other stuff

---
 src/client/util/DragManager.ts  |  16 +++---
 src/client/views/SearchBox.scss |  43 ++++++++--------
 src/client/views/SearchBox.tsx  | 106 ++++++++++++++++++++++++++++------------
 src/server/Search.ts            |   5 +-
 src/server/index.ts             |   4 +-
 5 files changed, 110 insertions(+), 64 deletions(-)

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

diff --git a/src/client/util/DragManager.ts b/src/client/util/DragManager.ts
index 266679c16..c0402f0c9 100644
--- a/src/client/util/DragManager.ts
+++ b/src/client/util/DragManager.ts
@@ -6,28 +6,28 @@ import { CollectionDockingView } from "../views/collections/CollectionDockingVie
 import * as globalCssVariables from "../views/globalCssVariables.scss";
 
 export type dropActionType = "alias" | "copy" | undefined;
-export function SetupDrag(_reference: React.RefObject<HTMLDivElement>, docFunc: () => Doc, moveFunc?: DragManager.MoveFunction, dropAction?: dropActionType) {
-    let onRowMove = action((e: PointerEvent): void => {
+export function SetupDrag(_reference: React.RefObject<HTMLElement>, docFunc: () => Doc | Promise<Doc>, moveFunc?: DragManager.MoveFunction, dropAction?: dropActionType) {
+    let onRowMove = async (e: PointerEvent) => {
         e.stopPropagation();
         e.preventDefault();
 
         document.removeEventListener("pointermove", onRowMove);
         document.removeEventListener('pointerup', onRowUp);
-        var dragData = new DragManager.DocumentDragData([docFunc()]);
+        var dragData = new DragManager.DocumentDragData([await docFunc()]);
         dragData.dropAction = dropAction;
         dragData.moveDocument = moveFunc;
         DragManager.StartDocumentDrag([_reference.current!], dragData, e.x, e.y);
-    });
-    let onRowUp = action((e: PointerEvent): void => {
+    };
+    let onRowUp = (): void => {
         document.removeEventListener("pointermove", onRowMove);
         document.removeEventListener('pointerup', onRowUp);
-    });
-    let onItemDown = (e: React.PointerEvent) => {
+    };
+    let onItemDown = async (e: React.PointerEvent) => {
         // if (this.props.isSelected() || this.props.isTopMost) {
         if (e.button === 0) {
             e.stopPropagation();
             if (e.shiftKey) {
-                CollectionDockingView.Instance.StartOtherDrag([docFunc()], e);
+                CollectionDockingView.Instance.StartOtherDrag([await docFunc()], e);
             } else {
                 document.addEventListener("pointermove", onRowMove);
                 document.addEventListener("pointerup", onRowUp);
diff --git a/src/client/views/SearchBox.scss b/src/client/views/SearchBox.scss
index 792d6dd3c..b38e6091d 100644
--- a/src/client/views/SearchBox.scss
+++ b/src/client/views/SearchBox.scss
@@ -1,47 +1,50 @@
 @import "globalCssVariables";
 
-.searchBox {
+.searchBox-bar {
     height: 32px;
-    //display: flex;
-    //padding: 4px;
-    -webkit-transition: width 0.4s ease-in-out;
-    transition: width 0.4s ease-in-out;
+    display: flex;
+    justify-content: flex-end;
     align-items: center;
+    padding-left: 2px;
+    padding-right: 2px;
 
-
-
-    input[type=text] {
+    .searchBox-input {
         width: 130px;
         -webkit-transition: width 0.4s;
         transition: width 0.4s;
-        position: absolute;
-        right: 100px;
+        align-self: stretch;
     }
 
-    input[type=text]:focus {
+    .searchBox-input:focus {
         width: 500px;
         outline: 3px solid lightblue;
     }
 
-    .filter-button {
-        position: absolute;
-        right: 30px;
+    .searchBox-barChild {
+        flex: 0 1 auto;
+        margin-left: 2px;
+        margin-right: 2px;
     }
 
-    .submit-search {
-        text-align: right;
+    .searchBox-filter {
+        align-self: stretch;
+    }
+
+    .searchBox-submit {
         color: $dark-color;
-        -webkit-transition: right 0.4s;
-        transition: right 0.4s;
     }
 
-    .submit-search:hover {
+    .searchBox-submit:hover {
         color: $main-accent;
         transform: scale(1.05);
         cursor: pointer;
     }
 }
 
+.searchBox-results {
+    margin-left: 27px; //Is there a better way to do this?
+}
+
 .filter-form {
     background: $dark-color;
     height: 400px;
@@ -64,7 +67,7 @@
     height: 20px;
 }
 
-.results {
+.searchBox-results {
     top: 300px;
     display: flex;
     flex-direction: column;
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 7dd1af4e7..9b9735a4b 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -4,7 +4,7 @@ import { observable, action, runInAction } from 'mobx';
 import { Utils } from '../../Utils';
 import { MessageStore } from '../../server/Message';
 import "./SearchBox.scss";
-import { faSearch } from '@fortawesome/free-solid-svg-icons';
+import { faSearch, faObjectGroup } from '@fortawesome/free-solid-svg-icons';
 import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
 import { library } from '@fortawesome/fontawesome-svg-core';
 // const app = express();
@@ -18,9 +18,11 @@ import { DocServer } from '../DocServer';
 import { Doc } from '../../new_fields/Doc';
 import { Id } from '../../new_fields/RefField';
 import { DocumentManager } from '../util/DocumentManager';
-
+import { SetupDrag } from '../util/DragManager';
+import { Docs } from '../documents/Documents';
 
 library.add(faSearch);
+library.add(faObjectGroup);
 
 @observer
 export class SearchBox extends React.Component {
@@ -40,30 +42,33 @@ export class SearchBox extends React.Component {
 
     @action
     submitSearch = async () => {
-        runInAction(() => this._results = []);
         let query = this.searchString;
-
-        let response = await rp.get('http://localhost:1050/search', {
-            qs: {
-                query
-            }
-        });
-        let results = JSON.parse(response);
-
         //gets json result into a list of documents that can be used
-        this.getResults(results);
+        const results = await this.getResults(query);
 
-        runInAction(() => { this._resultsOpen = true; });
+        runInAction(() => {
+            this._resultsOpen = true;
+            this._results = results;
+        });
     }
 
     @action
-    getResults = async (res: string[]) => {
-        res.map(async result => {
-            const doc = await DocServer.GetRefField(result);
-            if (doc instanceof Doc) {
-                runInAction(() => this._results.push(doc));
+    getResults = async (query: string) => {
+        let response = await rp.get('http://localhost:1050/search', {
+            qs: {
+                query
             }
         });
+        let res: string[] = JSON.parse(response);
+        const fields = await DocServer.GetRefFields(res);
+        const docs: Doc[] = [];
+        for (const id of res) {
+            const field = fields[id];
+            if (field instanceof Doc) {
+                docs.push(field);
+            }
+        }
+        return docs;
     }
 
     @action
@@ -82,6 +87,7 @@ export class SearchBox extends React.Component {
         var id = (e.target as any).id;
         if (id !== "result") {
             this._resultsOpen = false;
+            this._results = [];
         }
 
     }
@@ -107,27 +113,63 @@ export class SearchBox extends React.Component {
         }
     }
 
+    collectionRef = React.createRef<HTMLSpanElement>();
+    startDragCollection = async () => {
+        const results = await this.getResults(this.searchString);
+        const docs = results.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) {
+            doc.x = x;
+            doc.y = y;
+            doc.width = 200;
+            doc.height = 200;
+            x += 250;
+            if (x > 1000) {
+                x = 0;
+                y += 250;
+            }
+        }
+        return Docs.FreeformDocument(docs, { width: 400, height: 400, panX: 175, panY: 175, title: `Search Docs: "${this.searchString}"` });
+    }
+
     render() {
         return (
-            <div id="outer">
-                <div className="searchBox" id="outer">
-
-                    <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search.." className="search" id="input" onKeyPress={this.enter} />
-                    <button className="filter-button" onClick={this.toggleFilterDisplay}> Filter </button>
-                    <div className="submit-search" id="submit" onClick={this.submitSearch}><FontAwesomeIcon style={{ height: "100%" }} icon="search" size="lg" /></div>
-                    <div className="results" id="results" style={this._resultsOpen ? { display: "flex" } : { display: "none" }}>
-                        {this._results.map(result => <SearchItem doc={result} key={result[Id]} />)}
+            <div>
+                <div className="searchBox-container">
+                    <div className="searchBox-bar">
+                        <span onPointerDown={SetupDrag(this.collectionRef, this.startDragCollection)} ref={this.collectionRef}>
+                            <FontAwesomeIcon icon="object-group" className="searchBox-barChild" size="lg" />
+                        </span>
+                        <input value={this.searchString} onChange={this.onChange} type="text" placeholder="Search..."
+                            className="searchBox-barChild searchBox-input" onKeyPress={this.enter}
+                            style={{ width: this._resultsOpen ? "500px" : undefined }} />
+                        <button className="searchBox-barChild searchBox-filter" onClick={this.toggleFilterDisplay}>Filter</button>
+                        <FontAwesomeIcon icon="search" size="lg" className="searchBox-barChild searchBox-submit" />
                     </div>
+                    {this._resultsOpen ? (
+                        <div className="searchBox-results">
+                            {this._results.map(result => <SearchItem doc={result} key={result[Id]} />)}
+                        </div>
+                    ) : null}
                 </div>
-                <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
-                    <div className="filter-form" id="header">Filter Search Results</div>
-                    <div className="filter-form" id="option">
-                        filter by collection, key, type of node
+                {this._open ? (
+                    <div className="filter-form" id="filter" style={this._open ? { display: "flex" } : { display: "none" }}>
+                        <div className="filter-form" id="header">Filter Search Results</div>
+                        <div className="filter-form" id="option">
+                            filter by collection, key, type of node
                     </div>
 
-                </div>
+                    </div>
+                ) : null}
             </div>
-
         );
     }
 }
\ No newline at end of file
diff --git a/src/server/Search.ts b/src/server/Search.ts
index c3cb3c3e6..1bede5b49 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -8,11 +8,12 @@ export class Search {
 
     public async updateDocument(document: any) {
         try {
-            return await rp.post(this.url + "dash/update", {
+            const res = await rp.post(this.url + "dash/update", {
                 headers: { 'content-type': 'application/json' },
                 body: JSON.stringify([document])
             });
-        } catch { }
+            return res;
+        } catch (e) { }
     }
 
     public async search(query: string) {
diff --git a/src/server/index.ts b/src/server/index.ts
index 7a548607f..6c64aa161 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -356,12 +356,12 @@ function UpdateField(socket: Socket, diff: Diff) {
     for (let key in docfield) {
         if (!key.startsWith("fields.")) continue;
         dynfield = true;
-        Object.values(suffixMap).forEach(suf => update[key + getSuffix(suf)] = null);
         let val = docfield[key];
+        key = key.substring(7);
+        Object.values(suffixMap).forEach(suf => update[key + getSuffix(suf)] = null);
         let term = ToSearchTerm(val);
         if (term !== undefined) {
             let { suffix, value } = term;
-            key = key.substring(7);
             update[key + suffix] = { set: value };
         }
     }
-- 
cgit v1.2.3-70-g09d2


From 464843e773022edc9a6ce6228b88ffb72021fa85 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Fri, 10 May 2019 13:13:35 -0400
Subject: Fixed search url

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

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

diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 9b9735a4b..134201071 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -54,7 +54,7 @@ export class SearchBox extends React.Component {
 
     @action
     getResults = async (query: string) => {
-        let response = await rp.get('http://localhost:1050/search', {
+        let response = await rp.get(DocServer.prepend('/search'), {
             qs: {
                 query
             }
-- 
cgit v1.2.3-70-g09d2


From a225d9f4ee0d44e8cb14f30f27571ec0e846e1e1 Mon Sep 17 00:00:00 2001
From: Tyler Schicke <tyler_schicke@brown.edu>
Date: Sun, 12 May 2019 01:43:03 -0400
Subject: Small search changed

---
 solr/conf/schema.xml           | 3 ++-
 src/client/views/SearchBox.tsx | 3 +++
 src/server/Search.ts           | 4 +++-
 src/server/index.ts            | 1 +
 4 files changed, 9 insertions(+), 2 deletions(-)

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

diff --git a/solr/conf/schema.xml b/solr/conf/schema.xml
index a568db14c..9217e015b 100644
--- a/solr/conf/schema.xml
+++ b/solr/conf/schema.xml
@@ -48,8 +48,9 @@
   <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"/>
   <dynamicField name="*_d" type="pdaterange" indexed="true" stored="true" uninvertible="false" docValues="false"/>
-  <dynamicField name="*_l" type="text" indexed="true" stored="true" uninvertible="false" docValues="false" multiValued="true"/>
+  <dynamicField name="*_l" type="string" indexed="true" stored="true" uninvertible="false" docValues="false" multiValued="true"/>
   <dynamicField name="*_i" type="string" indexed="true" stored="true" uninvertible="false" docValues="false"/>
+  <dynamicField name="*_b" type="boolean" indexed="true" stored="true" uninvertible="false" docValues="false"/>
 
   <dynamicField name="*_a" type="text" indexed="true" stored="false" uninvertible="false" docValues="false"/>
 
diff --git a/src/client/views/SearchBox.tsx b/src/client/views/SearchBox.tsx
index 134201071..6e64e1af1 100644
--- a/src/client/views/SearchBox.tsx
+++ b/src/client/views/SearchBox.tsx
@@ -140,6 +140,9 @@ export class SearchBox extends React.Component {
         return Docs.FreeformDocument(docs, { width: 400, height: 400, panX: 175, panY: 175, title: `Search Docs: "${this.searchString}"` });
     }
 
+    // Useful queries:
+    // Delegates of a document: {!join from=id to=proto_i}id:{protoId}
+    // Documents in a collection: {!join from=data_l to=id}id:{collectionProtoId}
     render() {
         return (
             <div>
diff --git a/src/server/Search.ts b/src/server/Search.ts
index 1bede5b49..0f7004bdf 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -13,7 +13,9 @@ export class Search {
                 body: JSON.stringify([document])
             });
             return res;
-        } catch (e) { }
+        } catch (e) {
+            console.warn("Search error: " + e + document);
+        }
     }
 
     public async search(query: string) {
diff --git a/src/server/index.ts b/src/server/index.ts
index e5cc3ce68..da6bc0165 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -298,6 +298,7 @@ function GetRefFields([ids, callback]: [string[], (result?: Transferable[]) => v
 const suffixMap: { [type: string]: (string | [string, string | ((json: any) => any)]) } = {
     "number": "_n",
     "string": "_t",
+    // "boolean": "_b",
     "image": ["_t", "url"],
     "video": ["_t", "url"],
     "pdf": ["_t", "url"],
-- 
cgit v1.2.3-70-g09d2

