add template upload button
This commit is contained in:
@@ -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
|
||||
@@ -350,7 +350,7 @@ export default {
|
||||
onWindowResize (e) {
|
||||
const breakpointLg = 1024
|
||||
|
||||
this.isBreakpointLg = this.$el.getRootNode().querySelector('div').offsetWidth < breakpointLg
|
||||
this.isBreakpointLg = this.$el.getRootNode().querySelector('div[data-v-app]').offsetWidth < breakpointLg
|
||||
},
|
||||
setDocumentRefs (el) {
|
||||
if (el) {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<% if Docuseal.demo? %><%= render 'shared/demo_alert' %><% end %>
|
||||
<% if @templates.any? %>
|
||||
<div class="flex justify-between mb-4 items-center">
|
||||
<h1 class="text-4xl font-bold">Templates</h1>
|
||||
<%= link_to new_template_path, class: 'btn btn-primary text-base btn-md gap-2', data: { turbo_frame: :modal } do %>
|
||||
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
|
||||
<span class="hidden md:block">Create</span>
|
||||
<% end %>
|
||||
<h1 class="text-4xl font-bold"><span class="hidden md:inline">Document</span> Templates</h1>
|
||||
<div class="flex space-x-2">
|
||||
<%= render 'templates/upload_button' %>
|
||||
<%= link_to new_template_path, class: 'btn btn-primary text-base btn-md gap-2', data: { turbo_frame: :modal } do %>
|
||||
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
|
||||
<span class="hidden md:block">Create</span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid gap-4 md:grid-cols-3">
|
||||
<% @templates.each do |template| %>
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="<%= local_assigns[:class] %>" width="44" height="44" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
|
||||
<path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2"></path>
|
||||
<path d="M7 9l5 -5l5 5"></path>
|
||||
<path d="M12 4l0 12"></path>
|
||||
</svg>
|
||||
|
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 %>
|
||||
@@ -1,4 +1,4 @@
|
||||
<%= render 'shared/turbo_modal', title: @base_template ? 'Clone Template' : 'New Template' do %>
|
||||
<%= render 'shared/turbo_modal', title: @base_template ? 'Clone Template' : 'New Document Template' do %>
|
||||
<%= form_for @template, data: { turbo_frame: :_top } do |f| %>
|
||||
<% if @base_template %>
|
||||
<%= hidden_field_tag :base_template_id, @base_template.id %>
|
||||
|
||||
@@ -47,6 +47,7 @@ Rails.application.routes.draw do
|
||||
resources :users, only: %i[new create edit update destroy]
|
||||
resources :submissions, only: %i[show destroy]
|
||||
resources :console_redirect, only: %i[index]
|
||||
resource :templates_upload, only: %i[create]
|
||||
resources :templates, only: %i[new create edit show destroy] do
|
||||
resources :submissions, only: %i[new create]
|
||||
resources :submissions_export, only: %i[index new]
|
||||
|
||||
Reference in New Issue
Block a user