aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/search/SearchBox.tsx
diff options
context:
space:
mode:
authormadelinegr <monika_hedman@brown.edu>2019-06-11 14:10:18 -0400
committermadelinegr <monika_hedman@brown.edu>2019-06-11 14:10:18 -0400
commit0c066dac5eb3e7c47b708a6a5a1d95dc75f320fe (patch)
tree30a942553f684e0e3af91a96f05b63ec62ae28dc /src/client/views/search/SearchBox.tsx
parentf4a545e6e4b21ca28ce861325be69d920578d6c0 (diff)
making words required almost works (logic is there)
Diffstat (limited to 'src/client/views/search/SearchBox.tsx')
-rw-r--r--src/client/views/search/SearchBox.tsx20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/client/views/search/SearchBox.tsx b/src/client/views/search/SearchBox.tsx
index 329643464..67122b320 100644
--- a/src/client/views/search/SearchBox.tsx
+++ b/src/client/views/search/SearchBox.tsx
@@ -27,6 +27,7 @@ import { IconBar } from './IconBar';
@observer
export class SearchBox extends React.Component {
@observable _searchString: string = "";
+ //if true, any keywords can be used. if false, all keywords are required.
@observable _wordStatus: boolean = true;
@observable _icons: string[] = [];
@observable private _open: boolean = false;
@@ -42,6 +43,20 @@ export class SearchBox extends React.Component {
@action
submitSearch = async () => {
let query = this._searchString;
+
+ if(!this._wordStatus){
+ let oldWords = query.split(" ");
+ let newWords: string[] = [];
+ console.log(oldWords)
+ oldWords.forEach(word => {
+ let newWrd = "+" + word;
+ newWords.push(newWrd);
+ })
+ console.log(newWords)
+
+ query = newWords.join(" ")
+ }
+
//gets json result into a list of documents that can be used
const results = await this.getResults(query);
@@ -185,8 +200,9 @@ export class SearchBox extends React.Component {
return toReturn;
}
- handleWordQueryChange = (value: boolean) => {
- this._wordStatus = value;
+ //if true, any keywords can be used. if false, all keywords are required.
+ handleWordQueryChange = () => {
+ this._wordStatus = !this._wordStatus;
}
@action.bound