workarea-product_content 0.0.1.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/Gemfile +17 -0
  4. data/LICENSE +52 -0
  5. data/README.md +36 -0
  6. data/Rakefile +56 -0
  7. data/app/models/workarea/catalog/product.decorator +21 -0
  8. data/app/view_models/workarea/admin/product_view_model.decorator +11 -0
  9. data/app/view_models/workarea/storefront/product_view_model.decorator +9 -0
  10. data/app/views/.keep +0 -0
  11. data/app/views/workarea/admin/catalog_products/_cards.html.haml +266 -0
  12. data/app/views/workarea/admin/catalog_products/content.html.haml +42 -0
  13. data/bin/rails +25 -0
  14. data/config/initializers/workarea.rb +5 -0
  15. data/config/routes.rb +2 -0
  16. data/lib/workarea/product_content.rb +8 -0
  17. data/lib/workarea/product_content/engine.rb +10 -0
  18. data/lib/workarea/product_content/version.rb +5 -0
  19. data/test/dummy/.ruby-version +1 -0
  20. data/test/dummy/Rakefile +6 -0
  21. data/test/dummy/app/assets/config/manifest.js +2 -0
  22. data/test/dummy/app/assets/images/.keep +0 -0
  23. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  24. data/test/dummy/app/controllers/application_controller.rb +2 -0
  25. data/test/dummy/app/controllers/concerns/.keep +0 -0
  26. data/test/dummy/app/helpers/application_helper.rb +2 -0
  27. data/test/dummy/app/javascript/packs/application.js +14 -0
  28. data/test/dummy/app/jobs/application_job.rb +7 -0
  29. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  30. data/test/dummy/app/models/concerns/.keep +0 -0
  31. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  32. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  33. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  34. data/test/dummy/bin/rails +4 -0
  35. data/test/dummy/bin/rake +4 -0
  36. data/test/dummy/bin/setup +25 -0
  37. data/test/dummy/config.ru +5 -0
  38. data/test/dummy/config/application.rb +33 -0
  39. data/test/dummy/config/boot.rb +5 -0
  40. data/test/dummy/config/environment.rb +5 -0
  41. data/test/dummy/config/environments/development.rb +53 -0
  42. data/test/dummy/config/environments/production.rb +101 -0
  43. data/test/dummy/config/environments/test.rb +48 -0
  44. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  45. data/test/dummy/config/initializers/assets.rb +12 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/content_security_policy.rb +28 -0
  48. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  49. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  50. data/test/dummy/config/initializers/inflections.rb +16 -0
  51. data/test/dummy/config/initializers/mime_types.rb +4 -0
  52. data/test/dummy/config/initializers/workarea.rb +5 -0
  53. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  54. data/test/dummy/config/locales/en.yml +33 -0
  55. data/test/dummy/config/puma.rb +38 -0
  56. data/test/dummy/config/routes.rb +5 -0
  57. data/test/dummy/config/spring.rb +6 -0
  58. data/test/dummy/db/seeds.rb +2 -0
  59. data/test/dummy/lib/assets/.keep +0 -0
  60. data/test/dummy/log/.keep +0 -0
  61. data/test/models/catalog/product_test.decorator +13 -0
  62. data/test/teaspoon_env.rb +6 -0
  63. data/test/test_helper.rb +10 -0
  64. data/workarea-product_content.gemspec +20 -0
  65. metadata +120 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3fedf33c9292a5a66d457af8e83b08d297382212105d5d07e0e063a8de517e31
