This commit is contained in:
Julien Nahum 2024-06-03 12:05:23 +02:00
commit 32cda4be6b
5 changed files with 26 additions and 12 deletions

View File

@ -26,10 +26,10 @@ class CustomFieldValidationRule implements Rule
public function passes($attribute, $value) public function passes($attribute, $value)
{ {
if (!($this->validation['error_conditions']['conditions'] ?? null) || is_null( if (!($this->validation['error_conditions']['conditions'] ?? null) || is_null(
$this->validation['error_conditions']['conditions'] ?? null $this->validation['error_conditions']['conditions'] ?? null
)) { )) {
return true; return true;
} }
return FormLogicConditionChecker::conditionsMet( return FormLogicConditionChecker::conditionsMet(
$this->validation['error_conditions']['conditions'], $this->validation['error_conditions']['conditions'],
$this->formData $this->formData

View File

@ -17,6 +17,15 @@ class SubmissionConfirmationIntegration extends AbstractIntegrationHandler
public static function getValidationRules(): array public static function getValidationRules(): array
{ {
return [ return [
'respondent_email' => [
'required',
'boolean',
function ($attribute, $value, $fail) {
if ($value !== true) {
$fail('Need at least 1 email field.');
}
},
],
'confirmation_reply_to' => 'email|nullable', 'confirmation_reply_to' => 'email|nullable',
'notification_sender' => 'required', 'notification_sender' => 'required',
'notification_subject' => 'required', 'notification_subject' => 'required',

View File

@ -81,13 +81,14 @@ const emailSubmissionConfirmationHelp = computed(() => {
onBeforeMount(() => { onBeforeMount(() => {
for (const [keyname, defaultValue] of Object.entries({ for (const [keyname, defaultValue] of Object.entries({
respondent_email: emailSubmissionConfirmationField.value !== null,
notification_sender: "OpnForm", notification_sender: "OpnForm",
notification_subject: "We saved your answers", notification_subject: "We saved your answers",
notification_body: notification_body:
"Hello there 👋 <br>This is a confirmation that your submission was successfully saved.", "Hello there 👋 <br>This is a confirmation that your submission was successfully saved.",
notifications_include_submission: true, notifications_include_submission: true,
})) { })) {
if (props.integrationData.settings[keyname] === undefined) { if (keyname === 'respondent_email' || props.integrationData.settings[keyname] === undefined) {
props.integrationData.settings[keyname] = defaultValue props.integrationData.settings[keyname] = defaultValue
} }
} }

View File

@ -209,24 +209,24 @@ export default {
} }
}, },
computed: {
formData() {
return [...this.data].sort((a, b) => new Date(b.created_at) - new Date(a.created_at))
}
},
watch: { watch: {
columns: { columns: {
handler() { handler() {
this.internalColumns = clonedeep(this.columns) this.internalColumns = clonedeep(this.columns)
this.onStructureChange() this.onStructureChange()
}, },
deep: true, deep: true
}, },
data() { data() {
this.$nextTick(() => { this.$nextTick(() => {
this.handleScroll() this.handleScroll()
}) })
},
},
computed: {
formData(){
return this.data.sort((a, b) => new Date(b.created_at) - new Date(a.created_at));
} }
}, },

View File

@ -8,6 +8,7 @@ it('creates confirmation emails with the submitted data', function () {
$workspace = $this->createUserWorkspace($user); $workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace); $form = $this->createForm($user, $workspace);
$integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [ $integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [
'respondent_email' => true,
'notifications_include_submission' => true, 'notifications_include_submission' => true,
'notification_sender' => 'Custom Sender', 'notification_sender' => 'Custom Sender',
'notification_subject' => 'Test subject', 'notification_subject' => 'Test subject',
@ -31,6 +32,7 @@ it('creates confirmation emails without the submitted data', function () {
$workspace = $this->createUserWorkspace($user); $workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace); $form = $this->createForm($user, $workspace);
$integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [ $integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [
'respondent_email' => true,
'notifications_include_submission' => false, 'notifications_include_submission' => false,
'notification_sender' => 'Custom Sender', 'notification_sender' => 'Custom Sender',
'notification_subject' => 'Test subject', 'notification_subject' => 'Test subject',
@ -55,6 +57,7 @@ it('sends a confirmation email if needed', function () {
$form = $this->createForm($user, $workspace); $form = $this->createForm($user, $workspace);
$this->createFormIntegration('submission_confirmation', $form->id, [ $this->createFormIntegration('submission_confirmation', $form->id, [
'respondent_email' => true,
'notifications_include_submission' => true, 'notifications_include_submission' => true,
'notification_sender' => 'Custom Sender', 'notification_sender' => 'Custom Sender',
'notification_subject' => 'Test subject', 'notification_subject' => 'Test subject',
@ -118,6 +121,7 @@ it('does send a confirmation email even when reply to is broken', function () {
$workspace = $this->createUserWorkspace($user); $workspace = $this->createUserWorkspace($user);
$form = $this->createForm($user, $workspace); $form = $this->createForm($user, $workspace);
$integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [ $integrationData = $this->createFormIntegration('submission_confirmation', $form->id, [
'respondent_email' => true,
'notifications_include_submission' => true, 'notifications_include_submission' => true,
'notification_sender' => 'Custom Sender', 'notification_sender' => 'Custom Sender',
'notification_subject' => 'Test subject', 'notification_subject' => 'Test subject',