katalyst-koi 5.11.2 → 5.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea4f9e29a1eef22e9a178c663b56950384655fb7c91d27cccfbe406b1aaf7d93
4
- data.tar.gz: 7cd1ddf3134fdff40742dd19e0667a58060519ef1b21214003c1f5894dc10a52
3
+ metadata.gz: 7332f9e231b03a10934316e6be8d9fb00659b7231a8fef96379ef3631a335776
4
+ data.tar.gz: e1bf94e76433c4c11f0df385ba2c87df0cccec83d9f3275ee4c46bb171fc25a8
5
5
  SHA512:
6
- metadata.gz: a0ac94af56d9f31ba511cc25e747d3d72002c1b5997c0fa6094898d4b430810325c2b34efd3baf817ffe94797de4fc4ec2f7aa2ce6f9b60e4c0fd4375d9c1fde
7
- data.tar.gz: 1f74e303e8430572b1c5191ae303014f26bc7ea69a073483693f8a3c9945e640d7701ba4a6152f8d8d46383771b7f0d1fdea42dd622863e2a0cd444a1713a341
6
+ metadata.gz: 7403b011c65fd38c2e3443bcd8ee2a86cc8a3310298e75c5d7f9ebe1a4a04d36d9b8aaca02dad92f8ea99a5396888a6785601bdd11934bf88fe3f820bafeae4f
7
+ data.tar.gz: 7ee5ecda0d9265dae2cb1a18496ad5ac2b529a34a0032987dbedc357d198d114d256cd8bb0e5ef8104536157d114712b54a67f77bef44ac5439c73f56ab95371
@@ -114,7 +114,7 @@
114
114
  display: grid;
115
115
  grid-template-areas: "preview caption actions";
116
116
  grid-template-columns: auto 1fr auto;
117
- margin: 0 0 var(--flow-space) 0;
117
+ margin: unset;
118
118
  padding: var(--space-xs);
119
119
  grid-gap: var(--space-s);
120
120
  border: 1px solid var(--color-mid);
@@ -243,6 +243,12 @@ display, tab order, and accessibility tree. */
243
243
  }
244
244
  }
245
245
 
246
+ .govuk-file-upload-wrapper:has(input[type="file"][multiple]) {
247
+ .govuk-attachment + .govuk-attachment {
248
+ margin-block-start: var(--space-xs);
249
+ }
250
+ }
251
+
246
252
  /* Movement */
247
253
 
248
254
  .govuk-attachment {
@@ -31,7 +31,8 @@ module Koi
31
31
  ), &)
32
32
  end
33
33
 
34
- # Generates a column that renders an ActiveStorage attachment as a downloadable link.
34
+ # Generates a column that renders ActiveStorage attachments, from either
35
+ # has_one_attached or has_many_attached associations.
35
36
  #
36
37
  # @param column [Symbol] the column's name, called as a method on the record
37
38
  # @param label [String|nil] the label to use for the column header
@@ -5,9 +5,10 @@ module Koi
5
5
  module Cells
6
6
  # Shows an attachment
7
7
  #
8
- # The value is expected to be an ActiveStorage attachment
8
+ # The value is expected to be an ActiveStorage attachment, either
9
+ # singular (has_one_attached) or plural (has_many_attached).
9
10
  #
10
- # If it is representable, shows as a image tag using the specified variant.
11
+ # If it is representable, shows as an image tag using the specified variant.
11
12
  #
12
13
  # Otherwise shows as a link to download.
13
14
  class AttachmentComponent < Katalyst::Tables::CellComponent
@@ -18,21 +19,19 @@ module Koi
18
19
  end
19
20
 
20
21
  def rendered_value
21
- representation
22
+ safe_join(attachments.map { |attachment| representation(attachment) })
22
23
  end
23
24
 
24
- def representation
25
- if value.try(:variable?) && named_variant.present?
26
- image_tag(value.variant(@variant))
27
- elsif value.try(:attached?)
28
- filename.to_s
25
+ def representation(attachment = value.attachment)
26
+ if attachment&.variable? && named_variant.present?
27
+ image_tag(attachment.variant(@variant))
29
28
  else
30
- ""
29
+ attachment&.filename.to_s
31
30
  end
32
31
  end
33
32
 
34
33
  def filename
35
- value.blob.filename
34
+ value.attachment&.filename
36
35
  end
37
36
 
38
37
  # Utility for accessing the path Rails provides for retrieving the
@@ -46,6 +45,11 @@ module Koi
46
45
 
47
46
  private
48
47
 
48
+ # Attached::One and Attached::Many normalized to [ActiveStorage::Attachment]
49
+ def attachments
50
+ value.is_a?(ActiveStorage::Attached::Many) ? value.attachments : Array(value.attachment)
51
+ end
52
+
49
53
  def default_html_attributes
50
54
  { class: "type-attachment" }
51
55
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-koi
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.11.2
4
+ version: 5.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive