From da21c3725440fe588681a6f5220879e89a70e49e Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Thu, 4 Jun 2026 00:35:04 +0300 Subject: [PATCH] add Google Drive replace option --- app/javascript/template_builder/builder.vue | 4 + app/javascript/template_builder/controls.vue | 13 ++ .../google_drive_picker_modal.vue | 165 ++++++++++++++++++ app/javascript/template_builder/i18n.js | 28 ++- app/javascript/template_builder/preview.vue | 15 +- app/javascript/template_builder/replace.vue | 118 +++++++++++-- app/javascript/template_builder/upload.vue | 151 +++------------- spec/system/template_builder_spec.rb | 2 +- 8 files changed, 351 insertions(+), 145 deletions(-) create mode 100644 app/javascript/template_builder/google_drive_picker_modal.vue diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 7ddd1372..4fe13b4d 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -309,6 +309,8 @@ :data-document-uuid="item.attachment_uuid" :accept-file-types="acceptFileTypes" :with-replace-button="withUploadButton" + :with-google-drive="withGoogleDrive" + :authenticity-token="authenticityToken" :editable="editable" :dynamic-documents="dynamicDocuments" :with-dynamic-documents="withDynamicDocuments" @@ -456,6 +458,8 @@ :with-arrows="template.schema.length > 1" :item="template.schema.find((item) => item.attachment_uuid === document.uuid)" :with-replace-button="withUploadButton" + :with-google-drive="withGoogleDrive" + :authenticity-token="authenticityToken" :accept-file-types="acceptFileTypes" :document="document" :template="template" diff --git a/app/javascript/template_builder/controls.vue b/app/javascript/template_builder/controls.vue index e09397ae..df976002 100644 --- a/app/javascript/template_builder/controls.vue +++ b/app/javascript/template_builder/controls.vue @@ -10,6 +10,9 @@ v-if="withReplaceButton" :template-id="template.id" :accept-file-types="acceptFileTypes" + :authenticity-token="authenticityToken" + :with-google-drive="withGoogleDrive" + :google-drive-file-id="item.google_drive_file_id" @click.stop @success="$emit('replace', { replaceSchemaItem: item, ...$event })" /> @@ -73,6 +76,16 @@ export default { required: true, default: true }, + withGoogleDrive: { + type: Boolean, + required: false, + default: false + }, + authenticityToken: { + type: String, + required: false, + default: '' + }, withArrows: { type: Boolean, required: false, diff --git a/app/javascript/template_builder/google_drive_picker_modal.vue b/app/javascript/template_builder/google_drive_picker_modal.vue new file mode 100644 index 00000000..e4a40f14 --- /dev/null +++ b/app/javascript/template_builder/google_drive_picker_modal.vue @@ -0,0 +1,165 @@ +