mirror of https://github.com/docusealco/docuseal
parent
effa7b0fc7
commit
ec4f399fcc
@ -0,0 +1,18 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class TemplatesUploadsController < ApplicationController
|
||||||
|
def create
|
||||||
|
template = current_account.templates.new(author: current_user)
|
||||||
|
template.name = File.basename(params[:files].first.original_filename, '.*')
|
||||||
|
|
||||||
|
template.save!
|
||||||
|
|
||||||
|
documents = Templates::CreateAttachments.call(template, params)
|
||||||
|
|
||||||
|
schema = documents.map { |doc| { attachment_uuid: doc.uuid, name: doc.filename.base } }
|
||||||
|
|
||||||
|
template.update!(schema:)
|
||||||
|
|
||||||
|
redirect_to edit_template_path(template)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
After Width: | Height: | Size: 416 B |
@ -0,0 +1,17 @@
|
|||||||
|
<%= form_for '', url: templates_upload_path, method: :post, class: 'inline', html: { enctype: 'multipart/form-data' } do %>
|
||||||
|
<button type="submit" class="btn btn-ghost text-base" onclick="[event.preventDefault(), window.upload_template.click()]">
|
||||||
|
<span class="enabled">
|
||||||
|
<span class="flex items-center justify-center space-x-2">
|
||||||
|
<%= svg_icon('upload', class: 'w-6 h-6 stroke-2') %>
|
||||||
|
<span class="hidden md:block">Upload</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span class="disabled">
|
||||||
|
<span class="flex items-center justify-center space-x-2">
|
||||||
|
<%= local_assigns[:icon_disabled] || svg_icon('loader', class: 'w-5 h-5 animate-spin') %>
|
||||||
|
<span class="hidden md:block">Uploading...</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
<input id="upload_template" name="files[]" class="hidden" onchange="this.form.requestSubmit()" type="file" accept="image/*, application/pdf<%= ', .docx, .doc, .xlsx, .xls' if Docuseal.multitenant? %>" multiple>
|
||||||
|
<% end %>
|
||||||
Loading…
Reference in new issue