forked from HuygensING/solr-faceted-search-react
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from palantirnet/root-138-autocomplete
Root-198: add search-as-you-type suggestion query functionality
- Loading branch information
Showing
9 changed files
with
2,733 additions
and
2,015 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const initialState = {}; | ||
|
||
const setSuggestQuery = (state, action) => { | ||
return { | ||
...action.suggestQuery | ||
}; | ||
}; | ||
|
||
const setSuggestQueryField = (state, action) => { | ||
// Clear the suggestQueryField data only if the search field has been cleared. | ||
if (action.newFields.filter(field => field.field === "tm_rendered_item" && field.value ==="").length) { | ||
return Object.assign({}, | ||
...state, | ||
{ | ||
suggestQuery: { | ||
value: "" | ||
} | ||
}, | ||
); | ||
} | ||
return { | ||
...state | ||
}; | ||
}; | ||
|
||
export default function (state = initialState, action) { | ||
switch (action.type) { | ||
case "SET_SUGGEST_QUERY": | ||
return setSuggestQuery(state, action); | ||
case "SET_SEARCH_FIELDS": | ||
return setSuggestQueryField(state, action); | ||
} | ||
|
||
return state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const initialState = { | ||
suggestionsPending: false, | ||
docs: [] | ||
}; | ||
|
||
export default function (state = initialState, action) { | ||
switch (action.type) { | ||
case "SET_SUGGESTIONS": | ||
return { | ||
...state, | ||
docs: action.data.response ? action.data.response.docs : [], | ||
suggestionsPending: false | ||
}; | ||
|
||
case "SET_SUGGESTIONS_PENDING": | ||
return { | ||
...state, suggestionsPending: true | ||
}; | ||
} | ||
|
||
return state; | ||
} |
Oops, something went wrong.