lato_cms 3.2.5 → 3.2.6
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cdc7dae92de55a7a6e1e1290ee957bbf0b63fdf16404524c3f1803bd68123d0e
|
|
4
|
+
data.tar.gz: 1bc853f4846e25c41db7bddc0d53ac55f05699a06cf97a221abf6b7573458a7e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0117c7af5986170ce154bee821263a5ac8da6759d71a8fd682624e59b84d31a4f368d15d8c12d05549cd38d08baee38aa5a09550cad85a2bfaf9e30071baa50a
|
|
7
|
+
data.tar.gz: f18ef5c8dcaf4c2a3e2cd66e031bd2853eca12e69fc9aab6afcbe93989a90de362948317a526a45c08fe0ba38a647220505f95282e7e2b1910bc32c864386ca0
|
|
@@ -6,8 +6,16 @@ export default class extends Controller {
|
|
|
6
6
|
connect () {
|
|
7
7
|
this.handleComponentChange = this.handleComponentChange.bind(this)
|
|
8
8
|
this.handleIframeLoad = this.handleIframeLoad.bind(this)
|
|
9
|
+
this.handleMorph = this.handleMorph.bind(this)
|
|
9
10
|
|
|
10
11
|
document.addEventListener('lato-cms:component-change', this.handleComponentChange)
|
|
12
|
+
// Actions that re-render the editor server-side (cloning a component from
|
|
13
|
+
// another locale, editing the page settings) redirect back to this same
|
|
14
|
+
// URL, which Turbo treats as a page refresh and applies by morphing. Morph
|
|
15
|
+
// leaves an unchanged <iframe> exactly as it is — the element is never
|
|
16
|
+
// recreated, so the preview kept showing pre-clone content until a manual
|
|
17
|
+
// reload. The refresh is asked for explicitly here.
|
|
18
|
+
document.addEventListener('turbo:morph', this.handleMorph)
|
|
11
19
|
|
|
12
20
|
if (this.hasIframeTarget) {
|
|
13
21
|
this.iframeTarget.addEventListener('load', this.handleIframeLoad)
|
|
@@ -26,6 +34,7 @@ export default class extends Controller {
|
|
|
26
34
|
|
|
27
35
|
disconnect () {
|
|
28
36
|
document.removeEventListener('lato-cms:component-change', this.handleComponentChange)
|
|
37
|
+
document.removeEventListener('turbo:morph', this.handleMorph)
|
|
29
38
|
|
|
30
39
|
if (this.hasIframeTarget) {
|
|
31
40
|
this.iframeTarget.removeEventListener('load', this.handleIframeLoad)
|
|
@@ -109,6 +118,10 @@ export default class extends Controller {
|
|
|
109
118
|
this.postActiveComponent()
|
|
110
119
|
}
|
|
111
120
|
|
|
121
|
+
handleMorph () {
|
|
122
|
+
this.refresh()
|
|
123
|
+
}
|
|
124
|
+
|
|
112
125
|
syncInitiallyOpenComponent () {
|
|
113
126
|
const openCollapse = document.querySelector('#components-accordion .accordion-collapse.show')
|
|
114
127
|
if (!openCollapse) return
|
|
@@ -114,7 +114,12 @@ module LatoCms
|
|
|
114
114
|
respond_to do |format|
|
|
115
115
|
if errors.empty?
|
|
116
116
|
format.html { redirect_to lato_cms.pages_show_path(@page), notice: t('lato_cms.fields_saved') }
|
|
117
|
-
|
|
117
|
+
# Only the saved component's fields: the editor repaints its media
|
|
118
|
+
# fields from this list, matching them by persisted field id, which is
|
|
119
|
+
# unique within a component but not across the page (two components
|
|
120
|
+
# can both have an "image" field). Handing it the whole page let a
|
|
121
|
+
# field adopt another component's media, and the next save stored it.
|
|
122
|
+
format.json { render json: { message: t('lato_cms.fields_saved'), fields: @page.fields.reload.select { |field| field.template_component_id == template_component_id.to_s }.map(&:as_json) } }
|
|
118
123
|
else
|
|
119
124
|
error_messages = errors.map { |e| "#{e[:field_id]}: #{e[:errors].join(', ')}" }.join('; ')
|
|
120
125
|
format.html { redirect_to lato_cms.pages_show_path(@page), alert: error_messages }
|
|
@@ -104,10 +104,20 @@
|
|
|
104
104
|
<% page_field = component_fields.find { |f| f.field_id == field_id } %>
|
|
105
105
|
|
|
106
106
|
<div class="mb-3">
|
|
107
|
+
<%# The dom id prefix carries the template component: every
|
|
108
|
+
component of the page is rendered at once, and two of them
|
|
109
|
+
can expose the same field id (a template mounting one
|
|
110
|
+
component twice, or two components both calling their
|
|
111
|
+
image field "image"). Without it they shared input ids —
|
|
112
|
+
and, for media fields, the picker frame id the selection
|
|
113
|
+
event is correlated by, so a media picked in one component
|
|
114
|
+
landed in the other as well. Input *names* stay
|
|
115
|
+
component-agnostic: each form posts its own component. %>
|
|
107
116
|
<%= lato_cms_render_field(
|
|
108
117
|
field_id: field_id,
|
|
109
118
|
field_config: field_config,
|
|
110
|
-
page_field: page_field
|
|
119
|
+
page_field: page_field,
|
|
120
|
+
dom_id_prefix: "fields_#{tc[:template_component_id]}_#{field_id}"
|
|
111
121
|
) %>
|
|
112
122
|
</div>
|
|
113
123
|
<% end %>
|
data/lib/lato_cms/version.rb
CHANGED