Class: ActionAdmin::AttachmentInput
- Inherits:
-
SimpleForm::Inputs::Base
- Object
- SimpleForm::Inputs::Base
- ActionAdmin::AttachmentInput
- Defined in:
- app/inputs/action_admin/attachment_input.rb
Instance Method Summary collapse
- #attachment(image_url = nil) ⇒ Object
- #attachment_url ⇒ Object
- #empty_input ⇒ Object
- #hidden_input ⇒ Object
- #input(wrapper_options) ⇒ Object
- #input_html_id ⇒ Object
- #input_placeholder ⇒ Object
- #input_template ⇒ Object
- #label(wrapper_options) ⇒ Object
Instance Method Details
#attachment(image_url = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'app/inputs/action_admin/attachment_input.rb', line 36 def (image_url=nil) image = content_tag :img, nil, src: image_url, class: 'width-100 margin-bottom-1', data: { src: 'file.preview.url', url: "#{template.root_url.chomp('/')}[src]" } remove = content_tag :a, 'Remove', class: 'button alert small hollow margin-0', data: { remove: '' } change = content_tag :a, 'Change', class: 'button success small hollow margin-0', data: { open: input_html_id } remove = content_tag :div, remove, class: 'cell auto text-left' change = content_tag :div, change, class: 'cell shrink' = content_tag :div, remove + change, class: 'panel-section expanded border last grid-x' content_tag :div, hidden_input + image + , class: 'attachment text-center', data: { list_item: '' } end |
#attachment_url ⇒ Object
32 33 34 |
# File 'app/inputs/action_admin/attachment_input.rb', line 32 def object.send(attribute_name).try(:file_url, :preview) end |
#empty_input ⇒ Object
20 21 22 |
# File 'app/inputs/action_admin/attachment_input.rb', line 20 def empty_input @builder.hidden_field(:"#{attribute_name}_id", value: '', id: nil) end |
#hidden_input ⇒ Object
24 25 26 |
# File 'app/inputs/action_admin/attachment_input.rb', line 24 def hidden_input @builder.hidden_field(:"#{attribute_name}_id", data: { value: :id }) end |
#input(wrapper_options) ⇒ Object
3 4 5 6 7 8 |
# File 'app/inputs/action_admin/attachment_input.rb', line 3 def input() modal = .fetch :modal, 'media-modal' html = content_tag :div, input_placeholder, id: input_html_id, data: { media_attach: modal } html + input_template end |
#input_html_id ⇒ Object
28 29 30 |
# File 'app/inputs/action_admin/attachment_input.rb', line 28 def input_html_id hidden_input[/id=\"(.*)\"/, 1].dasherize end |
#input_placeholder ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/inputs/action_admin/attachment_input.rb', line 10 def input_placeholder span = content_tag :span, 'No thumbnail', class: 'margin-bottom-1' icon = content_tag :i, nil, class: 'mdi mdi-camera-off' = content_tag :a, 'Add Thumbnail', data: { open: input_html_id }, class: 'button success small hollow margin-0' content = content_tag :div, empty_input + icon + span + , class: 'no-content hide', data: { empty_state: '' } image = () if .present? content + content_tag(:div, image, data: { list_remove: '' }, class: 'attachments') end |
#input_template ⇒ Object
47 48 49 |
# File 'app/inputs/action_admin/attachment_input.rb', line 47 def input_template content_tag :script, , id: "#{input_html_id}-item-template", type: 'text/template' end |
#label(wrapper_options) ⇒ Object
51 52 53 |
# File 'app/inputs/action_admin/attachment_input.rb', line 51 def label() '' end |