workarea-admin 3.5.9 → 3.5.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/workarea/admin/modules/release_calendar_placeholders.js +1 -21
  3. data/app/controllers/workarea/admin/bulk_action_sequential_product_edits_controller.rb +6 -4
  4. data/app/controllers/workarea/admin/catalog_products_controller.rb +6 -4
  5. data/app/controllers/workarea/admin/catalog_variants_controller.rb +3 -2
  6. data/app/controllers/workarea/admin/create_catalog_products_controller.rb +8 -2
  7. data/app/controllers/workarea/admin/releases_controller.rb +0 -10
  8. data/app/view_models/workarea/admin/code_list_view_model.rb +1 -1
  9. data/app/views/workarea/admin/catalog_products/content.html.haml +2 -0
  10. data/app/views/workarea/admin/catalog_products/edit.html.haml +4 -0
  11. data/app/views/workarea/admin/catalog_variants/edit.html.haml +2 -0
  12. data/app/views/workarea/admin/comments/index.html.haml +14 -13
  13. data/app/views/workarea/admin/create_segments/setup.html.haml +2 -0
  14. data/app/views/workarea/admin/facets/_applied.html.haml +1 -1
  15. data/app/views/workarea/admin/insights/_most_discounted_products.html.haml +4 -4
  16. data/app/views/workarea/admin/inventory_skus/edit.html.haml +2 -0
  17. data/app/views/workarea/admin/pricing_discount_code_lists/_cards.html.haml +1 -1
  18. data/app/views/workarea/admin/pricing_discount_code_lists/promo_codes.html.haml +1 -1
  19. data/app/views/workarea/admin/releases/show.html.haml +5 -1
  20. data/config/locales/en.yml +5 -4
  21. data/test/integration/workarea/admin/products_integration_test.rb +13 -0
  22. data/test/system/workarea/admin/comments_system_test.rb +2 -2
  23. data/test/view_models/workarea/admin/code_list_view_model_test.rb +5 -0
  24. metadata +6 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82da557f0cac42433c14244bf15d473a83c15a3c1523ca9234e469f351da6c8e
4
- data.tar.gz: 6ce1a8026a486d0963ca10751c5ffbfeefa803b112705afdd92cfa6cc2311108
3
+ metadata.gz: c201b646f5e3ae657185dd5f6085a1ee0840a91409b3c000e18de951b72ddcbc
4
+ data.tar.gz: 31905444ac47e6974b7e0da312c5eaca3e998aa72d5bba2048491bb121daf2de
5
5
  SHA512:
