Module: EffectiveSearchAdminSearch
- Extended by:
- ActiveSupport::Concern
- Included in:
- Effective::AdminSearch
- Defined in:
- app/models/concerns/effective_search_admin_search.rb
Overview
EffectiveSearchAdminSearch Mark your search model with include EffectiveSearchAdminSearch
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #applicant_results(page: nil) ⇒ Object
- #applicants ⇒ Object
- #event_results(page: nil) ⇒ Object
- #events ⇒ Object
- #order_results(page: nil) ⇒ Object
- #orders ⇒ Object
- #organization_results(page: nil) ⇒ Object
- #organizations ⇒ Object
- #page_results(page: nil) ⇒ Object
- #pages ⇒ Object
- #per_page ⇒ Object
- #post_results(page: nil) ⇒ Object
- #posts ⇒ Object
- #present? ⇒ Boolean
-
#search! ⇒ Object
Search and assigns the collection Assigns the entire collection() if there are no search terms Otherwise validate the search terms.
- #to_s ⇒ Object
-
#user_results(page: nil) ⇒ Object
The paginated results.
- #users ⇒ Object
Instance Method Details
#applicant_results(page: nil) ⇒ Object
85 86 87 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 85 def applicant_results(page: nil) results(applicants, page: page) end |
#applicants ⇒ Object
47 48 49 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 47 def applicants @applicants ||= EffectiveMemberships.Applicant.where(user: users).order(created_at: :desc) end |
#event_results(page: nil) ⇒ Object
93 94 95 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 93 def event_results(page: nil) results(events, page: page) end |
#events ⇒ Object
51 52 53 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 51 def events @events ||= Effective::Resource.new(Effective::Event).search_any(term, columns: [:title]).reorder(start_at: :desc) end |
#order_results(page: nil) ⇒ Object
81 82 83 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 81 def order_results(page: nil) results(orders, page: page) end |
#orders ⇒ Object
43 44 45 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 43 def orders @orders ||= Effective::Resource.new(Effective::Order).search_any(term, columns: [:id]) end |
#organization_results(page: nil) ⇒ Object
89 90 91 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 89 def organization_results(page: nil) results(organizations, page: page) end |
#organizations ⇒ Object
39 40 41 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 39 def organizations @organizations ||= Effective::Resource.new(EffectiveMemberships.Organization).search_any(term, columns: [:title, :email]) end |
#page_results(page: nil) ⇒ Object
97 98 99 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 97 def page_results(page: nil) results(pages, page: page) end |
#pages ⇒ Object
55 56 57 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 55 def pages @pages ||= Effective::Resource.new(Effective::Page).search_any(term, columns: [:title]) end |
#per_page ⇒ Object
27 28 29 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 27 def per_page 5 end |
#post_results(page: nil) ⇒ Object
101 102 103 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 101 def post_results(page: nil) results(posts, page: page) end |
#posts ⇒ Object
59 60 61 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 59 def posts @posts ||= Effective::Resource.new(Effective::Post).search_any(term, columns: [:title]).reorder(published_start_at: :desc) end |
#present? ⇒ Boolean
31 32 33 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 31 def present? term.present? end |
#search! ⇒ Object
Search and assigns the collection Assigns the entire collection() if there are no search terms Otherwise validate the search terms
66 67 68 69 70 71 72 73 74 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 66 def search! @users = users() @orders = orders() @applicants = applicants() @organizations = organizations() @events = events() @pages = pages() @posts = posts() end |
#to_s ⇒ Object
23 24 25 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 23 def to_s term.to_s end |
#user_results(page: nil) ⇒ Object
The paginated results
77 78 79 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 77 def user_results(page: nil) results(users, page: page) end |
#users ⇒ Object
35 36 37 |
# File 'app/models/concerns/effective_search_admin_search.rb', line 35 def users @users ||= Effective::Resource.new(current_user.class).search_any(term, columns: [:first_name, :last_name, :email]) end |