workarea-admin 3.5.0 → 3.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5341f457a231d57f8903f5300d3ba014713adb1ae1b18a0497fed5215812e272
4
- data.tar.gz: 6bd7f5868b117fd2b837e8020cfda2422fb38e0e21fc3a2f3992d1d9e77cd774
3
+ metadata.gz: eb536eb2ddc3f8671312c61b42ab98cd2b22b2bdf430976a7ea6985e87925043
4
+ data.tar.gz: babe1c17567016f9cc95f3a95cb4b7285d6abb8a8360b9a4f60d3ae8c4720245
5
5
  SHA512:
6
- metadata.gz: f9aaf000aced6215c42222f10b4b925e1037b18b5782538be8244589194b23f6bc3f4e2ecb6b417459d98427392caa64aff7a4c8a1a1aed029ff7aec45aa544f
7
- data.tar.gz: 59934acecd3201289f6346ac94fae1381968137672e41f1dce637a94b958152e9d2104e7f86f39376adcb1df9cea6d25021b26e864f7efb958d47e666d89b1a8
6
+ metadata.gz: 4d5b3e614913fae1bb119973806d4c720f8c1dcdaf79334be6b5b40ed75475bd273562b4279d0ccbbe8c8f5a2d90428eafea2d47517fd471e460c03da18faf4e
7
+ data.tar.gz: fb4002effffbad7bdf6d57164306bc872b27e278e103c2febd887b87ee5490c7a61872b4cd6ff4cf27a16c8b7ac0353c4edf6aa1e6a5d4e7f434857f7c0be82f
@@ -80,8 +80,29 @@ module Workarea
80
80
  #
81
81
  # @return [Boolean]
82
82
  #
83
- def new_block?
84
- options[:new_block].present?
83
+ def new_block?(at: nil)
84
+ return false unless options[:new_block].present?
85
+ at.blank? || new_block.position == at
86
+ end
87
+
88
+ # HACK
89
+ #
90
+ # This method returns whether we can reliably determine the position of
91
+ # the new block being added. This can be very difficult to generate due to
92
+ # possible resorting of blocks within a release combined with release
93
+ # previewing based on publishing time.
94
+ #
95
+ # The only time this has caused an issue in use is adding a new first
96
+ # block, so this is used in combination with the above `new_block?` to
97
+ # decide whether to render the first block.
98
+ #
99
+ # @return [Boolean]
100
+ #
101
+ def ambiguous_new_block_position?
102
+ return false unless options[:new_block].present?
103
+
104
+ known_positions = [0] + current_blocks.map { |b| b.position + 1 }
105
+ known_positions.exclude?(new_block.position)
85
106
  end
86
107
 
87
108
  # An instance of the new block being created.
@@ -37,17 +37,17 @@ module Workarea
37
37
  {
38
38
  '$match' => {
39
39
  'created_at' => {
40
- '$gte' => starts_at.beginning_of_day,
41
- '$lte' => ends_at.end_of_day
40
+ '$gte' => starts_at.beginning_of_day.utc,
41
+ '$lte' => ends_at.end_of_day.utc
42
42
  }
43
43
  }
44
44
  },
