Class: Glib::JsonUi::ViewBuilder::Fields::File
- Inherits:
-
Text
show all
- Defined in:
- app/helpers/glib/json_ui/view_builder/fields.rb
Instance Attribute Summary
#json, #page
Instance Method Summary
collapse
#context, #default_url_options, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #value
Methods inherited from View
component_name
#initialize, #props
Instance Method Details
293
294
295
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 293
def buttonLabels(obj)
@buttonLabels = ActiveSupport::HashWithIndifferentAccess.new(obj)
end
|
#created ⇒ Object
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 297
def created
@buttonLabels ||= ActiveSupport::HashWithIndifferentAccess.new
@buttonLabels['change'] ||= I18n.t('common.change') if I18n.exists?('common.change')
@buttonLabels['upload'] ||= I18n.t('common.upload') if I18n.exists?('common.upload')
@buttonLabels['delete'] ||= I18n.t('common.delete') if I18n.exists?('common.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
318
319
320
321
322
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 318
def determine_value(context, prop)
if (value = context.field_value(prop)).attached?
value.signed_id || ''
end
end
|