diff --git a/app/controllers/template_documents_controller.rb b/app/controllers/template_documents_controller.rb index cfca1297..b29a18f6 100644 --- a/app/controllers/template_documents_controller.rb +++ b/app/controllers/template_documents_controller.rb @@ -3,6 +3,12 @@ class TemplateDocumentsController < ApplicationController load_and_authorize_resource :template + FILES_TTL = 5.minutes + + def index + render json: @template.schema_documents.map { |d| ActiveStorage::Blob.proxy_url(d.blob, expires_at: FILES_TTL.from_now.to_i) } + end + def create if params[:blobs].blank? && params[:files].blank? return render json: { error: I18n.t('file_is_missing') }, status: :unprocessable_content diff --git a/app/controllers/templates_debug_controller.rb b/app/controllers/templates_debug_controller.rb index edaedff0..4ff31835 100644 --- a/app/controllers/templates_debug_controller.rb +++ b/app/controllers/templates_debug_controller.rb @@ -17,7 +17,7 @@ class TemplatesDebugController < ApplicationController fields = Templates::FindAcroFields.call(pdf, attachment, data) end - fields = Templates::DetectFields.call(StringIO.new(data), attachment:) if fields.blank? + fields, = Templates::DetectFields.call(StringIO.new(data), attachment:) if fields.blank? attachment.metadata['pdf'] ||= {} attachment.metadata['pdf']['fields'] = fields diff --git a/app/javascript/application.js b/app/javascript/application.js index 9b17172b..b839039d 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -167,6 +167,7 @@ safeRegisterElement('template-builder', class extends HTMLElement { withConditions: this.dataset.withConditions === 'true', withGoogleDrive: this.dataset.withGoogleDrive === 'true', withReplaceAndCloneUpload: true, + withDownload: true, currencies: (this.dataset.currencies || '').split(',').filter(Boolean), acceptFileTypes: this.dataset.acceptFileTypes, showTourStartForm: this.dataset.showTourStartForm === 'true' diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index bcf376ac..76826eb5 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -175,7 +175,10 @@ {{ t('save') }} -