aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search/SearchBox.tsx
diff options
context:
space:
mode:
authoryipstanley <stanley_yip@brown.edu>2019-07-16 12:06:38 -0400
committeryipstanley <stanley_yip@brown.edu>2019-07-16 12:06:38 -0400
commitaa32601952f9387d85d6f109aef9ad39396d3f98 (patch)
treea3d8d0d6407b26049b5c49468f5102ca7e15144a /src/client/views/search/SearchBox.tsx
parent78faa73f1d4a315a3d76613bdcbb894e2428ee10 (diff)
parente51cfce53ea32047bec1fb72cebcc095c02c84a5 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/views/search/SearchBox.tsx')
-rw-r--r--src/client/views/search/SearchBox.tsx13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index dc1d35b1c..ec778b346 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -67,7 +67,7 @@ export class SearchBox extends React.Component {
this._maxSearchIndex = 0;
}
- enter = (e: React.KeyboardEvent) => { if (e.key === "Enter") { this.submitSearch(); } }
+ enter = (e: React.KeyboardEvent) => { if (e.key === "Enter") { this.submitSearch(); } };
public static async convertDataUri(imageUri: string, returnedFilename: string) {
try {
@@ -113,7 +113,12 @@ export class SearchBox extends React.Component {
}
getAllResults = async (query: string) => {
- return SearchUtil.Search(query, true, 0, 10000000);
+ return SearchUtil.Search(query, this.filterQuery, true, 0, 10000000);
+ }
+
+ private get filterQuery() {
+ const types = FilterBox.Instance.filterTypes;
+ return "proto_i:*" + (types ? ` AND (${types.map(type => `({!join from=id to=proto_i}type_t:"${type}" AND NOT type_t:*) OR type_t:"${type}"`).join(" ")})` : "");
}
@@ -124,7 +129,7 @@ export class SearchBox extends React.Component {
}
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, this._maxSearchIndex, 10).then(action((res: SearchUtil.DocSearchResult) => {
+ this._curRequest = SearchUtil.Search(query, this.filterQuery, true, this._maxSearchIndex, 10).then(action((res: SearchUtil.DocSearchResult) => {
// happens at the beginning
if (res.numFound !== this._numTotalResults && this._numTotalResults === -1) {
@@ -277,7 +282,7 @@ export class SearchBox extends React.Component {
@computed
get resFull() {
- console.log(this._numTotalResults)
+ console.log(this._numTotalResults);
return this._numTotalResults <= 8;
}