6
- metadata.gz: 900e003e4c2e4fbf4eb72a3c1d6b8ab43b519de48d6630fe07dbde60f89336414551d5852a6fed4afdec81b23f6f1ef1e2cf2336aafd0854b0509823a120c70e
7
- data.tar.gz: f69248afa53d26063e1dc98a538953427b777c1ae641db178720a4c75e82a5ea53909a4e31351a0280a6c9f11ed3c8af4cc94cb635993d710007833538c6bba2
6
+ metadata.gz: 4c75eb4586fe1a23e65098ddb89a11531ef98c75e8ded5721efc22195717cbf619f4b0d234c70ad5b5d779e808b2f2303fb14a4c9daa35dd3f11644ac5c67a42
7
+ data.tar.gz: d22da0aff0303e6302f2755d0e6c3c141da6d8498930ebd713ebf484e37fe0490548151da3fbbb65f814d903149145791c3a433156ef78149c677832092973cd
@@ -15,17 +15,6 @@ WORKAREA.registerModule('releaseCalendarPlaceholders', (function () {
15
15
  WORKAREA.initModules($calendar);
16
16
  },
17
17
 
18
- now = new Date(),
19
-
20
- standardTimezoneOffset = function() {
21
- var jan = new Date(now.getFullYear(), 0, 1).getTimezoneOffset(),
22
- jul = new Date(now.getFullYear(), 6, 1).getTimezoneOffset();
23
-
24
- return Math.max(jan, jul);
25
- },
26
-
27
- isDSTObserved = now.getTimezoneOffset() < standardTimezoneOffset(),
28
-
29
18
  /**
30
19
  * Makes the AJAX request for a new calendar based on a supplied time.
31
20
  * When the promise resolves the supplied placeholder element is
@@ -40,16 +29,7 @@ WORKAREA.registerModule('releaseCalendarPlaceholders', (function () {
40
29
  * @param {string} endpoint - the endpoint for the AJAX request
41
30
  */
42
31
  requestCalendar = function (startDate, placeholder, endpoint) {
43
- var timeOffset = parseInt(strftime('%z', new Date()));
44
-
45
- if (isDSTObserved) {
46
- timeOffset = timeOffset - 100;
47
- }
48
-
49
- $.get(endpoint, {
50
- start_date: startDate,
51
- time_offset: timeOffset
52
- })
32
+ $.get(endpoint, { start_date: startDate })
53
33
  .done(_.partial(displayCalendar, placeholder))
54
34
  .fail(
55
35
  _.partial(
@@ -64,19 +64,21 @@ module Workarea
64
64
  end
65
65
 
66
66
  def set_details
67
- HashUpdate.new(
67
+ @product.details = HashUpdate.new(
68
+ original: @product.details,
68
69
  adds: params[:new_details],
69
70
  updates: params[:details],
70
71
  removes: params[:details_to_remove]
71
- ).apply(@product.details)
72
+ ).result
72
73
  end
73
74
 
74
75
  def set_filters
75
- HashUpdate.new(
76
+ @product.filters = HashUpdate.new(
77
+ original: @product.filters,
76
78
  adds: params[:new_filters],
77
79
  updates: params[:filters],
78
80
  removes: params[:filters_to_remove]
79
- ).apply(@product.filters)
81
+ ).result
80
82
  end
81
83
 
82
84
  def set_images
@@ -64,19 +64,21 @@ module Workarea
64
64
  end
65
65
 
66
66
  def set_details
67
- HashUpdate.new(
67
+ @product.details = HashUpdate.new(
68
+ original: @product.details,
68
69
  adds: params[:new_details],
69
70
  updates: params[:details],
70
71
  removes: params[:details_to_remove]
71
- ).apply(@product.details)
72
+ ).result
72
73
  end
73
74
 
74
75
  def set_filters
75
- HashUpdate.new(
76
+ @product.filters = HashUpdate.new(
77
+ original: @product.filters,
76
78
  adds: params[:new_filters],
77
79
  updates: params[:filters],
78
80
  removes: params[:filters_to_remove]
79
- ).apply(@product.filters)
81
+ ).result
80
82
  end
81
83
  end
82
84
  end
@@ -83,11 +83,12 @@ module Workarea
83
83
  end
84
84
 
85
85
  def set_details
86
- HashUpdate.new(
86
+ @variant.details = HashUpdate.new(
87
+ original: @variant.details,
87
88
  adds: params[:new_details],
88
89
  updates: params[:details],
89
90
  removes: params[:details_to_remove]
90
- ).apply(@variant.details)
91
+ ).result
91
92
  end
92
93
  end
93
94
  end
@@ -74,8 +74,14 @@ module Workarea
74
74
  end
75
75
 
76
76
  def save_details
77
- HashUpdate.new(updates: params[:filters]).apply(@product.filters)
78
- HashUpdate.new(updates: params[:details]).apply(@product.details)
77
+ @product.filters = HashUpdate
78
+ .new(original: @product.filters, updates: params[:filters])
79
+ .result
80
+
81
+ @product.details = HashUpdate
82
+ .new(original: @product.details, updates: params[:details])
83
+ .result
84
+
79
85
  @product.save!
80
86
 
81
87
  flash[:success] = t('workarea.admin.create_catalog_products.flash_messages.saved')
@@ -9,7 +9,6 @@ module Workarea
9
9
  before_action :find_calendar, only: [:index, :update]
10
10
  before_action :authenticate_user_by_token, only: :calendar_feed
11
11
  skip_before_action :require_login, :require_admin, only: :calendar_feed
12
- around_action :set_time_zone, only: :index
13
12
 
14
13
  def index
15
14
  end
@@ -71,15 +70,6 @@ module Workarea
71
70
 
72
71
  private
73
72
 
74
- def set_time_zone
75
- old_time_zone = Time.zone
76
- time_offset = params[:time_offset].to_i / 100
77
- Time.zone = time_offset.hours unless params[:time_offset].blank?
78
- yield
79
- ensure
80
- Time.zone = old_time_zone
81
- end
82
-
83
73
  def find_release
84
74
  model = if params[:id].present?
85
75
  Release.find(params[:id])
@@ -10,7 +10,7 @@ module Workarea
10
10
  end
11
11
 
12
12
  def used_count
13
- model.count - unused_promo_codes.count
13
+ model.promo_codes.count - unused_promo_codes.count
14
14
  end
15
15
 
16
16
  def last_used_at
@@ -34,6 +34,8 @@
34
34
  = label_tag "product[meta_description]", t('workarea.admin.fields.meta_description'), class: 'property__name'
35
35
  = text_field_tag 'product[meta_description]', @product.meta_description, class: 'text-box text-box--i18n', id: "product_meta_description"
36
36
 
37
+ = append_partials('admin.product_content_fields', product: @product)
38
+
37
39
  .workflow-bar
38
40
  .grid.grid--auto.grid--right.grid--middle
39
41
  .grid__cell= render 'workarea/admin/shared/publishing_select'
@@ -110,6 +110,8 @@
110
110
  = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.details.learn_more'))
111
111
  %td.align-center -
112
112
 
113
+ = append_partials('admin.additional_product_details_information', product: @product)
114
+
113
115
  .section
114
116
 
115
117
  %h2= t('workarea.admin.catalog_products.edit.filters.label')
@@ -147,6 +149,8 @@
147
149
  = inline_svg('workarea/admin/icons/help.svg', class: 'svg-icon svg-icon--small svg-icon--blue', title: t('workarea.admin.catalog_products.edit.filters.learn_more'))
148
150
  %td.align-center -
149
151
 
152
+ = append_partials('admin.additional_product_filters_information', product: @product)
153
+
150
154
  .grid.grid--huge
151
155
  .grid__cell.grid__cell--50.grid__cell--25-at-medium
152
156
  .property
@@ -70,6 +70,8 @@
70
70
  = render 'workarea/admin/shared/csv_formatting_tooltip'
71
71
  %td.align-center -
72
72
 
73
+ = append_partials('admin.additional_variant_information_fields', variant: @variant)
74
+
73
75
  .workflow-bar
74
76
  .grid.grid--auto.grid--right.grid--middle
75
77
  .grid__cell= render 'workarea/admin/shared/publishing_select'
@@ -41,17 +41,6 @@
41
41
  .comments__comment-body
42
42
  %p= comment.body
43
43
 
44
- .section
45
- - if @commentable.subscribed_user_ids.include?(current_user.id.to_s)
46
- = form_tag unsubscribe_commentable_comments_path(@commentable.to_global_id), method: :put, id: 'comment_unsubscribe_form' do
47
- = button_tag t('workarea.admin.comments.index.unsubscribe'), value: 'comments_unsubscribe', class: 'button button--small'
48
- %span= t('workarea.admin.comments.index.subscribe_message')
49
- - else
50
- = form_tag subscribe_commentable_comments_path(@commentable.to_global_id), method: :put, id: 'comment_unsubscribe_form' do
51
- = button_tag t('workarea.admin.comments.index.subscribe'), value: 'comments_subscribe', class: 'button button--small'
52
- %span= t('workarea.admin.comments.index.unsubscribe_message')
53
-
54
-
55
44
  .section
56
45
  .comments__new-comment
57
46
  %h2= t('workarea.admin.comments.index.new')
@@ -66,5 +55,17 @@
66
55
  %span.property__note= t('workarea.admin.comments.index.mention_note')
67
56
 
68
57
  .workflow-bar
69
- .grid.grid--auto.grid--right.grid--middle
70
- .grid__cell= button_tag t('workarea.admin.comments.index.create'), value: 'create_comment', class: 'workflow-bar__button workflow-bar__button--create'
58
+ .grid.grid--middle
59
+ .grid__cell.grid__cell--80
60
+ - if @commentable.subscribed_user_ids.include?(current_user.id.to_s)
61
+ = link_to t('workarea.admin.comments.index.unsubscribe'), unsubscribe_commentable_comments_path(@commentable.to_global_id), data: { method: 'put', tooltip: { content_id: '#unsubscribe-info' } }, class: 'workflow-bar__button'
62
+ #unsubscribe-info.tooltip-content
63
+ %p= t('workarea.admin.comments.index.unsubscribe_message')
64
+
65
+ - else
66
+ = link_to t('workarea.admin.comments.index.subscribe'), subscribe_commentable_comments_path(@commentable.to_global_id), data: { method: 'put', tooltip: { content_id: '#subscribe-info' } }, class: 'workflow-bar__button'
67
+ #subscribe-info.tooltip-content
68
+ %p= t('workarea.admin.comments.index.subscribe_message')
69
+
70
+ .grid__cell.grid__cell--20
71
+ .align-right= button_tag t('workarea.admin.comments.index.create'), value: 'create_comment', class: 'workflow-bar__button workflow-bar__button--create'
@@ -10,6 +10,8 @@
10
10
  = render_message 'error', message
11
11
 
12
12
  = form_tag create_segments_path, method: 'post' do
13
+ = hidden_field_tag :id, @segment.id unless @segment.new_record?
14
+
13
15
  .section
14
16
  .property.property--required
15
17
  = label_tag 'segment_name', t('workarea.admin.fields.name'), class: 'property__name'
@@ -10,7 +10,7 @@
10
10
  - @search.facet_selections.each do |facet, values|
11
11
  - values.each do |value|
12
12
  %li.browsing-controls__applied-filter
13
- %span= value.titleize
13
+ %span= facet_value_display_name(facet, value)
14
14
  = link_to facet_path(facet, value), class: 'browsing-controls__applied-remove-link' do
15
15
  = inline_svg('workarea/admin/icons/close.svg', class: 'browsing-controls__applied-icon svg-icon svg-icon--small svg-icon--black', title: t('workarea.admin.facets.applied.remove_filter'))
16
16
 
@@ -18,15 +18,15 @@
18
18
  = result.product_id
19
19
  - else
20
20
  = link_to result.product.name, catalog_product_path(result.product)
21
- .insight__product-info
21
+ .insight__product-info.align-center
22
22
  %strong= insights_number_to_percentage(result.average_discount)
23
23
  = t('workarea.admin.insights.most_discounted_products.average_discount')
24
- .insight__product-info
24
+ .insight__product-info.align-center
25
25
  %strong= insights_number_to_percentage(result.discount_rate)
26
26
  = t('workarea.admin.insights.most_discounted_products.discount_rate')
27
- .insight__product-info
27
+ .insight__product-info.align-center
28
28
  %strong= number_with_delimiter(result.units_sold)
29
29
  = t('workarea.admin.insights.most_discounted_products.units_sold')
30
- .insight__product-info
30
+ .insight__product-info.align-center
31
31
  %strong= insights_number_to_percentage(result.conversion_rate)
32
32
  = t('workarea.admin.insights.most_discounted_products.conversion_rate')
@@ -56,6 +56,8 @@
56
56
  = label_tag 'sku[backordered_until]', t('workarea.admin.inventory_skus.edit.backordered_ship_date'), class: 'property__name'
57
57
  = datetime_picker_tag 'sku[backordered_until]', @sku.backordered_until.try(:to_s, :date_only), class: 'text-box text-box--medium', data: { datepicker_field: { } }
58
58
 
59
+ = append_partials('admin.inventory_sku_fields', sku: @sku)
60
+
59
61
  .grid.grid--huge
60
62
  .grid__cell.grid__cell--50.grid__cell--25-at-medium
61
63
  .property
@@ -45,7 +45,7 @@
45
45
  .grid
46
46
  .grid__cell.grid__cell--50
47
47
  .align-center
48
- %h2.heading.heading--no-margin= model.count
48
+ %h2.heading.heading--no-margin= model.promo_codes.count
49
49
  %p #{t('workarea.admin.pricing_discount_code_lists.cards.promo_codes.total')}
50
50
  .grid__cell.grid__cell--50
51
51
  .align-center
@@ -17,7 +17,7 @@
17
17
 
18
18
  .view__container.view__container--narrow
19
19
  = render_cards_for(@code_list, :promo_codes)
20
- %p.align-center= t('workarea.admin.pricing_discount_code_lists.promo_code', count: @code_list.count)
20
+ %p.align-center= t('workarea.admin.pricing_discount_code_lists.promo_code', count: @code_list.promo_codes.count)
21
21
 
22
22
  %table
23
23
  %thead
@@ -32,7 +32,11 @@
32
32
 
33
33
  - else
34
34
  .grid__cell
35
- - if current_release.try(:id) == @release.id
35
+ - if @release.published? && !@release.scheduled?
36
+ = link_to t('workarea.admin.releases.show.visit_storefront_to_preview'), '#cannot-preview-info', disabled: 'disabled', data: { tooltip: '' }, class: 'workflow-bar__button workflow-bar__button--update'
37
+ #cannot-preview-info.tooltip-content
38
+ %p= t('workarea.admin.releases.show.unscheduled_republish_preview_info')
39
+ - elsif current_release.try(:id) == @release.id
36
40
  = link_to t('workarea.admin.releases.show.visit_storefront_to_preview'), storefront.root_path, class: 'workflow-bar__button workflow-bar__button--update'
37
41
  - else
38
42
  = form_tag release_session_path, method: :post do
@@ -631,8 +631,8 @@ en:
631
631
  removed: Your comment has been removed
632
632
  saved: Your comment has been saved
633
633
  saved_error: There was a problem saving your comment
634
- comment_subscribed: Your comments subscription has been added. You will be notified of any future comments.
635
- comment_unsubscribed: You have been unsubscribed from future comments.
634
+ comment_subscribed: You have been subscribed to comment notifications.
635
+ comment_unsubscribed: You have been unsubscribed from comment notifications.
636
636
  index:
637
637
  body: Comment Body
638
638
  create: Create Comment
@@ -642,10 +642,10 @@ en:
642
642
  new: New Comment
643
643
  notify: Notify Admins
644
644
  subscribe: Subscribe
645
- subscribe_message: to receive emails about future comments.
645
+ subscribe_message: You'll be emailed when a new comment is posted on this.
646
646
  title: Comments on %{name}
647
647
  unsubscribe: Unsubscribe
648
- unsubscribe_message: to stop receiving emails about future comments.
648
+ unsubscribe_message: Click this to stop receiving email about future comments.
649
649
  icon:
650
650
  viewed: Comments
651
651
  unviewed: Unread Comments
@@ -3189,6 +3189,7 @@ en:
3189
3189
  start_preview_in_storefront: Start preview in storefront
3190
3190
  undo: Undo
3191
3191
  visit_storefront_to_preview: Preview
3192
+ unscheduled_republish_preview_info: This release is already published, you'll need to schedule it again to preview its changes.
3192
3193
  no_changes_to_preview: There are no changes to preview. Click on the Plan Changes card to start!
3193
3194
  no_changes_to_publish: There are no changes to publish for this release. Click on the Plan Changes card to start!
3194
3195
  no_changes_to_undo: There are no changes to undo for this release. Click on the Plan Changes card to start!
@@ -16,6 +16,19 @@ module Workarea
16
16
  assert(product.active)
17
17
  end
18
18
 
19
+ def test_updating_hash_fields_in_locales
20
+ set_locales(available: [:en, :es], default: :en, current: :en)
21
+ product = create_product(filters_translations: { 'en' => { 'Size' => ['Large'] } })
22
+
23
+ patch admin.catalog_product_path(product, locale: 'es'),
24
+ params: { new_filters: %w(Color Roja) }
25
+
26
+ assert_equal(
27
+ { 'en' => { 'Size' => ['Large'] }, 'es' => { 'Color' => ['Roja'] } },
28
+ product.reload.filters_translations
29
+ )
30
+ end
31
+
19
32
  def test_returns_a_list_of_filters
20
33
  create_product(filters: { 'Color' => 'Blue' })
21
34
 
@@ -53,10 +53,10 @@ module Workarea
53
53
  visit admin.user_path(user)
54
54
 
55
55
  click_link 'Comments'
56
- click_button t('workarea.admin.comments.index.subscribe')
56
+ click_link t('workarea.admin.comments.index.subscribe')
57
57
  assert(page.has_content?('Success'))
58
58
 
59
- click_button t('workarea.admin.comments.index.unsubscribe')
59
+ click_link t('workarea.admin.comments.index.unsubscribe')
60
60
  assert(page.has_content?('Success'))
61
61
  end
62
62
  end
@@ -21,6 +21,11 @@ module Workarea
21
21
 
22
22
  view_model = CodeListViewModel.wrap(code_list)
23
23
  assert_equal(1, view_model.used_count)
24
+
25
+ code_list.promo_codes.create!(code: "#{code_list.prefix}123")
26
+
27
+ view_model = CodeListViewModel.wrap(code_list)
28
+ assert_equal(1, view_model.used_count)
24
29
  end
25
30
 
26
31
  def test_last_used_at
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workarea-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.9
4
+ version: 3.5.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2020-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: workarea-core
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.5.9
19
+ version: 3.5.14
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.5.9
26
+ version: 3.5.14
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: workarea-storefront
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 3.5.9
33
+ version: 3.5.14
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 3.5.9
40
+ version: 3.5.14
41
41
  description: Provides site administration functionality for the Workarea Commerce
42
42
  Platform.
43
43
  email: