opnform-host-nginx/client/pages/forms/[slug]/show.vue

210 lines
6.1 KiB
Vue
Raw Normal View History

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">
<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>
<div class="flex mt-4 gap-2 lg:mt-0">
<UButton
v-if="form.visibility === 'draft'"
color="white"
class="hover:no-underline"
icon="i-heroicons-eye"
@click="showDraftFormWarningNotification"
>
<span class="hidden sm:inline">View <span class="hidden md:inline">form</span></span>
</UButton>
<UButton
v-else
v-track.view_form_click="{form_id:form.id, form_slug:form.slug}"
target="_blank"
:to="form.share_url"
color="white"
class="hover:no-underline"
icon="i-heroicons-eye"
>
<span class="hidden sm:inline">View <span class="hidden md:inline">form</span></span>
</UButton>
<UButton
Readonly User (#637) * Readonly User * Refactor FormPolicy and TemplatePolicy to centralize write operation logic - Introduced a private method `canPerformWriteOperation` in both FormPolicy and TemplatePolicy to encapsulate the logic for determining if a user can perform write operations on the respective models. - Updated the `update`, `delete`, `restore`, and `forceDelete` methods in FormPolicy to use the new method for improved readability and maintainability. - Simplified the `update` and `delete` methods in TemplatePolicy to leverage the centralized write operation logic. This refactoring enhances code clarity and reduces duplication across policy classes. * Refactor user and workspace permissions handling - Updated FormController to authorize form creation based on workspace context. - Removed the `is_readonly` attribute from UserResource and integrated it into WorkspaceResource for better encapsulation. - Refactored User model to eliminate the `getIsReadonlyAttribute` method, shifting readonly logic to the Workspace model. - Adjusted FormPolicy and TemplatePolicy to utilize workspace readonly checks for user permissions. - Updated various frontend components to reference workspace readonly status instead of user readonly status, enhancing clarity and consistency in permission handling. These changes improve the management of user permissions in relation to workspaces, ensuring a more robust and maintainable authorization system. * Fix isReadonlyUser * fix pint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-12-30 14:35:23 +01:00
v-if="!workspace.is_readonly"
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 } }"
>
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">
<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>
<FormStatusBadges
:form="form"
class="mt-2"
/>
2023-12-20 18:38:43 +01: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">
<li
v-for="(tab, i) in tabsList"
:key="i + 1"
class="mr-6"
>
<nuxt-link
:to="{ name: tab.route, params: tab.params ?? {} }"
Notification & Integrations refactoring (#346) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Lint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
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"
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">
Notification & Integrations refactoring (#346) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Lint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-03-28 18:14:30 +01:00
<NuxtPage :form="form" />
2023-12-20 18:38:43 +01:00
</div>
</template>
<div
v-else-if="loading"
class="text-center w-full p-5"
>
Notification & Integrations refactoring (#346) * Integrations Refactoring - WIP * integrations list & edit - WIP * Fix integration store binding issue * integrations refactor - WIP * Form integration - WIP * Form integration Edit - WIP * Integration Refactor - Slack - WIP * Integration Refactor - Discord - WIP * Integration Refactor - Webhook - WIP * Integration Refactor - Send Submission Confirmation - WIP * Integration Refactor - Backend handler - WIP * Form Integration Status field * Integration Refactor - Backend SubmissionConfirmation - WIP * IntegrationMigration Command * skip confirmation email test case * Small refactoring * FormIntegration status active/inactive * formIntegrationData to integrationData * Rename file name with Integration suffix for integration realted files * Loader on form integrations * WIP * form integration test case * WIP * Added Integration card - working on refactoring * change location for IntegrationCard and update package file * Form Integration Create/Edit in single Modal * Remove integration extra pages * crisp_help_page_slug for integration json * integration logic as collapse * UI improvements * WIP * Trying to debug vue devtools * WIP for integrations * getIntegrationHandler change namespace name * useForm for integration fields + validation structure * Integration Test case & apply validation rules * Apply useform changes to integration other files * validation rules for FormNotificationsMessageActions fields * Zapier integration as coming soon * Update FormCleaner * set default settings for confirmation integration * WIP * Finish validation for all integrations * Updated purify, added integration formatData * Fix testcase * Ran pint; working on integration errors * Handle integration events * command for Delete Old Integration Events * Display Past Events in Modal * on Integration event create with status error send email to form creator * Polish styling * Minor improvements * Finish badge and integration status * Fix tests and add an integration event test * Lint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
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>
<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>
import { computed } from "vue"
import ExtraMenu from "../../../components/pages/forms/show/ExtraMenu.vue"
import FormCleanings from "../../../components/pages/forms/show/FormCleanings.vue"
import FormStatusBadges from "../../../components/open/forms/components/FormStatusBadges.vue"
2023-12-20 18:38:43 +01:00
2024-01-11 17:16:50 +01:00
definePageMeta({
middleware: "auth",
2024-01-11 17:16:50 +01:00
})
useOpnSeoMeta({
title: "Home",
2024-01-11 17:16:50 +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
formsStore.startLoading()
2024-01-11 17:16:50 +01:00
const form = computed(() => formsStore.getByKey(slug))
Readonly User (#637) * Readonly User * Refactor FormPolicy and TemplatePolicy to centralize write operation logic - Introduced a private method `canPerformWriteOperation` in both FormPolicy and TemplatePolicy to encapsulate the logic for determining if a user can perform write operations on the respective models. - Updated the `update`, `delete`, `restore`, and `forceDelete` methods in FormPolicy to use the new method for improved readability and maintainability. - Simplified the `update` and `delete` methods in TemplatePolicy to leverage the centralized write operation logic. This refactoring enhances code clarity and reduces duplication across policy classes. * Refactor user and workspace permissions handling - Updated FormController to authorize form creation based on workspace context. - Removed the `is_readonly` attribute from UserResource and integrated it into WorkspaceResource for better encapsulation. - Refactored User model to eliminate the `getIsReadonlyAttribute` method, shifting readonly logic to the Workspace model. - Adjusted FormPolicy and TemplatePolicy to utilize workspace readonly checks for user permissions. - Updated various frontend components to reference workspace readonly status instead of user readonly status, enhancing clarity and consistency in permission handling. These changes improve the management of user permissions in relation to workspaces, ensuring a more robust and maintainable authorization system. * Fix isReadonlyUser * fix pint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
2024-12-30 14:35:23 +01:00
const workspace = computed(() => workspacesStore.getCurrent)
2024-01-11 17:16:50 +01:00
const loading = computed(() => formsStore.loading || workspacesStore.loading)
2023-12-20 18:38:43 +01:00
2024-01-11 17:16:50 +01:00
const tabsList = [
{
name: "Submissions",
route: "forms-slug-show-submissions",
params: { 'slug': slug }
2023-12-20 18:38:43 +01:00
},
Readonly User (#637) * Readonly User * Refactor FormPolicy and TemplatePolicy to centralize write operation logic - Introduced a private method `canPerformWriteOperation` in both FormPolicy and TemplatePolicy to encapsulate the logic for determining if a user can perform write operations on the respective models. - Updated the `update`, `delete`, `restore`, and `forceDelete` methods in FormPolicy to use the new method for improved readability and maintainability. - Simplified the `update` and `delete` methods in TemplatePolicy to leverage the centralized write operation logic. This refactoring enhances code clarity and reduces duplication across policy classes. * Refactor user and workspace permissions handling - Updated FormController to authorize form creation based on workspace context. - Removed the `is_readonly` attribute from UserResource and integrated it into WorkspaceResource for better encapsulation. - Refactored User model to eliminate the `getIsReadonlyAttribute` method, shifting readonly logic to the Workspace model. - Adjusted FormPolicy and TemplatePolicy to utilize workspace readonly checks for user permissions. - Updated various frontend components to reference workspace readonly status instead of user readonly status, enhancing clarity and consistency in permission handling. These changes improve the management of user permissions in relation to workspaces, ensuring a more robust and maintainable authorization system. * Fix isReadonlyUser * fix pint --------- Co-authored-by: Julien Nahum <julien@nahum.net>
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
{
name: "Analytics",
route: "forms-slug-show-stats",
params: { 'slug': slug }
2023-12-20 18:38:43 +01:00
},
2024-01-11 17:16:50 +01:00
{
name: "Share",
route: "forms-slug-show-share",
params: { 'slug': slug }
},
2024-01-11 17:16:50 +01:00
]
onMounted(() => {
workingFormStore.reset()
2024-01-11 17:16:50 +01:00
if (form.value) {
workingFormStore.set(form.value)
} else {
formsStore.loadForm(route.params.slug)
2024-01-11 17:16:50 +01:00
}
})
2023-12-20 18:38:43 +01:00
watch(
() => form?.value?.id,
(id) => {
if (id) {
workingFormStore.set(form.value)
}
},
)
2024-01-11 17:16:50 +01:00
const goBack = () => {
useRouter().push({ name: "home" })
2023-12-20 18:38:43 +01:00
}
const showDraftFormWarningNotification = () => {
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.",
)
}
2023-12-20 18:38:43 +01:00
</script>