|
|
|
|
@ -177,7 +177,7 @@
|
|
|
|
|
@change="save"
|
|
|
|
|
/>
|
|
|
|
|
<div
|
|
|
|
|
class="sticky bottom-0 py-2"
|
|
|
|
|
class="sticky bottom-0 py-2 space-y-2"
|
|
|
|
|
:style="{ backgroundColor }"
|
|
|
|
|
>
|
|
|
|
|
<Upload
|
|
|
|
|
@ -186,6 +186,22 @@
|
|
|
|
|
:template-id="template.id"
|
|
|
|
|
@success="updateFromUpload"
|
|
|
|
|
/>
|
|
|
|
|
<button
|
|
|
|
|
v-if="sortedDocuments.length && editable && withAddPageButton"
|
|
|
|
|
id="add_blank_page_button"
|
|
|
|
|
class="btn btn-outline w-full"
|
|
|
|
|
@click.prevent="addBlankPage"
|
|
|
|
|
>
|
|
|
|
|
<IconInnerShadowTop
|
|
|
|
|
v-if="isLoadingBlankPage"
|
|
|
|
|
class="animate-spin w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
<IconPlus
|
|
|
|
|
v-else
|
|
|
|
|
class="w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
{{ t('add_blank_page') }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div
|
|
|
|
|
@ -196,12 +212,30 @@
|
|
|
|
|
ref="documents"
|
|
|
|
|
class="pr-3.5 pl-0.5"
|
|
|
|
|
>
|
|
|
|
|
<Dropzone
|
|
|
|
|
v-if="!sortedDocuments.length && withUploadButton"
|
|
|
|
|
:template-id="template.id"
|
|
|
|
|
:accept-file-types="acceptFileTypes"
|
|
|
|
|
@success="updateFromUpload"
|
|
|
|
|
/>
|
|
|
|
|
<template v-if="!sortedDocuments.length && (withUploadButton || withAddPageButton)">
|
|
|
|
|
<Dropzone
|
|
|
|
|
v-if="withUploadButton"
|
|
|
|
|
:template-id="template.id"
|
|
|
|
|
:accept-file-types="acceptFileTypes"
|
|
|
|
|
@success="updateFromUpload"
|
|
|
|
|
/>
|
|
|
|
|
<button
|
|
|
|
|
v-if="withAddPageButton"
|
|
|
|
|
id="add_blank_page_button"
|
|
|
|
|
class="btn btn-outline w-full mt-4"
|
|
|
|
|
@click.prevent="addBlankPage"
|
|
|
|
|
>
|
|
|
|
|
<IconInnerShadowTop
|
|
|
|
|
v-if="isLoadingBlankPage"
|
|
|
|
|
class="animate-spin w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
<IconPlus
|
|
|
|
|
v-else
|
|
|
|
|
class="w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
{{ t('add_blank_page') }}
|
|
|
|
|
</button>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
|
|
|
|
<template
|
|
|
|
|
v-for="document in sortedDocuments"
|
|
|
|
|
@ -242,7 +276,7 @@
|
|
|
|
|
</template>
|
|
|
|
|
<div
|
|
|
|
|
v-if="sortedDocuments.length && isBreakpointLg && editable"
|
|
|
|
|
class="pb-4"
|
|
|
|
|
class="pb-4 space-y-2"
|
|
|
|
|
>
|
|
|
|
|
<Upload
|
|
|
|
|
v-if="withUploadButton"
|
|
|
|
|
@ -250,6 +284,22 @@
|
|
|
|
|
:accept-file-types="acceptFileTypes"
|
|
|
|
|
@success="updateFromUpload"
|
|
|
|
|
/>
|
|
|
|
|
<button
|
|
|
|
|
v-if="withAddPageButton"
|
|
|
|
|
id="add_blank_page_button"
|
|
|
|
|
class="btn btn-outline w-full mt-4"
|
|
|
|
|
@click.prevent="addBlankPage"
|
|
|
|
|
>
|
|
|
|
|
<IconInnerShadowTop
|
|
|
|
|
v-if="isLoadingBlankPage"
|
|
|
|
|
class="animate-spin w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
<IconPlus
|
|
|
|
|
v-else
|
|
|
|
|
class="w-5 h-5"
|
|
|
|
|
/>
|
|
|
|
|
{{ t('add_blank_page') }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</div>
|
|
|
|
|
@ -350,7 +400,7 @@ import Contenteditable from './contenteditable'
|
|
|
|
|
import DocumentPreview from './preview'
|
|
|
|
|
import DocumentControls from './controls'
|
|
|
|
|
import MobileFields from './mobile_fields'
|
|
|
|
|
import { IconUsersPlus, IconDeviceFloppy, IconChevronDown, IconEye, IconWritingSign, IconInnerShadowTop, IconInfoCircle } from '@tabler/icons-vue'
|
|
|
|
|
import { IconPlus, IconUsersPlus, IconDeviceFloppy, IconChevronDown, IconEye, IconWritingSign, IconInnerShadowTop, IconInfoCircle } from '@tabler/icons-vue'
|
|
|
|
|
import { v4 } from 'uuid'
|
|
|
|
|
import { ref, computed } from 'vue'
|
|
|
|
|
import { en as i18nEn } from './i18n'
|
|
|
|
|
@ -363,6 +413,7 @@ export default {
|
|
|
|
|
Fields,
|
|
|
|
|
IconInfoCircle,
|
|
|
|
|
MobileDrawField,
|
|
|
|
|
IconPlus,
|
|
|
|
|
IconWritingSign,
|
|
|
|
|
MobileFields,
|
|
|
|
|
Logo,
|
|
|
|
|
@ -420,6 +471,11 @@ export default {
|
|
|
|
|
required: false,
|
|
|
|
|
default: true
|
|
|
|
|
},
|
|
|
|
|
withAddPageButton: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: false,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
|
|
|
|
autosave: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
required: false,
|
|
|
|
|
@ -566,6 +622,7 @@ export default {
|
|
|
|
|
return {
|
|
|
|
|
documentRefs: [],
|
|
|
|
|
isBreakpointLg: false,
|
|
|
|
|
isLoadingBlankPage: false,
|
|
|
|
|
isSaving: false,
|
|
|
|
|
selectedSubmitter: null,
|
|
|
|
|
showDrawField: false,
|
|
|
|
|
@ -1148,6 +1205,35 @@ export default {
|
|
|
|
|
|
|
|
|
|
document.activeElement?.blur()
|
|
|
|
|
},
|
|
|
|
|
addBlankPage () {
|
|
|
|
|
this.isLoadingBlankPage = true
|
|
|
|
|
|
|
|
|
|
const canvas = document.createElement('canvas')
|
|
|
|
|
|
|
|
|
|
canvas.width = 816
|
|
|
|
|
canvas.height = 1056
|
|
|
|
|
|
|
|
|
|
const ctx = canvas.getContext('2d')
|
|
|
|
|
|
|
|
|
|
ctx.fillStyle = 'white'
|
|
|
|
|
ctx.fillRect(0, 0, canvas.width, canvas.height)
|
|
|
|
|
|
|
|
|
|
canvas.toBlob((blob) => {
|
|
|
|
|
const file = new File([blob], `Page ${this.template.schema.length + 1}.png`, { type: blob.type, lastModified: Date.now() })
|
|
|
|
|
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('files[]', file)
|
|
|
|
|
|
|
|
|
|
this.baseFetch(`/templates/${this.template.id}/documents`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData
|
|
|
|
|
}).then(async (resp) => {
|
|
|
|
|
this.updateFromUpload(await resp.json())
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
this.isLoadingBlankPage = false
|
|
|
|
|
})
|
|
|
|
|
}, 'image/png')
|
|
|
|
|
},
|
|
|
|
|
updateFromUpload (data) {
|
|
|
|
|
this.template.schema.push(...data.schema)
|
|
|
|
|
this.template.documents.push(...data.documents)
|
|
|
|
|
|