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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7332f9e231b03a10934316e6be8d9fb00659b7231a8fef96379ef3631a335776
|
|
4
|
+
data.tar.gz: e1bf94e76433c4c11f0df385ba2c87df0cccec83d9f3275ee4c46bb171fc25a8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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:
|
|
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
|
|
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
|
|
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
|
|
26
|
-
image_tag(
|
|
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.
|
|
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
|