2023-12-09 15:47:03 +01:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<v-button
|
2024-04-15 19:39:03 +02:00
|
|
|
v-track.regenerate_form_link_click="{
|
|
|
|
|
form_id: form.id,
|
|
|
|
|
form_slug: form.slug,
|
|
|
|
|
}"
|
2023-12-09 15:47:03 +01:00
|
|
|
class="w-full"
|
|
|
|
|
color="light-gray"
|
2024-04-15 19:39:03 +02:00
|
|
|
@click="showGenerateFormLinkModal = true"
|
2023-12-09 15:47:03 +01:00
|
|
|
>
|
2024-04-15 19:39:03 +02:00
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
class="h-6 w-6 mr-2 text-blue-600 inline"
|
|
|
|
|
fill="none"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
stroke-width="2"
|
|
|
|
|
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
|
2023-12-09 15:47:03 +01:00
|
|
|
/>
|
|
|
|
|
</svg>
|
2023-12-24 09:51:22 +01:00
|
|
|
Regenerate link
|
2023-12-09 15:47:03 +01:00
|
|
|
</v-button>
|
|
|
|
|
|
|
|
|
|
<!-- Regenerate form link modal -->
|
2024-04-15 19:39:03 +02:00
|
|
|
<modal
|
|
|
|
|
:show="showGenerateFormLinkModal"
|
|
|
|
|
@close="showGenerateFormLinkModal = false"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
<template #icon>
|
2024-04-15 19:39:03 +02:00
|
|
|
<svg
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
class="w-10 h-10 text-blue-600"
|
|
|
|
|
fill="none"
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
stroke-width="2"
|
|
|
|
|
d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"
|
2023-12-09 15:47:03 +01:00
|
|
|
/>
|
|
|
|
|
</svg>
|
|
|
|
|
</template>
|
|
|
|
|
<template #title>
|
|
|
|
|
Generate new form link
|
|
|
|
|
</template>
|
|
|
|
|
<div class="p-4">
|
|
|
|
|
<p>
|
|
|
|
|
You can choose between two different URL formats for your form.
|
2024-04-15 19:39:03 +02:00
|
|
|
<span class="font-semibold">Be careful, changing your form URL is not a reversible
|
2024-08-06 10:22:52 +02:00
|
|
|
operation</span>. Make sure to update your form URL everywhere where it's used.
|
2023-12-09 15:47:03 +01:00
|
|
|
</p>
|
|
|
|
|
<div class="border-t py-4 mt-4">
|
|
|
|
|
<h3 class="text-xl text-gray-700 font-semibold">
|
|
|
|
|
Human Readable URL
|
|
|
|
|
</h3>
|
2024-04-15 19:39:03 +02:00
|
|
|
<p>
|
|
|
|
|
If your users are going to see this url, you might want to make nice
|
|
|
|
|
and readable. Example:
|
|
|
|
|
</p>
|
2023-12-09 15:47:03 +01:00
|
|
|
<p class="text-gray-600 border p-4 bg-gray-50 rounded-md mt-4">
|
|
|
|
|
https://opnform.com/forms/contact
|
|
|
|
|
</p>
|
|
|
|
|
<div class="text-center mt-4">
|
2024-04-15 19:39:03 +02:00
|
|
|
<v-button
|
|
|
|
|
:loading="loadingNewLink"
|
|
|
|
|
color="outline-blue"
|
|
|
|
|
@click="regenerateLink('slug')"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
Generate a Human Readable URL
|
|
|
|
|
</v-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="border-t pt-4 mt-4">
|
|
|
|
|
<h3 class="text-xl text-gray-700 font-semibold">
|
|
|
|
|
Random ID URL
|
|
|
|
|
</h3>
|
|
|
|
|
<p>
|
2024-04-15 19:39:03 +02:00
|
|
|
If your user are not going to see your form url (if it's embedded),
|
|
|
|
|
and if you prefer to have a random non-guessable URL. Example:
|
2023-12-09 15:47:03 +01:00
|
|
|
</p>
|
|
|
|
|
<p class="text-gray-600 p-4 border bg-gray-50 rounded-md mt-4">
|
|
|
|
|
https://opnform.com/forms/b4417f9c-34ae-4421-8006-832ee47786e7
|
|
|
|
|
</p>
|
|
|
|
|
<div class="text-center mt-4">
|
2024-04-15 19:39:03 +02:00
|
|
|
<v-button
|
|
|
|
|
:loading="loadingNewLink"
|
|
|
|
|
color="outline-blue"
|
|
|
|
|
@click="regenerateLink('uuid')"
|
|
|
|
|
>
|
2023-12-09 15:47:03 +01:00
|
|
|
Generate a Random ID URL
|
|
|
|
|
</v-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</modal>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-04-15 19:39:03 +02:00
|
|
|
import { useFormsStore } from "../../../../stores/forms"
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
export default {
|
2024-04-15 19:39:03 +02:00
|
|
|
name: "RegenerateFormLink",
|
2023-12-09 15:47:03 +01:00
|
|
|
components: {},
|
|
|
|
|
props: {
|
2024-04-15 19:39:03 +02:00
|
|
|
form: { type: Object, required: true },
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
setup() {
|
|
|
|
|
const formsStore = useFormsStore()
|
|
|
|
|
return {
|
|
|
|
|
formsStore,
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-12-09 15:47:03 +01:00
|
|
|
|
|
|
|
|
data: () => ({
|
|
|
|
|
loadingNewLink: false,
|
|
|
|
|
showGenerateFormLinkModal: false,
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
computed: {
|
2024-04-15 19:39:03 +02:00
|
|
|
formEndpoint: () => "/open/forms/{id}",
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
regenerateLink(option) {
|
|
|
|
|
if (this.loadingNewLink) return
|
|
|
|
|
this.loadingNewLink = true
|
2024-04-15 19:39:03 +02:00
|
|
|
opnFetch(
|
|
|
|
|
this.formEndpoint.replace("{id}", this.form.id) +
|
|
|
|
|
"/regenerate-link/" +
|
|
|
|
|
option,
|
|
|
|
|
{ method: "PUT" },
|
|
|
|
|
)
|
|
|
|
|
.then((data) => {
|
|
|
|
|
this.formsStore.save(data.form)
|
|
|
|
|
this.$router.push({
|
|
|
|
|
name: "forms-slug-show-share",
|
|
|
|
|
params: { slug: data.form.slug },
|
|
|
|
|
})
|
|
|
|
|
useAlert().success(data.message)
|
|
|
|
|
this.loadingNewLink = false
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.showGenerateFormLinkModal = false
|
|
|
|
|
})
|
2023-12-09 15:47:03 +01:00
|
|
|
},
|
2024-04-15 19:39:03 +02:00
|
|
|
},
|
2023-12-09 15:47:03 +01:00
|
|
|
}
|
|
|
|
|
</script>
|