workarea-product_additional_details 2.0.2 → 2.0.34

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: 3e235f8b30c8067b9fd6366c84544be6548d3b000b4eaf58bee51bcb6da0b54f
4
- data.tar.gz: b87b4d155c5b13e678fbeb7f2b6a9b4cf6e09aa2e067bb2335d48ac5834a75ff
3
+ metadata.gz: 8e1a01ada470f9f04e0f68d83cd2ef351aab45213d4dd93bc13ec1e02257e6df
4
+ data.tar.gz: 3925c6fbd29514cae631751efd379b2dd66609085824ba70dbe39a771986f9b1
5
5
  SHA512:
6
- metadata.gz: 5ce7b2aba4e97048e000dedf1d4b73f5860a550813dca02e8a54cb84bb441d81e7158de8a1a40382629a928ade5bde90706a1032e5acd065dd13ff9fe8e2d112
7
- data.tar.gz: f58b83155832027b07b3c1f94f494507e4ab28718ca101e46cdcf2c279e279ca62ba7708ededc87344a4afb9ff03816f1ede02c1a19d6eb6b2531d9cda608f24
6
+ metadata.gz: e454aa115822134543bd69d9d7812cd8ffc1177919d6cfb2aa91493c34f237d3bf560625f79a3b931d11a913dbc57ad77bf984d89d1335746d287e07f568bc85
7
+ data.tar.gz: ecbaa85a35f636881cd63c1308807daa29036150416628ad3bb6844b79d2e3cb7c94f2ee23ec1a6ad874d4464af45fc6174334fe052018b4df58129e0279f8f1
@@ -17,7 +17,7 @@ module Workarea
17
17
 
18
18
  def set_additional_details
19
19
  @variant.additional_details = HashUpdate.new(
20
- original: @product.additional_details,
20
+ original: @variant.additional_details,
21
21
  adds: params[:new_additional_details],
22
22
  updates: params[:additional_details],
23
23
  removes: params[:additional_details_to_remove]
@@ -0,0 +1,9 @@
1
+ module Workarea
2
+ module Admin
3
+ module DetailsParseHelper
4
+ def parse_details_text(text)
5
+ JSON.parse(text).join(' ') rescue text
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,93 @@
1
+ module Workarea
2
+ module Search
3
+ class Storefront
4
+ class Product
5
+ module Text
6
+ def catalog_content
7
+ [model.browser_title, model.meta_description, model.description]
8
+ .reject(&:blank?)
9
+ .join(' ')
10
+ end
11
+
12
+ # A list of category names to which this product belongs,
13
+ # allows finding products by category names in search.
14
+ #
15
+ # @return [String]
16
+ #
17
+ def category_names
18
+ categorization.to_models.map(&:name).join(', ')
19
+ end
20
+
21
+ # A textual version of the product's filters hash that
22
+ # will be stored and analyzed in the search index.
23
+ #
24
+ # @return [String]
25
+ #
26
+ def facets_content
27
+ HashText.new(model.filters).text
28
+ end
29
+
30
+ # A textual version of the product's filters hash that
31
+ # will be stored and analyzed in the search index.
32
+ #
33
+ # @return [String]
34
+ #
35
+ def details_content
36
+ "#{HashText.new(model.details).text} #{variant_details_text} #{additional_details_content}"
37
+ end
38
+
39
+ # Text from the product's details hash and it's variants' details
40
+ # hash. Allows finding a product by one of these values.
41
+ #
42
+ # @return [String]
43
+ #
44
+ def details
45
+ "#{HashText.new(model.details).text} #{variant_details_text} #{additional_details_content}"
46
+ end
47
+
48
+ # Text from additional details hash
49
+ def additional_details_content
50
+ if model.additional_details.present? && model.additional_details.any?
51
+ parse_addtional_details(model.additional_details)
52
+ end
53
+ end
54
+
55
+ # Content to put in the index for making search query suggestions.
56
+ # Includes all content for the product.
57
+ #
58
+ # @return [String]
59
+ #
60
+ def suggestion_content
61
+ [
62
+ model.name,
63
+ category_names,
64
+ facets_content,
65
+ details_content
66
+ ].join(' ')
67
+ end
68
+
69
+ def variant_details_text
70
+ @variant_details_text ||= model.variants.active.map do |variant|
71
+ "#{variant.name} #{HashText.new(variant.details).text}"
72
+ end.join(' ')
73
+ end
74
+
75
+ private
76
+ # extract text content from html content
77
+ def parse_addtional_details(details)
78
+ parsed_data = []
79
+ details.each do |key, value|
80
+ data = Nokogiri::HTML.parse(value) if value.is_a?(String)
81
+ if data.present?
82
+ data.traverse do |node|
83
+ parsed_data.push(node.text)
84
+ end
85
+ end
86
+ end
87
+ parsed_data.flatten.compact.uniq.join(" ")
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
@@ -17,7 +17,7 @@
17
17
  %td
18
18
  .property
19
19
  = hidden_field_tag 'additional_details[]', name, id: nil
20
- = text_area_tag 'additional_details[]', value, class: 'text-box text-box--i18n', id: nil
20
+ = text_area_tag 'additional_details[]', parse_details_text(value), class: 'text-box text-box--i18n', id: nil
21
21
  %td.align-center= check_box_tag 'additional_details_to_remove[]', name, false, id: nil, title: "#{t('workarea.admin.actions.delete')}: #{name} #{value}"
22
22
  %tr{ data: { cloneable_row: '' } }
23
23
  %td
@@ -75,7 +75,7 @@
75
75
  = text_field_tag 'additional_details[]', name, class: 'text-box text-box--i18n', title: 'Name', placeholder: 'Name', id: nil
76
76
  %td
77
77
  .property
78
- = text_area_tag 'additional_details[]', hash_editing_value(value), class: 'text-box text-box--i18n', title: 'Value', placeholder: 'Value', id: nil
78
+ = text_area_tag 'additional_details[]', value, class: 'text-box text-box--i18n', title: 'Value', placeholder: 'Value', id: nil
79
79
  %tr{ data: { cloneable_row: '' } }
80
80
  %td
81
81
  .property
@@ -1,3 +1,6 @@
1
1
  Workarea.configure do |config|
2
2
  # Add custom configuration here
3
+ config.to_prepare do
4
+ Workarea::Admin::ApplicationController.helper(Workarea::Admin::DetailsParseHelper)
5
+ end
3
6
  end
@@ -1,5 +1,5 @@
1
1
  module Workarea
2
2
  module ProductAdditionalDetails
3
- VERSION = "2.0.2".freeze
3
+ VERSION = "2.0.34"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-product_additional_details
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gunasekaran Raja
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea
@@ -49,10 +49,12 @@ files:
49
49
  - app/controllers/workarea/admin/catalog_variants_controller.decorator
50
50
  - app/controllers/workarea/admin/create_catalog_products_controller.decorator
51
51
  - app/helpers/.keep
52
+ - app/helpers/workarea/admin/details_parse_helper.rb
52
53
  - app/mailers/.keep
53
54
  - app/models/.keep
54
55
  - app/models/workarea/catalog/product.decorator
55
56
  - app/models/workarea/catalog/variant.decorator
57
+ - app/models/workarea/search/storefront/product/text.rb
56
58
  - app/services/workarea/hash_update.decorator
57
59
  - app/views/.keep
58
60
  - app/views/workarea/admin/catalog_products/_additional_details.html.haml