aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search
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
parent78faa73f1d4a315a3d76613bdcbb894e2428ee10 (diff)
parente51cfce53ea32047bec1fb72cebcc095c02c84a5 (diff)
Merge branch 'master' of https://github.com/browngraphicslab/Dash-Web
Diffstat (limited to 'src/client/views/search')
-rw-r--r--src/client/views/search/FilterBox.tsx4
-rw-r--r--src/client/views/search/SearchBox.tsx13
-rw-r--r--src/client/views/search/SearchItem.tsx4
3 files changed, 15 insertions, 6 deletions
diff --git a/src/client/views/search/FilterBox.tsx b/src/client/views/search/FilterBox.tsx
index 435ca86e3..f11fb008c 100644
--- a/src/client/views/search/FilterBox.tsx
+++ b/src/client/views/search/FilterBox.tsx
@@ -237,6 +237,10 @@ export class FilterBox extends React.Component {
return "+(" + finalColString + ")" + query;
}
+ get filterTypes() {
+ return this._icons.length === 9 ? undefined : this._icons;
+ }
+
@action
filterDocsByType(docs: Doc[]) {
if (this._icons.length === 9) {
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;
}
diff --git a/src/client/views/search/SearchItem.tsx b/src/client/views/search/SearchItem.tsx
index 16ad71d16..e34d101a8 100644
--- a/src/client/views/search/SearchItem.tsx
+++ b/src/client/views/search/SearchItem.tsx
@@ -51,9 +51,9 @@ export class SelectorContextMenu extends React.Component<SearchItemProps> {
async fetchDocuments() {
let aliases = (await SearchUtil.GetViewsOfDocument(this.props.doc)).filter(doc => doc !== this.props.doc);
- const { docs } = await SearchUtil.Search(`data_l:"${this.props.doc[Id]}"`, true);
+ const { docs } = await SearchUtil.Search("", `data_l:"${this.props.doc[Id]}"`, true);
const map: Map<Doc, Doc> = new Map;
- const allDocs = await Promise.all(aliases.map(doc => SearchUtil.Search(`data_l:"${doc[Id]}"`, true).then(result => result.docs)));
+ const allDocs = await Promise.all(aliases.map(doc => SearchUtil.Search("", `data_l:"${doc[Id]}"`, true).then(result => result.docs)));
allDocs.forEach((docs, index) => docs.forEach(doc => map.set(doc, aliases[index])));
docs.forEach(doc => map.delete(doc));
runInAction(() => {