effective_search 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d53d74846e3d5e8b6c4b759e88d1362ed4fa18f2305fc80ecdda046b1909e91
4
- data.tar.gz: 5f46bbab96941100ce0250041d532a45edf9c328ca7d15c71297feef12a5e9a5
3
+ metadata.gz: 6fb95bd14c5e9823b0d8830420381d75b5f1c588376ed57438b19280ef9fc6c9
4
+ data.tar.gz: 25bdabad6a94d4193a6447f792b7fae91240c28d6bf4ec77d5563f084e0f2fb8
5
5
  SHA512:
6
- metadata.gz: f06e7ee79de96f4a4eedb848c4200a57ef8aa5f24747aef60c5833d5d4a8e4826ab6d1184b1b5b9df011fa726593c0c36fa620e3f861ce4a28447bdbde724b6a
7
- data.tar.gz: 3dabcc4fd22ee6f51dbf3ce42390f656616a01d46e93da8c1d569c71fa9fa8571c60fec928f9fd31323bb4326536cebc3ff9a9f3f540a7113e149b78123f058d
6
+ metadata.gz: 883de44e96a91311e015c6f2b237f3f5d3c09679cf894317ac5d9bfe4723444c752eba65c46d6da9f57c7b5d8889c3720670166ca58cd946d6f8430bab404502
7
+ data.tar.gz: b7ddca0b8cc5d25349e512d7235faa39c0a698c434de58ff4689c33d221dc5b1ff457f3eff868962cecdb48e398114c1b3ba8edfcd4d34b7fd792f1f44cb9f6a
@@ -45,7 +45,19 @@ module EffectiveSearchAdminSearch
45
45
  end
46
46
 
47
47
  def applicants
48
- @applicants = EffectiveMemberships.Applicant.where(user: users).order(created_at: :desc)
48
+ @applicants ||= EffectiveMemberships.Applicant.where(user: users).order(created_at: :desc)
49
+ end
50
+
51
+ def events
52
+ @events ||= Effective::Resource.new(Effective::Event).search_any(term, columns: [:title]).reorder(start_at: :desc)
53
+ end
54
+
55
+ def pages
56
+ @pages ||= Effective::Resource.new(Effective::Page).search_any(term, columns: [:title])
57
+ end
58
+
59
+ def posts
60
+ @posts ||= Effective::Resource.new(Effective::Post).search_any(term, columns: [:title]).reorder(published_start_at: :desc)
49
61
  end
50
62
 
51
63
  # Search and assigns the collection
@@ -56,6 +68,9 @@ module EffectiveSearchAdminSearch
56
68
  @orders = orders()
57
69
  @applicants = applicants()
58
70
  @organizations = organizations()
71
+ @events = events()
72
+ @pages = pages()
73
+ @posts = posts()
59
74
  end
60
75
 
61
76
  # The paginated results
@@ -75,6 +90,18 @@ module EffectiveSearchAdminSearch
75
90
  results(organizations, page: page)
76
91
  end
77
92
 
93
+ def event_results(page: nil)
94
+ results(events, page: page)
95
+ end
96
+
97
+ def page_results(page: nil)
98
+ results(pages, page: page)
99
+ end
100
+
101
+ def post_results(page: nil)
102
+ results(posts, page: page)
103
+ end
104
+
78
105
  private
79
106
 
80
107
  def results(collection, page: nil)
@@ -0,0 +1,7 @@
1
+ - path = (EffectiveResources.authorized?(self, :edit, event) ? effective_events.edit_admin_event_path(event) : effective_events.admin_event_path(event))
2
+
3
+ %a.list-group-item.list-group-item-action{href: path, title: event}
4
+ %strong= event.to_s
5
+ %small.text-muted
6
+ - if event.try(:start_at).present?
7
+ = event.start_at.strftime('%B %d, %Y')
@@ -6,4 +6,4 @@
6
6
  = render('admin/search/search', search: search, modal: true)
7
7
 
8
8
  .modal-footer.bg-light.p-1
9
- %small.text-muted Search by name, email, or order number. Quick open with /
9
+ %small.text-muted Search by name, title, email, or order number. Quick open with forward slash.
@@ -1,7 +1,7 @@
1
1
  - path = (EffectiveResources.authorized?(self, :edit, order) ? effective_orders.admin_edit_order_path(order) : effective_orders.admin_order_path(order))
2
2
 
