2024-03-28 18:14:30 +01:00
|
|
|
<template>
|
2024-04-15 19:39:03 +02:00
|
|
|
<IntegrationWrapper
|
|
|
|
|
v-model="props.integrationData"
|
|
|
|
|
:integration="props.integration"
|
|
|
|
|
:form="form"
|
|
|
|
|
>
|
2024-03-28 18:14:30 +01:00
|
|
|
<div>{{ emailSubmissionConfirmationHelp }}</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="emailSubmissionConfirmationField">
|
2024-04-15 19:39:03 +02:00
|
|
|
<text-input
|
|
|
|
|
:form="integrationData"
|
|
|
|
|
name="settings.notification_sender"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
required
|
2024-03-28 18:14:30 +01:00
|
|
|
label="Confirmation Email Sender Name"
|
2024-04-15 19:39:03 +02:00
|
|
|
help="Emails will be sent from our email address but you can customize the name of the Sender"
|
|
|
|
|
/>
|
|
|
|
|
<text-input
|
|
|
|
|
:form="integrationData"
|
|
|
|
|
name="settings.notification_subject"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
required
|
|
|
|
|
label="Confirmation email subject"
|
|
|
|
|
help="Subject of the confirmation email that will be sent"
|
|
|
|
|
/>
|
|
|
|
|
<rich-text-area-input
|
|
|
|
|
:form="integrationData"
|
|
|
|
|
name="settings.notification_body"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
required
|
|
|
|
|
label="Confirmation email content"
|
|
|
|
|
help="Content of the confirmation email that will be sent"
|
|
|
|
|
/>
|
|
|
|
|
<text-input
|
|
|
|
|
:form="integrationData"
|
|
|
|
|
name="settings.confirmation_reply_to"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
label="Confirmation Reply To"
|
|
|
|
|
help="If empty, Reply-to will be your own email."
|
|
|
|
|
/>
|
|
|
|
|
<toggle-switch-input
|
|
|
|
|
:form="integrationData"
|
|
|
|
|
name="settings.notifications_include_submission"
|
|
|
|
|
class="mt-4"
|
|
|
|
|
label="Include submission data"
|
|
|
|
|
help="If enabled the confirmation email will contain form submission answers"
|
|
|
|
|
/>
|
2024-03-28 18:14:30 +01:00
|
|
|
</div>
|
|
|
|
|
</IntegrationWrapper>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import IntegrationWrapper from "./components/IntegrationWrapper.vue"
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
integration: { type: Object, required: true },
|
|
|
|
|
form: { type: Object, required: true },
|
|
|
|
|
integrationData: { type: Object, required: true },
|
2024-04-15 19:39:03 +02:00
|
|
|
formIntegrationId: { type: Number, required: false, default: null },
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const emailSubmissionConfirmationField = computed(() => {
|
2024-04-15 19:39:03 +02:00
|
|
|
if (!props.form.properties || !Array.isArray(props.form.properties))
|
|
|
|
|
return null
|
2024-03-28 18:14:30 +01:00
|
|
|
const emailFields = props.form.properties.filter((field) => {
|
2024-04-15 19:39:03 +02:00
|
|
|
return field.type === "email" && !field.hidden
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
if (emailFields.length === 1) return emailFields[0]
|
|
|
|
|
return null
|
|
|
|
|
})
|
|
|
|
|
const emailSubmissionConfirmationHelp = computed(() => {
|
|
|
|
|
if (emailSubmissionConfirmationField.value) {
|
2024-04-15 19:39:03 +02:00
|
|
|
return (
|
|
|
|
|
'Confirmation will be sent to the email in the "' +
|
|
|
|
|
emailSubmissionConfirmationField.value.name +
|
|
|
|
|
'" field.'
|
|
|
|
|
)
|
2024-03-28 18:14:30 +01:00
|
|
|
}
|
2024-04-15 19:39:03 +02:00
|
|
|
return "Only available if your form contains 1 email field."
|
2024-03-28 18:14:30 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onBeforeMount(() => {
|
|
|
|
|
for (const [keyname, defaultValue] of Object.entries({
|
2024-04-15 19:39:03 +02:00
|
|
|
notification_sender: "OpnForm",
|
|
|
|
|
notification_subject: "We saved your answers",
|
|
|
|
|
notification_body:
|
|
|
|
|
"Hello there 👋 <br>This is a confirmation that your submission was successfully saved.",
|
|
|
|
|
notifications_include_submission: true,
|
2024-03-28 18:14:30 +01:00
|
|
|
})) {
|
|
|
|
|
if (props.integrationData.settings[keyname] === undefined) {
|
|
|
|
|
props.integrationData.settings[keyname] = defaultValue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|