workarea-gift_wrapping 1.2.1

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.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.gitignore +23 -0
  7. data/CHANGELOG.md +34 -0
  8. data/CODE_OF_CONDUCT.md +3 -0
  9. data/CONTRIBUTING.md +3 -0
  10. data/Gemfile +9 -0
  11. data/LICENSE +52 -0
  12. data/README.md +41 -0
  13. data/Rakefile +60 -0
  14. data/app/controllers/workarea/admin/catalog_gift_wraps_controller.rb +77 -0
  15. data/app/models/workarea/catalog/gift_wrap.rb +10 -0
  16. data/app/models/workarea/catalog/product.decorator +7 -0
  17. data/app/models/workarea/checkout/steps/shipping.decorator +57 -0
  18. data/app/models/workarea/order/item.decorator +53 -0
  19. data/app/models/workarea/pricing/calculators/gift_wrapping_calculator.rb +38 -0
  20. data/app/models/workarea/pricing/request.decorator +9 -0
  21. data/app/models/workarea/shipping.decorator +10 -0
  22. data/app/seeds/workarea/gift_wrapping_seeds.rb +19 -0
  23. data/app/view_models/workarea/order_item_view_model.decorator +19 -0
  24. data/app/view_models/workarea/storefront/checkout/gift_options_view_model.rb +45 -0
  25. data/app/view_models/workarea/storefront/checkout/summary_view_model.decorator +11 -0
  26. data/app/views/workarea/admin/catalog_gift_wraps/_aux_navigation.html.haml +7 -0
  27. data/app/views/workarea/admin/catalog_gift_wraps/_navigation.html.haml +1 -0
  28. data/app/views/workarea/admin/catalog_gift_wraps/edit.html.haml +38 -0
  29. data/app/views/workarea/admin/catalog_gift_wraps/index.html.haml +41 -0
  30. data/app/views/workarea/admin/catalog_gift_wraps/new.html.haml +39 -0
  31. data/app/views/workarea/admin/catalog_products/_gift_wrapping_fields.html.haml +3 -0
  32. data/app/views/workarea/admin/orders/_gift_wrapping.html.haml +4 -0
  33. data/app/views/workarea/admin/shippings/_gift_message.html.haml +5 -0
  34. data/app/views/workarea/storefront/checkouts/_gift_message.html.haml +10 -0
  35. data/app/views/workarea/storefront/checkouts/_gift_message_summary.html.haml +4 -0
  36. data/app/views/workarea/storefront/checkouts/_gift_wrapping.html.haml +34 -0
  37. data/app/views/workarea/storefront/checkouts/_gift_wrapping_summary.html.haml +5 -0
  38. data/app/views/workarea/storefront/order_mailer/_gift_message.html.haml +8 -0
  39. data/app/views/workarea/storefront/order_mailer/_gift_message.text.erb +5 -0
  40. data/app/views/workarea/storefront/order_mailer/_gift_wrapping.html.haml +4 -0
  41. data/app/views/workarea/storefront/order_mailer/_gift_wrapping.text.erb +3 -0
  42. data/app/views/workarea/storefront/orders/_gift_message.html.haml +7 -0
  43. data/app/views/workarea/storefront/orders/_gift_wrapping.html.haml +4 -0
  44. data/bin/rails +20 -0
  45. data/config/initializers/appends.rb +68 -0
  46. data/config/initializers/configuration.rb +15 -0
  47. data/config/locales/en.yml +42 -0
  48. data/config/routes.rb +5 -0
  49. data/lib/workarea/gift_wrapping/engine.rb +22 -0
  50. data/lib/workarea/gift_wrapping/version.rb +5 -0
  51. data/lib/workarea/gift_wrapping.rb +11 -0
  52. data/test/dummy/Rakefile +6 -0
  53. data/test/dummy/app/assets/config/manifest.js +4 -0
  54. data/test/dummy/app/assets/images/.keep +0 -0
  55. data/test/dummy/app/assets/javascripts/application.js +13 -0
  56. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  57. data/test/dummy/app/controllers/application_controller.rb +3 -0
  58. data/test/dummy/app/controllers/concerns/.keep +0 -0
  59. data/test/dummy/app/helpers/application_helper.rb +2 -0
  60. data/test/dummy/app/jobs/application_job.rb +2 -0
  61. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  62. data/test/dummy/app/models/concerns/.keep +0 -0
  63. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  64. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  65. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  66. data/test/dummy/bin/bundle +3 -0
  67. data/test/dummy/bin/rails +4 -0
  68. data/test/dummy/bin/rake +4 -0
  69. data/test/dummy/bin/setup +37 -0
  70. data/test/dummy/bin/update +29 -0
  71. data/test/dummy/bin/yarn +11 -0
  72. data/test/dummy/config/application.rb +27 -0
  73. data/test/dummy/config/boot.rb +5 -0
  74. data/test/dummy/config/cable.yml +10 -0
  75. data/test/dummy/config/environment.rb +5 -0
  76. data/test/dummy/config/environments/development.rb +54 -0
  77. data/test/dummy/config/environments/production.rb +91 -0
  78. data/test/dummy/config/environments/test.rb +44 -0
  79. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  80. data/test/dummy/config/initializers/assets.rb +14 -0
  81. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  82. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  83. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  84. data/test/dummy/config/initializers/inflections.rb +16 -0
  85. data/test/dummy/config/initializers/mime_types.rb +4 -0
  86. data/test/dummy/config/initializers/workarea.rb +5 -0
  87. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  88. data/test/dummy/config/locales/en.yml +33 -0
  89. data/test/dummy/config/puma.rb +56 -0
  90. data/test/dummy/config/routes.rb +5 -0
  91. data/test/dummy/config/secrets.yml +32 -0
  92. data/test/dummy/config/spring.rb +6 -0
  93. data/test/dummy/config.ru +5 -0
  94. data/test/dummy/db/seeds.rb +2 -0
  95. data/test/dummy/lib/assets/.keep +0 -0
  96. data/test/dummy/log/.keep +0 -0
  97. data/test/factories/workarea/gift_wrapping.rb +21 -0
  98. data/test/integration/workarea/admin/catalog_gift_wrap_integration_test.rb +50 -0
  99. data/test/integration/workarea/storefront/gift_wrapping_integration_test.rb +76 -0
  100. data/test/models/workarea/checkout/steps/gift_wrapping_shipping_test.rb +37 -0
  101. data/test/models/workarea/order/gift_wrapping_item_test.rb +52 -0
  102. data/test/models/workarea/pricing/calculators/gift_wrapping_calculator_test.rb +84 -0
  103. data/test/system/workarea/admin/gift_wrap_system_test.rb +48 -0
  104. data/test/system/workarea/storefront/gift_wrap_system_test.rb +93 -0
  105. data/test/teaspoon_env.rb +6 -0
  106. data/test/test_helper.rb +10 -0
  107. data/workarea-gift_wrapping.gemspec +21 -0
  108. metadata +170 -0
