Class: Glib::JsonUi::ViewBuilder::Fields::MultiUpload
Instance Attribute Summary
#json, #page
Instance Method Summary
collapse
Methods included from Default
#default_accepts
#autoValidate, #context, #default_url_options, #determine_value, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #validation, #value
Methods inherited from View
component_name
#initialize, #props
Instance Method Details
#accepts(value) ⇒ Object
366
367
368
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 366
def accepts(value)
@accepts = value
end
|
#created ⇒ Object
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 378
def created
super
@placeholder ||= I18n.t('glib.multi_upload.placeholder', default: nil)
@hint ||= I18n.t('glib.multi_upload.hint', default: nil)
['200', '403', '401', 'else'].each do |status|
key = "glib.multi_upload.responseMessages.#{status}"
@responseMessages[status] = I18n.t(key) if I18n.exists?(key)
end
json.responseMessages (@responseMessages || {}).reverse_merge({
'200' => 'Completed',
'403' => 'Forbidden',
'401' => 'Session expired',
'else' => 'Failed'
})
json.placeholder @placeholder if @placeholder
json.hint @hint if @hint
json.accepts default_accepts(@accepts)
if @prop && context
@files ||= context.field_value(@prop, collect_ids: false).to_a.map { |file| { name: file.blob&.filename, signed_id: file.signed_id, url: url_for(file) } }
end
json.files @files if @files.present?
end
|
#files(values) ⇒ Object
370
371
372
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 370
def files(values)
@files = values
end
|
#responseMessages(values) ⇒ Object
374
375
376
|
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 374
def responseMessages(values)
@responseMessages = values
end
|