Class: GalleryInput
- Inherits:
-
SimpleForm::Inputs::FileInput
- Object
- SimpleForm::Inputs::FileInput
- GalleryInput
- Includes:
- Assetable::Uploaders
- Defined in:
- app/inputs/gallery_input.rb
Instance Method Summary collapse
Methods included from Assetable::Uploaders
#ac, #asset_preview, #directions_html, #gallery_preview
Instance Method Details
#input ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/inputs/gallery_input.rb', line 5 def input # TODO:: Find a better way to do this fieldname = "#{object_name}[#{attribute_name}_attributes][asset_attachments_attributes]" # This is the hidden input that identifies which gallery we are saving # otherwise it will create a new gallery each time. hidden_input = template.hidden_field_tag("#{object_name}[#{attribute_name}_attributes][id]", (object.send(attribute_name).present? ? object.send(attribute_name).id : "")) # This is the hidden inputs for the uploader. Each asset added to the # gallery will use this input name gallery_hidden_input = template.hidden_field_tag(fieldname, nil, class: "assetable-uploader-input") # Gallery preview preview = gallery_preview(fieldname).html_safe rescue "" # Uploader HTML = preview + hidden input uploader_html = template.content_tag(:div, (gallery_hidden_input + preview), class: "uploader-assets-wrapper") # Create and return the uploader html directions = [:directions] uploader_wrapper = template.content_tag :div, (uploader_html + hidden_input + directions_html(directions, attribute_name).html_safe), class: "gallery-uploader" return uploader_wrapper end |