workarea-content_search 1.0.9 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e12fe17ff40450cc7b218bdaf03cf6faedaa6ed82cf59e5cdc68d3f7b25642b9
4
- data.tar.gz: 331dda0af1ff1de4967dd5e26dd9d9d3388aff0b08e1214a0a85cf58261ef1b2
3
+ metadata.gz: b9cb1b584de2dcbd3657b3baa6edbef7cb44e1d063d4219c8b13b842b3b654dd
4
+ data.tar.gz: d69ecbd89640eb29c0ce3f9ac9e96b58bdddf16a55b8d65aade7b9d90d3df3cb
5
5
  SHA512:
6
- metadata.gz: 3d0615611de822f8f215de471ee5f95334b2b69269ae035045f66e9dcc2197becb1a805872427b9433c415e76876a56d49a384f7486c793f5f396b20dcfeef48
7
- data.tar.gz: ce175aba27e1eedde6f9accd3dcfbf10220f2ff1e570ab2abefd79ce0807e7114029986381749865e9aaad94caeb630215c729d1e38c18972c50f342a147f46d
6
+ metadata.gz: 546668ec22ab7a4d54aedb9bc085f32eab4ec8bcb022d44abf266e812a8dcffdb4c5fff2e4217ad9926bb935083b7c19a1261ddd35dd3964bbf7bc002c676171
7
+ data.tar.gz: c4c58ed398937e63bdfb43a133a2c1301e1ffe06909697cc7057387756aed146863378ce10013611ae04701182083ce1c675d405c8beef56653001470d2a0efe
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ Workarea Content Search 1.1.0 (2019-11-26)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Add Autocomplete to Content Search
5
+
6
+ Using the shiny new **workarea-search-autocomplete** plugin, Content
7
+ Search can now provide autocomplete results for the given search term.
8
+ Content results are injected right below the common search terms, and
9
+ augments the existing autocomplete with results from pages, blog posts,
10
+ and other `Contentable` items.
11
+
12
+ CONTSEARCH-3
13
+ Tom Scott
14
+
15
+ * Enable changelog task in release task
16
+
17
+ Curt Howard
18
+
19
+ * Update checking for SearchSuggestion content to ensure decoration loading
20
+
21
+ CONTSEARCH-2
22
+ Matt Duffy
23
+
24
+ * Updates for v3.5
25
+
26
+ Ben Crouse
27
+
28
+
29
+
30
+ Workarea Content Search 1.0.9 (2019-10-30)
31
+ --------------------------------------------------------------------------------
32
+
33
+ * Update checking for SearchSuggestion content to ensure decoration loading
34
+
35
+ CONTSEARCH-2
36
+ Matt Duffy
37
+
38
+
39
+
1
40
  Workarea Content Search 1.0.8 (2019-07-09)
2
41
  --------------------------------------------------------------------------------
3
42
 
data/Gemfile CHANGED
@@ -7,3 +7,4 @@ gemspec
7
7
  # gem 'byebug', group: [:development, :test]
8
8
 
9
9
  gem 'workarea', github: 'workarea-commerce/workarea'
10
+ gem 'workarea-search_autocomplete', github: 'workarea-commerce/workarea-search-autocomplete', branch: :master
data/Rakefile CHANGED
@@ -16,10 +16,10 @@ desc "Release version #{Workarea::ContentSearch::VERSION} of the gem"
16
16
  task :release do
17
17
  host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
18
18
 
19
- #Rake::Task['workarea:changelog'].execute
20
- #system 'git add CHANGELOG.md'
21
- #system 'git commit -m "Update CHANGELOG"'
22
- #system 'git push origin HEAD'
19
+ Rake::Task['workarea:changelog'].execute
20
+ system 'git add CHANGELOG.md'
21
+ system 'git commit -m "Update CHANGELOG"'
22
+ system 'git push origin HEAD'
23
23
 
24
24
  system "git tag -a v#{Workarea::ContentSearch::VERSION} -m 'Tagging #{Workarea::ContentSearch::VERSION}'"
25
25
  system 'git push --tags'
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Extensions to the search autocomplete plugin to support content
3
+ * results.
4
+ */
5
+
6
+ .search-autocomplete__content {
7
+ @extend %list-reset;
8
+ text-align: left;
9
+ }
10
+ .search-autocomplete__content-item {}
11
+ .search-autocomplete__content-link {}
@@ -0,0 +1,17 @@
1
+ module Workarea
2
+ if Plugin.installed?(:search_autocomplete)
3
+ decorate Storefront::SearchAutocompleteViewModel, with: :content_search do
4
+ def content_results
5
+ @content_results ||= begin
6
+ return [] if searches.blank?
7
+
8
+ results = Storefront::ContentSearchViewModel.wrap(response, options)
9
+
10
+ results.content.take(
11
+ Workarea.config.storefront_search_autocomplete_max_content
12
+ )
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,7 @@
1
+ - if @autocomplete.content_results.any?
2
+ %ul.search-autocomplete__content
3
+ %span.search-autocomplete__heading
4
+ = t('workarea.storefront.search_autocomplete.content_heading', term: @autocomplete.searches.first)
5
+ - @autocomplete.content_results.each do |result|
6
+ %li.search-autocomplete__content-item
7
+ = link_to result.name, send("#{result.resource_name}_path", result), class: 'search-autocomplete__content-link'
@@ -2,3 +2,15 @@ Workarea.append_partials(
2
2
  'storefront.above_search_results',
3
3
  'workarea/storefront/searches/search_type_toggle'
4
4
  )
