maglevcms 3.0.2 → 3.0.3
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/assets/javascripts/maglev/editor/controllers/app/forms/section_form_controller.js +31 -6
- data/app/assets/javascripts/maglev/editor/controllers/app/page_preview_controller.js +20 -6
- data/app/controllers/concerns/maglev/editor/errors_concern.rb +1 -1
- data/app/controllers/concerns/maglev/editor/lock_version_concern.rb +27 -0
- data/app/controllers/maglev/editor/section_blocks_controller.rb +3 -9
- data/app/controllers/maglev/editor/sections_controller.rb +3 -9
- data/app/services/concerns/maglev/content/helpers_concern.rb +1 -1
- data/lib/maglev/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 91a5ea2feecec6351e3e7042be72418ce8e95374e50108d6a798b2f179d47ee4
|
|
4
|
+
data.tar.gz: c674bf2fb233c7aec70823875c804e7f7741df83f809a09cc670ac13eedb9d74
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f3301ae182676801e8fc2baecbc6774f1c3e10e072fa509a2272185ff6b62aa64c7cdd68a92426679b6545c14a40f376e0be3f038df1cb18d78cd6e55747da1
|
|
7
|
+
data.tar.gz: a1dce55e8a53f13e394b82f548a6726a06b2a3babe65e6e645d1ee5c00040022d10243f75c9eede599fe957e4b2bb0aafe5fd8a9becc32dfa8b35a3f4767a873
|
|
@@ -9,8 +9,10 @@ export default class extends Controller {
|
|
|
9
9
|
static debounces = ['afterSettingUpdate']
|
|
10
10
|
|
|
11
11
|
connect() {
|
|
12
|
-
useDebounce(this)
|
|
12
|
+
useDebounce(this)
|
|
13
|
+
|
|
13
14
|
this.sourceId = this.sectionBlockIdValue !== '' ? this.sectionBlockIdValue : this.sectionIdValue
|
|
15
|
+
|
|
14
16
|
requestAnimationFrame(() => {
|
|
15
17
|
this.dispatch('connected', { bubbles: true, detail: {
|
|
16
18
|
sectionId: this.sectionIdValue,
|
|
@@ -18,6 +20,12 @@ export default class extends Controller {
|
|
|
18
20
|
lockVersion: this.sectionLockVersionValue }
|
|
19
21
|
})
|
|
20
22
|
})
|
|
23
|
+
|
|
24
|
+
// we need to keep track of the submitting state to avoid multiple requests being sent with a wrong lock version
|
|
25
|
+
this.submitting = false
|
|
26
|
+
this.element.addEventListener('turbo:submit-end', (event) => {
|
|
27
|
+
if (!event.detail.success) this.submitting = false
|
|
28
|
+
})
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
onSettingChange(event) {
|
|
@@ -33,15 +41,32 @@ export default class extends Controller {
|
|
|
33
41
|
onPersist(event) {
|
|
34
42
|
log('[SectionForm::onPersist]', event.detail, typeof event.detail)
|
|
35
43
|
this.lockVersionTarget.value = event.detail.lockVersion
|
|
44
|
+
|
|
45
|
+
// we are done submitting, so we can reset the submitting flag
|
|
46
|
+
this.submitting = false
|
|
36
47
|
}
|
|
37
48
|
|
|
38
|
-
|
|
49
|
+
afterSettingUpdate(event) {
|
|
50
|
+
// if the request is still running (flight), we need to debounce the call
|
|
51
|
+
// to avoid multiple requests being sent with a wrong lock version
|
|
52
|
+
if (this.submitting) {
|
|
53
|
+
this.afterSettingUpdate(event)
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
log('[SectionForm::afterSettingUpdate] 🙌🙌', event.detail)
|
|
40
|
-
|
|
41
|
-
|
|
58
|
+
|
|
59
|
+
// we couldn't update the content just by modifying the DOM, so we have to refresh the whole section.
|
|
60
|
+
// The right time to do this is when the request is finished, so we listen for the turbo:submit-end event.
|
|
42
61
|
if (!event.detail.updated) {
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
this.element.addEventListener('turbo:submit-end', () => {
|
|
63
|
+
this.dispatch('updateSection', { detail: { sectionId: this.sectionIdValue } })
|
|
64
|
+
}, { once: true })
|
|
45
65
|
}
|
|
66
|
+
|
|
67
|
+
// better to set it to true instead of relying on the turbo:submit-start event
|
|
68
|
+
this.submitting = true
|
|
69
|
+
|
|
70
|
+
this.element.requestSubmit()
|
|
46
71
|
}
|
|
47
72
|
}
|
|
@@ -164,13 +164,14 @@ export default class extends Controller {
|
|
|
164
164
|
|
|
165
165
|
setupTransformations() {
|
|
166
166
|
this.calculateTransformations = this.calculateTransformations.bind(this)
|
|
167
|
-
this.
|
|
168
|
-
|
|
167
|
+
this.scheduleTransformations = this.scheduleTransformations.bind(this)
|
|
168
|
+
this.resizeObserver = new ResizeObserver(this.scheduleTransformations)
|
|
169
|
+
|
|
169
170
|
const sidebar = this.appLayoutSidebar
|
|
170
171
|
const pageLayout = document.querySelector('#page-layout')
|
|
171
|
-
if (sidebar) this.
|
|
172
|
-
if (pageLayout) this.
|
|
173
|
-
this.
|
|
172
|
+
if (sidebar) this.resizeObserver.observe(this.appLayoutSidebar())
|
|
173
|
+
if (pageLayout) this.resizeObserver.observe(pageLayout)
|
|
174
|
+
this.resizeObserver.observe(document.documentElement)
|
|
174
175
|
|
|
175
176
|
// Recompute on page layout toggles / VT renders
|
|
176
177
|
addEventListener("turbo:render", this.calculateTransformations)
|
|
@@ -180,7 +181,11 @@ export default class extends Controller {
|
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
teardownTransformations() {
|
|
183
|
-
this.
|
|
184
|
+
if (this.transformationsFrame) {
|
|
185
|
+
cancelAnimationFrame(this.transformationsFrame)
|
|
186
|
+
this.transformationsFrame = null
|
|
187
|
+
}
|
|
188
|
+
this.resizeObserver?.disconnect()
|
|
184
189
|
removeEventListener("turbo:render", this.calculateTransformations)
|
|
185
190
|
removeEventListener("turbo:before-render", this.calculateTransformations)
|
|
186
191
|
}
|
|
@@ -230,6 +235,15 @@ export default class extends Controller {
|
|
|
230
235
|
this.dispatch('scale-ratio-updated', { detail: { value: scaleRatio } })
|
|
231
236
|
}
|
|
232
237
|
|
|
238
|
+
scheduleTransformations() {
|
|
239
|
+
if (this.transformationsFrame) return
|
|
240
|
+
|
|
241
|
+
this.transformationsFrame = requestAnimationFrame(() => {
|
|
242
|
+
this.transformationsFrame = null
|
|
243
|
+
this.calculateTransformations()
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
|
|
233
247
|
calculateTransformX() {
|
|
234
248
|
if (!this.hasExpandedPageLayout()) return 0
|
|
235
249
|
return this.expandedPageLayout().offsetWidth - this.appLayoutSidebarWidth()
|
|
@@ -26,7 +26,7 @@ module Maglev
|
|
|
26
26
|
|
|
27
27
|
def handle_stale_object
|
|
28
28
|
respond_to do |format|
|
|
29
|
-
format.turbo_stream { render 'maglev/editor/shared/errors/stale_object_error' }
|
|
29
|
+
format.turbo_stream { render 'maglev/editor/shared/errors/stale_object_error', status: :conflict }
|
|
30
30
|
format.html { redirect_to editor_root_path }
|
|
31
31
|
end
|
|
32
32
|
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Maglev
|
|
4
|
+
module Editor
|
|
5
|
+
module LockVersionConcern
|
|
6
|
+
extend ActiveSupport::Concern
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
helper_method :source_lock_version
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def lock_source
|
|
15
|
+
@section.site_scoped? ? maglev_site : current_maglev_page
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def source_lock_version
|
|
19
|
+
lock_source.lock_version || 0
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def reload_lock_source
|
|
23
|
+
lock_source.reload if @section.site_scoped?
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
module Maglev
|
|
4
4
|
module Editor
|
|
5
5
|
class SectionBlocksController < Maglev::Editor::BaseController
|
|
6
|
+
include Maglev::Editor::LockVersionConcern
|
|
7
|
+
|
|
6
8
|
helper Maglev::Editor::SettingsHelper
|
|
7
|
-
helper_method :source_lock_version
|
|
8
9
|
|
|
9
10
|
before_action :set_section
|
|
10
11
|
before_action :set_section_block, only: %i[edit update destroy]
|
|
@@ -32,6 +33,7 @@ module Maglev
|
|
|
32
33
|
|
|
33
34
|
def update
|
|
34
35
|
update_section_block
|
|
36
|
+
reload_lock_source
|
|
35
37
|
flash.now[:notice] = flash_t(:success)
|
|
36
38
|
end
|
|
37
39
|
|
|
@@ -77,14 +79,6 @@ module Maglev
|
|
|
77
79
|
)
|
|
78
80
|
end
|
|
79
81
|
|
|
80
|
-
def lock_source
|
|
81
|
-
@section.site_scoped? ? maglev_site : current_maglev_page
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def source_lock_version
|
|
85
|
-
lock_source.lock_version || 0
|
|
86
|
-
end
|
|
87
|
-
|
|
88
82
|
def redirect_to_section_blocks_path(success: true)
|
|
89
83
|
flash = case success
|
|
90
84
|
when true then { notice: flash_t(:success) }
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
module Maglev
|
|
4
4
|
module Editor
|
|
5
5
|
class SectionsController < Maglev::Editor::BaseController
|
|
6
|
+
include Maglev::Editor::LockVersionConcern
|
|
7
|
+
|
|
6
8
|
helper Maglev::Editor::SettingsHelper
|
|
7
|
-
helper_method :source_lock_version
|
|
8
9
|
|
|
9
10
|
before_action :ensure_turbo_frame_request, only: [:new]
|
|
10
11
|
before_action :set_section, only: %i[edit update]
|
|
@@ -39,6 +40,7 @@ module Maglev
|
|
|
39
40
|
|
|
40
41
|
def update
|
|
41
42
|
update_section
|
|
43
|
+
reload_lock_source
|
|
42
44
|
flash.now[:notice] = flash_t(:success)
|
|
43
45
|
end
|
|
44
46
|
|
|
@@ -95,14 +97,6 @@ module Maglev
|
|
|
95
97
|
headers['X-Section-Position'] = flash[:position]
|
|
96
98
|
end
|
|
97
99
|
|
|
98
|
-
def lock_source
|
|
99
|
-
@section.site_scoped? ? maglev_site : current_maglev_page
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def source_lock_version
|
|
103
|
-
lock_source.lock_version || 0
|
|
104
|
-
end
|
|
105
|
-
|
|
106
100
|
def redirect_to_sections_path
|
|
107
101
|
redirect_to editor_sections_path_with_context, notice: flash_t(:success), status: :see_other
|
|
108
102
|
end
|
|
@@ -58,7 +58,7 @@ module Maglev
|
|
|
58
58
|
|
|
59
59
|
def update_setting_value(setting, current_content)
|
|
60
60
|
setting_content = current_content.find { |s| s['id'] == setting.id }
|
|
61
|
-
value = content[setting.id.to_sym]
|
|
61
|
+
value = setting.cast_value(content[setting.id.to_sym])
|
|
62
62
|
|
|
63
63
|
if setting_content.nil?
|
|
64
64
|
current_content.push({ id: setting.id, value: value })
|
data/lib/maglev/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: maglevcms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0.
|
|
4
|
+
version: 3.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Didier Lafforgue
|
|
@@ -359,6 +359,7 @@ files:
|
|
|
359
359
|
- app/controllers/concerns/maglev/back_action_concern.rb
|
|
360
360
|
- app/controllers/concerns/maglev/content_locale_concern.rb
|
|
361
361
|
- app/controllers/concerns/maglev/editor/errors_concern.rb
|
|
362
|
+
- app/controllers/concerns/maglev/editor/lock_version_concern.rb
|
|
362
363
|
- app/controllers/concerns/maglev/editor/preview_urls_concern.rb
|
|
363
364
|
- app/controllers/concerns/maglev/editor/turbo_concern.rb
|
|
364
365
|
- app/controllers/concerns/maglev/errors_concern.rb
|