Skip to content

Conversation

@baieric
Copy link

@baieric baieric commented May 22, 2018

Proof-of-concept, because the current Autosuggest package used is not optimal.

I recommend using this package, once Poly's webpack issues are resolved (though I haven't fully tested it out): https://github.com/ericgio/react-bootstrap-typeahead

Other possible packages to try:
https://github.com/fmoo/react-typeahead
https://github.com/ezequiel/react-typeahead-component

To test this out, run this branch and the Language Ontology API locally. No database changes will be stored properly until #305 is merged in. Right now the API's URL is hard-coded to http://localhost:6543/ but we can change that.

Would appreciate some feedback on the stylesheet code changes, not sure if I'm following your best practices!

this.setState({ book: newBook, [suggestionsField]: [item] });
}

languageSearchOnChange(value, languageField, languageIdField, suggestionsField) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a bit of code duplication of the languageSearchOnSelect and languageSearchOnChange functions in NewBook.es6.jsx, Book.es6.jsx, and SearchBar.es6.jsx. Didn't have the React expertise to fix this.


renderLanguageSuggestion(item, isHighlighted) {
// TODO couldn't figure out how to call getItemTitle here, even after binding it in constructor
const title = item.matched_identifiers.length == 0 ? item.glottocode : item.matched_identifiers[0];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is the same as in the getItemTitle function, which I couldn't properly call for some reason.


function asyncSearchLanguage(query, callback) {
// TODO don't hardcode URL
const url = `http://localhost:6543/search?q=${query}`
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this hard-coded URL should be from a config constant, and should use the actual production Language Ontology API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants