Class: Glib::JsonUi::ViewBuilder::Fields::AbstractField
- Inherits:
-
View
show all
- Defined in:
- app/helpers/glib/json_ui/view_builder/fields.rb
Direct Known Subclasses
Autocomplete, CheckGroup, Country, CreditCard, Date, Datetime, DynamicGroup, DynamicSelect, Location, MultipleUpload, Otp, Phone, RadioGroup, Rating, Select, StripeExternalAccount, StripeToken, Submit, Text, TimeZone
Instance Attribute Summary
#json, #page
Instance Method Summary
collapse
Methods inherited from View
component_name
#initialize, #props
Instance Method Details
#created ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 49
def created
if @prop && (form = page.current_form)
association = form.nested_associations.last
context = association || form
context.field_assert_respond_to(@prop)
@name ||= context.field_name(@prop, @multiple || false)
@label ||= context.field_label(@prop, @label_args || {})
@hint ||= context.hint_label(@prop, @hint_args || {})
@placeholder ||= context.placeholder_label(@prop, @placeholder_args || {})
@validation ||= context.field_validation(@prop)
if form.current_dynamic_group.nil?
@value ||= context.field_value(@prop)
end
end
json.name @name
json.value @value if @value
json.label @label if @label
json.hint @hint if @hint
json.placeholder @placeholder if @placeholder
end
|
#hint(hint) ⇒ Object
20
21
22
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 20
def hint(hint)
@hint = hint
end
|
#hint_args(hint_args) ⇒ Object
24
25
26
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 24
def hint_args(hint_args)
@hint_args = hint_args
end
|
#label(label) ⇒ Object
12
13
14
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 12
def label(label)
@label = label
end
|
#label_args(label_args) ⇒ Object
16
17
18
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 16
def label_args(label_args)
@label_args = label_args
end
|
#name(name) ⇒ Object
36
37
38
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 36
def name(name)
@name = name if name != Glib::Value::DEFAULT
end
|
#placeholder(placeholder) ⇒ Object
28
29
30
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 28
def placeholder(placeholder)
@placeholder = placeholder
end
|
#placeholder_args(placeholder_args) ⇒ Object
32
33
34
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 32
def placeholder_args(placeholder_args)
@placeholder_args = placeholder_args
end
|
#prop(prop) ⇒ Object
44
45
46
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 44
def prop(prop)
@prop = prop
end
|
#value(value) ⇒ Object
40
41
42
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 40
def value(value)
@value = value if value != Glib::Value::DEFAULT
end
|