Sha256: b1f0d354bd5a634a85abf0851fb2339d1634747b0801143c2dc4fcaf795fa65f

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

# FileMaterialInput
class FileMaterialInput < SimpleForm::Inputs::Base
  def input(_wrapper_options = nil)
    template.content_tag(:div, file_input, class: 'btn') +
      template.content_tag(
        :div,
        file_path,
        class: 'file-path-wrapper',
        id: "file-#{attribute_name}"
      )
  end

  private

  def file_input
    template.content_tag(:span, t("activerecord.attributes.#{attribute_name}").humanize) +
      @builder.file_field(attribute_name)
  end

  def file_path
    template.content_tag(
      :input,
      nil,
      class: 'file-path validate',
      type: 'text',
      value: object_value(object)
    )
  end

  def object_value(object)
    object.send(attribute_name).file&.filename
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
keppler-2.0.2 installer/core/app/inputs/file_material_input.rb
keppler-2.0.1 installer/core/app/inputs/file_material_input.rb
keppler-2.0.0 installer/core/app/inputs/file_material_input.rb