lato_cms 3.1.0 → 3.1.2

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: fe4976c31eee3bc5137206d66037755baf19825e152a1c37a4be32e5b715dd6d
4
- data.tar.gz: a209a52cb918989ce0179da4c902e3f4f71f0bb0843b6c4e7fac83c8b901424c
3
+ metadata.gz: 2c31c3c48793c6d20d23de01e4ccf7e42d9086d299e7ae5b713061e5ddd8861b
4
+ data.tar.gz: 0f575950a6a54cf1f4321fd9127297a8c1941c4684b7b7ccaefbe251e67a4aa4
5
5
  SHA512:
6
- metadata.gz: 469fa040c5c8ea3b04d630c1d664e0ff2db92a418089852eb2252c57899da646325c76969b4389dd219f20ff96c3f679b0581548107e19a354e9f47977bde3bd
7
- data.tar.gz: 7638ec4ca940ab161bb361ec69fff832fb3950ab814dd656d3f4dabe422cafdf6b91ebff1962949dfcd89e86fd269d2bde9d95d17fff3f1a25eb16a36dc9413b
6
+ metadata.gz: d67ec60c551ffb117fc461d00b1279f058dfb2f8a3ffcd5b72a30f7eb4e05c5494811d4dedee733c41409fca5232774ac8818a90a3b30f70b7697fbeed72f86c
7
+ data.tar.gz: f09db9cfb78554e68063210c37f46621b42ce4131ed9e2d849d68409056a76e218cd26c2cc8af0dd9c771318052828147dde86ea2e7d306dc55f939cf0f17518
@@ -94,8 +94,10 @@ export default class extends Controller {
94
94
  appendItem (item) {
95
95
  if (!item || this.gridTarget.querySelector(`[data-media-id="${item.id}"]`)) return
96
96
 
97
+ const wide = !this.multipleValue && ['image', 'video'].includes(this.kindValue)
98
+
97
99
  const wrapper = document.createElement('div')
98
- wrapper.className = 'lato-cms-media-field__tile lato-cms-media-field__item'
100
+ wrapper.className = `lato-cms-media-field__tile lato-cms-media-field__item${wide ? ' lato-cms-media-field__tile--wide' : ''}`
99
101
  wrapper.dataset.mediaId = item.id
100
102
  if (this.multipleValue) {
101
103
  wrapper.draggable = true
@@ -118,8 +120,7 @@ export default class extends Controller {
118
120
 
119
121
  previewMarkup (item) {
120
122
  if (this.kindValue === 'video') {
121
- return `<video muted preload="metadata" class="lato-cms-media-field__player" src="${item.url}"></video>
122
- <i class="bi bi-play-circle-fill lato-cms-media-field__badge"></i>`
123
+ return `<video controls preload="metadata" class="lato-cms-media-field__player" src="${item.url}"></video>`
123
124
  }
124
125
  if (item.thumbnailUrl || item.url) {
125
126
  return `<img src="${item.thumbnailUrl || item.url}" class="lato-cms-media-field__thumb">`
@@ -1,12 +1,17 @@
1
1
  import { Controller } from '@hotwired/stimulus'
2
2
 
3
- // Refreshes the enclosing turbo-frame (or the whole page) whenever a
4
- // Bootstrap modal on the page closes. Used after triggering a
3
+ // Refreshes the enclosing turbo-frame (or the whole page) when the shared
4
+ // `lato_operation` progress modal closes used after triggering a
5
5
  // Lato::Operation (e.g. "Regenerate with AI", "Clone & translate") from a
6
6
  // link inside it: the underlying page/frame has no way to know when that
7
7
  // background job finishes, so once the admin dismisses the operation's
8
8
  // progress modal, refresh so the result is shown without a manual reload.
9
9
  //
10
+ // Only reacts when the modal that just closed actually contains the
11
+ // `#lato_operation` frame — every Bootstrap modal on the page fires
12
+ // `hidden.bs.modal`, including ones with nothing to do with an operation
13
+ // (e.g. this very form's own modal), and those must not trigger a reload.
14
+ //
10
15
  // Mounted on an element INSIDE the turbo-frame's content, not on the frame
11
16
  // tag itself: when this frame is opened inside a modal, `lato-action`
12
17
  // pre-creates a bare `<turbo-frame>` via innerHTML before Turbo fetches
@@ -18,15 +23,17 @@ import { Controller } from '@hotwired/stimulus'
18
23
  // page (no frame at all, so it falls back to reloading the whole page).
19
24
  export default class extends Controller {
20
25
  connect () {
21
- this.reload = this.reload.bind(this)
22
- document.addEventListener('hidden.bs.modal', this.reload)
26
+ this.onModalHidden = this.onModalHidden.bind(this)
27
+ document.addEventListener('hidden.bs.modal', this.onModalHidden)
23
28
  }
24
29
 
25
30
  disconnect () {
26
- document.removeEventListener('hidden.bs.modal', this.reload)
31
+ document.removeEventListener('hidden.bs.modal', this.onModalHidden)
27
32
  }
28
33
 
29
- reload () {
34
+ onModalHidden (event) {
35
+ if (!event.target.querySelector('#lato_operation')) return
36
+
30
37
  const frame = this.element.closest('turbo-frame')
31
38
  if (frame && frame.getAttribute('src')) {
32
39
  frame.reload()
@@ -212,6 +212,15 @@ body.controller-pages.action-show {
212
212
  width: 110px;
213
213
  }
214
214
 
215
+ // Single image/video fields (never galleries, never plain files): a full-width
216
+ // preview reads much better than a 110px square, and gives a real video
217
+ // player enough room to be usable.
218
+ .lato-cms-media-field__tile--wide {
219
+ aspect-ratio: 16 / 9;
220
+ height: auto;
221
+ width: 100%;
222
+ }
223
+
215
224
  .lato-cms-media-field__item {
216
225
  background: var(--bs-light);
217
226
  border: 1px solid rgba(33, 37, 41, 0.1);
@@ -253,16 +262,6 @@ body.controller-pages.action-show {
253
262
  width: 100%;
254
263
  }
255
264
 
256
- .lato-cms-media-field__badge {
257
- bottom: 4px;
258
- color: #fff;
259
- filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
260
- font-size: 0.9rem;
261
- pointer-events: none;
262
- position: absolute;
263
- right: 4px;
264
- }
265
-
266
265
  // Name overlay: hidden until the tile is hovered.
267
266
  .lato-cms-media-field__overlay {
268
267
  bottom: 0;
@@ -10,6 +10,7 @@
10
10
  lato_cms_field_input_name(field_id, 'media_ids', input_name_prefix: local_assigns[:input_name_prefix], multiple: true) :
11
11
  lato_cms_field_input_name(field_id, 'media_id', input_name_prefix: local_assigns[:input_name_prefix]) %>
12
12
  <% picker_type = kind == 'file' ? nil : kind %>
13
+ <% wide = !multiple && %w[image video].include?(kind) %>
13
14
 
14
15
  <label class="form-label">
15
16
  <%= label %><%= ' *' if required %>
@@ -42,7 +43,7 @@
42
43
  default navigation itself and sets the frame's `src` explicitly
43
44
  (Turbo's documented, non-racy way to trigger a frame-scoped fetch). %>
44
45
  <%= link_to lato_cms.media_picker_action_path(frame_id: frame_id, multiple: multiple, type: picker_type),
45
- class: "lato-cms-media-field__tile lato-cms-media-field__tile--add#{' d-none' if !multiple && current_media.any?}",
46
+ class: "lato-cms-media-field__tile lato-cms-media-field__tile--add#{' lato-cms-media-field__tile--wide' if wide}#{' d-none' if !multiple && current_media.any?}",
46
47
  data: {
47
48
  lato_cms_media_field_target: 'addTile',
48
49
  action: 'click->lato-cms-media-field#openPicker',
@@ -1,4 +1,5 @@
1
- <div class="lato-cms-media-field__tile lato-cms-media-field__item"
1
+ <% wide = !multiple && %w[image video].include?(kind) %>
2
+ <div class="lato-cms-media-field__tile lato-cms-media-field__item<%= ' lato-cms-media-field__tile--wide' if wide %>"
2
3
  data-media-id="<%= media.id %>"
3
4
  data-lato-cms-media-field-target="item"
4
5
  <% if multiple %>
@@ -7,8 +8,7 @@
7
8
  data-action="dragstart->lato-cms-media-reorder#onDragStart dragend->lato-cms-media-reorder#onDragEnd"
8
9
  <% end %>>
9
10
  <% if kind == 'video' %>
10
- <video muted preload="metadata" class="lato-cms-media-field__player" src="<%= media.url %>"></video>
11
- <i class="bi bi-play-circle-fill lato-cms-media-field__badge"></i>
11
+ <video controls preload="metadata" class="lato-cms-media-field__player" src="<%= media.url %>"></video>
12
12
  <% elsif media.thumbnail_url %>
13
13
  <img src="<%= media.thumbnail_url %>" class="lato-cms-media-field__thumb" alt="<%= media.alt_text %>">
14
14
  <% else %>
@@ -1,3 +1,3 @@
1
1
  module LatoCms
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.2"
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.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante