47
48
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
80
81
82
|
# File 'app/avo/resources/db_config.rb', line 47
def fields
field :id, as: :id
field :key
if record.present?
field :value, as: VALUE_TYPE_CONVERSIONS[record.value_type], update_using: ->{
return value unless record.value_type == "Boolean"
case value
when "1"
"true"
when "0"
"false"
else
value
end
}, visible: -> { !resource.view.new? }
else
field :value, visible: -> { !resource.view.new? }
end
field :value_type,
as: :select,
name: "Type",
options: DBConfig::Record::VALUE_TYPES, disabled: -> { record.persisted? },
help: -> {
return if !record.persisted?
path, data = Avo::Resources::DbConfig::ForceChangeType.link_arguments(resource: resource)
"Can't change the type of a configuration that has already been set.<br>
Click #{link_to("here", path, data: data).html_safe} to force the type change."
}
field :eager_load, as: :boolean
end
|