diff options
author | madelinegr <monika_hedman@brown.edu> | 2019-06-11 17:00:55 -0400 |
---|---|---|
committer | madelinegr <monika_hedman@brown.edu> | 2019-06-11 17:00:55 -0400 |
commit | b0b75c59bc5e1efcef54f70ac6c92e415707590a (patch) | |
tree | 37f106deb2e2204256c719ad9c2fa58bf738cad5 | |
parent | e65fba03470cc38bc610baf4ff77fcc13cc08b74 (diff) |
filter by type works yehaw
-rw-r--r-- | src/client/views/search/SearchBox.tsx | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx index deeb56762..0303707c7 100644 --- a/src/client/views/search/SearchBox.tsx +++ b/src/client/views/search/SearchBox.tsx @@ -13,7 +13,7 @@ import { Id } from '../../../new_fields/FieldSymbols'; import { SetupDrag } from '../../util/DragManager'; import { Docs, DocTypes } from '../../documents/Documents'; import { RouteStore } from '../../../server/RouteStore'; -import { NumCast } from '../../../new_fields/Types'; +import { NumCast, Cast } from '../../../new_fields/Types'; import { SearchUtil } from '../../util/SearchUtil'; import * as anime from 'animejs'; import { updateFunction } from '../../../new_fields/util'; @@ -22,6 +22,7 @@ import * as _ from "lodash"; import { findDOMNode } from 'react-dom'; import { ToggleBar } from './ToggleBar'; import { IconBar } from './IconBar'; +import { type } from 'os'; @observer @@ -83,7 +84,23 @@ export class SearchBox extends React.Component { docs.push(field); } } - return docs; + return this.filterDocs(docs); + } + + @action filterDocs(docs: Doc[]){ + console.log(this._icons) + if(this._icons.length === 0){ + console.log("length is 0") + return docs; + } + let finalDocs: Doc[] = []; + docs.forEach(doc => { + let layoutresult = Cast(doc.type, "string", ""); + if(this._icons.includes(layoutresult)){ + finalDocs.push(doc) + } + }); + return finalDocs; } public static async convertDataUri(imageUri: string, returnedFilename: string) { @@ -110,12 +127,14 @@ export class SearchBox extends React.Component { //handles case with filter button if (String(name).indexOf("filter") !== -1 || String(name).indexOf("SVG") !== -1) { this._resultsOpen = false; + this._results = []; this._open = true; } else if (element && element.parentElement) { //if the filter element is found, show the form and hide the results if (this.findAncestor(element, "filter-form")) { this._resultsOpen = false; + this._results = []; this._open = true; } //if in main search div, keep results open and close filter @@ -127,6 +146,7 @@ export class SearchBox extends React.Component { //not in either, close both else { this._resultsOpen = false; + this._results = []; this._open = false; } |