5
+
6
+ if Workarea::Plugin.installed?(:search_autocomplete)
7
+ Workarea.append_stylesheets(
8
+ 'storefront.components',
9
+ 'workarea/storefront/content_search/components/search_autocomplete'
10
+ )
11
+
12
+ Workarea.append_partials(
13
+ 'storefront.search_autocomplete_under_searches',
14
+ 'workarea/storefront/searches/autocomplete_content'
15
+ )
16
+ end
@@ -16,4 +16,8 @@ Workarea.configure do |config|
16
16
  Workarea::Search::Customization
17
17
  Workarea::Navigation::Menu
18
18
  )
19
+
20
+ if Workarea::Plugin.installed?(:search_autocomplete)
21
+ config.storefront_search_autocomplete_max_content = 5
22
+ end
19
23
  end
@@ -5,3 +5,5 @@ en:
5
5
  product_result: product result
6
6
  content_result: content result
7
7
  content: Content
8
+ search_autocomplete:
9
+ content_heading: "Content Results: %{term}"
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module ContentSearch
3
- VERSION = '1.0.9'.freeze
3
+ VERSION = '1.1.0'.freeze
4
4
  end
5
5
  end
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ if Plugin.installed?(:search_autocomplete)
5
+ module Storefront
6
+ class ContentSearchAutocompleteSystemTest < Workarea::SystemTest
7
+ def test_content_appears_in_autocomplete
8
+ create_page(name: 'Content Test One')
9
+ create_page(name: 'Content Test Two')
10
+ create_page(name: 'Content Test Three')
11
+ create_product(name: 'Test One')
12
+ create_product(name: 'Test Two')
13
+ create_search_by_week(query_string: 'test one', searches: 5, total_results: 5)
14
+ create_search_by_week(query_string: 'test two', searches: 10, total_results: 5)
15
+
16
+ visit storefront.root_path
17
+
18
+ fill_in :q, with: 'te'
19
+
20
+ within '#search_autocomplete' do
21
+ assert_text(
22
+ t(
23
+ 'workarea.storefront.search_autocomplete.content_heading',
24
+ term: 'test two'
25
+ )
26
+ )
27
+ assert_text('Content Test One')
28
+ assert_text('Content Test Two')
29
+ assert_text('Content Test Three')
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
1
+ require 'test_helper'
2
+
3
+ module Workarea
4
+ if Plugin.installed?(:search_autocomplete)
5
+ module Storefront
6
+ class SearchAutocompleteViewModelTest < Workarea::TestCase
7
+ include TestCase::SearchIndexing
8
+
9
+ def test_content
10
+ query = QueryString.new('te').pretty
11
+ search = Storefront::SearchAutocompleteViewModel.wrap(query)
12
+
13
+ Sidekiq::Callbacks.enable do
14
+ create_page(name: 'Content Test One')
15
+ create_page(name: 'Content Test Two')
16
+ create_page(name: 'Content Test Three')
17
+ create_product(name: 'Test One')
18
+ create_product(name: 'Test Two')
19
+ create_search_by_week(
20
+ query_string: 'test one',
21
+ searches: 5,
22
+ total_results: 5
23
+ )
24
+ create_search_by_week(
25
+ query_string: 'test two',
26
+ searches: 10,
27
+ total_results: 5
28
+ )
29
+ end
30
+
31
+ refute_empty(search.content_results)
32
+ assert_equal(3, search.content_results.count)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-content_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Duffy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-30 00:00:00.000000000 Z
11
+ date: 2019-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -47,6 +47,7 @@ files:
47
47
  - LICENSE
48
48
  - README.md
49
49
  - Rakefile
50
+ - app/assets/stylesheets/workarea/storefront/content_search/components/_search_autocomplete.scss
50
51
  - app/controllers/workarea/.keep
51
52
  - app/controllers/workarea/storefront/searches_controller.decorator
52
53
  - app/models/workarea/search/storefront.decorator
@@ -58,6 +59,8 @@ files:
58
59
  - app/queries/workarea/search/storefront_search/template_with_content.rb
59
60
  - app/view_models/workarea/storefront/content_search_results.rb
60
61
  - app/view_models/workarea/storefront/content_search_view_model.rb
62
+ - app/view_models/workarea/storefront/search_autocomplete_view_model.decorator
63
+ - app/views/workarea/storefront/searches/_autocomplete_content.html.haml
61
64
  - app/views/workarea/storefront/searches/_search_type_toggle.html.haml
62
65
  - app/views/workarea/storefront/searches/content.html.haml
63
66
  - app/workers/workarea/bulk_index_content.rb
@@ -123,8 +126,10 @@ files:
123
126
  - test/dummy/public/favicon.ico
124
127
  - test/models/workarea/search/storefront/content_test.rb
125
128
  - test/queries/workarea/search/content_search_test.rb
129
+ - test/system/workarea/storefront/content_search_autocomplete_system_test.rb
126
130
  - test/system/workarea/storefront/content_search_system_test.rb
127
131
  - test/test_helper.rb
132
+ - test/view_models/workarea/storefront/content_search_autocomplete_view_model_test.rb
128
133
  - test/view_models/workarea/storefront/content_search_results_test.rb
129
134
  - test/view_models/workarea/storefront/content_search_view_model_test.rb
130
135
  - test/workers/workarea/bulk_index_content_test.rb