documentcloud / visualsearch

A Rich Search Box for Real Data
http://documentcloud.github.io/visualsearch/
MIT License
1.8k stars 225 forks source link

Refactored and fixed SearchInput view - added `addFacet` method. #136

Closed golubev closed 10 months ago

golubev commented 10 years ago

Added addFacet method to the SearchInput (see a comment above the function definition): https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L94

Fixed colon (:) logic. See: https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L357 E.g. try to type "qwerty filter" using the current master (http://documentcloud.github.io/visualsearch/demo.html) and then type the colon - nothing happens. The fix that is proposed allows VisualSearch to add "qwerty" as a remainder and "filter" - as a facet in this case.

Fixed tab logic. See: https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js#L393 Current master allows to add any facet that is not in the list of facets, provided in the facetMatches callback. E.g. type "qwerty" and then press the tab button - a new facet with a category "qwerty" will be added, but "qwerty" is not in the list of available facets. Or another strange behaviour is observed: type "qwerty city", then press the "down arrow" button (to deselect autocomplete menu - to fire exactly this event, but not the autocomplete's select callback) and then press the tab button - "TEXT: qwerty city" will be added. Proposed fix adds the same logic to this event as when typing the colon. Providing the same input in this fixed version will lead to the same logic as described above: "qwerty" as a remainder and a category "locality" (value for "city" - there are some details in the next paragraph) - as a facet.

Fixed facets value and label autocomplete items properties usage. To see search "label" through the https://github.com/golubev/visualsearch/blob/master/lib/js/views/search_input.js. The main point is that:

samuelclay commented 10 years ago

Thanks for this PR. This is quite a big one, so I'll only have time to look at it in a few weeks. Ping me if it takes too long. This will require some testing and verification.

golubev commented 10 years ago

Okay! Thanks for the response!