2023-12-20 18:38:43 +01:00
|
|
|
<template>
|
|
|
|
|
<div class="bg-white">
|
|
|
|
|
<template v-if="form">
|
|
|
|
|
<div class="flex bg-gray-50">
|
|
|
|
|
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl px-4">
|
|
|
|
|
<div class="pt-4 pb-0">
|
2024-04-15 19:39:03 +02:00
|
|
|
<a
|
|
|
|
|
href="#"
|
|
|
|
|
class="flex text-blue mb-2 font-semibold text-sm"
|
|
|
|
|
@click.prevent="goBack"
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
class="w-3 h-3 text-blue mt-1 mr-1"
|
|
|
|
|
viewBox="0 0 6 10"
|
|
|
|
|
fill="none"
|
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
|
>
|
|
|
|
|
<path
|
|
|
|
|
d="M5 9L1 5L5 1"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
stroke-width="1.5"
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
/>
|
2023-12-20 18:38:43 +01:00
|
|
|
</svg>
|
|
|
|
|
Go back
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div class="flex flex-wrap">
|
|
|
|
|
<h2 class="flex-grow text-gray-900 truncate">
|
|
|
|
|
{{ form.title }}
|
|
|
|
|
</h2>
|
2025-01-03 16:09:53 +01:00
|
|
|
<div class="flex mt-4 gap-2 lg:mt-0">
|
|
|
|
|
<UButton
|
2024-04-15 19:39:03 +02:00
|
|
|
v-if="form.visibility === 'draft'"
|
|
|
|
|
color="white"
|
2025-01-03 16:09:53 +01:00
|
|
|
class="hover:no-underline"
|
|
|
|
|
icon="i-heroicons-eye"
|
2024-04-15 19:39:03 +02:00
|
|
|
@click="showDraftFormWarningNotification"
|
|
|
|
|
>
|
2025-01-03 16:09:53 +01:00
|
|
|
<span class="hidden sm:inline">View <span class="hidden md:inline">form</span></span>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton
|
2024-04-15 19:39:03 +02:00
|
|
|
v-else
|
2025-01-03 16:09:53 +01:00
|
|
|
v-track.view_form_click="{form_id:form.id, form_slug:form.slug}"
|
2024-04-15 19:39:03 +02:00
|
|
|
target="_blank"
|
2025-01-03 16:09:53 +01:00
|
|
|
:to="form.share_url"
|
2024-04-15 19:39:03 +02:00
|
|
|
color="white"
|
2025-01-03 16:09:53 +01:00
|
|
|
class="hover:no-underline"
|
|
|
|
|
icon="i-heroicons-eye"
|
2024-04-15 19:39:03 +02:00
|
|
|
>
|
2025-01-03 16:09:53 +01:00
|
|
|
<span class="hidden sm:inline">View <span class="hidden md:inline">form</span></span>
|
|
|
|
|
</UButton>
|
|
|
|
|
<UButton
|
2024-12-30 14:35:23 +01:00
|
|
|
v-if="!workspace.is_readonly"
|
2025-01-03 16:09:53 +01:00
|
|
|
v-track.edit_form_click="{form_id: form.id, form_slug: form.slug}"
|
|
|
|
|
color="primary"
|
|
|
|
|
icon="i-heroicons-pencil"
|
|
|
|
|
class="hover:no-underline"
|
|
|
|
|
:to="{ name: 'forms-slug-edit', params: { slug: form.slug } }"
|
2024-04-15 19:39:03 +02:00
|
|
|
>
|
2025-01-03 16:09:53 +01:00
|
|
|
Edit <span class="hidden md:inline">form</span>
|
|
|
|
|
</UButton>
|
|
|
|
|
<extra-menu
|
|
|
|
|
v-if="!workspace.is_readonly"
|
|
|
|
|
:form="form"
|
|
|
|
|
/>
|
2023-12-20 18:38:43 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p class="text-gray-500 text-sm">
|
2024-04-15 19:39:03 +02:00
|
|
|
<span class="pr-1">{{ form.views_count }} view{{
|
|
|
|
|
form.views_count > 0 ? "s" : ""
|
|
|
|
|
}}</span>
|
|
|
|
|
<span class="pr-1">- {{ form.submissions_count }} submission{{
|
|
|
|
|
form.submissions_count > 0 ? "s" : ""
|
|
|
|
|
}}
|
2023-12-20 18:38:43 +01:00
|
|
|
</span>
|
|
|
|
|
<span>- Edited {{ form.last_edited_human }}</span>
|
|
|
|
|
</p>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-if="
|
|
|
|
|
['draft', 'closed'].includes(form.visibility) ||
|
|
|
|
|
(form.tags && form.tags.length > 0)
|
|
|
|
|
"
|
|
|
|
|
class="mt-2 flex items-center flex-wrap gap-3"
|
|
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
v-if="form.visibility == 'draft'"
|
|
|
|
|
class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-600 ring-1 ring-inset ring-gray-500/10 dark:text-white dark:bg-gray-700"
|
|
|
|
|
>
|
2023-12-20 18:38:43 +01:00
|
|
|
Draft - not publicly accessible
|
|
|
|
|
</span>
|
2024-04-15 19:39:03 +02:00
|
|
|
<span
|
|
|
|
|
v-else-if="form.visibility == 'closed'"
|
|
|
|
|
class="inline-flex items-center rounded-full bg-yellow-100 px-2 py-1 text-xs font-medium text-yellow-600 ring-1 ring-inset ring-gray-500/10 dark:text-white dark:bg-gray-700"
|
|
|
|
|
>
|
2023-12-20 18:38:43 +01:00
|
|
|
Closed - won't accept new submissions
|
|
|
|
|
</span>
|
2024-04-15 19:39:03 +02:00
|
|
|
<span
|
|
|
|
|
v-for="(tag) in form.tags"
|
|
|
|
|
:key="tag"
|
|
|
|
|
class="inline-flex items-center rounded-full bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 ring-1 ring-inset ring-gray-500/10 dark:text-white dark:bg-gray-700"
|
|
|
|
|
>
|
2023-12-20 18:38:43 +01:00
|
|
|
{{ tag }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
<p
|
|
|
|
|
v-if="form.closes_at"
|
|
|
|
|
class="text-yellow-500"
|
|
|
|
|
>
|
|
|
|
|
<span v-if="form.is_closed">
|
|
|
|
|
This form stopped accepting submissions on the
|
|
|
|
|
{{ displayClosesDate }}
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else>
|
|
|
|
|
This form will stop accepting submissions on the
|
|
|
|
|
{{ displayClosesDate }}
|
|
|
|
|
</span>
|
2023-12-20 18:38:43 +01:00
|
|
|
</p>
|
2024-04-15 19:39:03 +02:00
|
|
|
<p
|
|
|
|
|
v-if="form.max_submissions_count > 0"
|
|
|
|
|
class="text-yellow-500"
|
|
|
|
|
>
|
|
|
|
|
<span v-if="form.max_number_of_submissions_reached">
|
|
|
|
|
The form is now closed because it reached its limit of
|
|
|
|
|
{{ form.max_submissions_count }} submissions.
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else>
|
|
|
|
|
This form will stop accepting submissions after
|
|
|
|
|
{{ form.max_submissions_count }} submissions.
|
2024-03-28 18:14:30 +01:00
|
|
|
</span>
|
2023-12-20 18:38:43 +01:00
|
|
|
</p>
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
<form-cleanings
|
|
|
|
|
class="mt-4"
|
|
|
|
|
:form="form"
|
|
|
|
|
/>
|
2023-12-20 18:38:43 +01:00
|
|
|
|
|
|
|
|
<div class="border-b border-gray-200 dark:border-gray-700">
|
|
|
|
|
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center">
|
2024-04-15 19:39:03 +02:00
|
|
|
<li
|
|
|
|
|
v-for="(tab, i) in tabsList"
|
|
|
|
|
:key="i + 1"
|
|
|
|
|
class="mr-6"
|
|
|
|
|
>
|
|
|
|
|
<nuxt-link
|
2024-06-07 12:12:24 +02:00
|
|
|
:to="{ name: tab.route, params: tab.params ?? {} }"
|
2024-03-28 18:14:30 +01:00
|
|
|
class="hover:no-underline inline-block py-4 rounded-t-lg border-b-2 text-gray-500 hover:text-gray-600"
|
2024-04-15 19:39:03 +02:00
|
|
|
active-class="text-blue-600 hover:text-blue-900 dark:text-blue-500 dark:hover:text-blue-500 border-blue-600 dark:border-blue-500"
|
|
|
|
|
>
|
2023-12-20 18:38:43 +01:00
|
|
|
{{ tab.name }}
|
|
|
|
|
</nuxt-link>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-02-22 16:56:35 +01:00
|
|
|
<div class="flex flex-col bg-white">
|
2024-03-28 18:14:30 +01:00
|
|
|
<NuxtPage :form="form" />
|
2023-12-20 18:38:43 +01:00
|
|
|
</div>
|
|
|
|
|
</template>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-else-if="loading"
|
|
|
|
|
class="text-center w-full p-5"
|
|
|
|
|
>
|
2024-03-28 18:14:30 +01:00
|
|
|
<Loader class="h-6 w-6 mx-auto" />
|
2023-12-20 18:38:43 +01:00
|
|
|
</div>
|
2024-04-15 19:39:03 +02:00
|
|
|
<div
|
|
|
|
|
v-else
|
|
|
|
|
class="text-center w-full p-5"
|
|
|
|
|
>
|
2023-12-20 18:38:43 +01:00
|
|
|
Form not found.
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-01-11 17:16:50 +01:00
|
|
|
<script setup>
|
2024-04-15 19:39:03 +02:00
|
|
|
import { computed } from "vue"
|
|
|
|
|
import ExtraMenu from "../../../components/pages/forms/show/ExtraMenu.vue"
|
|
|
|
|
import FormCleanings from "../../../components/pages/forms/show/FormCleanings.vue"
|
2023-12-20 18:38:43 +01:00
|
|
|
|
2024-01-11 17:16:50 +01:00
|
|
|
definePageMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
middleware: "auth",
|
2024-01-11 17:16:50 +01:00
|
|
|
})
|
|
|
|
|
useOpnSeoMeta({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Home",
|
2024-01-11 17:16:50 +01:00
|
|
|
})
|
|
|
|
|
|
2024-03-25 16:05:24 +01:00
|
|
|
const route = useRoute()
|
2024-01-11 17:16:50 +01:00
|
|
|
const formsStore = useFormsStore()
|
|
|
|
|
const workingFormStore = useWorkingFormStore()
|
|
|
|
|
const workspacesStore = useWorkspacesStore()
|
|
|
|
|
|
|
|
|
|
const slug = useRoute().params.slug
|
|
|
|
|
|
2024-02-03 12:50:57 +01:00
|
|
|
formsStore.startLoading()
|
2024-01-11 17:16:50 +01:00
|
|
|
const form = computed(() => formsStore.getByKey(slug))
|
2024-12-30 14:35:23 +01:00
|
|
|
const workspace = computed(() => workspacesStore.getCurrent)
|
2024-04-15 19:39:03 +02:00
|
|
|
|
2024-01-11 17:16:50 +01:00
|
|
|
const loading = computed(() => formsStore.loading || workspacesStore.loading)
|
|
|
|
|
const displayClosesDate = computed(() => {
|
|
|
|
|
if (form.value && form.value.closes_at) {
|
|
|
|
|
const dateObj = new Date(form.value.closes_at)
|
2024-04-15 19:39:03 +02:00
|
|
|
return (
|
|
|
|
|
dateObj.getFullYear() +
|
|
|
|
|
"-" +
|
|
|
|
|
String(dateObj.getMonth() + 1).padStart(2, "0") +
|
|
|
|
|
"-" +
|
|
|
|
|
String(dateObj.getDate()).padStart(2, "0") +
|
|
|
|
|
" " +
|
|
|
|
|
String(dateObj.getHours()).padStart(2, "0") +
|
|
|
|
|
":" +
|
|
|
|
|
String(dateObj.getMinutes()).padStart(2, "0")
|
|
|
|
|
)
|
2024-01-11 17:16:50 +01:00
|
|
|
}
|
2024-04-15 19:39:03 +02:00
|
|
|
return ""
|
2024-01-11 17:16:50 +01:00
|
|
|
})
|
2023-12-20 18:38:43 +01:00
|
|
|
|
2024-01-11 17:16:50 +01:00
|
|
|
const tabsList = [
|
|
|
|
|
{
|
2024-04-15 19:39:03 +02:00
|
|
|
name: "Submissions",
|
|
|
|
|
route: "forms-slug-show-submissions",
|
2024-06-07 12:12:24 +02:00
|
|
|
params: { 'slug': slug }
|
2023-12-20 18:38:43 +01:00
|
|
|
},
|
2024-12-30 14:35:23 +01:00
|
|
|
...workspace.value.is_readonly ? [] : [
|
|
|
|
|
{
|
|
|
|
|
name: "Integrations",
|
|
|
|
|
route: "forms-slug-show-integrations",
|
|
|
|
|
params: { 'slug': slug }
|
|
|
|
|
},
|
|
|
|
|
],
|
2024-01-11 17:16:50 +01:00
|
|
|
{
|
2024-04-15 19:39:03 +02:00
|
|
|
name: "Analytics",
|
|
|
|
|
route: "forms-slug-show-stats",
|
2024-06-07 12:12:24 +02:00
|
|
|
params: { 'slug': slug }
|
2023-12-20 18:38:43 +01:00
|
|
|
},
|
2024-01-11 17:16:50 +01:00
|
|
|
{
|
2024-04-15 19:39:03 +02:00
|
|
|
name: "Share",
|
|
|
|
|
route: "forms-slug-show-share",
|
2024-06-07 12:12:24 +02:00
|
|
|
params: { 'slug': slug }
|
2024-04-15 19:39:03 +02:00
|
|
|
},
|
2024-01-11 17:16:50 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2024-01-17 14:52:32 +01:00
|
|
|
workingFormStore.reset()
|
2024-01-11 17:16:50 +01:00
|
|
|
if (form.value) {
|
|
|
|
|
workingFormStore.set(form.value)
|
|
|
|
|
} else {
|
2024-03-25 16:05:24 +01:00
|
|
|
formsStore.loadForm(route.params.slug)
|
2024-01-11 17:16:50 +01:00
|
|
|
}
|
|
|
|
|
})
|
2023-12-20 18:38:43 +01:00
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
watch(
|
|
|
|
|
() => form?.value?.id,
|
|
|
|
|
(id) => {
|
|
|
|
|
if (id) {
|
|
|
|
|
workingFormStore.set(form.value)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
2024-01-11 17:16:50 +01:00
|
|
|
|
|
|
|
|
const goBack = () => {
|
2024-04-15 19:39:03 +02:00
|
|
|
useRouter().push({ name: "home" })
|
2023-12-20 18:38:43 +01:00
|
|
|
}
|
2024-01-29 21:15:16 +01:00
|
|
|
|
|
|
|
|
const showDraftFormWarningNotification = () => {
|
2024-04-15 19:39:03 +02:00
|
|
|
useAlert().warning(
|
|
|
|
|
"This form is currently in Draft mode and is not publicly accessible, You can change the form status on the edit form page.",
|
|
|
|
|
)
|
2024-01-29 21:15:16 +01:00
|
|
|
}
|
2023-12-20 18:38:43 +01:00
|
|
|
</script>
|