Sha256: 50a80f38ad0aba16c44e04208dbfa64e448a9eb77734f930bc99555bae14c7e4
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
module Releaf::Builders::FormBuilder::FileFields def releaf_image_field(name, input: {}, label: {}, field: {}, options: {}, &block) name = name.to_s.sub(/_uid$/, '') attributes = { accept: 'image/png,image/jpeg,image/bmp,image/gif' }.merge(input) attributes = input_attributes(name, attributes, options) options = {field: {type: "image"}}.deep_merge(options) content = file_field(name, attributes) if object.send(name).present? content += tag(:div, class: "value-preview") do inner_content = tag(:div, class: "image-wrap") do thumbnail = image_tag(object.send(name).thumb('400x400>').url, alt: '') hidden_field("retained_#{name}") + link_to(thumbnail, object.send(name).url, target: :_blank, class: :ajaxbox, rel: :image) end inner_content << releaf_file_remove_button(name) end end input_wrapper_with_label(name, content, label: label, field: field, options: options, &block) end def releaf_file_remove_button(name) tag(:div, class: "remove") do check_box("remove_#{name}") << label("remove_#{name}", t("Remove")) end end def releaf_file_field(name, input: {}, label: {}, field: {}, options: {}, &block) name = name.to_s.sub(/_uid$/, '') attributes = input_attributes(name, input, options) options = {field: {type: "file"}}.deep_merge(options) content = file_field(name, attributes) if object.send(name).present? content << hidden_field("retained_#{name}") content << link_to(t("Download"), object.send(name).url, target: "_blank") content << releaf_file_remove_button(name) end input_wrapper_with_label(name, content, label: label, field: field, options: options, &block) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
releaf-core-3.1.0 | app/builders/releaf/builders/form_builder/file_fields.rb |
releaf-core-3.0.3 | app/builders/releaf/builders/form_builder/file_fields.rb |