@@ -0,0 +1,45 @@
1
+ module Workarea
2
+ module Storefront
3
+ module Checkout
4
+ module GiftOptionsViewModel
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ delegate :gift_message, to: :shipping, allow_nil: true
9
+ end
10
+
11
+ def gift_message?
12
+ gift_message.present?
13
+ end
14
+
15
+ # Whether to show gift wrapping as an option in checkout.
16
+ # Based on whether the Catalog has any configured gift wrap.
17
+ #
18
+ # @return [Boolean]
19
+ #
20
+ def offer_gift_wrapping?
21
+ gift_wraps.any?
22
+ end
23
+
24
+ # An array of gift wrapping options from the Catalog.
25
+ # First element is the name, second is the id.
26
+ # Used in the gift wrap select on the shipping step.
27
+ #
28
+ # @return [Array<Array>]
29
+ #
30
+ def gift_wrapping_options
31
+ @gift_wrapping_options ||=
32
+ [['None', nil]] + gift_wraps.map do |gift_wrap|
33
+ [gift_wrap.name, gift_wrap.id.to_s]
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ def gift_wraps
40
+ @gift_wraps ||= Catalog::GiftWrap.all.to_a
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ module Workarea
2
+ decorate Storefront::Checkout::SummaryViewModel, with: :gift_wrapping do
3
+ # Whether to show order gift messages summary info.
4
+ #
5
+ # @return [Boolean]
6
+ #
7
+ def show_gift_message?
8
+ shippings.one? && shipping.gift_message.present?
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ .grid.grid--auto.grid--right.grid--middle
2
+ .grid__cell
3
+ - if @pricing.present?
4
+ = link_to t('workarea.admin.catalog_gift_wraps.edit.view_pricing'), pricing_sku_path(@pricing)
5
+ - else
6
+ = link_to t('workarea.admin.catalog_gift_wraps.edit.create_pricing'), new_pricing_sku_path('sku[id]' => model.sku)
7
+ = append_partials('admin.catalog_gift_wrap_aux_navigation', model: model)
@@ -0,0 +1 @@
1
+ %li{ class: "primary-nav__item" }= link_to t('workarea.admin.shared.primary_nav.gift_wraps'), catalog_gift_wraps_path, class: navigation_link_classes(catalog_gift_wraps_path)
@@ -0,0 +1,38 @@
1
+ - @page_title = t('workarea.admin.catalog_gift_wraps.edit.title', name: @gift_wrap.name)
2
+
3
+ .view
4
+ .view__header
5
+ .grid
6
+ .grid__cell.grid__cell--25
7
+ .grid__cell.grid__cell--50
8
+ .view__heading
9
+ = link_to_index_for(@gift_wrap)
10
+ %h1= t('workarea.admin.catalog_gift_wraps.edit.title', name: @gift_wrap.name)
11
+ .grid__cell.grid__cell--25
12
+ = render_aux_navigation_for(@gift_wrap)
13
+
14
+
15
+ .view__container
16
+ - if @gift_wrap.errors.present?
17
+ - @gift_wrap.errors.full_messages.each do |message|
18
+ = render_message 'error', message
19
+
20
+ = form_tag catalog_gift_wrap_path(@gift_wrap), method: :put, id: 'shipping_gift_wrap_form', data: { unsaved_changes: '' } do
21
+
22
+ .section
23
+
24
+ .property.property--required
25
+ = label_tag 'gift_wrap[name]', t('workarea.admin.fields.name'), class: 'property__name'
26
+ = text_field_tag 'gift_wrap[name]', @gift_wrap.name, class: 'text-box text-box--i18n', required: true
27
+
28
+ .property
29
+ = label_tag 'gift_wrap[sku]', t('workarea.admin.fields.sku'), class: 'property__name'
30
+ = text_field_tag "gift_wrap[sku]", @gift_wrap.sku, class: 'text-box', required: true
31
+ %span.property__note= t('workarea.admin.catalog_gift_wraps.sku_note')
32
+
33
+ .workflow-bar
34
+ .grid
35
+ .grid__cell.grid__cell--50
36
+ = link_to t('workarea.admin.actions.delete'), catalog_gift_wrap_path(@gift_wrap), class: 'workflow-bar__button workflow-bar__button--delete', data: { method: 'delete', confirm: t('workarea.admin.actions.delete_confirmation') }
37
+ .grid__cell.grid__cell--50
38
+ .align-right= button_tag t('workarea.admin.catalog_gift_wraps.edit.button'), value: 'create_gift_wrap', class: 'workflow-bar__button workflow-bar__button--create'
@@ -0,0 +1,41 @@
1
+ - @page_title = t('workarea.admin.catalog_gift_wraps.index.title')
2
+
3
+ .view
4
+ .view__header
5
+ .grid.grid--middle.grid--center
6
+ .grid__cell.grid__cell--50
7
+ .view__heading
8
+ = link_to "↑ #{t('workarea.admin.catalog.dashboard_link')}", catalog_dashboards_path, class: 'view__dashboard-button'
9
+ %h1= t('workarea.admin.catalog_gift_wraps.index.title')
10
+
11
+ .view__container
12
+
13
+ .browsing-controls
14
+ %p.browsing-controls__count{ data: { browsing_controls_count: @gift_wraps.count } }
15
+ = pluralize(@gift_wraps.count, t('workarea.admin.catalog_gift_wraps.name'))
16
+
17
+ - if @gift_wraps.any?
18
+ %table.index-table
19
+ %thead
20
+ %tr
21
+ %th.index-table__control-cell
22
+ %th= t('workarea.admin.fields.name')
23
+ %th= t('workarea.admin.fields.sku')
24
+ %th= t('workarea.admin.fields.updated_at')
25
+ %tbody
26
+ - @gift_wraps.each do |result|
27
+ %tr.index-table__row
28
+ %td.index-table__control-cell
29
+ .checkbox.hidden
30
+ = check_box_tag 'global_id', result.to_global_id.to_param, false, class: 'checkbox__input', id: dom_id(result)
31
+ = label_tag dom_id(result), t('workarea.admin.bulk_actions.add_summary_button'), class: 'checkbox__label'
32
+ %td= link_to result.name, edit_catalog_gift_wrap_path(result)
33
+ %td= result.sku
34
+ %td= local_time_ago(result.updated_at)
35
+
36
+ - if @gift_wraps.total_pages > 1
37
+ = render 'workarea/admin/shared/pagination', collection: @gift_wraps
38
+
39
+ .workflow-bar
40
+ .grid.grid--auto.grid--right
41
+ .grid__cell= link_to t('workarea.admin.catalog_gift_wraps.index.button'), new_catalog_gift_wrap_path, id: 'add_gift_wrap', class: 'workflow-bar__button workflow-bar__button--create'
@@ -0,0 +1,39 @@
1
+ - @page_title = t('workarea.admin.catalog_gift_wraps.new.title')
2
+
3
+ .view
4
+ .view__header
5
+ .grid.grid--middle.grid--center
6
+ .grid__cell.grid__cell--50
7
+ .view__heading
8
+ = link_to_index_for(@gift_wrap)
9
+ %h1= t('workarea.admin.catalog_gift_wraps.new.title')
10
+
11
+ .view__container
12
+ - if @gift_wrap.errors.present?
13
+ - @gift_wrap.errors.full_messages.each do |message|
14
+ = render_message 'error', message
15
+
16
+ = form_tag catalog_gift_wraps_path, method: :post, id: 'shipping_gift_wrap_form', data: { unsaved_changes: '' } do
17
+
18
+ .section
19
+
20
+ .property.property--required
21
+ = label_tag 'gift_wrap[name]', t('workarea.admin.fields.name'), class: 'property__name'
22
+ = text_field_tag 'gift_wrap[name]', @gift_wrap.name, class: 'text-box text-box--i18n', required: true
23
+
24
+ .property
25
+ = label_tag 'gift_wrap[sku]', t('workarea.admin.fields.sku'), class: 'property__name'
26
+ = text_field_tag "gift_wrap[sku]", @gift_wrap.sku, class: 'text-box', required: true
27
+
28
+ .property
29
+ = label_tag 'pricing_sku[regular]', t('workarea.admin.fields.price'), class: 'property__name'
30
+ = currency_symbol
31
+ = text_field_tag 'pricing_sku[regular]', params['pricing'].try(:[], 'regular'), class: 'text-box text-box--small', title: t('workarea.admin.fields.regular'), placeholder: t('workarea.admin.prices.placeholder')
32
+
33
+ .property
34
+ = label_tag 'pricing_sku[tax_code]', t('workarea.admin.fields.tax_code'), class: 'property__name'
35
+ = text_field_tag 'pricing_sku[tax_code]', params['pricing'].try(:[], 'tax_code'), class: 'text-box', placeholder: t('workarea.admin.pricing_skus.tax_code_placeholder')
36
+
37
+ .workflow-bar
38
+ .grid.grid--auto.grid--right.grid--middle
39
+ .grid__cell= button_tag t('workarea.admin.catalog_gift_wraps.new.button'), value: 'create_gift_wrap', class: 'workflow-bar__button workflow-bar__button--create'
@@ -0,0 +1,3 @@
1
+ .property
2
+ = label_tag 'product[allow_gift_wrapping]', t('workarea.admin.catalog_products.gift_wrapping_fields.allow_gift_wrapping'), class: 'property__name'
3
+ = toggle_button_for 'product[allow_gift_wrapping]', product.allow_gift_wrapping?
@@ -0,0 +1,4 @@
1
+ - if item.gift_wrapped?
2
+ .gift-wrap
3
+ = t('workarea.admin.orders.attributes.gift_wrap')
4
+ = item.gift_wraps.map(&:name).to_sentence
@@ -0,0 +1,5 @@
1
+ - if shipping.gift_message.present?
2
+ .grid__cell.grid__cell--33-at-medium
3
+ %h2= t('workarea.admin.fields.gift_message')
4
+ .section
5
+ %p= shipping.gift_message
@@ -0,0 +1,10 @@
1
+ .checkout-shipping__section
2
+ %h2.checkout-shipping__heading= t('workarea.storefront.checkouts.gift_message')
3
+ - field_name = step.shippings.many? ? "shippings[#{step.shipping.id}][gift_message]" : 'gift_message'
4
+
5
+ .property.property--responsive
6
+ = label_tag field_name, nil, class: 'property__name' do
7
+ %span.property__text= t('workarea.storefront.checkouts.gift_message')
8
+ .value
9
+ = text_area_tag field_name, step.gift_message, class: 'text-box text-box--multi-line', title: t('workarea.storefront.checkouts.gift_message'), maxlength: Workarea.config.gift_message_max_length, id: nil
10
+ %span.value__note= t('workarea.storefront.checkouts.gift_message_note', length: Workarea.config.gift_message_max_length)
@@ -0,0 +1,4 @@
1
+ - if shipping.gift_message?
2
+ .checkout-step-summary__section
3
+ %strong= t('workarea.storefront.checkouts.gift_message')
4
+ %p= shipping.gift_message
@@ -0,0 +1,34 @@
1
+ - if step.offer_gift_wrapping?
2
+ .checkout-shipping__section
3
+ %h2.checkout-shipping__heading= t('workarea.storefront.checkouts.gift_wrapping')
4
+ - field_name = step.shippings.many? ? "shippings[#{step.shipping.id}][gift_wrapping]" : 'gift_wrapping'
5
+
6
+ %ul.product-list{ data: { analytics: product_list_analytics_data('Cart').to_json } }
7
+ - cart.items.each_with_index do |item, index|
8
+ %li.product-list__item
9
+ .product-list__item-cell
10
+ .product-list__summary
11
+ %p.product-list__media= link_to image_tag(product_image_url(item.image, :small_thumb), alt: item.product_name, class: 'product-list__media-image'), product_url(item.product, sku: item.sku), class: 'product-list__media-link'
12
+ .product-list__info
13
+ %p.product-list__name= link_to item.product_name, product_path(item.product, sku: item.sku)
14
+ %p.product-list__id= item.sku_name
15
+ %p.product-list__inventory-status= item.inventory_status
16
+ - if item.has_options?
17
+ .product-list__option-group
18
+ - item.details.each do |name, value|
19
+ %p.product-list__option #{name.titleize}: #{value}
20
+ - item.customizations.each do |name, value|
21
+ %p.product-list__customization #{name.titleize}: #{value}
22
+ .grid.grid--auto
23
+ .grid__cell
24
+ - if !item.allow_gift_wrapping?
25
+ %span.text= t('workarea.storefront.checkouts.gift_wrapping_unavailable')
26
+
27
+ - else
28
+ .inline-form__cell{ data: { checkout_shipping_service: '' } }
29
+ = label_tag "#{field_name}[#{item.id}][gift_wrap]", nil, class: 'name' do
30
+ %span.text= t('workarea.storefront.checkouts.gift_wrapping')
31
+ .value= select_tag "#{field_name}[#{item.id}][gift_wrap]", options_for_select(step.gift_wrapping_options, item.gift_wrap_id), title: t('workarea.storefront.checkouts.gift_wrapping_title', name: item.product_name), data: { checkout_shipping_service_option: '' }
32
+
33
+ - if step.content_blocks_for('gift_wrapping').present?
34
+ = render_content_blocks(step.content_blocks_for('gift_wrapping'))
@@ -0,0 +1,5 @@
1
+ - if item.gift_wrapped?
2
+ .gift-wrap
3
+ = t('workarea.storefront.checkouts.item_gift_wrap')
4
+ - item.gift_wraps.each do |gift_wrap|
5
+ #{gift_wrap.name} - #{link_to t('workarea.storefront.forms.edit'), checkout_shipping_path}
@@ -0,0 +1,8 @@
1
+ - if shipping.gift_message.present?
2
+ %tr
3
+ %td{ valign: "top" }
4
+ %h2{ style: "margin: 0 0 6px; font: bold 14px arial; color: #{@config.text_color};" }
5
+ = t('workarea.storefront.checkouts.gift_message')
6
+
7
+ %p{ style: "margin: 0 0 6px; font: 13px/1.5 arial; color: #{@config.text_color};" }
8
+ = shipping.gift_message
@@ -0,0 +1,5 @@
1
+ <% if shipping.gift_message.present? %>
2
+ <%= t('workarea.storefront.checkouts.gift_message') %>
3
+ -------------
4
+ <%= shipping.gift_message %>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ - if item.gift_wrapped?
2
+ %p{ style: "margin: 0 0 6px; font: 13px/1.5 arial; color: #{@config.text_color};" }
3
+ %strong= t('workarea.storefront.checkouts.item_gift_wrap')
4
+ = item.gift_wraps.map(&:name).to_sentence
@@ -0,0 +1,3 @@
1
+ <% if item.gift_wrapped? %>
2
+ <%= "#{t('workarea.storefront.checkouts.item_gift_wrap')} #{item.gift_wraps.map(&:name).to_sentence}" %>
3
+ <% end %>
@@ -0,0 +1,7 @@
1
+ - if shipping.gift_message.present?
2
+ .grid__cell
3
+ .box
4
+ .box__header
5
+ %h3.box__heading= t('workarea.storefront.checkouts.gift_message')
6
+ .box__body
7
+ %p= shipping.gift_message
@@ -0,0 +1,4 @@
1
+ - if item.gift_wrapped?
2
+ .gift-wrap
3
+ = t('workarea.storefront.checkouts.item_gift_wrap')
4
+ = item.gift_wraps.map(&:name).to_sentence
data/bin/rails ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails gems
3
+ # installed from the root of your application.
4
+
5
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
6
+ ENGINE_PATH = File.expand_path('../../lib/workarea/gift_wrapping/engine', __FILE__)
7
+ APP_PATH = File.expand_path('../../test/dummy/config/application', __FILE__)
8
+
9
+ # Set up gems listed in the Gemfile.
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
11
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
+
13
+ require 'action_controller/railtie'
14
+ require 'action_view/railtie'
15
+ require 'action_mailer/railtie'
16
+ require 'rails/test_unit/railtie'
17
+ require 'sprockets/railtie'
18
+ require 'teaspoon-mocha'
19
+
20
+ require 'rails/engine/commands'
@@ -0,0 +1,68 @@
1
+ Workarea.append_partials(
2
+ 'storefront.checkout_shipping_fields',
3
+ 'workarea/storefront/checkouts/gift_message'
4
+ )
5
+
6
+ Workarea.append_partials(
7
+ 'storefront.checkout_shipping_step_form',
8
+ 'workarea/storefront/checkouts/gift_wrapping'
9
+ )
10
+
11
+ Workarea.append_partials(
12
+ 'storefront.checkout_cart_summary_item_details',
13
+ 'workarea/storefront/checkouts/gift_wrapping_summary'
14
+ )
15
+
16
+ Workarea.append_partials(
17
+ 'storefront.checkout_summary_shipping_attributes',
18
+ 'workarea/storefront/checkouts/gift_message_summary'
19
+ )
20
+
21
+ Workarea.append_partials(
22
+ 'storefront.order_summary_item_details',
23
+ 'workarea/storefront/orders/gift_wrapping'
24
+ )
25
+
26
+ Workarea.append_partials(
27
+ 'storefront.cart_summary_item_details',
28
+ 'workarea/storefront/orders/gift_wrapping'
29
+ )
30
+
31
+ Workarea.append_partials(
32
+ 'storefront.order_summary_shipping',
33
+ 'workarea/storefront/orders/gift_message'
34
+ )
35
+
36
+ Workarea.append_partials(
37
+ 'storefront.order_mailer_summary_order_details',
38
+ 'workarea/storefront/order_mailer/gift_wrapping'
39
+ )
40
+
41
+ Workarea.append_partials(
42
+ 'storefront.order_mailer_summary_shipping',
43
+ 'workarea/storefront/order_mailer/gift_message'
44
+ )
45
+
46
+ #
47
+ # ADMIN
48
+ #
49
+
50
+ Workarea.append_partials(
51
+ 'admin.catalog_menu',
52
+ 'workarea/admin/catalog_gift_wraps/navigation'
53
+ )
54
+
55
+ Workarea.append_partials(
56
+ 'admin.product_fields',
57
+ 'workarea/admin/catalog_products/gift_wrapping_fields'
58
+ )
59
+
60
+ Workarea.append_partials(
61
+ 'admin.shipping_details',
62
+ 'workarea/admin/shippings/gift_message'
63
+ )
64
+
65
+ Workarea.append_partials(
66
+ 'admin.order_attributes_item_details',
67
+ 'workarea/admin/orders/gift_wrapping'
68
+ )
@@ -0,0 +1,15 @@
1
+ Workarea.configure do |config|
2
+ # Maximum length allowed for order gift messages
3
+ config.gift_message_max_length = 500
4
+
5
+ # Add checkout content area for gift wrapping
6
+ config.content_areas['checkout'] ||= []
7
+ config.content_areas['checkout'] << 'gift_wrapping'
8
+
9
+ config.pricing_calculators.insert_after(
10
+ 'Workarea::Pricing::Calculators::CustomizationsCalculator',
11
+ 'Workarea::Pricing::Calculators::GiftWrappingCalculator'
12
+ )
13
+
14
+ config.seeds << 'Workarea::GiftWrappingSeeds'
15
+ end
@@ -0,0 +1,42 @@
1
+ en:
2
+ workarea:
3
+ admin:
4
+ catalog_products:
5
+ gift_wrapping_fields:
6
+ allow_gift_wrapping: Allow Gift Wrapping?
7
+ catalog_gift_wraps:
8
+ name: Gift Wrap
9
+ sku_note: SKU should correspond to pricing for this gift wrap.
10
+ index:
11
+ title: Gift Wrap
12
+ button: Add New Gift Wrap
13
+ new:
14
+ title: Add a Gift Wrap
15
+ button: Create Gift Wrap
16
+ edit:
17
+ title: Edit %{name} Gift Wrap
18
+ view_pricing: View Pricing
19
+ create_pricing: Create Pricing
20
+ button: Save Gift Wrap
21
+ flash_messages:
22
+ success: Gift wrap successfully saved.
23
+ error: There was a problem saving your gift wrap.
24
+ destroyed: Gift wrap has been deleted.
25
+ fields:
26
+ gift_message: Gift Message
27
+ orders:
28
+ attributes:
29
+ gift_wrap: Gift Wrap
30
+ shared:
31
+ primary_nav:
32
+ gift_wraps: Gift Wrap
33
+ storefront:
34
+ checkouts:
35
+ gift_message: Gift Message
36
+ gift_message_note: "%{length} Character Limit."
37
+ gift_wrapping: Gift Wrapping
38
+ gift_wrapping_unavailable: This item cannot be gift wrapped.
39
+ gift_wrapping_title: Gift wrapping for %{name}
40
+ item_gift_wrap: "Gift Wrap:"
41
+ gift_wrap:
42
+ price_adjustment: Gift Wrapping
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Workarea::Admin::Engine.routes.draw do
2
+ scope '(:locale)', constraints: Workarea::I18n.routes_constraint do
3
+ resources :catalog_gift_wraps, except: :show
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ module Workarea
2
+ module GiftWrapping
3
+ class Engine < ::Rails::Engine
4
+ include Workarea::Plugin
5
+ isolate_namespace Workarea::GiftWrapping
6
+
7
+ config.to_prepare do
8
+ Storefront::Checkout::ShippingViewModel.send(
9
+ :include,
10
+ Storefront::Checkout::GiftOptionsViewModel
11
+ )
12
+
13
+ if Plugin.installed?('split_shipping')
14
+ Storefront::Checkout::SplitShippingViewModel.send(
15
+ :include,
16
+ Storefront::Checkout::GiftOptionsViewModel
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module Workarea
2
+ module GiftWrapping
3
+ VERSION = '1.2.1'.freeze
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'workarea'
2
+ require 'workarea/storefront'
3
+ require 'workarea/admin'
4
+
5
+ require 'workarea/gift_wrapping/engine'
6
+ require 'workarea/gift_wrapping/version'
7
+
8
+ module Workarea
9
+ module GiftWrapping
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
File without changes
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+
7
+ <%= stylesheet_link_tag 'application', media: 'all' %>
8
+ <%= javascript_include_tag 'application' %>
9
+ </head>
10
+
11
+ <body>
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run