workarea-product_additional_details 2.0.0 → 2.0.32
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 +4 -4
- data/app/controllers/workarea/admin/catalog_products_controller.decorator +1 -1
- data/app/controllers/workarea/admin/catalog_variants_controller.decorator +27 -0
- data/app/controllers/workarea/admin/create_catalog_products_controller.decorator +1 -1
- data/app/models/workarea/catalog/product.decorator +1 -1
- data/app/models/workarea/catalog/variant.decorator +7 -0
- data/app/models/workarea/search/storefront/product/text.rb +93 -0
- data/app/services/workarea/hash_update.decorator +1 -1
- data/app/views/workarea/admin/catalog_variants/_additional_details.html.haml +31 -0
- data/app/views/workarea/admin/create_catalog_products/details.html.haml +1 -1
- data/config/initializers/appends.rb +4 -0
- data/lib/workarea/product_additional_details/version.rb +1 -1
- data/test/models/workarea/catalog/product_test.decorator +1 -1
- data/test/models/workarea/user_test.decorator +1 -1
- data/test/workarea/hash_update_test.decorator +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf388085dcce8abed17ce4c1dae2ddbb81c277bd24755323b70612c83159892
|
4
|
+
data.tar.gz: 56c3b49d63f0195293422da2c607f715c90c921ae8e9a6bdbea5322885342c04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 157555f62295ca411375f2540073b19b20cc3c31eb6caa286f7c2ff611ab49366e4fba3f5b26158d15eec5b5f0eee833825a68c832f015c9cc294eadf55c8a36
|
7
|
+
data.tar.gz: fc268a0a385cc2892b3bc25bfe26cddcdb259a08f232b0730345877b2ae59cb6ed8f7a9b4055f24ddef7d12a25395a006c1307b1e2a8050c5b033dc3605a3f40
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Admin::CatalogVariantsController, with: :product_additional_details do
|
3
|
+
|
4
|
+
def update
|
5
|
+
@variant = @product.variants.find(params[:id])
|
6
|
+
set_details
|
7
|
+
set_additional_details
|
8
|
+
|
9
|
+
if @variant.update_attributes(params[:variant])
|
10
|
+
flash[:success] = t('workarea.admin.catalog_variants.flash_messages.saved')
|
11
|
+
redirect_to catalog_product_variants_path(@product)
|
12
|
+
else
|
13
|
+
flash[:error] = t('workarea.admin.catalog_variants.flash_messages.changes_error')
|
14
|
+
render :edit
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_additional_details
|
19
|
+
@variant.additional_details = HashUpdate.new(
|
20
|
+
original: @variant.additional_details,
|
21
|
+
adds: params[:new_additional_details],
|
22
|
+
updates: params[:additional_details],
|
23
|
+
removes: params[:additional_details_to_remove]
|
24
|
+
).result_grouped
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Workarea
|
2
|
-
decorate Admin::CreateCatalogProductsController, with: :
|
2
|
+
decorate Admin::CreateCatalogProductsController, with: :product_additional_details do
|
3
3
|
def save_details
|
4
4
|
@product.additional_details = HashUpdate
|
5
5
|
.new(original: @product.additional_details, updates: params[:additional_details])
|
@@ -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
|
@@ -0,0 +1,31 @@
|
|
1
|
+
.section.section--additional-details
|
2
|
+
%h2= "Additional Details"
|
3
|
+
|
4
|
+
%table
|
5
|
+
%thead
|
6
|
+
%tr
|
7
|
+
%th= t('workarea.admin.catalog_products.edit.details.name')
|
8
|
+
%th= "Content"
|
9
|
+
%th.align-center= t('workarea.admin.actions.delete')
|
10
|
+
%tbody.bottom-align
|
11
|
+
- variant.additional_details.each do |name, value|
|
12
|
+
%tr
|
13
|
+
%td
|
14
|
+
.property
|
15
|
+
= label_tag "details_#{name}" do
|
16
|
+
#{name}
|
17
|
+
%td
|
18
|
+
.property
|
19
|
+
= hidden_field_tag 'additional_details[]', name, id: nil
|
20
|
+
= text_area_tag 'additional_details[]', value, class: 'text-box text-box--i18n', id: nil
|
21
|
+
%td.align-center= check_box_tag 'additional_details_to_remove[]', name, false, id: nil, title: "#{t('workarea.admin.actions.delete')}: #{name} #{value}"
|
22
|
+
%tr{ data: { cloneable_row: '' } }
|
23
|
+
%td
|
24
|
+
.property
|
25
|
+
= text_field_tag 'new_additional_details[]', nil, id: nil, class: 'text-box text-box--i18n', title: t('workarea.admin.catalog_products.edit.details.new_attribute_name'), placeholder: t('workarea.admin.catalog_products.edit.details.new_attribute_name_placeholder')
|
26
|
+
%span.property__note= "Example: User Manual"
|
27
|
+
%td
|
28
|
+
.property
|
29
|
+
= text_area_tag 'new_additional_details[]', nil, id: nil, class: 'text-box text-box--i18n', title: t('workarea.admin.catalog_products.edit.details.new_attribute_value'), placeholder: t('workarea.admin.catalog_products.edit.details.new_attribute_value_placeholder')
|
30
|
+
%span.property__note= "Example: <a href='/manuals'>Download Manuals</a>"
|
31
|
+
%td.align-center -
|
@@ -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[]',
|
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
|
@@ -2,3 +2,7 @@ Workarea.append_partials(
|
|
2
2
|
'admin.additional_product_details_information',
|
3
3
|
'workarea/admin/catalog_products/additional_details'
|
4
4
|
)
|
5
|
+
Workarea.append_partials(
|
6
|
+
'admin.additional_variant_information_fields',
|
7
|
+
'workarea/admin/catalog_variants/additional_details'
|
8
|
+
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Workarea
|
4
|
-
decorate Catalog::ProductTest, with: :
|
4
|
+
decorate Catalog::ProductTest, with: :product_additional_details do
|
5
5
|
# Define additional tests based on new functionality or
|
6
6
|
# override tests originally defined in the decorated class for
|
7
7
|
# changes that alter default behavior.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Workarea
|
4
|
-
decorate UserTest, with: :
|
4
|
+
decorate UserTest, with: :product_additional_details do
|
5
5
|
# Define additional tests based on new functionality or
|
6
6
|
# override tests originally defined in the decorated class for
|
7
7
|
# changes that alter default behavior.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Workarea
|
4
|
-
decorate HashUpdateTest, with: :
|
4
|
+
decorate HashUpdateTest, with: :product_additional_details do
|
5
5
|
# Define additional tests based on new functionality or
|
6
6
|
# override tests originally defined in the decorated class for
|
7
7
|
# changes that alter default behavior.
|
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.
|
4
|
+
version: 2.0.32
|
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-
|
11
|
+
date: 2020-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -46,14 +46,18 @@ files:
|
|
46
46
|
- app/assets/stylesheets/workarea/storefront/product_additional_details/.keep
|
47
47
|
- app/controllers/.keep
|
48
48
|
- app/controllers/workarea/admin/catalog_products_controller.decorator
|
49
|
+
- app/controllers/workarea/admin/catalog_variants_controller.decorator
|
49
50
|
- app/controllers/workarea/admin/create_catalog_products_controller.decorator
|
50
51
|
- app/helpers/.keep
|
51
52
|
- app/mailers/.keep
|
52
53
|
- app/models/.keep
|
53
54
|
- app/models/workarea/catalog/product.decorator
|
55
|
+
- app/models/workarea/catalog/variant.decorator
|
56
|
+
- app/models/workarea/search/storefront/product/text.rb
|
54
57
|
- app/services/workarea/hash_update.decorator
|
55
58
|
- app/views/.keep
|
56
59
|
- app/views/workarea/admin/catalog_products/_additional_details.html.haml
|
60
|
+
- app/views/workarea/admin/catalog_variants/_additional_details.html.haml
|
57
61
|
- app/views/workarea/admin/create_catalog_products/details.html.haml
|
58
62
|
- bin/rails
|
59
63
|
- config/initializers/appends.rb
|