Class: Plutonium::UI::Form::Components::Uppy
- Inherits:
-
Phlexi::Form::Components::Input
- Object
- Phlexi::Form::Components::Input
- Plutonium::UI::Form::Components::Uppy
- Includes:
- Phlexi::Form::Components::Concerns::UploadsFile
- Defined in:
- lib/plutonium/ui/form/components/uppy.rb
Instance Method Summary collapse
Instance Method Details
#view_template ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/plutonium/ui/form/components/uppy.rb', line 10 def view_template div(class: tokens(field.dom.id, "flex flex-col-reverse gap-2")) do div do # Hidden field for ensuring removal of esp. has_one_attached attachments input(type: :hidden, name: attributes[:name], multiple: attributes[:multiple], value: nil, autocomplete: "off", hidden: true) # Always render the preview container — even when empty — so the # `attachment-input` controller's `attachment-preview-container` # OUTLET exists on a fresh (valueless) field. Without it the FIRST # upload can't inject its preview: Stimulus raises on the missing # outlet and the uploaded token never reaches the form. div( class: "attachment-preview-container grid grid-cols-[repeat(auto-fill,minmax(0,180px))] gap-4", data_controller: "attachment-preview-container" ) do unless field.value.nil? end end div(class: "attachment-input") do input( **, **attributes, class: tokens(@input_class, attributes[:class]) ) end end end |