trenni-formatters 2.11.0 → 2.12.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
  SHA256:
3
- metadata.gz: 6d6feaaa592cf7b7ee7470871eb4a169485b1141978ca45fc0bae655e76494fc
4
- data.tar.gz: 78e3dec788ea4b9439d64a281f13b1dd8a4b4845d65340d595e4e8489437d93c
3
+ metadata.gz: 55e7e7cfc1294e06ad765330a6ea896e5b28feb1402c323b31dcc6befd7179ee
4
+ data.tar.gz: adee9ac28a0e967322e0a2d9a7e86ec4264e753fe8f504e8bff3858b3c0adb4b
5
5
  SHA512:
6
- metadata.gz: 1ed0633355b499980dadbcb900a651020f9718d43bae54b8dbbe2f8e0c491d06dec7bb9cf63e4eab58f6aa5bdba84742a31f1824711c124e95c2a24f8930fd0f
7
- data.tar.gz: 151c6d08577bfc6481591c3b2c0733083b5d847c02f633525c5225629dc717f45b532b6c957fb27450cda2787e88d939e63d1bc4e6c15fe15bc4e570f2b78c4b
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
@@ -127,7 +127,7 @@ module Trenni
127
127
  }
128
128
  end
129
129
 
130
- def call(options = {}, &block)
130
+ def call(**options, &block)
131
131
  Builder.fragment(@builder) do |builder|
132
132
  builder.tag :select, select_attributes_for(**options) do
133
133
  if options[:optional]
@@ -100,7 +100,7 @@ module Trenni
100
100
  end
101
101
  end
102
102
 
103
- def call(options = {}, &block)
103
+ def call(**options, &block)
104
104
  Builder.fragment(@builder) do |builder|
105
105
  builder.tag :table do
106
106
  builder.tag :tbody do
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Trenni
24
24
  module Formatters
25
- VERSION = "2.11.0"
25
+ VERSION = "2.12.0"
26
26
  end
27
27
  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.11.0
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-03 00:00:00.000000000 Z
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