trenni-formatters 2.3.0 → 2.4.0
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8211316a3883ea35000eac2f2d7577066801285c
|
4
|
+
data.tar.gz: 1e663830ec43445a1580b330d1d3285633b40c46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2883f0457f3bdb1c6a82390be80d435ed68ee6532cbe50129a3e283cb97e9ced70007e086a993cd4fc912e8ed1c04ad61d2904f3d38b9c3ea4bd7d93c02eb8cf
|
7
|
+
data.tar.gz: 875cc5c45745c8f1e67e4ad5c814ec101529459cf72a52f6dd46811b8d36e6e3117f4d164ef5a81dace38e2049b336802a03f80620b2dc32d60602f7a5d077fb
|
@@ -77,14 +77,22 @@ module Trenni
|
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
80
|
-
def item(
|
80
|
+
def item(builder: nil, **options)
|
81
81
|
options[:field] ||= 'id'
|
82
82
|
|
83
|
-
Builder.fragment(
|
83
|
+
Builder.fragment(builder) do |builder|
|
84
84
|
builder.inline(:option, option_attributes_for(options)) { builder.text title_for(options) }
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def optional_title_for(options)
|
89
|
+
if options[:optional] == true
|
90
|
+
options[:blank] || ''
|
91
|
+
else
|
92
|
+
options[:optional]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
88
96
|
def group_attributes_for(options)
|
89
97
|
return {
|
90
98
|
:label => title_for(options),
|
@@ -98,7 +106,7 @@ module Trenni
|
|
98
106
|
Builder.fragment(@builder) do |builder|
|
99
107
|
builder.tag :optgroup, group_attributes_for(options) do
|
100
108
|
if options[:optional]
|
101
|
-
item(:title =>
|
109
|
+
item(:title => optional_title_for(options), :value => nil, :builder => builder)
|
102
110
|
end
|
103
111
|
|
104
112
|
builder.append Trenni::Template.capture(&block)
|
@@ -120,7 +128,7 @@ module Trenni
|
|
120
128
|
Builder.fragment(@builder) do |builder|
|
121
129
|
builder.tag :select, select_attributes_for(options) do
|
122
130
|
if options[:optional]
|
123
|
-
item(:title =>
|
131
|
+
item(:title => optional_title_for(options), :value => nil, :builder => builder)
|
124
132
|
end
|
125
133
|
|
126
134
|
builder.append Trenni::Template.capture(self, &block)
|
@@ -72,8 +72,8 @@ module Trenni
|
|
72
72
|
}
|
73
73
|
end
|
74
74
|
|
75
|
-
def item(
|
76
|
-
Builder.fragment do |builder|
|
75
|
+
def item(builder: nil, **options, &block)
|
76
|
+
Builder.fragment(builder) do |builder|
|
77
77
|
builder.tag :tr do
|
78
78
|
builder.inline(:td, :class => :handle) do
|
79
79
|
builder.tag :input, radio_attributes_for(options)
|
@@ -90,10 +90,22 @@ module Trenni
|
|
90
90
|
end >> block
|
91
91
|
end
|
92
92
|
|
93
|
+
def optional_title_for(options)
|
94
|
+
if options[:optional] == true
|
95
|
+
options[:blank] || ''
|
96
|
+
else
|
97
|
+
options[:optional]
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
93
101
|
def call(options = {}, &block)
|
94
102
|
Builder.fragment(@builder) do |builder|
|
95
103
|
builder.tag :table do
|
96
104
|
builder.tag :tbody do
|
105
|
+
if options[:optional]
|
106
|
+
item(:title => optional_title_for(options), :value => nil, :builder => builder)
|
107
|
+
end
|
108
|
+
|
97
109
|
builder.append Trenni::Template.capture(self, &block)
|
98
110
|
end
|
99
111
|
end
|