2022-11-09 10:23:17 +00: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">
|
2023-12-01 20:24:38 +00:00
|
|
|
<a href="#" class="flex text-blue mb-2 font-semibold text-sm" @click.prevent="goBack">
|
2022-11-09 10:23:17 +00:00
|
|
|
<svg class="w-3 h-3 text-blue mt-1 mr-1" viewBox="0 0 6 10" fill="none"
|
2023-12-01 20:24:38 +00:00
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
2022-11-09 10:23:17 +00:00
|
|
|
<path d="M5 9L1 5L5 1" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"
|
2023-12-01 20:24:38 +00:00
|
|
|
stroke-linejoin="round"
|
|
|
|
/>
|
2022-11-09 10:23:17 +00:00
|
|
|
</svg>
|
|
|
|
Go back
|
|
|
|
</a>
|
|
|
|
|
2023-06-30 13:53:04 +00:00
|
|
|
<div class="flex flex-wrap">
|
2022-11-09 10:23:17 +00:00
|
|
|
<h2 class="flex-grow text-gray-900 truncate">
|
|
|
|
{{ form.title }}
|
|
|
|
</h2>
|
|
|
|
<div class="flex">
|
|
|
|
<extra-menu :form="form" />
|
2023-06-30 13:53:04 +00:00
|
|
|
|
2023-12-01 20:24:38 +00:00
|
|
|
<v-button v-track.view_form_click="{form_id:form.id, form_slug:form.slug}" target="_blank"
|
2023-11-29 13:53:08 +00:00
|
|
|
:href="form.share_url" color="white"
|
2023-12-01 20:24:38 +00:00
|
|
|
class="mr-2 text-blue-600 hidden sm:block"
|
|
|
|
>
|
2022-11-09 10:23:17 +00:00
|
|
|
<svg class="w-6 h-6 inline -mt-1" viewBox="0 0 24 24" fill="none"
|
2023-12-01 20:24:38 +00:00
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
2022-11-09 10:23:17 +00:00
|
|
|
<path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"
|
2023-12-01 20:24:38 +00:00
|
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
|
|
/>
|
2022-11-09 10:23:17 +00:00
|
|
|
<path
|
|
|
|
d="M12 15C13.6569 15 15 13.6569 15 12C15 10.3431 13.6569 9 12 9C10.3431 9 9 10.3431 9 12C9 13.6569 10.3431 15 12 15Z"
|
2023-12-01 20:24:38 +00:00
|
|
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
|
|
|
/>
|
2022-11-09 10:23:17 +00:00
|
|
|
</svg>
|
|
|
|
</v-button>
|
|
|
|
<v-button class="text-white" @click="openEdit">
|
|
|
|
<svg class="inline mr-1 -mt-1" width="18" height="17" viewBox="0 0 18 17" fill="none"
|
2023-12-01 20:24:38 +00:00
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
>
|
2022-11-09 10:23:17 +00:00
|
|
|
<path
|
|
|
|
d="M8.99998 15.6662H16.5M1.5 15.6662H2.89545C3.3031 15.6662 3.50693 15.6662 3.69874 15.6202C3.8688 15.5793 4.03138 15.512 4.1805 15.4206C4.34869 15.3175 4.49282 15.1734 4.78107 14.8852L15.25 4.4162C15.9404 3.72585 15.9404 2.60656 15.25 1.9162C14.5597 1.22585 13.4404 1.22585 12.75 1.9162L2.28105 12.3852C1.9928 12.6734 1.84867 12.8175 1.7456 12.9857C1.65422 13.1348 1.58688 13.2974 1.54605 13.4675C1.5 13.6593 1.5 13.8631 1.5 14.2708V15.6662Z"
|
2023-12-01 20:24:38 +00:00
|
|
|
stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"
|
|
|
|
/>
|
2022-11-09 10:23:17 +00:00
|
|
|
</svg>
|
|
|
|
Edit form
|
|
|
|
</v-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2023-06-30 13:53:04 +00:00
|
|
|
<p class="text-gray-500 text-sm">
|
|
|
|
<span class="pr-1">{{ form.views_count }} view{{ form.views_count > 0 ? 's' : '' }}</span>
|
|
|
|
<span class="pr-1">- {{ form.submissions_count }}
|
2022-11-09 10:23:17 +00:00
|
|
|
submission{{ form.submissions_count > 0 ? 's' : '' }}
|
2023-06-30 13:53:04 +00:00
|
|
|
</span>
|
2023-11-15 09:17:39 +00:00
|
|
|
<span>- Edited {{ form.last_edited_human }}</span>
|
2023-06-30 13:53:04 +00:00
|
|
|
</p>
|
2023-11-15 09:17:39 +00: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">
|
2023-12-01 20:24:38 +00:00
|
|
|
<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-08-31 08:56:14 +00:00
|
|
|
Draft - not publicly accessible
|
|
|
|
</span>
|
2023-12-01 20:24:38 +00: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-11-15 09:17:39 +00:00
|
|
|
Closed - won't accept new submissions
|
|
|
|
</span>
|
2023-08-31 08:56:14 +00:00
|
|
|
<span v-for="(tag,i) in form.tags" :key="tag"
|
2023-12-01 20:24:38 +00:00
|
|
|
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-08-31 08:56:14 +00:00
|
|
|
>
|
|
|
|
{{ tag }}
|
|
|
|
</span>
|
|
|
|
</div>
|
2022-11-09 10:23:17 +00:00
|
|
|
|
|
|
|
<p v-if="form.closes_at" class="text-yellow-500">
|
|
|
|
<span v-if="form.is_closed"> This form stopped accepting submissions on the {{
|
2023-12-01 20:24:38 +00:00
|
|
|
displayClosesDate
|
|
|
|
}} </span>
|
2022-11-09 10:23:17 +00:00
|
|
|
<span v-else> This form will stop accepting submissions on the {{ displayClosesDate }} </span>
|
|
|
|
</p>
|
|
|
|
<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 {{
|
2023-12-01 20:24:38 +00:00
|
|
|
form.max_submissions_count
|
|
|
|
}} submissions. </span>
|
2022-11-09 10:23:17 +00:00
|
|
|
<span v-else> This form will stop accepting submissions after {{ form.max_submissions_count }} submissions. </span>
|
|
|
|
</p>
|
|
|
|
|
2023-08-30 07:58:29 +00:00
|
|
|
<form-cleanings class="mt-4" :form="form" />
|
|
|
|
|
|
|
|
<div class="border-b border-gray-200 dark:border-gray-700">
|
2022-11-09 10:23:17 +00:00
|
|
|
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center">
|
2023-12-01 20:24:38 +00:00
|
|
|
<li v-for="(tab, i) in tabsList" :key="i+1" class="mr-6">
|
2022-11-09 10:23:17 +00:00
|
|
|
<router-link :to="{ name: tab.route }"
|
2023-12-01 20:24:38 +00:00
|
|
|
class="hover:no-underline inline-block py-4 rounded-t-lg border-b-2 text-gray-500 hover:text-gray-600"
|
|
|
|
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"
|
|
|
|
>
|
|
|
|
{{ tab.name }}
|
|
|
|
</router-link>
|
2022-11-09 10:23:17 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="flex bg-white">
|
|
|
|
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl px-4">
|
|
|
|
<div class="py-4">
|
|
|
|
<transition name="fade" mode="out-in">
|
2023-12-01 20:24:38 +00:00
|
|
|
<router-view v-slot="{ Component }">
|
|
|
|
<transition name="page" mode="out-in">
|
|
|
|
<component :is="Component" :form="form" />
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
2022-11-09 10:23:17 +00:00
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<div v-else-if="loading" class="text-center w-full p-5">
|
2023-12-01 20:24:38 +00:00
|
|
|
<loader class="h-6 w-6 mx-auto" />
|
2022-11-09 10:23:17 +00:00
|
|
|
</div>
|
|
|
|
<div v-else class="text-center w-full p-5">
|
|
|
|
Form not found.
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-12-01 17:57:14 +00:00
|
|
|
import { computed } from 'vue'
|
2022-11-09 10:23:17 +00:00
|
|
|
import Form from 'vform'
|
2023-12-01 17:57:14 +00:00
|
|
|
import { useAuthStore } from '../../../stores/auth'
|
|
|
|
import { useFormsStore } from '../../../stores/forms'
|
|
|
|
import { useWorkingFormStore } from '../../../stores/working_form'
|
|
|
|
import { useWorkspacesStore } from '../../../stores/workspaces'
|
2023-01-21 11:57:37 +00:00
|
|
|
import ProTag from '../../../components/common/ProTag.vue'
|
2023-12-01 20:24:38 +00:00
|
|
|
import VButton from '../../../components/common/Button.vue'
|
2023-01-21 11:57:37 +00:00
|
|
|
import ExtraMenu from '../../../components/pages/forms/show/ExtraMenu.vue'
|
|
|
|
import SeoMeta from '../../../mixins/seo-meta.js'
|
2023-08-30 07:58:29 +00:00
|
|
|
import FormCleanings from '../../../components/pages/forms/show/FormCleanings.vue'
|
2022-11-09 10:23:17 +00:00
|
|
|
|
|
|
|
const loadForms = function () {
|
2023-12-01 17:57:14 +00:00
|
|
|
const formsStore = useFormsStore()
|
|
|
|
const workspacesStore = useWorkspacesStore()
|
|
|
|
formsStore.startLoading()
|
|
|
|
workspacesStore.loadIfEmpty().then(() => {
|
|
|
|
formsStore.loadIfEmpty(workspacesStore.currentId)
|
2022-11-09 10:23:17 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'ShowForm',
|
|
|
|
components: {
|
|
|
|
VButton,
|
|
|
|
ProTag,
|
2023-08-30 07:58:29 +00:00
|
|
|
ExtraMenu,
|
|
|
|
FormCleanings
|
2022-11-09 10:23:17 +00:00
|
|
|
},
|
2022-12-22 10:55:17 +00:00
|
|
|
mixins: [SeoMeta],
|
2022-11-09 10:23:17 +00:00
|
|
|
|
2023-12-01 20:24:38 +00:00
|
|
|
beforeRouteEnter (to, from, next) {
|
2022-11-09 10:23:17 +00:00
|
|
|
loadForms()
|
|
|
|
next()
|
|
|
|
},
|
|
|
|
|
2023-12-01 20:24:38 +00:00
|
|
|
beforeRouteLeave (to, from, next) {
|
2022-11-09 10:23:17 +00:00
|
|
|
this.workingForm = null
|
|
|
|
next()
|
|
|
|
},
|
|
|
|
middleware: 'auth',
|
|
|
|
|
2023-12-01 17:57:14 +00:00
|
|
|
setup () {
|
|
|
|
const authStore = useAuthStore()
|
|
|
|
const formsStore = useFormsStore()
|
|
|
|
const workingFormStore = useWorkingFormStore()
|
|
|
|
const workspacesStore = useWorkspacesStore()
|
|
|
|
return {
|
|
|
|
formsStore,
|
|
|
|
workingFormStore,
|
|
|
|
workspacesStore,
|
2023-12-01 20:24:38 +00:00
|
|
|
user: computed(() => authStore.user),
|
|
|
|
formsLoading: computed(() => formsStore.loading),
|
|
|
|
workspacesLoading: computed(() => workspacesStore.loading)
|
2023-12-01 17:57:14 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-12-01 20:24:38 +00:00
|
|
|
data () {
|
2022-11-09 10:23:17 +00:00
|
|
|
return {
|
2022-12-22 10:55:17 +00:00
|
|
|
metaTitle: 'Home',
|
2022-11-09 10:23:17 +00:00
|
|
|
tabsList: [
|
|
|
|
{
|
|
|
|
name: 'Submissions',
|
|
|
|
route: 'forms.show'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Analytics',
|
|
|
|
route: 'forms.show.analytics'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Share',
|
|
|
|
route: 'forms.show.share'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
workingForm: {
|
2023-12-07 10:34:55 +00:00
|
|
|
get () {
|
2023-12-01 17:57:14 +00:00
|
|
|
return this.workingFormStore.content
|
2022-11-09 10:23:17 +00:00
|
|
|
},
|
2023-12-01 17:57:14 +00:00
|
|
|
/* We add a setter */
|
|
|
|
set (value) {
|
|
|
|
this.workingFormStore.set(value)
|
2022-11-09 10:23:17 +00:00
|
|
|
}
|
|
|
|
},
|
2023-12-01 20:24:38 +00:00
|
|
|
workspace () {
|
2022-11-09 10:23:17 +00:00
|
|
|
if (!this.form) return null
|
2023-12-01 17:57:14 +00:00
|
|
|
return this.workspacesStore.getById(this.form.workspace_id)
|
2022-11-09 10:23:17 +00:00
|
|
|
},
|
2023-12-01 20:24:38 +00:00
|
|
|
form () {
|
2023-12-01 17:57:14 +00:00
|
|
|
return this.formsStore.getBySlug(this.$route.params.slug)
|
2022-11-09 10:23:17 +00:00
|
|
|
},
|
|
|
|
formEndpoint: () => '/api/open/forms/{id}',
|
2023-12-01 20:24:38 +00:00
|
|
|
loading () {
|
2022-11-09 10:23:17 +00:00
|
|
|
return this.formsLoading || this.workspacesLoading
|
|
|
|
},
|
2023-12-01 20:24:38 +00:00
|
|
|
displayClosesDate () {
|
2022-11-09 10:23:17 +00:00
|
|
|
if (this.form.closes_at) {
|
2023-12-01 20:24:38 +00:00
|
|
|
const dateObj = new Date(this.form.closes_at)
|
|
|
|
return dateObj.getFullYear() + '-' +
|
|
|
|
String(dateObj.getMonth() + 1).padStart(2, '0') + '-' +
|
|
|
|
String(dateObj.getDate()).padStart(2, '0') + ' ' +
|
|
|
|
String(dateObj.getHours()).padStart(2, '0') + ':' +
|
2022-11-09 10:23:17 +00:00
|
|
|
String(dateObj.getMinutes()).padStart(2, '0')
|
|
|
|
}
|
2023-12-01 20:24:38 +00:00
|
|
|
return ''
|
2022-11-09 10:23:17 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
2023-12-01 20:24:38 +00:00
|
|
|
form () {
|
2022-11-09 10:23:17 +00:00
|
|
|
this.workingForm = new Form(this.form)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-12-01 20:24:38 +00:00
|
|
|
mounted () {
|
2022-11-09 10:23:17 +00:00
|
|
|
if (this.form) {
|
|
|
|
this.workingForm = new Form(this.form)
|
|
|
|
}
|
|
|
|
},
|
2023-06-30 13:53:04 +00:00
|
|
|
|
2022-11-09 10:23:17 +00:00
|
|
|
methods: {
|
2023-12-01 20:24:38 +00:00
|
|
|
openCrisp () {
|
2022-11-09 10:23:17 +00:00
|
|
|
window.$crisp.push(['do', 'chat:show'])
|
|
|
|
window.$crisp.push(['do', 'chat:open'])
|
|
|
|
},
|
2023-12-01 20:24:38 +00:00
|
|
|
goBack () {
|
|
|
|
this.$router.push({ name: 'home' })
|
2022-11-09 10:23:17 +00:00
|
|
|
},
|
2023-12-01 20:24:38 +00:00
|
|
|
openEdit () {
|
|
|
|
this.$router.push({ name: 'forms.edit', params: { slug: this.form.slug } })
|
2022-11-09 10:23:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|