Class: Glib::JsonUi::ViewBuilder::Fields::MultiUpload
- Inherits:
-
AbstractField
- Object
- JsonUiElement
- View
- AbstractField
- Glib::JsonUi::ViewBuilder::Fields::MultiUpload
- Includes:
- Default
- Defined in:
- app/helpers/glib/json_ui/view_builder/fields.rb
Instance Attribute Summary
Attributes inherited from JsonUiElement
Instance Method Summary collapse
- #accepts(value) ⇒ Object
- #created ⇒ Object
- #files(values) ⇒ Object
- #responseMessages(values) ⇒ Object
-
#subtitle(value) ⇒ Object
deprecated.
-
#title(value) ⇒ Object
deprecated.
Methods included from Default
Methods inherited from AbstractField
#context, #default_url_options, #determine_value, #hint, #hint_args, #label, #label_args, #name, #placeholder, #placeholder_args, #prop, #value
Methods inherited from View
Methods inherited from JsonUiElement
Constructor Details
This class inherits a constructor from Glib::JsonUi::JsonUiElement
Instance Method Details
#accepts(value) ⇒ Object
349 350 351 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 349 def accepts(value) @accepts = value end |
#created ⇒ Object
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 361 def created super @placeholder ||= I18n.t('common.multi_upload.placeholder', default: nil) @hint ||= I18n.t('common.multi_upload.hint', default: nil) ['200', '403', '401', 'else'].each do |status| key = "common.multi_upload.responseMessages.#{status}" @responseMessages[status] = I18n.t(key) if I18n.exists?(key) end json.responseMessages (@responseMessages || {}).reverse_merge({ '200' => 'File uploaded', '403' => 'Forbidden', '401' => 'Session expired', 'else' => 'Upload failed' }) json.placeholder @placeholder if @placeholder json.hint @hint if @hint json.accepts default_accepts(@accepts) if @prop && context # association = form.nested_associations.last # context = association || form @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
353 354 355 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 353 def files(values) @files = values end |
#responseMessages(values) ⇒ Object
357 358 359 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 357 def responseMessages(values) @responseMessages = values end |
#subtitle(value) ⇒ Object
deprecated
345 346 347 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 345 def subtitle(value) @hint = value end |
#title(value) ⇒ Object
deprecated
340 341 342 |
# File 'app/helpers/glib/json_ui/view_builder/fields.rb', line 340 def title(value) @placeholder = value end |