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

118 lines
2.9 KiB
Vue
Raw Normal View History

2024-03-09 18:24:21 +02:00
<template>
<div
class="modal modal-open items-start !animate-none overflow-y-auto"
>
<div
class="absolute top-0 bottom-0 right-0 left-0"
@click.prevent="$emit('close')"
/>
<div class="modal-box pt-4 pb-6 px-6 mt-20 max-h-none w-full max-w-xl">
<div class="flex justify-between items-center border-b pb-2 mb-2 font-medium">
2025-03-18 17:34:11 +02:00
<span class="modal-title">
2026-01-30 09:58:30 +02:00
{{ (defaultField ? (defaultField.title || field.title || field.name) : field.name) || buildDefaultName(field) }}
2024-03-09 18:24:21 +02:00
</span>
<a
href="#"
2025-03-18 17:34:11 +02:00
class="text-xl modal-close-button"
2024-03-09 18:24:21 +02:00
@click.prevent="$emit('close')"
>&times;</a>
</div>
<div>
<form @submit.prevent="saveAndClose">
<div class="space-y-1 mb-1">
<div>
<label
dir="auto"
class="label text-sm"
2024-03-10 12:03:46 +02:00
for="description_field"
2024-03-09 18:24:21 +02:00
>
{{ t('description') }}
</label>
<textarea
id="description_field"
ref="textarea"
v-model="description"
dir="auto"
class="base-textarea !text-base w-full"
2024-04-15 16:34:44 +03:00
:readonly="!editable"
2024-03-09 18:24:21 +02:00
@input="resizeTextarea"
/>
</div>
<div>
<label
dir="auto"
class="label text-sm"
for="title_field"
>
{{ t('display_title') }} ({{ t('optional') }})
</label>
<input
id="title_field"
v-model="title"
dir="auto"
2024-04-15 16:34:44 +03:00
:readonly="!editable"
2024-03-09 18:24:21 +02:00
class="base-input !text-base w-full"
>
</div>
</div>
2025-03-18 17:34:11 +02:00
<button class="base-button w-full mt-4 modal-save-button">
2024-03-09 18:24:21 +02:00
{{ t('save') }}
</button>
</form>
</div>
</div>
</div>
</template>
<script>
export default {
name: 'DescriptionModal',
2026-01-30 21:36:33 +02:00
inject: ['t', 'template'],
2024-03-09 18:24:21 +02:00
props: {
field: {
type: Object,
required: true
},
2025-08-23 21:46:51 +03:00
defaultField: {
type: Object,
required: false,
default: null
},
2024-04-15 16:34:44 +03:00
editable: {
type: Boolean,
required: false,
default: true
},
2024-03-09 18:24:21 +02:00
buildDefaultName: {
type: Function,
required: true
}
},
2026-01-30 21:36:33 +02:00
emits: ['close', 'save'],
2024-03-09 18:24:21 +02:00
data () {
return {
description: this.field.description,
title: this.field.title
}
},
mounted () {
this.resizeTextarea()
},
methods: {
saveAndClose () {
this.field.description = this.description
this.field.title = this.title
2026-01-30 21:36:33 +02:00
this.$emit('save')
2024-03-09 18:24:21 +02:00
this.$emit('close')
},
resizeTextarea () {
const textarea = this.$refs.textarea
textarea.style.height = 'auto'
textarea.style.height = textarea.scrollHeight + 'px'
}
}
}
</script>