From 72dd2c6bc5b4071d8f1817d11a2890487b48f915 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Wed, 5 Nov 2025 11:59:37 +0200 Subject: [PATCH] add template download --- .../template_documents_controller.rb | 6 + app/javascript/application.js | 1 + app/javascript/template_builder/builder.vue | 107 +++++++++++++++++- app/javascript/template_builder/i18n.js | 14 +++ config/routes.rb | 2 +- 5 files changed, 127 insertions(+), 3 deletions(-) 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/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..5ce17324 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -175,7 +175,10 @@ {{ t('save') }} -