trenni-formatters 2.11.0 → 2.12.0
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: 55e7e7cfc1294e06ad765330a6ea896e5b28feb1402c323b31dcc6befd7179ee
|
4
|
+
data.tar.gz: adee9ac28a0e967322e0a2d9a7e86ec4264e753fe8f504e8bff3858b3c0adb4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3822f8dfd5b5c31ebb6f90c5a60c38f2693efb385d4c66728c770a9173de745fd13fdf3dd8f9fddcda5d5a39ca630cf593204b80d0ea0426433f0f143e472ea
|
7
|
+
data.tar.gz: ab8913082ec7c68b94a434c30c9d7912600ea79b17c5b527cf7a20f9b36a9b73266af8f489094346160e855b00f2bf153b681437dc96198aa961be1789fa4283
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2020, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'trenni/builder'
|
24
|
+
|
25
|
+
module Trenni
|
26
|
+
module Formatters
|
27
|
+
module HTML
|
28
|
+
class AcceptCheckbox
|
29
|
+
def self.call(formatter, builder, **options, &block)
|
30
|
+
instance = self.new(formatter, builder, **options)
|
31
|
+
|
32
|
+
instance.call(options, &block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(formatter, builder, **options)
|
36
|
+
@formatter = formatter
|
37
|
+
@object = formatter.object
|
38
|
+
|
39
|
+
@builder = builder
|
40
|
+
|
41
|
+
@options = options
|
42
|
+
@field = options[:field]
|
43
|
+
end
|
44
|
+
|
45
|
+
def name_for(**options)
|
46
|
+
@formatter.name_for(**options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def title_for(**options)
|
50
|
+
@formatter.title_for(**options)
|
51
|
+
end
|
52
|
+
|
53
|
+
def checkbox_attributes_for(**options)
|
54
|
+
@formatter.checkbox_attributes_for(**options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def call(options = {}, &block)
|
58
|
+
Builder.fragment(@builder) do |builder|
|
59
|
+
builder.inline('span') do
|
60
|
+
builder.inline :input, :type => :hidden, :name => name_for(**options), :value => 'false'
|
61
|
+
|
62
|
+
builder.tag :input, checkbox_attributes_for(**options)
|
63
|
+
|
64
|
+
builder.text " "
|
65
|
+
|
66
|
+
builder.capture(self, &block)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -99,8 +99,6 @@ module Trenni
|
|
99
99
|
builder.inline :input, :type => :hidden, :name => name_for(**options), :value => 'false'
|
100
100
|
|
101
101
|
builder.inline(:span) do
|
102
|
-
builder.text title_for(**options)
|
103
|
-
|
104
102
|
if details = details_for(**options)
|
105
103
|
builder.inline(:small) {builder.text details}
|
106
104
|
end
|
@@ -108,7 +106,7 @@ module Trenni
|
|
108
106
|
|
109
107
|
builder.tag :input, checkbox_attributes_for(**options)
|
110
108
|
|
111
|
-
# We would like a little bit of whitespace between the checkbox and the title
|
109
|
+
# We would like a little bit of whitespace between the checkbox and the title:
|
112
110
|
builder.text " " + title_for(**options)
|
113
111
|
end
|
114
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: trenni-formatters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mapping
|
@@ -130,6 +130,7 @@ extra_rdoc_files: []
|
|
130
130
|
files:
|
131
131
|
- lib/trenni/formatters.rb
|
132
132
|
- lib/trenni/formatters/formatter.rb
|
133
|
+
- lib/trenni/formatters/html/accept_checkbox.rb
|
133
134
|
- lib/trenni/formatters/html/definition_list_form.rb
|
134
135
|
- lib/trenni/formatters/html/form_formatter.rb
|
135
136
|
- lib/trenni/formatters/html/label_form.rb
|