4
+ data.tar.gz: 360ef98311659f7ed6583c3fc6cdc6f3f4b5fec7a42d934e57a4a52d1e3bdb07
5
+ SHA512:
6
+ metadata.gz: 0e226dc4ddf6b6f1c02cfe119c7b907c055a9649db048ea606dfd80d2f94b67183e363f79d9492ea641bd6c82d48c2e66d879205b2bcf9d646c57856644e37c2
7
+ data.tar.gz: 1c0abf521c1da9721ba0e0ba45b2c181bb551766b7a4fba8f73e63d38cfefac0125dafbd4c9201326f4f41e8eb0c2112228e1438192eac57607e138b4b52d537
@@ -0,0 +1,21 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/tmp/
6
+ .DS_Store
7
+ .byebug_history
8
+ .bundle/
9
+ .sass-cache/
10
+ Gemfile.lock
11
+ pkg/
12
+ test/dummy/tmp/
13
+ test/dummy/public/
14
+ log/*.log
15
+ test/dummy/log/*.log
16
+ test/dummy/db/*.sqlite3
17
+ test/dummy/db/*.sqlite3-journal
18
+ node_modules
19
+ yarn.lock
20
+ yarn-error.log
21
+ package-lock.json
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in product_content.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
16
+
17
+ gem 'workarea', github: 'workarea-commerce/workarea'
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
@@ -0,0 +1,36 @@
1
+ Workarea Product Content
2
+ ================================================================================
3
+
4
+ Content block implementation for product deatils page. Admin can add content blocks above and below the details.
5
+
6
+
7
+ Getting Started
8
+ --------------------------------------------------------------------------------
9
+
10
+ This gem contains a Rails engine that must be mounted onto a host Rails application.
11
+
12
+ Then add the gem to your application's Gemfile specifying the source:
13
+
14
+ # ...
15
+ gem 'workarea-product_content'
16
+ # ...
17
+
18
+ Update your application's bundle.
19
+
20
+ cd path/to/application
21
+ bundle
22
+
23
+ Features
24
+ --------------------------------------------------------------------------------
25
+
26
+ ### TODO
27
+
28
+ Workarea Platform Documentation
29
+ --------------------------------------------------------------------------------
30
+
31
+ See [https://developer.workarea.com](https://developer.workarea.com) for Workarea platform documentation.
32
+
33
+ License
34
+ --------------------------------------------------------------------------------
35
+
36
+ Workarea Product Content is released under the [Business Software License](LICENSE)
@@ -0,0 +1,56 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Product Content'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/product_content/version'
32
+
33
+ desc "Release version #{Workarea::ProductContent::VERSION} of the gem"
34
+ task :release do
35
+ Rake::Task['workarea:changelog'].execute
36
+ system 'git add CHANGELOG.md'
37
+ system 'git commit -m "Update CHANGELOG"'
38
+
39
+ system "git tag -a v#{Workarea::ProductContent::VERSION} -m 'Tagging #{Workarea::ProductContent::VERSION}'"
40
+ system 'git push origin HEAD --follow-tags'
41
+
42
+ system "gem build workarea-product_content.gemspec"
43
+ system "gem push workarea-product_content-#{Workarea::ProductContent::VERSION}.gem"
44
+ system "rm workarea-product_content-#{Workarea::ProductContent::VERSION}.gem"
45
+ end
46
+
47
+ desc 'Run the JavaScript tests'
48
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
49
+ task teaspoon: 'app:teaspoon'
50
+
51
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
52
+ task :teaspoon_server do
53
+ Dir.chdir("test/dummy")
54
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
55
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
56
+ end
@@ -0,0 +1,21 @@
1
+ module Workarea
2
+ decorate Catalog::Product, with: :product_content do
3
+ decorated do
4
+ # Place code to decorate here that would normally go on the class
5
+ # level, e.g.:
6
+ #
7
+ # field :name, type: String
8
+ include Contentable
9
+ end
10
+
11
+ class_methods do
12
+ # Place methods to define on the class level here. These methods
13
+ # will be available by calling Catalog::Product.your_method. Do
14
+ # not prefix these methods with `self.`
15
+ end
16
+
17
+ # Instance methods can go right in the main definition of the
18
+ # decorator, as it is a module that gets prepended into the class of
19
+ # your choice.
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ module Workarea
2
+ decorate Admin::ProductViewModel, with: :product_content do
3
+ decorated do
4
+ # Place code to decorate here that would normally go on the class
5
+ # level, e.g.:
6
+ #
7
+ # field :name, type: String
8
+ include Admin::ContentableViewModel
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Workarea
2
+ module Storefront
3
+ decorate Storefront::ProductViewModel, with: :product_content do
4
+ decorated do
5
+ include DisplayContent
6
+ end
7
+ end
8
+ end
9
+ end
File without changes
@@ -0,0 +1,266 @@
1
+ .grid.grid--auto.grid--flush.grid--center{ class: "product-cards product-cards--#{model.template}"}
2
+ .grid__cell
3
+ .card{ class: card_classes(:attributes, local_assigns[:active]) }
4
+ = link_to edit_catalog_product_path(model), class: 'card__header' do
5
+ %span.card__header-text= t('workarea.admin.cards.attributes.title')
6
+ = inline_svg 'workarea/admin/icons/attributes.svg', class: 'card__icon'
7
+
8
+ - if local_assigns[:active].blank?
9
+ .card__body
10
+ %ul.list-reset
11
+ %li
12
+ %strong= t('workarea.admin.fields.id')
13
+ = model.id
14
+ %li
15
+ %strong= t('workarea.admin.fields.active')
16
+ = check_box_tag 'product', 'active', model.active?, disabled: true
17
+ = segments_icons_for(model)
18
+ %li
19
+ %strong= t('workarea.admin.fields.template')
20
+ = model.template.try(:titleize)
21
+ %li
22
+ %strong= t('workarea.admin.fields.details')
23
+ = model.details.values.flatten.join(', ').presence || t('workarea.admin.cards.attributes.no_value')
24
+ %li
25
+ %strong= t('workarea.admin.fields.filters')
26
+ = model.filters.values.flatten.join(', ').presence || t('workarea.admin.cards.attributes.no_value')
27
+ %li
28
+ %strong= t('workarea.admin.fields.customizations')
29
+ = model.customizations.try(:titleize).presence || t('workarea.admin.cards.attributes.no_value')
30
+ %li
31
+ %strong= t('workarea.admin.fields.tags')
32
+ = model.tags.join(', ').presence || t('workarea.admin.cards.attributes.no_value')
33
+ %li
34
+ %strong= t('workarea.admin.fields.updated_at')
35
+ #{local_time_ago(model.updated_at)}
36
+ %li
37
+ %strong= t('workarea.admin.fields.created_at')
38
+ #{local_time_ago(model.created_at)}
39
+ - if model.copied_from_id.present?
40
+ %li
41
+ %strong= t('workarea.admin.fields.copied_from_id')
42
+ = model.copied_from_id
43
+ = append_partials('admin.product_attributes_card', product: model)
44
+
45
+ = link_to edit_catalog_product_path(model), class: 'card__button' do
46
+ %span.button.button--small= t('workarea.admin.cards.attributes.button')
47
+
48
+ .grid__cell
49
+ .card{ class: card_classes(:images, local_assigns[:active]) }
50
+ = link_to catalog_product_images_path(model), class: 'card__header' do
51
+ %span.card__header-text= t('workarea.admin.catalog_products.cards.images.title')
52
+ = inline_svg 'workarea/admin/icons/images.svg', class: 'card__icon'
53
+
54
+ - if local_assigns[:active].blank?
55
+ .card__body
56
+ - if model.images.empty?
57
+ %p= t('workarea.admin.catalog_products.cards.images.description')
58
+ = link_to catalog_product_images_path(model), class: 'card__button' do
59
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.images.add_images')
60
+ - else
61
+ %ul.grid
62
+ - model.images.take(4).each_with_index do |image, i|
63
+ %li.grid__cell.grid__cell--50
64
+ .card__photo-box
65
+ - if i == 3 && model.images.size > 4
66
+ %span.card__photo +#{model.images.size - i}
67
+ - else
68
+ = image_tag product_image_url(image, :medium), alt: image.name, class: 'card__photo'
69
+ = link_to catalog_product_images_path(model), class: 'card__button' do
70
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.images.manage_images')
71
+
72
+ .grid__cell
73
+ .card{ class: card_classes(:variants, local_assigns[:active]) }
74
+ = link_to catalog_product_variants_path(model), class: 'card__header' do
75
+ %span.card__header-text= t('workarea.admin.catalog_products.cards.variants.title')
76
+ = inline_svg 'workarea/admin/icons/variants.svg', class: 'card__icon'
77
+
78
+ - if local_assigns[:active].blank?
79
+ .card__body
80
+ - if model.variants.empty?
81
+ %p.card__empty-note= t('workarea.admin.catalog_products.cards.variants.no_variants')
82
+ = link_to catalog_product_variants_path(model), class: 'card__button' do
83
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.variants.add_variants')
84
+ - else
85
+ .section
86
+ %span.heading.heading--3.heading--no-margin.align-center
87
+ - if model.one_price?
88
+ = number_to_currency model.sell_min_price
89
+ - if model.show_sell_range?
90
+ \- #{number_to_currency model.sell_max_price}
91
+ - else
92
+ - if model.on_sale?
93
+ = number_to_currency model.sell_min_price
94
+ - if model.show_sell_range?
95
+ \- #{number_to_currency model.sell_max_price}
96
+ - else
97
+ = number_to_currency model.sell_min_price
98
+ - if model.show_sell_range?
99
+ \- #{number_to_currency model.sell_max_price}
100
+ %p.align-center= t('workarea.admin.fields.price')
101
+
102
+ %span.heading.heading--3.heading--no-margin.align-center
103
+ - if model.ignore_inventory?
104
+ = t('workarea.admin.catalog_products.index.ignore_inventory', variants: pluralize(model.variants.size, t('workarea.admin.catalog_products.index.variant')))
105
+ - else
106
+ = t('workarea.admin.catalog_products.index.inventory', count: model.available_inventory, variants: pluralize(model.variants.size, t('workarea.admin.catalog_products.index.variant')))
107
+
108
+ %p.align-center= t('workarea.admin.fields.inventory')
109
+
110
+ %span.heading.heading--3.heading--no-margin.align-center
111
+ = model.variant_details.keys.to_sentence
112
+ %p.align-center= t('workarea.admin.fields.options')
113
+
114
+ = link_to catalog_product_variants_path(model), class: 'card__button' do
115
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.variants.manage_variants')
116
+
117
+ .grid__cell
118
+ .card{ class: card_classes(:description, local_assigns[:active]) }
119
+ = link_to content_catalog_product_path(model), class: 'card__header' do
120
+ %span.card__header-text= "Description & SEO"
121
+ = inline_svg 'workarea/admin/icons/content.svg', class: 'card__icon'
122
+
123
+ - if local_assigns[:active].blank?
124
+ .card__body
125
+ %ul.list-reset
126
+ %li
127
+ %strong= t('workarea.admin.fields.description')
128
+ = truncate(model.description.presence || t('workarea.admin.cards.attributes.no_value'))
129
+ %li
130
+ %strong= t('workarea.admin.fields.browser_title')
131
+ = truncate(model.browser_title.presence || t('workarea.admin.cards.attributes.no_value'))
132
+ %li
133
+ %strong= t('workarea.admin.fields.meta_description')
134
+ = truncate(model.meta_description.presence || t('workarea.admin.cards.attributes.no_value'))
135
+
136
+ = link_to content_catalog_product_path(model), class: 'card__button' do
137
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.content.manage_content')
138
+
139
+ .grid__cell
140
+ = render 'workarea/admin/content/card', content: model.content, active: local_assigns[:active]
141
+
142
+ .grid__cell
143
+ .card{ class: card_classes(:categories, local_assigns[:active]) }
144
+ = link_to catalog_product_categorizations_path(model), class: 'card__header' do
145
+ %span.card__header-text= t('workarea.admin.catalog_products.cards.categories.title')
146
+ = inline_svg 'workarea/admin/icons/categories.svg', class: 'card__icon'
147
+
148
+ - if local_assigns[:active].blank?
149
+ .card__body
150
+ - if model.categories.empty?
151
+ %p.card__empty-note= t('workarea.admin.catalog_products.cards.categories.no_categories')
152
+ = link_to catalog_product_categorizations_path(model), class: 'card__button' do
153
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.categories.add_categories')
154
+ - else
155
+ - if model.featured_categories.any?
156
+ %strong= t('workarea.admin.catalog_products.cards.categories.featured')
157
+
158
+ %ul.list-reset
159
+ - model.featured_categories.each do |category|
160
+ %li
161
+ = category.name
162
+ - if category == model.default_category
163
+ = t('workarea.admin.catalog_products.cards.categories.default')
164
+ %br
165
+ - if model.rules_categories.any?
166
+ %strong= t('workarea.admin.catalog_products.cards.categories.rules')
167
+
168
+ %ul.list-reset
169
+ - model.rules_categories.each do |category|
170
+ %li
171
+ = category.name
172
+ - if category == model.default_category
173
+ = t('workarea.admin.catalog_products.cards.categories.default')
174
+
175
+ = link_to catalog_product_categorizations_path(model), class: 'card__button' do
176
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.categories.manage_categories')
177
+
178
+ .grid__cell
179
+ .card{ class: card_classes(:recommendations, local_assigns[:active]) }
180
+ = link_to edit_catalog_product_recommendations_path(model), class: 'card__header' do
181
+ %span.card__header-text= t('workarea.admin.catalog_products.cards.recommendations.title')
182
+ = inline_svg 'workarea/admin/icons/recommendations.svg', class: 'card__icon'
183
+
184
+ - if local_assigns[:active].blank?
185
+ .card__body
186
+ - unless model.storefront_recommendations.any?
187
+ %p.card__empty-note= t('workarea.admin.catalog_products.cards.recommendations.no_recommendations')
188
+ = link_to edit_catalog_product_recommendations_path(model), class: 'card__button' do
189
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.recommendations.add_recommendations')
190
+ - else
191
+ %ol.grid
192
+ - model.storefront_recommendations.take(4).each_with_index do |product, i|
193
+ %li.grid__cell.grid__cell--50
194
+ .card__photo-box
195
+ - if i == 3 && model.storefront_recommendations.size > 4
196
+ %span.card__photo +#{model.storefront_recommendations.size - i}
197
+ - else
198
+ = image_tag product_image_url(product.primary_image, :medium), alt: product.name, class: 'card__photo'
199
+ = link_to edit_catalog_product_recommendations_path(model), class: 'card__button' do
200
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.recommendations.manage_recommendations')
201
+
202
+ .grid__cell
203
+ .card{ class: card_classes(:insights, local_assigns[:active]) }
204
+ = link_to insights_catalog_product_path(model), class: 'card__header' do
205
+ %span.card__header-text= t('workarea.admin.catalog_products.cards.insights.title')
206
+ = inline_svg 'workarea/admin/icons/insights.svg', class: 'card__icon'
207
+
208
+ - if local_assigns[:active].blank?
209
+ .card__body
210
+ %p.align-center
211
+ %span.spark.spark--large
212
+ {#{sparkline_analytics_data_for(model.insights.orders_sparkline).join(',')}}
213
+
214
+ %span.heading.heading--4.align-center
215
+ #{number_with_delimiter model.insights.orders}
216
+ #{t('workarea.admin.catalog_products.cards.insights.orders')}
217
+ #{insights_trend_icon(model.insights.orders_percent_change)}
218
+
219
+ .grid
220
+ .grid__cell.grid__cell--50
221
+ %p.align-center
222
+ %strong= number_to_currency model.insights.revenue
223
+ #{insights_trend_icon(model.insights.revenue_percent_change)}
224
+ %br
225
+ #{t('workarea.admin.catalog_products.cards.insights.revenue')}
226
+ .grid__cell.grid__cell--50
227
+ %p.align-center
228
+ %strong
229
+ - if model.insights.average_price.blank?
230
+ \-
231
+ - else
232
+ = number_to_currency model.insights.average_price
233
+
234
+ #{insights_trend_icon(model.insights.average_price_percent_change)}
235
+ %br
236
+ #{t('workarea.admin.catalog_products.cards.insights.average_price')}
237
+
238
+ .grid
239
+ .grid__cell.grid__cell--50
240
+ %p.align-center
241
+ %strong= number_with_delimiter model.insights.units_sold
242
+ #{insights_trend_icon(model.insights.units_sold_percent_change)}
243
+ %br
244
+ #{t('workarea.admin.catalog_products.cards.insights.units_sold')}
245
+ .grid__cell.grid__cell--50
246
+ %p.align-center
247
+ %strong= number_with_delimiter model.insights.views
248
+ #{insights_trend_icon(model.insights.views_percent_change)}
249
+ %br
250
+ #{t('workarea.admin.catalog_products.cards.insights.views')}
251
+
252
+ %p.align-center
253
+ = distance_of_time_in_words(model.insights.starts_at, model.insights.ends_at)
254
+ = top_icon_for(model)
255
+ = trending_icon_for(model)
256
+
257
+ = link_to insights_catalog_product_path(model), class: 'card__button' do
258
+ %span.button.button--small= t('workarea.admin.catalog_products.cards.insights.button')
259
+
260
+ = append_partials('admin.catalog_product_cards', model: model, active: local_assigns[:active])
261
+
262
+ .grid__cell
263
+ = render 'workarea/admin/timeline/card', timeline: model.timeline, active: local_assigns[:active]
264
+
265
+ .grid__cell
266
+ = render 'workarea/admin/comments/card', commentable: model, active: local_assigns[:active]