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

118 lines
2.5 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">
2025-02-02 12:30:01 +02:00
<div class="flex justify-between items-end w-full mb-3.5 md:mb-4">
2023-06-15 01:05:04 +03:00
<label
v-if="showFieldNames"
:for="field.uuid"
2025-03-18 17:34:11 +02:00
class="label text-xl sm:text-2xl py-0 field-name-label"
>
<MarkdownContent
v-if="field.title"
:string="field.title"
/>
<template v-else>
{{ field.name || t('image') }}
</template>
</label>
2023-06-15 01:05:04 +03:00
<button
2026-05-31 09:09:57 +03:00
type="button"
2025-03-18 17:34:11 +02:00
class="btn btn-outline btn-sm reupload-button"
2023-06-15 01:05:04 +03:00
@click.prevent="remove"
>
2026-04-17 14:49:14 +03:00
<IconReload
:width="16"
aria-hidden="true"
/>
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"
2026-04-16 12:41:42 +03:00
:alt="field.name || t('image')"
2025-03-18 17:34:11 +02:00
class="h-52 border border-base-300 rounded mx-auto uploaded-image-preview"
2023-06-15 01:05:04 +03:00
>
</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"
2025-03-18 17:34:11 +02:00
class="mb-3 px-1 field-description-text"
2024-03-09 18:24:21 +02:00
>
<MarkdownContent :string="field.description" />
</div>
2023-05-25 22:47:52 +03:00
<FileDropzone
:message="`${t('upload')} ${(field.title || 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>