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, #disableDirtyCheck, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #validation, #value
Methods inherited from View
component_name
#initialize, #props
Instance Method Details
348
349
350
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 348
def buttonLabels(obj)
@buttonLabels = ActiveSupport::HashWithIndifferentAccess.new(obj)
end
|
#created ⇒ Object
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 352
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
373
374
375
376
377
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 373
def determine_value(context, prop)
if (value = context.field_value(prop)).attached?
value.signed_id || ''
end
end
|