bard-tag_field 0.1.0 → 0.2.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 +4 -4
- data/lib/bard/tag_field/field.rb +11 -14
- data/lib/bard/tag_field/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b02f3ddad60e5123de67a5eabce0f7055f78ca2acacc6420e6f8217619040b9
|
4
|
+
data.tar.gz: d5e46540cba56d49a543f4ce5493ad7049271546134c03e7cc5fac6ed145e00d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8b3e7375d573b1b388cdb834b521b1196bd0a037cf709c2ca3b953c46f9b174b2731d7eb6e6e0c2d1681343658fb554585a3a2e7e949630268f1973a3c5b7e9
|
7
|
+
data.tar.gz: cdbfa395648b8d5b593552bebe246607309ff62cbe11c514a70e5ba960c9717efa6bb41b19fd0eb0566e1b378d9f9412bdbc193d32b09bc929ce463ecbe2b82e
|
data/lib/bard/tag_field/field.rb
CHANGED
@@ -10,21 +10,15 @@ module Bard
|
|
10
10
|
# Store choices for render_object_values method
|
11
11
|
@choices = choices
|
12
12
|
|
13
|
-
# Generate unique datalist ID if we have choices and no block
|
14
|
-
datalist_id = nil
|
15
|
-
if choices&.any? && !block
|
16
|
-
datalist_id = "#{@options[:id]}_datalist"
|
17
|
-
@options[:list] = datalist_id
|
18
|
-
end
|
19
|
-
|
20
13
|
result = @template_object.content_tag("input-tag", @options) do
|
21
|
-
|
22
|
-
render_object_values
|
23
|
-
end
|
14
|
+
content = block ? block.call(@options) : render_object_values
|
24
15
|
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
# Add nested anonymous datalist if we have choices, no block, and no external list specified
|
17
|
+
if choices&.any? && !block && !@options[:list]
|
18
|
+
content += render_datalist(nil, choices)
|
19
|
+
end
|
20
|
+
|
21
|
+
content
|
28
22
|
end
|
29
23
|
|
30
24
|
result
|
@@ -33,7 +27,10 @@ module Bard
|
|
33
27
|
private
|
34
28
|
|
35
29
|
def render_datalist(datalist_id, choices)
|
36
|
-
|
30
|
+
# Use id attribute only if datalist_id is provided (for external datalist)
|
31
|
+
attributes = datalist_id ? { id: datalist_id } : {}
|
32
|
+
|
33
|
+
@template_object.content_tag("datalist", attributes) do
|
37
34
|
choices.map do |choice|
|
38
35
|
case choice
|
39
36
|
when Array
|