Module: Card::Set::Abstract::Search::Views::JsonFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- tmpsets/set/mod020-search/abstract/search/views.rb
Constant Summary collapse
- AUTOCOMPLETE_LIMIT =
number of name suggestions for autocomplete text fields
8
Instance Method Summary collapse
- #complete_or_match_search(limit: AUTOCOMPLETE_LIMIT) ⇒ Object
- #complete_search(limit: AUTOCOMPLETE_LIMIT) ⇒ Object
- #complete_wql ⇒ Object
- #item_cards ⇒ Object
- #match_search(limit: AUTOCOMPLETE_LIMIT, not_names: []) ⇒ Object
- #match_wql(not_names) ⇒ Object
- #name_wql(limit) ⇒ Object
- #term_param ⇒ Object
Instance Method Details
#complete_or_match_search(limit: AUTOCOMPLETE_LIMIT) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 51 def complete_or_match_search limit: AUTOCOMPLETE_LIMIT starts_with = complete_search limit: limit return starts_with if Card.config. remaining_slots = limit - starts_with.size return starts_with if remaining_slots.zero? starts_with + match_search(not_names: starts_with, limit: remaining_slots) end |
#complete_search(limit: AUTOCOMPLETE_LIMIT) ⇒ Object
60 61 62 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 60 def complete_search limit: AUTOCOMPLETE_LIMIT card.search name_wql(limit).merge(complete_wql) end |
#complete_wql ⇒ Object
72 73 74 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 72 def complete_wql { complete: term_param } end |
#item_cards ⇒ Object
33 34 35 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 33 def item_cards search_with_params end |
#match_search(limit: AUTOCOMPLETE_LIMIT, not_names: []) ⇒ Object
64 65 66 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 64 def match_search limit: AUTOCOMPLETE_LIMIT, not_names: [] card.search name_wql(limit).merge(match_wql(not_names)) end |
#match_wql(not_names) ⇒ Object
76 77 78 79 80 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 76 def match_wql not_names wql = { name_match: term_param } wql[:name] = ["not in"] + not_names if not_names.any? wql end |
#name_wql(limit) ⇒ Object
68 69 70 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 68 def name_wql limit { limit: limit, sort: "name", return: "name" } end |
#term_param ⇒ Object
82 83 84 |
# File 'tmpsets/set/mod020-search/abstract/search/views.rb', line 82 def term_param params[:term] end |