Skip to content

Beautiful Open-Source Form Builder

Refactor OpenCompleteForm and OpenFormButton components for improved submission handling

Julien Nahum0dd7f5d2cbc0
diff --git a/client/components/open/forms/OpenCompleteForm.vue b/client/components/open/forms/OpenCompleteForm.vue
index 3ad5c19f6..64cd50e8f 100644
--- a/client/components/open/forms/OpenCompleteForm.vue
+++ b/client/components/open/forms/OpenCompleteForm.vue
@@ -140,26 +140,24 @@
:form="form"
:form-data="submittedData"
/>
+ <div class="flex w-full gap-2 items-center mt-4">
+
+ <open-form-button
+ v-if="form.re_fillable"
+ :form="form"
+ icon="i-lucide-rotate-ccw"
+ @click="restart"
+ >
+ {{ form.re_fill_button_text || t('forms.buttons.re_fill') }}
+ </open-form-button>
<open-form-button
- v-if="form.re_fillable"
+ v-if="form.editable_submissions && submissionId"
:form="form"
- class="my-4"
- @click="restart"
+ @click="editSubmission"
>
- {{ form.re_fill_button_text || t('forms.buttons.re_fill') }}
+ {{ form.editable_submissions_button_text }}
</open-form-button>
- <p
- v-if="form.editable_submissions && submissionId"
- class="mt-5"
- >
- <a
- target="_parent"
- :href="form.share_url+'?submission_id='+submissionId"
- class="text-blue-500 hover:underline"
- >
- {{ form.editable_submissions_button_text }}
- </a>
- </p>
+ </div>
<PoweredBy v-if="!form.no_branding && formModeStrategy.display.showBranding" :color="form.color" />
</div>
</v-transition>
@@ -405,6 +403,11 @@ const restart = () => {
})
}
+const editSubmission = () => {
+ const editUrl = props.form.share_url + '?submission_id=' + submissionId.value
+ window.parent.location.href = editUrl
+}
+
const passwordEntered = () => {
if (passwordForm.password) {
emit('password-entered', passwordForm.password)
diff --git a/client/components/open/forms/OpenFormButton.vue b/client/components/open/forms/OpenFormButton.vue
index c6d15ee14..3cdf69db1 100644
--- a/client/components/open/forms/OpenFormButton.vue
+++ b/client/components/open/forms/OpenFormButton.vue
@@ -6,6 +6,7 @@
:loading="loading"
:class="['btn', buttonClass]"
:size="buttonSize"
+ :icon="icon"
>
<slot />
</UButton>
@@ -25,6 +26,10 @@ const props = defineProps({
type: Boolean,
default: false,
},
+ icon: {
+ type: String,
+ default: null,
+ },
})
const getTextClass = (bgColor, lightColor = "text-white", darkColor = "text-neutral-900") => {