45
45
  {
46
46
  '$group' => {
47
47
  '_id' => {
48
- 'day' => { '$dayOfMonth' => '$created_at' },
49
- 'month' => { '$month' => '$created_at' },
50
- 'year' => { '$year' => '$created_at' }
48
+ 'day' => { '$dayOfMonth' => created_at_in_time_zone },
49
+ 'month' => { '$month' => created_at_in_time_zone },
50
+ 'year' => { '$year' => created_at_in_time_zone }
51
51
  },
52
52
  'created_at' => { '$first' => '$created_at' },
53
53
  'count' => { '$sum' => 1 }
@@ -61,6 +61,10 @@ module Workarea
61
61
  end
62
62
  end
63
63
 
64
+ def created_at_in_time_zone
65
+ { 'date' => '$created_at', 'timezone' => Time.zone.tzinfo.name }
66
+ end
67
+
64
68
  def insights
65
69
  @insights ||= InsightViewModel.wrap(
66
70
  Workarea::Insights::Base.by_dashboard('marketing').page(options[:page])
@@ -30,7 +30,7 @@
30
30
 
31
31
  - else
32
32
  .content-editor__area
33
- - if content.new_block? && content.new_block.position == 0
33
+ - if content.new_block?(at: 0) || content.ambiguous_new_block_position?
34
34
  .content-block{ id: dom_id(content.new_block), data: { content_block: storefront.draft_content_block_path(content.new_block_draft) }, class: ('content-block--active' if content.new_block?), style: "order: #{content.new_block.position}" }
35
35
  .content-block__iframe-placeholder
36
36
  = form_tag content_area_blocks_path(content, content.current_area), method: :post, class: 'content-editor__form', data: { content_editor_form: { previewId: "##{dom_id(content.new_block)}", params: { 'block[content_id]': content.id, 'block[type_id]': content.new_block.type_id, 'block[area]': content.current_area } }.to_json, unsaved_changes: '' } do
@@ -54,7 +54,7 @@
54
54
  = form_tag content_area_block_path(content, content.current_area, block), method: :patch, class: 'content-editor__form', data: { content_editor_form: { previewId: "##{dom_id(block)}", params: { 'block[content_id]': content.id, 'block[type_id]': block.type_id, 'block[area]': content.current_area } }.to_json, unsaved_changes: '' } do
55
55
  = render 'workarea/admin/content/form', content: content, block: block
56
56
 
57
- - if content.new_block? && content.new_block.position == block.position + 1
57
+ - if content.new_block?(at: block.position + 1)
58
58
  .content-block{ id: dom_id(content.new_block), data: { content_block: storefront.draft_content_block_path(content.new_block_draft) }, class: ('content-block--active' if content.new_block?), style: "order: #{content.new_block.position}" }
59
59
  .content-block__iframe-placeholder
60
60
  = form_tag content_area_blocks_path(content, content.current_area), method: :post, class: 'content-editor__form', data: { content_editor_form: { previewId: "##{dom_id(content.new_block)}", params: { 'block[content_id]': content.id, 'block[type_id]': content.new_block.type_id, 'block[area]': content.current_area } }.to_json, unsaved_changes: '' } do
@@ -28,7 +28,7 @@
28
28
  .grid__cell.grid__cell--50-at-medium
29
29
  .property
30
30
  = label_tag 'release_publish_at', t('workarea.admin.fields.publish_at'), class: 'property__name'
31
- .box.box--rounded= hidden_field_tag 'release[publish_at]', @release.publish_at, data: { datetimepicker_field: { inline: true } }
31
+ .box.box--rounded= hidden_field_tag 'release[publish_at]', @release.publish_at, data: { datetimepicker_field: { inline: true, uiOptions: { minDate: 0 } } }
32
32
 
33
33
  .workflow-bar
34
34
  .grid.grid--middle
@@ -28,4 +28,4 @@
28
28
  - if current_user.can_publish_now?
29
29
  .property
30
30
  = label_tag 'release[publish_at]', t('workarea.admin.releases.publish.when_does_it_publish'), class: 'property__name'
31
- = hidden_field_tag 'release[publish_at]', nil, placeholder: t('workarea.admin.releases.publish.when_does_it_publish'), data: { datetimepicker_field: { inline: true } }
31
+ = hidden_field_tag 'release[publish_at]', nil, placeholder: t('workarea.admin.releases.publish.when_does_it_publish'), data: { datetimepicker_field: { inline: true, uiOptions: { minDate: 0 } }.to_json }
@@ -37,7 +37,7 @@
37
37
  = label_tag 'release_publish_at', t('workarea.admin.fields.publish_at'), class: 'property__name'
38
38
 
39
39
  - if current_user.can_publish_now?
40
- .box.box--rounded.box--padded= hidden_field_tag 'release[publish_at]', @release.publish_at, data: { datetimepicker_field: { inline: true } }
40
+ .box.box--rounded.box--padded= hidden_field_tag 'release[publish_at]', @release.publish_at, data: { datetimepicker_field: { inline: true, uiOptions: { minDate: 0 } } }
41
41
  - elsif @release.publish_at.present?
42
42
  = local_time(@release.publish_at)
43
43
  - else
File without changes
@@ -63,52 +63,6 @@ module Workarea
63
63
  assert(page.has_selector?('.ui-sortable'))
64
64
  end
65
65
 
66
- def test_active_by_segment
67
- create_life_cycle_segments
68
- create_content(name: 'home_page')
69
-
70
- visit admin.content_index_path
71
- click_link 'Home Page'
72
- within '.card--content' do
73
- click_link 'Content'
74
- end
75
-
76
- click_link 'add_new_block'
77
- click_link 'HTML'
78
-
79
- fill_in 'block[data][html]', with: '<h1>Some Content!</h1>'
80
- click_button 'create_block'
81
- assert(page.has_content?('Success'))
82
-
83
- find('.content-block-list__name', text: 'HTML').click
84
- find('.tabs__menu-link', text: t('workarea.admin.content.form.display')).click
85
-
86
- within '.tabs__panel' do
87
- find('.select2-selection--multiple').click
88
- end
89
-
90
- find('.select2-results__option:first-of-type').click
91
-
92
- find('body').click # close the select2 UI
93
-
94
- click_button t('workarea.admin.form.save_changes')
95
- assert(page.has_content?('Success'))
96
-
97
- find('.content-block-list__name', text: 'HTML').click
98
- click_link t('workarea.admin.content.form.display')
99
-
100
- assert_selector('.select2-selection__choice')
101
- find('.select2-selection__choice__remove').click
102
-
103
- click_button t('workarea.admin.form.save_changes')
104
- assert(page.has_content?('Success'))
105
-
106
- find('.content-block-list__name', text: 'HTML').click
107
- click_link t('workarea.admin.content.form.display')
108
-
109
- refute_selector('.select2-selection__choice')
110
- end
111
-
112
66
  def test_managing_content_blocks_for_a_release
113
67
  home = create_content(name: 'home_page', blocks: [])
114
68
  release = create_release(name: 'Foo')
@@ -106,6 +106,31 @@ module Workarea
106
106
 
107
107
  refute(og_asset.open_graph_placeholder?)
108
108
  end
109
+
110
+ def test_ambiguous_new_block_position
111
+ content = create_content
112
+ refute(ContentViewModel.wrap(content).ambiguous_new_block_position?)
113
+
114
+ new_block_params = { type_id: 'text', position: 0 }
115
+ view_model = ContentViewModel.wrap(content, new_block: new_block_params)
116
+ refute(view_model.ambiguous_new_block_position?)
117
+
118
+ view_model = ContentViewModel.wrap(content, new_block: new_block_params.merge(position: 1))
119
+ assert(view_model.ambiguous_new_block_position?)
120
+
121
+ release = create_release
122
+ content.blocks.create!(type_id: 'text', position: 0, activate_with: release.id)
123
+ content.blocks.create!(type_id: 'text', position: 1)
124
+
125
+ view_model = ContentViewModel.wrap(content, new_block: new_block_params)
126
+ refute(view_model.ambiguous_new_block_position?)
127
+
128
+ view_model = ContentViewModel.wrap(content, new_block: new_block_params.merge(position: 1))
129
+ assert(view_model.ambiguous_new_block_position?)
130
+
131
+ view_model = ContentViewModel.wrap(content, new_block: new_block_params.merge(position: 2))
132
+ refute(view_model.ambiguous_new_block_position?)
133
+ end
109
134
  end
110
135
  end
111
136
  end
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.0
4
+ version: 3.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Crouse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-26 00:00:00.000000000 Z
11
+ date: 2019-12-18 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.0
19
+ version: 3.5.1
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.0
26
+ version: 3.5.1
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.0
33
+ version: 3.5.1
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.0
40
+ version: 3.5.1
41
41
  description: Provides site administration functionality for the Workarea Commerce
42
42
  Platform.
43
43
  email:
@@ -1284,6 +1284,7 @@ files:
1284
1284
  - test/dummy/public/500.html
1285
1285
  - test/dummy/public/favicon.ico
1286
1286
  - test/dummy/script/rails
1287
+ - test/dummy/tmp/screenshots/.keep
1287
1288
  - test/helpers/workarea/admin/application_helper_test.rb
1288
1289
  - test/helpers/workarea/admin/facets_helper_test.rb
1289
1290
  - test/helpers/workarea/admin/icons_helper_test.rb