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, ChipGroup, Country, CreditCard, Date, Datetime, DynamicGroup, DynamicSelect, Location, MultiUpload, 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
#context ⇒ Object
89
90
91
92
93
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 89
def context
form = page.current_form
association = form.nested_associations.last
@context ||= association || form
end
|
#created ⇒ Object
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
80
81
82
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 55
def created
if @prop && (form = page.current_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 ||= determine_value(context, @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
|
#default_url_options ⇒ Object
14
15
16
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 14
def default_url_options
{ only_path: true }
end
|
#determine_value(context, prop) ⇒ Object
85
86
87
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 85
def determine_value(context, prop)
context.field_value(prop)
end
|
#hint(hint) ⇒ Object
26
27
28
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 26
def hint(hint)
@hint = hint
end
|
#hint_args(hint_args) ⇒ Object
30
31
32
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 30
def hint_args(hint_args)
@hint_args = hint_args
end
|
#label(label) ⇒ Object
18
19
20
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 18
def label(label)
@label = label
end
|
#label_args(label_args) ⇒ Object
22
23
24
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 22
def label_args(label_args)
@label_args = label_args
end
|
#name(name) ⇒ Object
42
43
44
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 42
def name(name)
@name = name if name != Glib::Value::DEFAULT
end
|
#placeholder(placeholder) ⇒ Object
34
35
36
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 34
def placeholder(placeholder)
@placeholder = placeholder
end
|
#placeholder_args(placeholder_args) ⇒ Object
38
39
40
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 38
def placeholder_args(placeholder_args)
@placeholder_args = placeholder_args
end
|
#prop(prop) ⇒ Object
50
51
52
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 50
def prop(prop)
@prop = prop
end
|
#value(value) ⇒ Object
46
47
48
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 46
def value(value)
@value = value if value != Glib::Value::DEFAULT
end
|