Sha256: 5a084145f88ae974b765eae7f22deb43f3d251d06af9ae723edc275ca7cca8dd

Contents?: true

Size: 1.47 KB

Versions: 33

Compression:

Stored size: 1.47 KB

Contents

<% file_types = configuration(:uploader)['allowed_filetypes'][object.class.model_name.collection] || ['*'] %>
<% accept = file_types == ["*"] ? false : file_types.map {|type| ".#{type}"}.join(", ") %>

<alchemy-uploader dropzone="<%= local_assigns[:dropzone] || "#main_content" %>">
  <%= form_for [:admin, object], html: { multipart: true, class: 'upload-button' } do |f| %>
    <%= f.file_field file_attribute,
      class: 'fileupload fileupload--field', multiple: true, accept: accept,
      name: "#{f.object_name}[#{file_attribute}]", tabindex: '-1' %>
    <%= hidden_field_tag("#{f.object_name}[upload_hash]", Time.current.hash) if object.respond_to?(:upload_hash) %>
    <%= f.label file_attribute, data: { alchemy_hotkey: 'alt+n' } do %>
      <%= content_tag "sl-tooltip", content: local_assigns[:label] ||
                Alchemy.t(:button_label, scope: [:uploader, object.class.model_name.i18n_key]), placement: "top-start" do %>
        <span class="icon_button" tabindex="0"><%= render_icon "upload-2" %></span>
      <% end %>
    <% end %>
  <% end %>
</alchemy-uploader>

<script type='text/javascript'>
  document.querySelector("alchemy-uploader").addEventListener("Alchemy.upload.successful", (evt) => {
    setTimeout(() => {
      var url = '<%= redirect_url.html_safe %>';
      evt.target.uploadProgress.visible = false;
      <% if local_assigns[:in_dialog] %>
      $.get(url, null, null, 'script');
      <% else %>
      Turbo.visit(url);
      <% end %>
    }, 1000)
  })
</script>

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
alchemy_cms-7.4.2 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.6 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.9 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.4.1 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.4.0 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.5 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.8 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.1.13 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.4 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.3 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.2 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.7 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.1 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.3.0 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.6 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.5 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.1.12 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.4 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.1.11 app/views/alchemy/admin/uploader/_button.html.erb
alchemy_cms-7.2.3 app/views/alchemy/admin/uploader/_button.html.erb