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: 29cb78070d1a03bb67b5c2ad9c06b212303ae2c390e3b3a2f17b07bbae26f949
4
- data.tar.gz: 82dd11dac19e77c935a037561d668be95b6d4cc0a6cb08d53ce1e4eec81445b4
3
+ metadata.gz: cdc7dae92de55a7a6e1e1290ee957bbf0b63fdf16404524c3f1803bd68123d0e
4
+ data.tar.gz: 1bc853f4846e25c41db7bddc0d53ac55f05699a06cf97a221abf6b7573458a7e
5
5
  SHA512:
6
- metadata.gz: e07ea70a61268187c94a66ad273339bed785d0cc3e6f5562624b4924b6e721ff6f01d039e47a1ca9f18de58681b051ac50bbc03bc1ceeefa79dd351f94ff8250
7
- data.tar.gz: b39a29416a88c3cace9b780a4a0582b721b5d038df0c0e7b14d6814b48612db14530c8e6bc8259a7fdca30febd8a70e8a290a3fb9ad33b6e4289333c4556e8ad
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
- format.json { render json: { message: t('lato_cms.fields_saved'), fields: @page.fields.reload.map(&:as_json) } }
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 %>
@@ -1,3 +1,3 @@
1
1
  module LatoCms
2
- VERSION = "3.2.5"
2
+ VERSION = "3.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.5
4
+ version: 3.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante