Files
docuseal/app/javascript/submission_form/image_step.vue
T

103 lines
2.1 KiB
Vue
Raw Normal View History

2023-05-25 22:47:52 +03:00
<template>
2023-06-15 01:05:04 +03:00
<div v-if="modelValue">
<div class="flex justify-between items-center w-full mb-2">
<label
class="label text-2xl"
2024-01-24 23:20:53 +02:00
>{{ showFieldNames && field.name ? field.name : t('image') }}</label>
2023-06-15 01:05:04 +03:00
<button
class="btn btn-outline btn-sm"
@click.prevent="remove"
>
<IconReload :width="16" />
2024-01-26 16:45:32 +02:00
{{ t('reupload') }}
2023-06-15 01:05:04 +03:00
</button>
</div>
<div>
<img
:src="attachmentsIndex[modelValue].url"
class="h-52 border border-base-300 rounded mx-auto"
>
</div>
2023-05-25 22:47:52 +03:00
<input
:value="modelValue"
type="hidden"
:name="`values[${field.uuid}]`"
>
2023-06-15 01:05:04 +03:00
</div>
2024-03-09 18:24:21 +02:00
<div
v-if="!modelValue"
>
<div
v-if="field.description"
dir="auto"
class="mb-3 px-1"
>
<MarkdownContent :string="field.description" />
</div>
2023-05-25 22:47:52 +03:00
<FileDropzone
2024-01-26 16:45:32 +02:00
:message="`${t('upload')} ${field.name || t('image')}${field.required ? '' : ` (${t('optional')})`}`"
2023-06-13 00:29:07 +03:00
:submitter-slug="submitterSlug"
2024-07-02 20:27:25 +03:00
:dry-run="dryRun"
2023-05-25 22:47:52 +03:00
:accept="'image/*'"
@upload="onImageUpload"
/>
</div>
</template>
<script>
import FileDropzone from './dropzone'
2023-06-15 01:05:04 +03:00
import { IconReload } from '@tabler/icons-vue'
2024-03-09 18:24:21 +02:00
import MarkdownContent from './markdown_content'
2023-06-15 01:05:04 +03:00
2023-05-25 22:47:52 +03:00
export default {
name: 'ImageStep',
components: {
2023-06-15 01:05:04 +03:00
FileDropzone,
2024-03-09 18:24:21 +02:00
IconReload,
MarkdownContent
2023-05-25 22:47:52 +03:00
},
2024-01-24 23:20:53 +02:00
inject: ['t'],
2023-05-25 22:47:52 +03:00
props: {
field: {
type: Object,
required: true
},
2024-01-24 23:20:53 +02:00
showFieldNames: {
type: Boolean,
required: false,
default: true
},
2024-07-02 20:27:25 +03:00
dryRun: {
type: Boolean,
required: false,
default: false
},
2023-06-13 00:29:07 +03:00
submitterSlug: {
2023-05-25 22:47:52 +03:00
type: String,
required: true
},
attachmentsIndex: {
type: Object,
required: false,
default: () => ({})
},
modelValue: {
type: String,
required: false,
default: ''
}
},
emits: ['attached', 'update:model-value'],
methods: {
remove () {
this.$emit('update:model-value', '')
},
onImageUpload (attachments) {
this.$emit('attached', attachments[0])
this.$emit('update:model-value', attachments[0].uuid)
}
}
}
</script>