katalyst-koi 4.5.8 → 4.5.9
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08771b81c4521daf6ece3e3772876dd33aae6b5f28c9192f20f098b7044a6fec'
|
4
|
+
data.tar.gz: 255024e1221fcaac47c145a866d331a8ed135686cad306e7104578602c72ac2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4835ecf31eccc9160aa3ba9ed93cdb0d8391f63996046f74bf82a5d25991ba9b9b546ad7c4750e470fcffcf398b74118ecf4525bab059bb560e2374f99cf9722
|
7
|
+
data.tar.gz: 9195e5a7a56909414f36ce7bdf2ebd714ca7b9525577f2c8a6bb816ae74712e985098418e1a5897ee64c33f031ac14f4b8c32e54a94af2468d451274d4f77ad8
|
@@ -7,15 +7,11 @@ module GOVUKDesignSystemFormBuilder
|
|
7
7
|
class Document < Base
|
8
8
|
include FileElement
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
application/pdf audio/*
|
13
|
-
].freeze
|
14
|
-
|
15
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, **kwargs, &block)
|
10
|
+
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:,
|
11
|
+
**kwargs, &block)
|
16
12
|
super(builder, object_name, attribute_name, &block)
|
17
13
|
|
18
|
-
@mime_types =
|
14
|
+
@mime_types = mime_types
|
19
15
|
@label = label
|
20
16
|
@caption = caption
|
21
17
|
@hint = hint
|
@@ -57,9 +53,17 @@ module GOVUKDesignSystemFormBuilder
|
|
57
53
|
# @example A upload field with label as a proc
|
58
54
|
# = f.govuk_document_field :data, label: -> { tag.h3('Upload your document') }
|
59
55
|
#
|
60
|
-
def govuk_document_field(attribute_name,
|
61
|
-
|
62
|
-
|
56
|
+
def govuk_document_field(attribute_name,
|
57
|
+
label: {},
|
58
|
+
caption: {},
|
59
|
+
hint: {},
|
60
|
+
form_group: {},
|
61
|
+
mime_types: Koi.config.document_mime_types,
|
62
|
+
**kwargs,
|
63
|
+
&block)
|
64
|
+
Elements::Document.new(
|
65
|
+
self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **kwargs, &block
|
66
|
+
).html
|
63
67
|
end
|
64
68
|
end
|
65
69
|
end
|
@@ -8,12 +8,11 @@ module GOVUKDesignSystemFormBuilder
|
|
8
8
|
class Image < Base
|
9
9
|
include FileElement
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, **kwargs, &block)
|
11
|
+
def initialize(builder, object_name, attribute_name, hint:, label:, caption:, form_group:, mime_types:,
|
12
|
+
**kwargs, &block)
|
14
13
|
super(builder, object_name, attribute_name, &block)
|
15
14
|
|
16
|
-
@mime_types =
|
15
|
+
@mime_types = mime_types
|
17
16
|
@label = label
|
18
17
|
@caption = caption
|
19
18
|
@hint = hint
|
@@ -84,9 +83,17 @@ module GOVUKDesignSystemFormBuilder
|
|
84
83
|
# @example A image upload field with label as a proc
|
85
84
|
# = f.govuk_image_field :image, label: -> { tag.h3('Upload your image') }
|
86
85
|
#
|
87
|
-
def govuk_image_field(attribute_name,
|
88
|
-
|
89
|
-
|
86
|
+
def govuk_image_field(attribute_name,
|
87
|
+
label: {},
|
88
|
+
caption: {},
|
89
|
+
hint: {},
|
90
|
+
form_group: {},
|
91
|
+
mime_types: Koi.config.image_mime_types,
|
92
|
+
**kwargs,
|
93
|
+
&block)
|
94
|
+
Elements::Image.new(
|
95
|
+
self, object_name, attribute_name, label:, caption:, hint:, form_group:, mime_types:, **kwargs, &block
|
96
|
+
).html
|
90
97
|
end
|
91
98
|
end
|
92
99
|
end
|
data/lib/koi/config.rb
CHANGED
@@ -9,8 +9,18 @@ module Koi
|
|
9
9
|
|
10
10
|
config_accessor(:resource_name_candidates) { %i[title name] }
|
11
11
|
|
12
|
-
config_accessor(:image_size_limit) { 10.megabytes }
|
13
|
-
|
14
12
|
config_accessor(:admin_stylesheet) { "koi/admin" }
|
13
|
+
|
14
|
+
config_accessor(:document_mime_types) do
|
15
|
+
%w[image/png image/gif image/jpeg image/webp application/pdf audio/*].freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
config_accessor(:document_size_limit) { 10.megabytes }
|
19
|
+
|
20
|
+
config_accessor(:image_mime_types) do
|
21
|
+
%w[image/png image/gif image/jpeg image/webp].freeze
|
22
|
+
end
|
23
|
+
|
24
|
+
config_accessor(:image_size_limit) { 10.megabytes }
|
15
25
|
end
|
16
26
|
end
|
data/lib/koi/form_builder.rb
CHANGED
@@ -36,28 +36,24 @@ module Koi
|
|
36
36
|
|
37
37
|
# @api internal
|
38
38
|
# @see GOVUKDesignSystemFormBuilder::Builder#govuk_document_field
|
39
|
-
def govuk_document_field(attribute_name, hint: {},
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
concat(yield)
|
44
|
-
else
|
45
|
-
concat(t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size)))
|
46
|
-
end
|
39
|
+
def govuk_document_field(attribute_name, hint: {}, **, &)
|
40
|
+
if hint.is_a?(Hash)
|
41
|
+
max_size = hint.fetch(:max_size, Koi.config.document_size_limit)
|
42
|
+
hint[:text] ||= t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size))
|
47
43
|
end
|
44
|
+
|
45
|
+
super(attribute_name, hint:, **, &)
|
48
46
|
end
|
49
47
|
|
50
48
|
# @api internal
|
51
49
|
# @see GOVUKDesignSystemFormBuilder::Builder#govuk_image_field
|
52
|
-
def govuk_image_field(attribute_name, hint: {},
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
concat(yield)
|
57
|
-
else
|
58
|
-
concat(t("helpers.hint.default.image", max_size: @template.number_to_human_size(max_size)))
|
59
|
-
end
|
50
|
+
def govuk_image_field(attribute_name, hint: {}, **, &)
|
51
|
+
if hint.is_a?(Hash)
|
52
|
+
max_size = hint.fetch(:max_size, Koi.config.image_size_limit)
|
53
|
+
hint[:text] ||= t("helpers.hint.default.document", max_size: @template.number_to_human_size(max_size))
|
60
54
|
end
|
55
|
+
|
56
|
+
super(attribute_name, hint:, **, &)
|
61
57
|
end
|
62
58
|
|
63
59
|
# Use content editor trix setup by default.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-koi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.5.
|
4
|
+
version: 4.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|