Class: Plutonium::UI::Form::Components::Uppy

Inherits:
Phlexi::Form::Components::Input
  • Object
show all
Includes:
Phlexi::Form::Components::Concerns::UploadsFile
Defined in:
lib/plutonium/ui/form/components/uppy.rb

Instance Method Summary collapse

Instance Method Details

#view_templateObject



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
# 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)

      next if field.value.nil?

      div(
        class: "attachment-preview-container grid grid-cols-[repeat(auto-fill,minmax(0,180px))] gap-4",
        data_controller: "attachment-preview-container"
      ) do
        render_existing_attachments
      end
    end

    div(class: "attachment-input") do
      input(
        **build_direct_upload_options,
        **attributes,
        class: tokens(@input_class, attributes[:class])
      )
    end
  end
end