shimmer 0.0.22 → 0.0.23
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 +4 -4
- data/lib/shimmer/form/builder.rb +6 -5
- data/lib/shimmer/form/checkbox_field.rb +13 -0
- data/lib/shimmer/form/datetime_field.rb +13 -0
- data/lib/shimmer/form/field.rb +4 -0
- data/lib/shimmer/form/image_field.rb +13 -0
- data/lib/shimmer/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b8e13a67c158deb5255b9a047415eca407baded8da093d1710c2a63d4e505fb
|
4
|
+
data.tar.gz: ecdfa43b53f32bca080085f2a1ffafe6393ba2c6739137843d54913fdadd0327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84811ac4a7369eff4cd958e0a111151dc98a9998ef0a087959b2ecb41cc883def34ffe4db77d0eb2ec66be752106f654a8884d01aad7e8d5666a02ef80555ca9
|
7
|
+
data.tar.gz: 5830376aea6021ddf9b557ddab8ebe3b1157cc08ecc5badaead61cf024d24bed9013b3264b350c362b0b3b4f63eb295496595b07d900a36a0f2efe5b3a7a3912
|
data/lib/shimmer/form/builder.rb
CHANGED
@@ -13,7 +13,7 @@ module Shimmer
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def input(method, as: guess_type(method), **options)
|
16
|
+
def input(method, as: guess_type(method), wrapper_options: {}, description: nil, **options)
|
17
17
|
as ||= guess_type(method)
|
18
18
|
options[:class] ||= "input__input"
|
19
19
|
collection = options.delete :collection
|
@@ -25,12 +25,12 @@ module Shimmer
|
|
25
25
|
options[:required] ||= true if options[:required].nil? && required_attributes.include?(method)
|
26
26
|
options[:data] ||= {}
|
27
27
|
options[:data][:controller] = options.delete(:controller) if options[:controller]
|
28
|
-
wrapper_data = {}
|
29
28
|
extra = []
|
30
29
|
input_class = self.class.input_registry[as]
|
31
30
|
raise "Unknown type #{as}" unless input_class
|
32
31
|
input = input_class.new(builder: self, method: method, options: options, id_method: id_method, collection: collection, name_method: name_method)
|
33
|
-
|
32
|
+
wrapper_options.reverse_merge! input.wrapper_options
|
33
|
+
wrap method: method, content: input.render, classes: classes + ["input--#{as}"], label: options[:label], extra: extra, description: description, options: wrapper_options
|
34
34
|
end
|
35
35
|
|
36
36
|
private
|
@@ -65,13 +65,14 @@ module Shimmer
|
|
65
65
|
object.class.types.keys if object.class.respond_to?(method.to_s.pluralize)
|
66
66
|
end
|
67
67
|
|
68
|
-
def wrap(method:, content:, classes:, label:, data: nil, extra: nil)
|
68
|
+
def wrap(method:, content:, classes:, label:, data: nil, extra: nil, description: nil, options: {})
|
69
69
|
if object&.errors&.[](method)&.any?
|
70
70
|
classes << "input--error"
|
71
71
|
errors = safe_join(object.errors[method].map { |e| content_tag :div, e, class: "input__error" })
|
72
72
|
end
|
73
73
|
label = label == false ? nil : self.label(method, label, class: "input__label")
|
74
|
-
content_tag(:div,
|
74
|
+
description = description.presence ? content_tag(:div, description, class: "input__description") : nil
|
75
|
+
content_tag(:div, safe_join([label, content, description, errors, extra].compact), class: ["input"] + classes, **options)
|
75
76
|
end
|
76
77
|
|
77
78
|
def helper
|
data/lib/shimmer/form/field.rb
CHANGED
data/lib/shimmer/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jens Ravens
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -147,10 +147,13 @@ files:
|
|
147
147
|
- lib/shimmer/controllers/sitemaps_controller.rb
|
148
148
|
- lib/shimmer/form.rb
|
149
149
|
- lib/shimmer/form/builder.rb
|
150
|
+
- lib/shimmer/form/checkbox_field.rb
|
150
151
|
- lib/shimmer/form/checkboxes_field.rb
|
151
152
|
- lib/shimmer/form/date_field.rb
|
153
|
+
- lib/shimmer/form/datetime_field.rb
|
152
154
|
- lib/shimmer/form/email_field.rb
|
153
155
|
- lib/shimmer/form/field.rb
|
156
|
+
- lib/shimmer/form/image_field.rb
|
154
157
|
- lib/shimmer/form/number_field.rb
|
155
158
|
- lib/shimmer/form/password_field.rb
|
156
159
|
- lib/shimmer/form/pdf_field.rb
|