Class: Glib::JsonUi::ViewBuilder::Fields::File
- Inherits:
-
Text
show all
- Includes:
- Upload
- Defined in:
- app/helpers/glib/json_ui/view_builder/fields.rb
Instance Attribute Summary
#json, #page
Instance Method Summary
collapse
#autoValidate, #context, #default_url_options, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #validation, #value
Methods inherited from View
component_name
#initialize, #props
Instance Method Details
315
316
317
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 315
def buttonLabels(obj)
@buttonLabels = ActiveSupport::HashWithIndifferentAccess.new(obj)
end
|
#created ⇒ Object
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 319
def created
@buttonLabels ||= ActiveSupport::HashWithIndifferentAccess.new
@buttonLabels['change'] ||= I18n.t('glib.change') if I18n.exists?('glib.change')
@buttonLabels['upload'] ||= I18n.t('glib.upload') if I18n.exists?('glib.upload')
@buttonLabels['delete'] ||= I18n.t('glib.delete') if I18n.exists?('glib.delete')
json.set! :buttonLabels, @buttonLabels
if @prop && context
if (value = context.field_value(@prop)).attached?
json.fileTitle value.blob.filename
json.fileUrl url_for(value)
end
end
super
end
|
#determine_value(context, prop) ⇒ Object
340
341
342
343
344
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 340
def determine_value(context, prop)
if (value = context.field_value(prop)).attached?
value.signed_id || ''
end
end
|