Files
docuseal/app/javascript/template_builder/document.vue
T

72 lines
1.4 KiB
Vue
Raw Normal View History

2023-05-21 17:59:36 +03:00
<template>
2023-05-31 00:50:43 +03:00
<div>
<Page
v-for="(image, index) in sortedPreviewImages"
:key="image.id"
2023-06-03 00:53:46 +03:00
:ref="setPageRefs"
2023-05-31 00:50:43 +03:00
:number="index"
:areas="areasIndex[index]"
:is-draw="isDraw"
:is-drag="isDrag"
:image="image"
@drop-field="$emit('drop-field', {...$event, attachment_uuid: document.uuid })"
@draw="$emit('draw', {...$event, attachment_uuid: document.uuid })"
/>
</div>
2023-05-21 17:59:36 +03:00
</template>
<script>
import Page from './page'
export default {
2023-05-31 23:19:20 +03:00
name: 'TemplateDocument',
2023-05-21 17:59:36 +03:00
components: {
Page
},
props: {
document: {
type: Object,
required: true
},
areasIndex: {
type: Object,
required: false,
default: () => ({})
},
isDraw: {
type: Boolean,
required: false,
default: false
2023-05-23 00:03:26 +03:00
},
isDrag: {
type: Boolean,
required: false,
default: false
2023-05-21 17:59:36 +03:00
}
},
2023-05-23 00:03:26 +03:00
emits: ['draw', 'drop-field'],
2023-06-03 00:53:46 +03:00
data () {
return {
pageRefs: []
}
},
2023-05-21 17:59:36 +03:00
computed: {
sortedPreviewImages () {
return [...this.document.preview_images].sort((a, b) => parseInt(a.filename) - parseInt(b.filename))
}
2023-06-03 00:53:46 +03:00
},
beforeUpdate () {
this.pageRefs = []
},
methods: {
scrollToArea (area) {
this.pageRefs[area.page].areaRefs.find((e) => e.bounds === area).$el.scrollIntoView({ behavior: 'smooth', block: 'center' })
},
setPageRefs (el) {
if (el) {
this.pageRefs.push(el)
}
}
2023-05-21 17:59:36 +03:00
}
}
</script>