Class: KonoUtils::Object::Cell::Forms::Fields::FileField

Inherits:
Base
  • Object
show all
Defined in:
app/concepts/kono_utils/object/cell/forms/fields/file_field.rb

Instance Method Summary collapse

Methods inherited from Base

#_prefixes, #base_class, #concept, #content_for_layout, #content_for_layout?, #destroy_custom_polymorphic_path, #edit_custom_polymorphic_path, #index_custom_polymorphic_path, #kono_user, #legacy_concept, logger, #model_gender, #new_custom_polymorphic_path, #show_custom_polymorphic_path, #title_del, #title_del_g, #title_edit_g, #title_mod, #title_new, #title_new_g, #title_newa, #title_show_g

Methods included from KonoUtilsBootstrapView4::ApplicationIconHelper

#fa_icon, #icon

Instance Method Details

#base_field_optionsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/concepts/kono_utils/object/cell/forms/fields/file_field.rb', line 12

def base_field_options
  download_button = nil
  remove_checkbox = remove_checkbox
  if form.object.send(attribute_name).attached?
    download_button = concept("cell/buttons/download", form.object.send(attribute_name), button_options: { class: 'btn-outline-secondary' })
    if form.object.class.respond_to?(:attribute_purger_name)
      attribute_purger_name = form.object.class.attribute_purger_name(attribute_name)
      if form.object.respond_to?(attribute_purger_name)

        label = form.object.class.han(attribute_purger_name,
                                      default: I18n.t('kono_utils.bootstrap4.forms.fields.file_field.purge_file.label'))

        remove_checkbox = concept("cell/forms/fields/check_box",
                                  KonoUtilsBootstrapView4::EditableField.new(attribute_purger_name),
                                  field_options: { label: label }
        )
      end
    end
  end
  super.merge({ as: :file_input_download, download_button: download_button, remove_checkbox: remove_checkbox })
end

#show(&block) ⇒ Object



8
9
10
# File 'app/concepts/kono_utils/object/cell/forms/fields/file_field.rb', line 8

def show(&block)
  form.input(attribute_name, field_options)
end