3
3
  %a.list-group-item.list-group-item-action{href: path, title: order}
4
- = order.to_s
4
+ %strong= order.to_s
5
5
  %small.text-muted
6
6
  = order.billing_name
7
7
  •
@@ -1,5 +1,5 @@
1
1
  %a.list-group-item.list-group-item-action{href: effective_memberships.edit_admin_organization_path(organization), title: organization}
2
- %p.mb-0= organization
2
+ %strong= organization
3
3
  %small.text-muted
4
4
  - if organization.class.try(:effective_memberships_organization_owner?)
5
5
  - if (membership = organization.try(:membership)).present?
@@ -0,0 +1,9 @@
1
+ - path = (EffectiveResources.authorized?(self, :edit, page) ? effective_pages.edit_admin_page_path(page) : effective_pages.admin_page_path(page))
2
+
3
+ %a.list-group-item.list-group-item-action{href: path, title: page}
4
+ %strong= page.to_s
5
+ %small.text-muted
6
+ = badge(page.try(:draft?) ? :draft : :published)
7
+ - if page.try(:slug).present?
8
+ •
9
+ = page.slug
@@ -0,0 +1,12 @@
1
+ - path = (EffectiveResources.authorized?(self, :edit, post) ? effective_posts.edit_admin_post_path(post) : effective_posts.admin_post_path(post))
2
+
3
+ %a.list-group-item.list-group-item-action{href: path, title: post}
4
+ %strong= post.to_s
5
+ %small.text-muted
6
+ - if post.try(:published_at).present?
7
+ = post.published_at.strftime('%B %d, %Y')
8
+ •
9
+ = badge(post.try(:draft?) ? :draft : :published)
10
+ - if post.try(:category).present?
11
+ •
12
+ = post.category
@@ -5,7 +5,7 @@
5
5
 
6
6
  .d-flex.align-items-center.mb-3
7
7
  .flex-grow-1
8
- = f.text_field :term, placeholder: 'Search users, companies, applicants, and orders', label: false, autofocus: true, autocomplete: 'off',
8
+ = f.text_field :term, placeholder: 'Search users, companies, applicants, orders, events, pages, and posts', label: false, autofocus: true, autocomplete: 'off',
9
9
  'data-load-ajax-url': effective_search.admin_search_path,
10
10
  'data-load-ajax-div': '#effective-search-results',
11
11
  'data-load-ajax-all': true,
@@ -36,3 +36,18 @@
36
36
  - if search.applicant_results.present?
37
37
  %small.font-weight-bold Applicants (#{search.applicants.count})
38
38
  .list-group.list-group-flush= render(collection: search.applicant_results, partial: 'admin/search/applicant')
39
+ %hr
40
+
41
+ - if search.event_results.present?
42
+ %small.font-weight-bold Events (#{search.events.count})
43
+ .list-group.list-group-flush= render(collection: search.event_results, partial: 'admin/search/event')
44
+ %hr
45
+
46
+ - if search.page_results.present?
47
+ %small.font-weight-bold Pages (#{search.pages.count})
48
+ .list-group.list-group-flush= render(collection: search.page_results, partial: 'admin/search/page')
49
+ %hr
50
+
51
+ - if search.post_results.present?
52
+ %small.font-weight-bold Posts (#{search.posts.count})
53
+ .list-group.list-group-flush= render(collection: search.post_results, partial: 'admin/search/post')
@@ -1,3 +1,3 @@
1
1
  module EffectiveSearch
2
- VERSION = '0.4.1'.freeze
2
+ VERSION = '0.4.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -178,11 +178,14 @@ files:
178
178
  - app/models/effective/search.rb
179
179
  - app/models/effective/search_content.rb
180
180
  - app/views/admin/search/_applicant.html.haml
181
+ - app/views/admin/search/_event.html.haml
181
182
  - app/views/admin/search/_form_nav_icon.html.haml
182
183
  - app/views/admin/search/_layout.html.haml
183
184
  - app/views/admin/search/_modal.html.haml
184
185
  - app/views/admin/search/_order.html.haml
185
186
  - app/views/admin/search/_organization.html.haml
187
+ - app/views/admin/search/_page.html.haml
188
+ - app/views/admin/search/_post.html.haml
186
189
  - app/views/admin/search/_search.html.haml
187
190
  - app/views/admin/search/_user.html.haml
188
191
  - app/views/admin/search/index.html.haml