diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 2b0c8d2d..3da4b0c8 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -80,6 +80,8 @@ :editable="editable" :template="template" :is-direct-upload="isDirectUpload" + :is-loading="isLoading" + :is-deleting="isDeleting" @scroll-to="scrollIntoDocument" @add-blank-page="addBlankPage" @remove="onDocumentRemove" @@ -336,7 +338,9 @@ export default { isSaving: false, selectedSubmitter: null, drawField: null, - dragFieldType: null + dragFieldType: null, + isLoading: false, + isDeleting: false } }, computed: { @@ -750,6 +754,7 @@ export default { if (indexToRemove !== -1) { const confirmed = window.confirm('Are you sure you want to delete this image?') if (confirmed) { + this.isDeleting = true const documentId = document.id const apiUrl = `/api/templates/${this.template.id}/documents/${documentId}/del_image` fetch(apiUrl, { @@ -777,6 +782,9 @@ export default { .catch((error) => { console.error('Error:', error) }) + .finally(() => { + this.isDeleting = false + }) } } } @@ -785,6 +793,7 @@ export default { const documentRef = this.documentRefs.find((e) => e.document.uuid === item.attachment_uuid) const confirmed = window.confirm('Are you sure you want to create new image?') if (confirmed) { + this.isLoading = true const documentId = documentRef.document.id const apiUrl = `/api/templates/${this.template.id}/documents/${documentId}/add_new_image` fetch(apiUrl, { @@ -811,6 +820,9 @@ export default { .catch((error) => { console.error('Error: ---', error) }) + .finally(() => { + this.isLoading = false + }) } } } diff --git a/app/javascript/template_builder/preview.vue b/app/javascript/template_builder/preview.vue index 52b13e5f..87110172 100644 --- a/app/javascript/template_builder/preview.vue +++ b/app/javascript/template_builder/preview.vue @@ -84,8 +84,15 @@ @@ -94,9 +101,17 @@
@@ -115,12 +130,14 @@ import Contenteditable from './contenteditable' import Upload from './upload' import ReplaceButton from './replace' +import { IconInnerShadowTop } from '@tabler/icons-vue' export default { name: 'DocumentPreview', components: { Contenteditable, - ReplaceButton + ReplaceButton, + IconInnerShadowTop }, props: { item: { @@ -154,6 +171,16 @@ export default { type: Boolean, required: false, default: true + }, + isLoading: { + type: Boolean, + required: true, + default: false + }, + isDeleting: { + type: Boolean, + required: true, + default: false } }, emits: ['scroll-to', 'change', 'remove', 'up', 'down', 'replace', 'remove-image', 'add-blank-page'],