shimmer 0.0.22 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- 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/utils/file_helper.rb +12 -4
- 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: c0eaed2568e6fdbdc41b8c47337b1c514f0db410c597c3b5727eb3de9ffa2367
|
4
|
+
data.tar.gz: b946998c24efbe8fe0307ef55ea9971233be36623cdbcdbd283306c319132d02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13279649e9331c200c8491974f57fc659aff3b60242f93683fba9a55d0d75583a32c6b9eaab4a4d128207f5be416b55493af629cd87edd02d01cc52c946da4da
|
7
|
+
data.tar.gz: 8f200cd8ed792dc4a33d2ab7fc2d0607a00ea9a2a4ad32f278d655a21d1510d7cd614483d15077cb99ab2ca9b124c6ec94b02cf8471740b0b17497f94bc61354
|
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
@@ -27,19 +27,27 @@ module Shimmer
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def image_file_path(source, width: nil, height: nil)
|
30
|
-
image_file_proxy(source, width: width, height: height)
|
30
|
+
image_file_proxy(source, width: width, height: height, return_type: :path)
|
31
31
|
end
|
32
32
|
|
33
33
|
def image_file_url(source, width: nil, height: nil)
|
34
|
-
image_file_proxy(source, width: width, height: height)
|
34
|
+
image_file_proxy(source, width: width, height: height, return_type: :url)
|
35
35
|
end
|
36
36
|
|
37
|
-
def image_file_proxy(source, width: nil, height: nil)
|
37
|
+
def image_file_proxy(source, width: nil, height: nil, return_type: nil)
|
38
38
|
return if source.blank?
|
39
39
|
return source if source.is_a?(String)
|
40
40
|
|
41
41
|
blob = source.try(:blob) || source
|
42
|
-
Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
|
42
|
+
proxy = Shimmer::FileProxy.new(blob_id: blob.id, width: width, height: height)
|
43
|
+
case return_type
|
44
|
+
when nil
|
45
|
+
proxy
|
46
|
+
when :path
|
47
|
+
proxy.path
|
48
|
+
when :url
|
49
|
+
proxy.url
|
50
|
+
end
|
43
51
|
end
|
44
52
|
end
|
45
53
|
end
|
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.24
|
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
|