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

87 lines
2.3 KiB
Vue
Raw Normal View History

2023-12-09 15:47:03 +01:00
<template>
2024-02-22 16:56:35 +01:00
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl p-4">
<div class="mb-20">
<div class="mb-6 pb-6 border-b w-full flex flex-col sm:flex-row gap-2">
<regenerate-form-link
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"
class="sm:w-1/2 flex"
:form="props.form"
/>
2023-12-24 09:51:22 +01:00
<url-form-prefill
class="sm:w-1/2"
:form="props.form"
:extra-query-param="shareUrlForQueryParams"
/>
2023-12-24 09:51:22 +01:00
<embed-form-as-popup-modal
class="sm:w-1/2 flex"
:form="props.form"
/>
2024-02-22 16:56:35 +01:00
</div>
2023-12-24 09:51:22 +01:00
<share-link
class="mt-4"
:form="props.form"
:extra-query-param="shareUrlForQueryParams"
/>
2023-12-09 15:47:03 +01:00
<embed-code
class="mt-6"
:form="props.form"
:extra-query-param="shareUrlForQueryParams"
/>
2023-12-09 15:47:03 +01:00
<form-qr-code
class="mt-6"
:form="props.form"
:extra-query-param="shareUrlForQueryParams"
/>
2023-12-09 15:47:03 +01:00
<advanced-form-url-settings
v-model="shareFormConfig"
:form="props.form"
/>
2024-02-22 16:56:35 +01:00
</div>
2023-12-09 15:47:03 +01:00
</div>
</template>
2024-01-11 17:16:50 +01:00
<script setup>
import ShareLink from "~/components/pages/forms/show/ShareLink.vue"
import EmbedCode from "~/components/pages/forms/show/EmbedCode.vue"
import FormQrCode from "~/components/pages/forms/show/FormQrCode.vue"
import UrlFormPrefill from "~/components/pages/forms/show/UrlFormPrefill.vue"
import RegenerateFormLink from "~/components/pages/forms/show/RegenerateFormLink.vue"
import AdvancedFormUrlSettings from "~/components/open/forms/components/AdvancedFormUrlSettings.vue"
import EmbedFormAsPopupModal from "~/components/pages/forms/show/EmbedFormAsPopupModal.vue"
2024-02-06 09:59: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
const workspace = computed(() => useWorkspacesStore().getCurrent)
2024-02-06 09:59:43 +01:00
const props = defineProps({
form: { type: Object, required: true },
2024-02-06 09:59:43 +01:00
})
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: props.form ? "Share Form - " + props.form.title : "Share Form",
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 shareFormConfig = ref({
hide_title: false,
auto_submit: false,
2024-01-11 17:16:50 +01:00
})
2023-12-09 15:47:03 +01:00
2024-01-11 17:16:50 +01:00
const shareUrlForQueryParams = computed(() => {
let queryStr = ""
2024-01-11 17:16:50 +01:00
for (const [key, value] of Object.entries(shareFormConfig.value)) {
if (value && value !== "false" && value !== false) {
queryStr +=
"&" + encodeURIComponent(key) + "=" + encodeURIComponent(value)
2023-12-09 15:47:03 +01:00
}
2024-01-11 17:16:50 +01:00
}
return queryStr.slice(1)
})
2023-12-09 15:47:03 +01:00
</script>