Sha256: b15015887e94a2ddf3491b6087049ff8278c63f60fc6fcf1c87d08f4acf30b59

Contents?: true

Size: 1.53 KB

Versions: 12

Compression:

Stored size: 1.53 KB

Contents

module KonoUtils
  module Object
    module Cell
      module Forms # namespace
        module Fields
          class FileField < Base

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

            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

          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kono_utils_bootstrap_view4-0.3.2 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.3.1 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.3 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.2.3 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.2.2 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.2.1 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.2 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.1.2 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.1.1 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.1.0 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.1.0.pre.rc.7 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb
kono_utils_bootstrap_view4-0.1.0.pre.rc.4 app/concepts/kono_utils/object/cell/forms/fields/file_field.rb