glib-web 0.5.40 → 0.5.41
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: 667c7e9bef646b1a11ed8237b4fca8490dfd5cc6308dc6bbe01284402fbf605d
|
4
|
+
data.tar.gz: 159bda20f1a5d19c1834d51669f7f8c990ad3ae34d766bec28e7b2ac6110b9cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2443bf21f9099aae0fddeed21226f02c466b4b123c5a7f69d9677a0a96c268f45b96ff7c91abebbd203ed88d71dc92ce817252083d8997cf0b8e09a1fd46ddae
|
7
|
+
data.tar.gz: 05e3fca19eb376087e2444af5b8635110a0d14fc86a4c88210a4234018e90b228129ff6cd19ecb4792db6e060c5d3cf6dc3aa9777dcf3c996b4cf064ef21c96e
|
@@ -4,10 +4,11 @@ class Glib::JsonUi::ViewBuilder
|
|
4
4
|
class AbstractField < View
|
5
5
|
bool :readOnly
|
6
6
|
hash :validation
|
7
|
+
string :label
|
7
8
|
|
8
|
-
def label(label)
|
9
|
-
|
10
|
-
end
|
9
|
+
# def label(label)
|
10
|
+
# @label = label
|
11
|
+
# end
|
11
12
|
|
12
13
|
def label_args(label_args)
|
13
14
|
@label_args = label_args
|
@@ -39,16 +40,13 @@ class Glib::JsonUi::ViewBuilder
|
|
39
40
|
|
40
41
|
def prop(prop)
|
41
42
|
@prop = prop
|
42
|
-
# if (form = page.current_form)
|
43
|
-
# @name ||= form.field_name(prop)
|
44
|
-
# @value ||= form.field_value(prop)
|
45
|
-
# end
|
46
|
-
|
47
43
|
end
|
48
44
|
|
49
45
|
# Override
|
50
46
|
def created
|
51
47
|
if @prop && (form = page.current_form)
|
48
|
+
form.field_assert_respond_to(@prop)
|
49
|
+
|
52
50
|
@name ||= form.field_name(@prop, @multiple || false)
|
53
51
|
@value ||= form.field_value(@prop)
|
54
52
|
@label ||= form.field_label(@prop, @label_args || {})
|
@@ -56,7 +54,6 @@ class Glib::JsonUi::ViewBuilder
|
|
56
54
|
@placeholder ||= form.placeholder_label(@prop, @placeholder_args || {})
|
57
55
|
|
58
56
|
@validation ||= form.field_validation(@prop)
|
59
|
-
|
60
57
|
end
|
61
58
|
json.name @name
|
62
59
|
json.value @value if @value
|
@@ -68,7 +65,8 @@ class Glib::JsonUi::ViewBuilder
|
|
68
65
|
# - Placeholder competes with label for space
|
69
66
|
json.placeholder @placeholder if @placeholder
|
70
67
|
|
71
|
-
|
68
|
+
# TODO: Add a flag so the framework's user can turn it on and off.
|
69
|
+
# json.validation @validation if @validation
|
72
70
|
end
|
73
71
|
|
74
72
|
end
|
@@ -16,6 +16,11 @@ class Glib::JsonUi::ViewBuilder
|
|
16
16
|
@model.class.try(:reflect_on_association, prop)&.macro == :has_many
|
17
17
|
end
|
18
18
|
|
19
|
+
def field_assert_respond_to(prop)
|
20
|
+
# Identify a prop being used on a nil model or incorrect model.
|
21
|
+
raise "Invalid property `#{prop}` on '#{@model.class}'" unless @model.respond_to?(prop)
|
22
|
+
end
|
23
|
+
|
19
24
|
def field_name(prop, multiple)
|
20
25
|
suffix = is_array_association?(prop) || multiple ? '[]' : ''
|
21
26
|
"#{@model_name}[#{prop}]#{suffix}"
|