0351d front end linting (#377)

* feat: disable custom script for  trial users

* after lint fix

* frontend linting

---------

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
Favour Olayinka
2024-04-15 18:39:03 +01:00
committed by GitHub
parent 8d35fc8b1a
commit bcd45ce8a6
228 changed files with 17036 additions and 8744 deletions

View File

@@ -1,42 +1,58 @@
<template>
<modal :show="show" max-width="lg" @close="emit('close')">
<open-form :theme="theme" :loading="false" :show-hidden="true" :form="form" :fields="form.properties" @submit="updateForm" :default-data-form="submission">
<template #submit-btn="{submitForm}">
<v-button :loading="loading" class="mt-2 px-8 mx-1" @click.prevent="submitForm">
Update Submission
</v-button>
</template>
</open-form>
</modal>
<modal
:show="show"
max-width="lg"
@close="emit('close')"
>
<open-form
:theme="theme"
:loading="false"
:show-hidden="true"
:form="form"
:fields="form.properties"
:default-data-form="submission"
@submit="updateForm"
>
<template #submit-btn="{ submitForm }">
<v-button
:loading="loading"
class="mt-2 px-8 mx-1"
@click.prevent="submitForm"
>
Update Submission
</v-button>
</template>
</open-form>
</modal>
</template>
<script setup>
import {ref, defineProps, defineEmits, onMounted } from 'vue'
import OpenForm from '../forms/OpenForm.vue';
import { themes } from '~/lib/forms/form-themes.js'
import { ref, defineProps, defineEmits } from "vue"
import OpenForm from "../forms/OpenForm.vue"
import { themes } from "~/lib/forms/form-themes.js"
const props = defineProps({
show: { type: Boolean, required: true },
form: { type: Object, required: true },
theme:{type:Object, default:themes.default},
submission:{type:Object}
theme: { type: Object, default: themes.default },
submission: { type: Object },
})
let loading = ref(false)
const loading = ref(false)
const emit = defineEmits(['close', 'updated'])
const updateForm = (form, onFailure) =>{
loading.value = true
form.put('/open/forms/' + props.form.id + '/submissions/'+props.submission.id).then((res) => {
useAlert().success(res.message)
loading.value = false
emit('close')
emit('updated', res.data.data)
}).catch((error) => {
console.error(error)
loading.value = false
onFailure()
})
const emit = defineEmits(["close", "updated"])
const updateForm = (form, onFailure) => {
loading.value = true
form
.put("/open/forms/" + props.form.id + "/submissions/" + props.submission.id)
.then((res) => {
useAlert().success(res.message)
loading.value = false
emit("close")
emit("updated", res.data.data)
})
.catch((error) => {
console.error(error)
loading.value = false
onFailure()
})
}
</script>
</script>

View File

@@ -1,79 +1,115 @@
<template>
<div class="flex items-center justify-center space-x-1">
<button v-track.delete_record_click
class="border rounded py-1 px-2 text-gray-500 dark:text-gray-400 hover:text-blue-700"
@click="showEditSubmissionModal=true"
<button
v-track.delete_record_click
class="border rounded py-1 px-2 text-gray-500 dark:text-gray-400 hover:text-blue-700"
@click="showEditSubmissionModal = true"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-4 h-4">
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125" />
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-4 h-4"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"
/>
</svg>
</button>
<button v-track.delete_record_click
class="border rounded py-1 px-2 text-gray-500 dark:text-gray-400 hover:text-red-700"
@click="onDeleteClick"
<button
v-track.delete_record_click
class="border rounded py-1 px-2 text-gray-500 dark:text-gray-400 hover:text-red-700"
@click="onDeleteClick"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-4 h-4"
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-4 h-4"
>
<path stroke-linecap="round" stroke-linejoin="round"
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0"
/>
</svg>
</button>
</div>
<EditSubmissionModal :show="showEditSubmissionModal" :form="form" :submission="submission" @close="showEditSubmissionModal=false" @updated="(submission)=>$emit('updated', submission)"/>
<EditSubmissionModal
:show="showEditSubmissionModal"
:form="form"
:submission="submission"
@close="showEditSubmissionModal = false"
@updated="(submission) => $emit('updated', submission)"
/>
</template>
<script>
import EditSubmissionModal from './EditSubmissionModal.vue'
import EditSubmissionModal from "./EditSubmissionModal.vue"
export default {
components: { EditSubmissionModal },
emits: ["updated", "deleted"],
props: {
form: {
type: Object,
required: true
required: true,
},
structure: {
type: Array,
default: () => []
default: () => [],
},
submission: {
type: Object,
default: () => {}
}
},
setup () {
return {
useAlert: useAlert()
}
},
data () {
return {
showEditSubmissionModal:false,
}
},
computed: {
},
mounted () {
},
methods: {
onDeleteClick () {
this.useAlert.confirm('Do you really want to delete this record?', this.deleteRecord)
default: () => {},
},
async deleteRecord () {
opnFetch('/open/forms/' + this.form.id + '/records/' + this.submission.id + '/delete', {method:'DELETE'}).then(async (data) => {
if (data.type === 'success') {
this.$emit('deleted',this.submission)
this.useAlert.success(data.message)
} else {
this.useAlert.error('Something went wrong!')
}
}).catch((error) => {
this.useAlert.error(error.data.message)
})
},
emits: ["updated", "deleted"],
setup() {
return {
useAlert: useAlert(),
}
}
},
data() {
return {
showEditSubmissionModal: false,
}
},
computed: {},
mounted() {},
methods: {
onDeleteClick() {
this.useAlert.confirm(
"Do you really want to delete this record?",
this.deleteRecord,
)
},
async deleteRecord() {
opnFetch(
"/open/forms/" +
this.form.id +
"/records/" +
this.submission.id +
"/delete",
{ method: "DELETE" },
)
.then(async (data) => {
if (data.type === "success") {
this.$emit("deleted", this.submission)
this.useAlert.success(data.message)
} else {
this.useAlert.error("Something went wrong!")
}
})
.catch((error) => {
this.useAlert.error(error.data.message)
})
},
},
}
</script>

View File

@@ -1,11 +1,20 @@
<template>
<collapse class="p-4 w-full border-b" v-model="show">
<collapse
v-model="show"
class="p-4 w-full border-b"
>
<template #title>
<div class="flex items-center pr-8">
<div class="mr-3" :class="{'text-blue-600':show, 'text-gray-500':!show}">
<div
class="mr-3"
:class="{ 'text-blue-600': show, 'text-gray-500': !show }"
>
<slot name="icon" />
</div>
<h3 id="v-step-2" class="font-semibold flex-grow">
<h3
id="v-step-2"
class="font-semibold flex-grow"
>
{{ name }}
</h3>
<pro-tag v-if="hasProTag" />
@@ -17,30 +26,30 @@
</template>
<script>
import Collapse from '~/components/global/Collapse.vue'
import ProTag from '~/components/global/ProTag.vue'
import Collapse from "~/components/global/Collapse.vue"
import ProTag from "~/components/global/ProTag.vue"
export default {
name: 'EditorOptionsPanel',
name: "EditorOptionsPanel",
components: { Collapse, ProTag },
props: {
name: {
type: String,
required: true
required: true,
},
hasProTag: {
type: Boolean,
default: false
default: false,
},
alreadyOpened: {
type: Boolean,
default: false
default: false,
},
},
data() {
return {
show: this.alreadyOpened,
}
},
data () {
return {
show: this.alreadyOpened
}
}
}
</script>

View File

@@ -1,7 +1,9 @@
<template>
<transition @leave="(el,done) => sidebarMotion?.leave(done)">
<div v-if="show" ref="sidebar"
class="absolute shadow-lg shadow-gray-800/30 top-0 h-[calc(100vh-53px)] right-0 lg:shadow-none lg:relative bg-white w-full md:w-1/2 lg:w-2/5 border-l overflow-y-scroll md:max-w-[20rem] flex-shrink-0 z-30"
<transition @leave="(el, done) => sidebarMotion?.leave(done)">
<div
v-if="show"
ref="sidebar"
class="absolute shadow-lg shadow-gray-800/30 top-0 h-[calc(100vh-53px)] right-0 lg:shadow-none lg:relative bg-white w-full md:w-1/2 lg:w-2/5 border-l overflow-y-scroll md:max-w-[20rem] flex-shrink-0 z-30"
>
<slot />
</div>
@@ -9,24 +11,26 @@
</template>
<script setup>
import {slideRight, useMotion} from "@vueuse/motion"
import {watch} from "vue";
import { slideRight, useMotion } from "@vueuse/motion"
import { watch } from "vue"
const props = defineProps({
show: {
type: Boolean,
default: false
}
default: false,
},
})
const sidebar = ref(null)
const sidebarMotion = ref(null)
watch(() => props.show, (newVal) => {
if (newVal) {
nextTick(() => {
sidebarMotion.value = useMotion(sidebar.value, slideRight)
})
}
})
watch(
() => props.show,
(newVal) => {
if (newVal) {
nextTick(() => {
sidebarMotion.value = useMotion(sidebar.value, slideRight)
})
}
},
)
</script>

View File

@@ -1,8 +1,19 @@
<template>
<div v-if="form" class="open-complete-form">
<h1 v-if="!isHideTitle" class="mb-4 px-2" :class="{'mt-4':isEmbedPopup}" v-text="form.title" />
<div v-if="form.description" v-html="form.description"
class="form-description mb-4 text-gray-700 dark:text-gray-300 whitespace-pre-wrap px-2"/>
<div
v-if="form"
class="open-complete-form"
>
<h1
v-if="!isHideTitle"
class="mb-4 px-2"
:class="{'mt-4':isEmbedPopup}"
v-text="form.title"
/>
<div
v-if="form.description"
class="form-description mb-4 text-gray-700 dark:text-gray-300 whitespace-pre-wrap px-2"
v-html="form.description"
/>
<div v-if="isPublicFormPage && form.is_password_protected">
<p class="form-description mb-4 text-gray-700 dark:text-gray-300 px-2">
@@ -10,48 +21,77 @@
</p>
<div class="form-group flex flex-wrap w-full">
<div class="relative mb-3 w-full px-2">
<text-input :theme="theme" :form="passwordForm" name="password" native-type="password" label="Password" />
<text-input
:theme="theme"
:form="passwordForm"
name="password"
native-type="password"
label="Password"
/>
</div>
</div>
<div class="flex flex-wrap justify-center w-full text-center">
<open-form-button :theme="theme" :color="form.color" class="my-4" @click="passwordEntered">
<open-form-button
:theme="theme"
:color="form.color"
class="my-4"
@click="passwordEntered"
>
Submit
</open-form-button>
</div>
</div>
<v-transition>
<div v-if="!form.is_password_protected && form.password && !hidePasswordDisabledMsg"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
<div
v-if="!form.is_password_protected && form.password && !hidePasswordDisabledMsg"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
>
<div class="flex flex-grow">
<p class="mb-0 py-2 px-4 text-yellow-600 dark:text-yellow-600">
We disabled the password protection for this form because you are an owner of it.
</p>
<v-button color="yellow" @click="hidePasswordDisabledMsg=true">
<v-button
color="yellow"
@click="hidePasswordDisabledMsg=true"
>
OK
</v-button>
</div>
</div>
</v-transition>
<div v-if="isPublicFormPage && (form.is_closed || form.visibility=='closed')"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
<div
v-if="isPublicFormPage && (form.is_closed || form.visibility=='closed')"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
>
<div class="flex-grow">
<p class="mb-0 py-2 px-4 text-yellow-600" v-html="form.closed_text" />
<p
class="mb-0 py-2 px-4 text-yellow-600"
v-html="form.closed_text"
/>
</div>
</div>
<div v-if="isPublicFormPage && form.max_number_of_submissions_reached"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
<div
v-if="isPublicFormPage && form.max_number_of_submissions_reached"
class="border shadow-sm p-2 my-4 flex items-center rounded-md bg-yellow-100 border-yellow-500"
>
<div class="flex-grow">
<p class="mb-0 py-2 px-4 text-yellow-600" v-html="form.max_submissions_reached_text" />
<p
class="mb-0 py-2 px-4 text-yellow-600"
v-html="form.max_submissions_reached_text"
/>
</div>
</div>
<form-cleanings v-if="!adminPreview" :hideable="true" class="mb-4 mx-2" :form="form" :specify-form-owner="true" />
<form-cleanings
v-if="!adminPreview"
:hideable="true"
class="mb-4 mx-2"
:form="form"
:specify-form-owner="true"
/>
<transition
v-if="!form.is_password_protected && (!isPublicFormPage || (!form.is_closed && !form.max_number_of_submissions_reached && form.visibility!='closed'))"
@@ -63,45 +103,85 @@
leave-to-class="translate-x-full opacity-0"
mode="out-in"
>
<div v-if="!submitted" key="form">
<open-form v-if="form"
:form="form"
:loading="loading"
:fields="form.properties"
:theme="theme"
:dark-mode="darkMode"
:admin-preview="adminPreview"
@submit="submitForm"
<div
v-if="!submitted"
key="form"
>
<open-form
v-if="form"
:form="form"
:loading="loading"
:fields="form.properties"
:theme="theme"
:dark-mode="darkMode"
:admin-preview="adminPreview"
@submit="submitForm"
>
<template #submit-btn="{submitForm}">
<open-form-button :loading="loading" :theme="theme" :color="form.color" class="mt-2 px-8 mx-1"
:class="submitButtonClass" @click.prevent="submitForm"
<open-form-button
:loading="loading"
:theme="theme"
:color="form.color"
class="mt-2 px-8 mx-1"
:class="submitButtonClass"
@click.prevent="submitForm"
>
{{ form.submit_button_text }}
</open-form-button>
</template>
</open-form>
<p v-if="!form.no_branding" class="text-center w-full mt-2">
<a href="https://opnform.com?utm_source=form&utm_content=powered_by"
class="text-gray-400 hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-500 cursor-pointer hover:underline text-xs"
target="_blank"
<p
v-if="!form.no_branding"
class="text-center w-full mt-2"
>
<a
href="https://opnform.com?utm_source=form&utm_content=powered_by"
class="text-gray-400 hover:text-gray-500 dark:text-gray-600 dark:hover:text-gray-500 cursor-pointer hover:underline text-xs"
target="_blank"
>
Powered by <span class="font-semibold">OpnForm</span>
</a>
</p>
</div>
<div v-else key="submitted" class="px-2">
<p class="form-description text-gray-700 dark:text-gray-300 whitespace-pre-wrap" v-html="form.submitted_text " />
<open-form-button v-if="form.re_fillable" :theme="theme" :color="form.color" class="my-4" @click="restart">
<div
v-else
key="submitted"
class="px-2"
>
<p
class="form-description text-gray-700 dark:text-gray-300 whitespace-pre-wrap"
v-html="form.submitted_text "
/>
<open-form-button
v-if="form.re_fillable"
:theme="theme"
:color="form.color"
class="my-4"
@click="restart"
>
{{ form.re_fill_button_text }}
</open-form-button>
<p v-if="form.editable_submissions && submissionId" class="mt-5">
<a target="_parent" :href="form.share_url+'?submission_id='+submissionId" class="text-nt-blue hover:underline">
<p
v-if="form.editable_submissions && submissionId"
class="mt-5"
>
<a
target="_parent"
:href="form.share_url+'?submission_id='+submissionId"
class="text-nt-blue hover:underline"
>
{{ form.editable_submissions_button_text }}
</a>
</p>
<p v-if="!form.no_branding" class="mt-5">
<a target="_parent" href="https://opnform.com/?utm_source=form&utm_content=create_form_free" class="text-nt-blue hover:underline">
<p
v-if="!form.no_branding"
class="mt-5"
>
<a
target="_parent"
href="https://opnform.com/?utm_source=form&utm_content=create_form_free"
class="text-nt-blue hover:underline"
>
Create your form for free with OpnForm
</a>
</p>
@@ -117,8 +197,8 @@ import { themes } from '~/lib/forms/form-themes.js'
import VButton from '~/components/global/VButton.vue'
import FormCleanings from '../../pages/forms/show/FormCleanings.vue'
import VTransition from '~/components/global/transitions/VTransition.vue'
import {pendingSubmission} from "~/composables/forms/pendingSubmission.js";
import clonedeep from "clone-deep";
import {pendingSubmission} from "~/composables/forms/pendingSubmission.js"
import clonedeep from "clone-deep"
import { default as _has } from 'lodash/has'
export default {

View File

@@ -4,34 +4,54 @@
<Loader class="h-6 w-6 text-nt-blue mx-auto" />
</p>
</div>
<form v-else-if="dataForm" @submit.prevent="">
<template v-if='form.show_progress_bar'>
<div v-if='isIframe' class='mb-4 p-2'>
<div class='w-full h-2 bg-gray-200 dark:bg-gray-600 relative border rounded-full overflow-hidden'>
<div class='h-full transition-all duration-300 rounded-r-full'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
<form
v-else-if="dataForm"
@submit.prevent=""
>
<template v-if="form.show_progress_bar">
<div
v-if="isIframe"
class="mb-4 p-2"
>
<div class="w-full h-2 bg-gray-200 dark:bg-gray-600 relative border rounded-full overflow-hidden">
<div
class="h-full transition-all duration-300 rounded-r-full"
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
<div v-else class='fixed top-0 left-0 right-0 z-50'>
<div class='w-full h-[0.2rem] bg-gray-200 dark:bg-gray-600 relative overflow-hidden'>
<div class='h-full transition-all duration-300'
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
<div
v-else
class="fixed top-0 left-0 right-0 z-50"
>
<div class="w-full h-[0.2rem] bg-gray-200 dark:bg-gray-600 relative overflow-hidden">
<div
class="h-full transition-all duration-300"
:class="{ 'w-0': formProgress === 0 }"
:style="{ width: formProgress + '%', background: form.color }"
/>
</div>
</div>
</template>
<transition name="fade" mode="out-in">
<div :key="currentFieldGroupIndex" class="form-group flex flex-wrap w-full">
<draggable v-model="currentFields"
item-key="id"
class="flex flex-wrap transition-all w-full"
:class="{'-m-6 p-2 bg-gray-50 rounded-md':dragging}"
ghost-class="ghost-item"
handle=".draggable" :animation="200"
@start="onDragStart" @end="onDragEnd"
<transition
name="fade"
mode="out-in"
>
<div
:key="currentFieldGroupIndex"
class="form-group flex flex-wrap w-full"
>
<draggable
v-model="currentFields"
item-key="id"
class="flex flex-wrap transition-all w-full"
:class="{'-m-6 p-2 bg-gray-50 rounded-md':dragging}"
ghost-class="ghost-item"
handle=".draggable"
:animation="200"
@start="onDragStart"
@end="onDragEnd"
>
<template #item="{element}">
<open-form-field
@@ -52,22 +72,43 @@
<!-- Captcha -->
<template v-if="form.use_captcha && isLastPage">
<div class="mb-3 px-2 mt-2 mx-auto w-max">
<vue-hcaptcha ref="hcaptcha" :sitekey="hCaptchaSiteKey" :theme="darkMode?'dark':'light'" />
<has-error :form="dataForm" field="h-captcha-response" />
<vue-hcaptcha
ref="hcaptcha"
:sitekey="hCaptchaSiteKey"
:theme="darkMode?'dark':'light'"
/>
<has-error
:form="dataForm"
field="h-captcha-response"
/>
</div>
</template>
<!-- Submit, Next and previous buttons -->
<div class="flex flex-wrap justify-center w-full">
<open-form-button v-if="currentFieldGroupIndex>0 && previousFieldsPageBreak && !loading" native-type="button"
:color="form.color" :theme="theme" class="mt-2 px-8 mx-1" @click="previousPage"
<open-form-button
v-if="currentFieldGroupIndex>0 && previousFieldsPageBreak && !loading"
native-type="button"
:color="form.color"
:theme="theme"
class="mt-2 px-8 mx-1"
@click="previousPage"
>
{{ previousFieldsPageBreak.previous_btn_text }}
</open-form-button>
<slot v-if="isLastPage" name="submit-btn" :submitForm="submitForm" />
<open-form-button v-else-if="currentFieldsPageBreak" native-type="button" :color="form.color" :theme="theme" class="mt-2 px-8 mx-1"
@click.stop="nextPage"
<slot
v-if="isLastPage"
name="submit-btn"
:submit-form="submitForm"
/>
<open-form-button
v-else-if="currentFieldsPageBreak"
native-type="button"
:color="form.color"
:theme="theme"
class="mt-2 px-8 mx-1"
@click.stop="nextPage"
>
{{ currentFieldsPageBreak.next_btn_text }}
</open-form-button>
@@ -337,7 +378,7 @@ export default {
async initForm () {
if(this.defaultDataForm){
this.dataForm = useForm(this.defaultDataForm)
return;
return
}
if (this.isPublicFormPage && this.form.editable_submissions) {
@@ -351,7 +392,7 @@ export default {
}
}
if (this.isPublicFormPage && this.form.auto_save) {
let pendingData = this.pendingSubmission.get()
const pendingData = this.pendingSubmission.get()
if (pendingData !== null && pendingData && Object.keys(this.pendingSubmission.get()).length !== 0) {
this.fields.forEach((field) => {
if (field.type === 'date' && field.prefill_today === true) { // For Prefill with 'today'

View File

@@ -1,73 +1,82 @@
<template>
<button :type="nativeType" :disabled="loading?true:null" :class="`py-${sizes['p-y']} px-${sizes['p-x']} text-${sizes['font']} ${theme.Button.body}`" :style="buttonStyle"
class="btn">
<button
:type="nativeType"
:disabled="loading ? true : null"
:class="`py-${sizes['p-y']} px-${sizes['p-x']} text-${sizes['font']} ${theme.Button.body}`"
:style="buttonStyle"
class="btn"
>
<template v-if="!loading">
<slot />
</template>
<Loader v-else class="h-6 w-6 text-white mx-auto" />
<Loader
v-else
class="h-6 w-6 text-white mx-auto"
/>
</button>
</template>
<script>
import { themes } from '~/lib/forms/form-themes.js'
import { themes } from "~/lib/forms/form-themes.js"
export default {
name: 'OpenFormButton',
name: "OpenFormButton",
props: {
color: {
type: String,
required: true
required: true,
},
size: {
type: String,
default: 'medium'
default: "medium",
},
nativeType: {
type: String,
default: 'submit'
default: "submit",
},
loading: {
type: Boolean,
default: false
default: false,
},
theme: { type: Object, default: () => themes.default }
theme: { type: Object, default: () => themes.default },
},
computed: {
buttonStyle () {
buttonStyle() {
return {
backgroundColor: this.color,
color: this.getTextColor(this.color),
'--tw-ring-color': this.color
"--tw-ring-color": this.color,
}
},
sizes () {
if (this.size === 'small') {
sizes() {
if (this.size === "small") {
return {
font: 'sm',
'p-y': '1',
'p-x': '2'
font: "sm",
"p-y": "1",
"p-x": "2",
}
}
return {
font: 'base',
'p-y': '2',
'p-x': '4'
font: "base",
"p-y": "2",
"p-x": "4",
}
}
},
},
methods: {
getTextColor (bgColor, lightColor = '#FFFFFF', darkColor = '#000000') {
getTextColor(bgColor, lightColor = "#FFFFFF", darkColor = "#000000") {
if (!bgColor) {
return darkColor
}
const color = (bgColor.charAt(0) === '#') ? bgColor.substring(1, 7) : bgColor
const color =
bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor
const r = parseInt(color.substring(0, 2), 16) // hexToR
const g = parseInt(color.substring(2, 4), 16) // hexToG
const b = parseInt(color.substring(4, 6), 16) // hexToB
@@ -78,9 +87,9 @@ export default {
}
return Math.pow((col + 0.055) / 1.055, 2.4)
})
const L = (0.2126 * c[0]) + (0.7152 * c[1]) + (0.0722 * c[2])
return (L > 0.45) ? darkColor : lightColor
}
}
const L = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]
return L > 0.45 ? darkColor : lightColor
},
},
}
</script>

View File

@@ -1,52 +1,128 @@
<template>
<div v-if="!isFieldHidden" :id="'block-' + field.id" :class="getFieldWidthClasses(field)">
<div
v-if="!isFieldHidden"
:id="'block-' + field.id"
:class="getFieldWidthClasses(field)"
>
<div :class="getFieldClasses(field)">
<div v-if="adminPreview"
class="absolute -translate-x-full top-0 bottom-0 opacity-0 group-hover/nffield:opacity-100 transition-opacity mb-4">
<div class="flex flex-col bg-white rounded-md"
:class="{ 'lg:flex-row': !fieldSideBarOpened, 'xl:flex-row': fieldSideBarOpened }">
<div class="p-2 -mr-3 -mb-2 text-gray-300 hover:text-blue-500 cursor-pointer hidden xl:block" role="button"
<div
v-if="adminPreview"
class="absolute -translate-x-full top-0 bottom-0 opacity-0 group-hover/nffield:opacity-100 transition-opacity mb-4"
>
<div
class="flex flex-col bg-white rounded-md"
:class="{ 'lg:flex-row': !fieldSideBarOpened, 'xl:flex-row': fieldSideBarOpened }"
>
<div
class="p-2 -mr-3 -mb-2 text-gray-300 hover:text-blue-500 cursor-pointer hidden xl:block"
role="button"
:class="{ 'lg:block': !fieldSideBarOpened, 'xl:block': fieldSideBarOpened }"
@click.prevent="openAddFieldSidebar">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="3"
stroke="currentColor" class="w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
@click.prevent="openAddFieldSidebar"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="3"
stroke="currentColor"
class="w-5 h-5"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M12 4.5v15m7.5-7.5h-15"
/>
</svg>
</div>
<div class="p-2 text-gray-300 hover:text-blue-500 cursor-pointer" role="button"
<div
class="p-2 text-gray-300 hover:text-blue-500 cursor-pointer"
role="button"
:class="{ 'lg:-mr-2': !fieldSideBarOpened, 'xl:-mr-2': fieldSideBarOpened }"
@click.prevent="editFieldOptions">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5">
<path fill-rule="evenodd"
@click.prevent="editFieldOptions"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="w-5 h-5"
>
<path
fill-rule="evenodd"
d="M11.828 2.25c-.916 0-1.699.663-1.85 1.567l-.091.549a.798.798 0 01-.517.608 7.45 7.45 0 00-.478.198.798.798 0 01-.796-.064l-.453-.324a1.875 1.875 0 00-2.416.2l-.243.243a1.875 1.875 0 00-.2 2.416l.324.453a.798.798 0 01.064.796 7.448 7.448 0 00-.198.478.798.798 0 01-.608.517l-.55.092a1.875 1.875 0 00-1.566 1.849v.344c0 .916.663 1.699 1.567 1.85l.549.091c.281.047.508.25.608.517.06.162.127.321.198.478a.798.798 0 01-.064.796l-.324.453a1.875 1.875 0 00.2 2.416l.243.243c.648.648 1.67.733 2.416.2l.453-.324a.798.798 0 01.796-.064c.157.071.316.137.478.198.267.1.47.327.517.608l.092.55c.15.903.932 1.566 1.849 1.566h.344c.916 0 1.699-.663 1.85-1.567l.091-.549a.798.798 0 01.517-.608 7.52 7.52 0 00.478-.198.798.798 0 01.796.064l.453.324a1.875 1.875 0 002.416-.2l.243-.243c.648-.648.733-1.67.2-2.416l-.324-.453a.798.798 0 01-.064-.796c.071-.157.137-.316.198-.478.1-.267.327-.47.608-.517l.55-.091a1.875 1.875 0 001.566-1.85v-.344c0-.916-.663-1.699-1.567-1.85l-.549-.091a.798.798 0 01-.608-.517 7.507 7.507 0 00-.198-.478.798.798 0 01.064-.796l.324-.453a1.875 1.875 0 00-.2-2.416l-.243-.243a1.875 1.875 0 00-2.416-.2l-.453.324a.798.798 0 01-.796.064 7.462 7.462 0 00-.478-.198.798.798 0 01-.517-.608l-.091-.55a1.875 1.875 0 00-1.85-1.566h-.344zM12 15.75a3.75 3.75 0 100-7.5 3.75 3.75 0 000 7.5z"
clip-rule="evenodd" />
clip-rule="evenodd"
/>
</svg>
</div>
<div
class="px-2 xl:pl-0 lg:pr-1 lg:pt-2 pb-2 bg-white rounded-md text-gray-300 hover:text-gray-500 cursor-grab draggable"
:class="{ 'lg:pr-1 lg:pl-0': !fieldSideBarOpened, 'xl:-mr-2': fieldSideBarOpened }" role="button">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z" />
:class="{ 'lg:pr-1 lg:pl-0': !fieldSideBarOpened, 'xl:-mr-2': fieldSideBarOpened }"
role="button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 5v.01M12 12v.01M12 19v.01M12 6a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2zm0 7a1 1 0 110-2 1 1 0 010 2z"
/>
</svg>
</div>
</div>
</div>
<component :is="getFieldComponents" v-if="getFieldComponents" v-bind="inputProperties(field)"
:required="isFieldRequired" :disabled="isFieldDisabled ? true : null" />
<component
:is="getFieldComponents"
v-if="getFieldComponents"
v-bind="inputProperties(field)"
:required="isFieldRequired"
:disabled="isFieldDisabled ? true : null"
/>
<template v-else>
<div v-if="field.type === 'nf-text' && field.content" :id="field.id" :key="field.id" class="nf-text w-full mb-3"
:class="[getFieldAlignClasses(field)]" v-html="field.content" />
<div v-if="field.type === 'nf-code' && field.content" :id="field.id" :key="field.id"
class="nf-code w-full px-2 mb-3" v-html="field.content" />
<div v-if="field.type === 'nf-divider'" :id="field.id" :key="field.id" class="border-b my-4 w-full mx-2" />
<div v-if="field.type === 'nf-image' && (field.image_block || !isPublicFormPage)" :id="field.id" :key="field.id"
class="my-4 w-full px-2" :class="[getFieldAlignClasses(field)]">
<div v-if="!field.image_block" class="p-4 border border-dashed">
<div
v-if="field.type === 'nf-text' && field.content"
:id="field.id"
:key="field.id"
class="nf-text w-full mb-3"
:class="[getFieldAlignClasses(field)]"
v-html="field.content"
/>
<div
v-if="field.type === 'nf-code' && field.content"
:id="field.id"
:key="field.id"
class="nf-code w-full px-2 mb-3"
v-html="field.content"
/>
<div
v-if="field.type === 'nf-divider'"
:id="field.id"
:key="field.id"
class="border-b my-4 w-full mx-2"
/>
<div
v-if="field.type === 'nf-image' && (field.image_block || !isPublicFormPage)"
:id="field.id"
:key="field.id"
class="my-4 w-full px-2"
:class="[getFieldAlignClasses(field)]"
>
<div
v-if="!field.image_block"
class="p-4 border border-dashed"
>
Open <b>{{ field.name }}'s</b> block settings to upload image.
</div>
<img v-else :alt="field.name" :src="field.image_block" class="max-w-full" />
<img
v-else
:alt="field.name"
:src="field.image_block"
class="max-w-full"
>
</div>
</template>
</div>
@@ -298,7 +374,7 @@ export default {
inputProperties.maxSlider = parseInt(field.slider_max_value) ?? 50
inputProperties.stepSlider = parseInt(field.slider_step_value) ?? 5
} else if (field.type === 'number' || (field.type === 'phone_number' && field.use_simple_text_input)) {
inputProperties.pattern = '/\d*'
inputProperties.pattern = '/d*'
} else if (field.type === 'phone_number' && !field.use_simple_text_input) {
inputProperties.unavailableCountries = field.unavailable_countries ?? []
}

View File

@@ -1,66 +1,88 @@
<template>
<collapse class="py-5 w-full" :model-value="false">
<collapse
class="py-5 w-full"
:model-value="false"
>
<template #title>
<div class="flex">
<h3 class="font-semibold block text-lg">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 inline text-gray-500 mr-2 -mt-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg> Show advanced sharing options
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5 inline text-gray-500 mr-2 -mt-1"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
Show advanced sharing options
</h3>
</div>
</template>
<toggle-switch-input :model-value="modelValue.hide_title" name="hide_title" class="mt-4"
label="Hide Form Title"
:disabled="(form.hide_title===true)?true:null"
:help="hideTitleHelp"
@update:model-value="onChangeHideTitle"
<toggle-switch-input
:model-value="modelValue.hide_title"
name="hide_title"
class="mt-4"
label="Hide Form Title"
:disabled="form.hide_title === true ? true : null"
:help="hideTitleHelp"
@update:model-value="onChangeHideTitle"
/>
<toggle-switch-input :model-value="modelValue.auto_submit" name="auto_submit" class="mt-4"
label="Auto Submit Form"
help="Form will auto submit immediate after open URL"
@update:model-value="onChangeAutoSubmit"
<toggle-switch-input
:model-value="modelValue.auto_submit"
name="auto_submit"
class="mt-4"
label="Auto Submit Form"
help="Form will auto submit immediate after open URL"
@update:model-value="onChangeAutoSubmit"
/>
</collapse>
</template>
<script>
import Collapse from '~/components/global/Collapse.vue'
import Collapse from "~/components/global/Collapse.vue"
export default {
name: 'AdvancedFormUrlSettings',
name: "AdvancedFormUrlSettings",
components: { Collapse },
props: {
form: {
type: Object,
required: true
required: true,
},
modelValue: {
type: Object,
required: true
}
required: true,
},
},
data () {
return {
}
data() {
return {}
},
computed: {
hideTitleHelp () {
return this.form.hide_title ? 'This option is disabled because the form title is already hidden' : null
}
hideTitleHelp() {
return this.form.hide_title
? "This option is disabled because the form title is already hidden"
: null
},
},
watch: {},
mounted () {},
mounted() {},
methods: {
onChangeHideTitle (val) {
onChangeHideTitle(val) {
this.modelValue.hide_title = val
},
onChangeAutoSubmit (val) {
onChangeAutoSubmit(val) {
this.modelValue.auto_submit = val
}
}
},
},
}
</script>

View File

@@ -1,48 +1,64 @@
<template>
<div class="flex flex-wrap sm:flex-nowrap my-4 w-full">
<div class="w-full sm:w-auto border border-gray-300 rounded-md p-2 flex-grow select-all bg-gray-100">
<div
class="w-full sm:w-auto border border-gray-300 rounded-md p-2 flex-grow select-all bg-gray-100"
>
<p class="select-all text-gray-900">
{{ content }}
</p>
</div>
<div class="w-full sm:w-40 sm:ml-2 mt-2 sm:mt-0 shrink-0">
<v-button color="light-gray" class="w-full" @click="copyToClipboard">
<v-button
color="light-gray"
class="w-full"
@click="copyToClipboard"
>
<slot name="icon">
<svg class="h-4 w-4 -mt-1 text-blue-600 inline mr-1" viewBox="0 0 20 20" fill="none"
xmlns="http://www.w3.org/2000/svg">
<svg
class="h-4 w-4 -mt-1 text-blue-600 inline mr-1"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M4.16667 12.4998C3.3901 12.4998 3.00182 12.4998 2.69553 12.373C2.28715 12.2038 1.9627 11.8794 1.79354 11.471C1.66667 11.1647 1.66667 10.7764 1.66667 9.99984V4.33317C1.66667 3.39975 1.66667 2.93304 1.84833 2.57652C2.00812 2.26292 2.26308 2.00795 2.57669 1.84816C2.93321 1.6665 3.39992 1.6665 4.33334 1.6665H10C10.7766 1.6665 11.1649 1.6665 11.4711 1.79337C11.8795 1.96253 12.204 2.28698 12.3731 2.69536C12.5 3.00165 12.5 3.38993 12.5 4.1665M10.1667 18.3332H15.6667C16.6001 18.3332 17.0668 18.3332 17.4233 18.1515C17.7369 17.9917 17.9919 17.7368 18.1517 17.4232C18.3333 17.0666 18.3333 16.5999 18.3333 15.6665V10.1665C18.3333 9.23308 18.3333 8.76637 18.1517 8.40985C17.9919 8.09625 17.7369 7.84128 17.4233 7.68149C17.0668 7.49984 16.6001 7.49984 15.6667 7.49984H10.1667C9.23325 7.49984 8.76654 7.49984 8.41002 7.68149C8.09642 7.84128 7.84145 8.09625 7.68166 8.40985C7.50001 8.76637 7.50001 9.23308 7.50001 10.1665V15.6665C7.50001 16.5999 7.50001 17.0666 7.68166 17.4232C7.84145 17.7368 8.09642 17.9917 8.41002 18.1515C8.76654 18.3332 9.23325 18.3332 10.1667 18.3332Z"
stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
stroke="currentColor"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</slot>
<slot></slot>
<slot />
</v-button>
</div>
</div>
</template>
<script setup>
import { defineProps } from 'vue'
import { defineProps } from "vue"
const { copy } = useClipboard()
const props = defineProps({
content: {
type: String,
required: true
required: true,
},
isDraft: {
type: Boolean,
default: false
}
default: false,
},
})
const copyToClipboard = () => {
if (import.meta.server) return
copy(props.content)
if(props.isDraft){
useAlert().warning('Copied! But other people won\'t be able to see the form since it\'s currently in draft mode')
if (props.isDraft) {
useAlert().warning(
"Copied! But other people won't be able to see the form since it's currently in draft mode",
)
} else {
useAlert().success('Copied!')
useAlert().success("Copied!")
}
}
</script>

View File

@@ -1,13 +1,29 @@
<template>
<div v-if="form" id="form-editor" class="relative flex w-full flex-col grow max-h-screen">
<div
v-if="form"
id="form-editor"
class="relative flex w-full flex-col grow max-h-screen"
>
<!-- Navbar -->
<div class="w-full border-b p-2 flex items-center justify-between bg-white">
<a v-if="backButton" href="#" class="ml-2 flex text-blue font-semibold text-sm"
@click.prevent="$router.back()"
<a
v-if="backButton"
href="#"
class="ml-2 flex text-blue font-semibold text-sm"
@click.prevent="$router.back()"
>
<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"
<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"
/>
</svg>
Go back
@@ -18,25 +34,39 @@
</h3>
</div>
<div class="flex items-center" :class="{'mx-auto md:mx-0':!backButton}">
<div
class="flex items-center"
:class="{ 'mx-auto md:mx-0': !backButton }"
>
<div class="hidden md:block mr-10 relative">
<a href="#"
class="text-sm px-3 py-2 hover:bg-gray-50 cursor-pointer rounded-md text-gray-500 px-0 sm:px-3 hover:text-gray-800 cursor-pointer mt-1"
@click.prevent="openCrisp"
<a
href="#"
class="text-sm px-3 py-2 hover:bg-gray-50 cursor-pointer rounded-md text-gray-500 px-0 sm:px-3 hover:text-gray-800 cursor-pointer mt-1"
@click.prevent="openCrisp"
>
Help
</a>
</div>
<v-button v-track.save_form_click size="small" class="w-full px-8 md:px-4 py-2"
:loading="updateFormLoading" :class="saveButtonClass"
@click="saveForm"
<v-button
v-track.save_form_click
size="small"
class="w-full px-8 md:px-4 py-2"
:loading="updateFormLoading"
:class="saveButtonClass"
@click="saveForm"
>
<svg class="w-4 h-4 text-white inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="w-4 h-4 text-white inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M17 21V13H7V21M7 3V8H15M19 21H5C4.46957 21 3.96086 20.7893 3.58579 20.4142C3.21071 20.0391 3 19.5304 3 19V5C3 4.46957 3.21071 3.96086 3.58579 3.58579C3.96086 3.21071 4.46957 3 5 3H16L21 8V19C21 19.5304 20.7893 20.0391 20.4142 20.4142C20.0391 20.7893 19.5304 21 19 21Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
<template v-if="form.visibility === 'public'">
@@ -50,9 +80,12 @@
</div>
<div class="w-full flex grow overflow-y-scroll relative bg-gray-50">
<div class="relative w-full bg-white shrink-0 overflow-y-scroll border-r md:w-1/2 md:max-w-sm lg:w-2/5">
<div
class="relative w-full bg-white shrink-0 overflow-y-scroll border-r md:w-1/2 md:max-w-sm lg:w-2/5"
>
<div class="border-b bg-blue-50 p-5 text-nt-blue-dark md:hidden">
Please create this form on a device with a larger screen. That will allow you to preview your form changes.
Please create this form on a device with a larger screen. That will
allow you to preview your form changes.
</div>
<form-information />
@@ -72,33 +105,36 @@
<form-error-modal
:show="showFormErrorModal"
:form="form"
@close="showFormErrorModal=false"
@close="showFormErrorModal = false"
/>
</div>
</div>
<div v-else class="flex justify-center items-center p-8">
<div
v-else
class="flex justify-center items-center p-8"
>
<Loader class="w-6 h-6" />
</div>
</template>
<script>
import FormEditorSidebar from './form-components/FormEditorSidebar.vue'
import FormErrorModal from './form-components/FormErrorModal.vue'
import FormInformation from './form-components/FormInformation.vue'
import FormStructure from './form-components/FormStructure.vue'
import FormCustomization from './form-components/FormCustomization.vue'
import FormCustomCode from './form-components/FormCustomCode.vue'
import FormAboutSubmission from './form-components/FormAboutSubmission.vue'
import FormEditorPreview from './form-components/FormEditorPreview.vue'
import FormSecurityPrivacy from './form-components/FormSecurityPrivacy.vue'
import FormCustomSeo from './form-components/FormCustomSeo.vue'
import FormAccess from './form-components/FormAccess.vue'
import {validatePropertiesLogic} from "~/composables/forms/validatePropertiesLogic.js"
import opnformConfig from "~/opnform.config.js";
import {captureException} from "@sentry/core";
import FormEditorSidebar from "./form-components/FormEditorSidebar.vue"
import FormErrorModal from "./form-components/FormErrorModal.vue"
import FormInformation from "./form-components/FormInformation.vue"
import FormStructure from "./form-components/FormStructure.vue"
import FormCustomization from "./form-components/FormCustomization.vue"
import FormCustomCode from "./form-components/FormCustomCode.vue"
import FormAboutSubmission from "./form-components/FormAboutSubmission.vue"
import FormEditorPreview from "./form-components/FormEditorPreview.vue"
import FormSecurityPrivacy from "./form-components/FormSecurityPrivacy.vue"
import FormCustomSeo from "./form-components/FormCustomSeo.vue"
import FormAccess from "./form-components/FormAccess.vue"
import { validatePropertiesLogic } from "~/composables/forms/validatePropertiesLogic.js"
import opnformConfig from "~/opnform.config.js"
import { captureException } from "@sentry/core"
export default {
name: 'FormEditor',
name: "FormEditor",
components: {
FormEditorSidebar,
FormEditorPreview,
@@ -110,36 +146,38 @@ export default {
FormErrorModal,
FormSecurityPrivacy,
FormCustomSeo,
FormAccess
FormAccess,
},
props: {
isEdit: {
required: false,
type: Boolean,
default: false
default: false,
},
isGuest: {
required: false,
type: Boolean,
default: false
default: false,
},
backButton: {
required: false,
type: Boolean,
default: true
default: true,
},
saveButtonClass: {
required: false,
type: String,
default: ''
}
default: "",
},
},
setup () {
const {user} = storeToRefs(useAuthStore())
emits: ['mounted', 'on-save', 'openRegister'],
setup() {
const { user } = storeToRefs(useAuthStore())
const formsStore = useFormsStore()
const {content: form} = storeToRefs(useWorkingFormStore())
const {getCurrent: workspace} = storeToRefs(useWorkspacesStore())
const { content: form } = storeToRefs(useWorkingFormStore())
const { getCurrent: workspace } = storeToRefs(useWorkspacesStore())
return {
appStore: useAppStore(),
crisp: useCrisp(),
@@ -148,90 +186,96 @@ export default {
workspace,
formsStore,
form,
user
user,
}
},
data () {
data() {
return {
showFormErrorModal: false,
validationErrorResponse: null,
updateFormLoading: false,
createdFormSlug: null
createdFormSlug: null,
}
},
computed: {
createdForm () {
createdForm() {
return this.formsStore.getByKey(this.createdFormSlug)
},
steps () {
steps() {
return [
{
target: '#v-step-0',
target: "#v-step-0",
header: {
title: 'Welcome to the OpnForm Editor!'
title: "Welcome to the OpnForm Editor!",
},
content: 'Discover <strong>your form Editor</strong>!'
content: "Discover <strong>your form Editor</strong>!",
},
{
target: '#v-step-1',
target: "#v-step-1",
header: {
title: 'Change your form fields'
title: "Change your form fields",
},
content: 'Here you can decide which field to include or not, but also the ' +
'order you want your fields to be and so on. You also have custom options available for each field, just ' +
'click the blue cog.'
content:
"Here you can decide which field to include or not, but also the " +
"order you want your fields to be and so on. You also have custom options available for each field, just " +
"click the blue cog.",
},
{
target: '#v-step-2',
target: "#v-step-2",
header: {
title: 'Notifications, Customizations and more!'
title: "Notifications, Customizations and more!",
},
content: 'Many more options are available: change colors, texts and receive a ' +
'notifications whenever someones submits your form.'
content:
"Many more options are available: change colors, texts and receive a " +
"notifications whenever someones submits your form.",
},
{
target: '.v-last-step',
target: ".v-last-step",
header: {
title: 'Create your form'
title: "Create your form",
},
content: 'Click this button when you\'re done to save your form!'
}
content: "Click this button when you're done to save your form!",
},
]
},
helpUrl () {
helpUrl() {
return this.opnformConfig.links.help
}
},
},
watch: {},
mounted () {
this.$emit('mounted')
mounted() {
this.$emit("mounted")
this.appStore.hideNavbar()
},
beforeUnmount () {
beforeUnmount() {
this.appStore.showNavbar()
},
methods: {
displayFormModificationAlert (responseData) {
displayFormModificationAlert(responseData) {
const alert = useAlert()
if (responseData.form && responseData.form.cleanings && Object.keys(responseData.form.cleanings).length > 0) {
if (
responseData.form &&
responseData.form.cleanings &&
Object.keys(responseData.form.cleanings).length > 0
) {
alert.warning(responseData.message)
} else if (responseData.message) {
alert.success(responseData.message)
}
},
openCrisp () {
openCrisp() {
this.crisp.openChat()
},
showValidationErrors () {
showValidationErrors() {
this.showFormErrorModal = true
},
saveForm () {
saveForm() {
this.form.properties = validatePropertiesLogic(this.form.properties)
if (this.isGuest) {
this.saveFormGuest()
@@ -241,63 +285,90 @@ export default {
this.saveFormCreate()
}
},
saveFormEdit () {
saveFormEdit() {
if (this.updateFormLoading) return
this.updateFormLoading = true
this.validationErrorResponse = null
this.form.put('/open/forms/{id}/'.replace('{id}', this.form.id)).then((data) => {
this.formsStore.save(data.form)
this.$emit('on-save')
this.$router.push({ name: 'forms-slug-show-share', params: { slug: this.form.slug } })
this.amplitude.logEvent('form_saved', { form_id: this.form.id, form_slug: this.form.slug })
this.displayFormModificationAlert(data)
}).catch((error) => {
if (error?.response?.status === 422) {
this.validationErrorResponse = error.response.data
this.showValidationErrors()
} else {
useAlert().error('An error occurred while saving the form, please try again.')
captureException(error)
}
}).finally(() => {
this.updateFormLoading = false
})
this.form
.put("/open/forms/{id}/".replace("{id}", this.form.id))
.then((data) => {
this.formsStore.save(data.form)
this.$emit("on-save")
this.$router.push({
name: "forms-slug-show-share",
params: { slug: this.form.slug },
})
this.amplitude.logEvent("form_saved", {
form_id: this.form.id,
form_slug: this.form.slug,
})
this.displayFormModificationAlert(data)
})
.catch((error) => {
if (error?.response?.status === 422) {
this.validationErrorResponse = error.response.data
this.showValidationErrors()
} else {
useAlert().error(
"An error occurred while saving the form, please try again.",
)
captureException(error)
}
})
.finally(() => {
this.updateFormLoading = false
})
},
saveFormCreate () {
saveFormCreate() {
if (this.updateFormLoading) return
this.form.workspace_id = this.workspace.id
this.validationErrorResponse = null
this.updateFormLoading = true
this.form.post('/open/forms').then((response) => {
this.formsStore.save(response.form)
this.$emit('on-save')
this.createdFormSlug = response.form.slug
this.form
.post("/open/forms")
.then((response) => {
this.formsStore.save(response.form)
this.$emit("on-save")
this.createdFormSlug = response.form.slug
this.amplitude.logEvent('form_created', { form_id: response.form.id, form_slug: response.form.slug })
this.crisp.pushEvent('form_created',{
form_id: response.form.id,
form_slug: response.form.slug
this.amplitude.logEvent("form_created", {
form_id: response.form.id,
form_slug: response.form.slug,
})
this.crisp.pushEvent("form_created", {
form_id: response.form.id,
form_slug: response.form.slug,
})
this.displayFormModificationAlert(response)
useRouter().push({
name: "forms-slug-show-share",
params: {
slug: this.createdFormSlug,
new_form: response.users_first_form,
},
})
})
.catch((error) => {
if (error?.response?.status === 422) {
this.validationErrorResponse = error.response
this.showValidationErrors()
} else {
useAlert().error(
"An error occurred while saving the form, please try again.",
)
captureException(error)
}
})
.finally(() => {
this.updateFormLoading = false
})
this.displayFormModificationAlert(response)
useRouter().push({ name: 'forms-slug-show-share', params: { slug: this.createdFormSlug, new_form: response.users_first_form } })
}).catch((error) => {
if (error?.response?.status === 422) {
this.validationErrorResponse = error.response
this.showValidationErrors()
} else {
useAlert().error('An error occurred while saving the form, please try again.')
captureException(error)
}
}).finally(() => {
this.updateFormLoading = false
})
},
saveFormGuest () {
this.$emit('openRegister')
}
}
saveFormGuest() {
this.$emit("openRegister")
},
},
}
</script>
@@ -305,13 +376,13 @@ export default {
.v-step {
color: white;
.v-step__header, .v-step__content {
.v-step__header,
.v-step__content {
color: white;
div {
color: white;
}
}
}
</style>

View File

@@ -1,43 +1,75 @@
<template>
<div>
<v-button v-if="form.properties && form.properties.length > 8"
class="w-full mb-3" color="light-gray"
@click="openAddFieldSidebar"
<v-button
v-if="form.properties && form.properties.length > 8"
class="w-full mb-3"
color="light-gray"
@click="openAddFieldSidebar"
>
<svg class="w-4 h-4 text-nt-blue inline mr-1 -mt-1" viewBox="0 0 14 14" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="w-4 h-4 text-nt-blue inline mr-1 -mt-1"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M7.00001 1.1665V12.8332M1.16667 6.99984H12.8333" stroke="currentColor" stroke-width="1.67"
stroke-linecap="round" stroke-linejoin="round"
<path
d="M7.00001 1.1665V12.8332M1.16667 6.99984H12.8333"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Add block
</v-button>
<draggable v-model="form.properties"
item-key="id"
class="bg-white overflow-hidden dark:bg-notion-dark-light rounded-md w-full mx-auto border transition-colors"
ghost-class="bg-gray-50"
handle=".draggable"
:animation="200"
<draggable
v-model="form.properties"
item-key="id"
class="bg-white overflow-hidden dark:bg-notion-dark-light rounded-md w-full mx-auto border transition-colors"
ghost-class="bg-gray-50"
handle=".draggable"
:animation="200"
>
<template #item="{element, index}">
<div class="w-full mx-auto transition-colors"
:class="{'bg-gray-100 dark:bg-gray-800':element.hidden,'bg-white dark:bg-notion-dark-light':!element.hidden && !element.type==='nf-page-break', 'border-b': (index!== form.properties.length -1), 'bg-blue-50 dark:bg-blue-900':element && element.type==='nf-page-break'}"
<template #item="{ element, index }">
<div
class="w-full mx-auto transition-colors"
:class="{
'bg-gray-100 dark:bg-gray-800': element.hidden,
'bg-white dark:bg-notion-dark-light':
!element.hidden && !element.type === 'nf-page-break',
'border-b': index !== form.properties.length - 1,
'bg-blue-50 dark:bg-blue-900':
element && element.type === 'nf-page-break',
}"
>
<div v-if="element" class="flex items-center space-x-1 group py-2 pr-4 relative">
<div
v-if="element"
class="flex items-center space-x-1 group py-2 pr-4 relative"
>
<!-- Drag handler -->
<div class="cursor-move draggable p-2 -mr-2">
<svg class="h-4 w-4 text-gray-400" viewBox="0 0 18 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.5 1.0835H16.5M1.5 6.91683H16.5" stroke="currentColor" stroke-width="1.67"
stroke-linecap="round" stroke-linejoin="round"
<svg
class="h-4 w-4 text-gray-400"
viewBox="0 0 18 8"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M1.5 1.0835H16.5M1.5 6.91683H16.5"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
<!-- Field name and type -->
<div class="flex flex-col flex-grow truncate">
<editable-div class="max-w-full flex items-center" :model-value="element.name"
@update:model-value="onChangeName(element, $event)"
<editable-div
class="max-w-full flex items-center"
:model-value="element.name"
@update:model-value="onChangeName(element, $event)"
>
<div class="cursor-pointer max-w-full truncate">
{{ element.name }}
@@ -52,10 +84,20 @@
<template v-if="removing == element.id">
<div class="flex text-sm items-center">
Remove block?
<v-button class="inline ml-1" color="red" size="small" @click="removeBlock(index)">
<v-button
class="inline ml-1"
color="red"
size="small"
@click="removeBlock(index)"
>
Yes
</v-button>
<v-button class="inline ml-1" color="light-gray" size="small" @click="removing=false">
<v-button
class="inline ml-1"
color="light-gray"
size="small"
@click="removing = false"
>
No
</v-button>
</div>
@@ -63,82 +105,151 @@
<template v-else>
<button
class="hover:bg-red-50 text-gray-500 hover:text-red-600 rounded transition-colors cursor-pointer p-2 hidden md:group-hover:block"
@click="removing=element.id"
@click="removing = element.id"
>
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="h-4 w-4"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3 6H5M5 6H21M5 6V20C5 20.5304 5.21071 21.0391 5.58579 21.4142C5.96086 21.7893 6.46957 22 7 22H17C17.5304 22 18.0391 21.7893 18.4142 21.4142C18.7893 21.0391 19 20.5304 19 20V6H5ZM8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M10 11V17M14 11V17"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</button>
<button class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2 hidden"
:class="{'text-blue-500': !element.hidden, 'text-gray-500': element.hidden, 'group-hover:md:block': !element.hidden, 'md:block':element.hidden}"
@click="toggleHidden(element)"
<button
class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2 hidden"
:class="{
'text-blue-500': !element.hidden,
'text-gray-500': element.hidden,
'group-hover:md:block': !element.hidden,
'md:block': element.hidden,
}"
@click="toggleHidden(element)"
>
<template v-if="!element.hidden">
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"
stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
<svg
class="h-4 w-4"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M1 12C1 12 5 4 12 4C19 4 23 12 23 12C23 12 19 20 12 20C5 20 1 12 1 12Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<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"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<template v-else>
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="h-4 w-4"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clip-path="url(#clip0_1027_7292)">
<path
d="M9.9 4.24C10.5883 4.07888 11.2931 3.99834 12 4C19 4 23 12 23 12C22.393 13.1356 21.6691 14.2047 20.84 15.19M14.12 14.12C13.8454 14.4147 13.5141 14.6512 13.1462 14.8151C12.7782 14.9791 12.3809 15.0673 11.9781 15.0744C11.5753 15.0815 11.1752 15.0074 10.8016 14.8565C10.4281 14.7056 10.0887 14.481 9.80385 14.1962C9.51897 13.9113 9.29439 13.5719 9.14351 13.1984C8.99262 12.8248 8.91853 12.4247 8.92563 12.0219C8.93274 11.6191 9.02091 11.2218 9.18488 10.8538C9.34884 10.4859 9.58525 10.1546 9.88 9.88M1 1L23 23M17.94 17.94C16.2306 19.243 14.1491 19.9649 12 20C5 20 1 12 1 12C2.24389 9.6819 3.96914 7.65661 6.06 6.06L17.94 17.94Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
<defs>
<clipPath id="clip0_1027_7292">
<rect width="24" height="24" fill="white"/>
<rect
width="24"
height="24"
fill="white"
/>
</clipPath>
</defs>
</svg>
</template>
</button>
<button v-if="!element.type.startsWith('nf-')"
class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2 hidden"
:class="{'group-hover:md:block': !element.required, 'md:block':element.required}"
@click="toggleRequired(element)"
<button
v-if="!element.type.startsWith('nf-')"
class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2 hidden"
:class="{
'group-hover:md:block': !element.required,
'md:block': element.required,
}"
@click="toggleRequired(element)"
>
<div class="w-4 h-4 text-center font-bold text-3xl"
:class="{'text-red-500': element.required, 'text-gray-500': !element.required}"
<div
class="w-4 h-4 text-center font-bold text-3xl"
:class="{
'text-red-500': element.required,
'text-gray-500': !element.required,
}"
>
<svg class="w-4 h-4" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-4 h-4"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 2V12M12 12V22M12 12L4.93 4.93M12 12L19.07 19.07M12 12H2M12 12H22M12 12L4.93 19.07M12 12L19.07 4.93"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</div>
</button>
<button class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2"
@click="editOptions(index)"
<button
class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer p-2"
@click="editOptions(index)"
>
<svg class="h-4 w-4 text-blue-600" width="24" height="24" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="h-4 w-4 text-blue-600"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<g clip-path="url(#clip0_1027_7210)">
<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"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M19.4 15C19.2669 15.3016 19.2272 15.6362 19.286 15.9606C19.3448 16.285 19.4995 16.5843 19.73 16.82L19.79 16.88C19.976 17.0657 20.1235 17.2863 20.2241 17.5291C20.3248 17.7719 20.3766 18.0322 20.3766 18.295C20.3766 18.5578 20.3248 18.8181 20.2241 19.0609C20.1235 19.3037 19.976 19.5243 19.79 19.71C19.6043 19.896 19.3837 20.0435 19.1409 20.1441C18.8981 20.2448 18.6378 20.2966 18.375 20.2966C18.1122 20.2966 17.8519 20.2448 17.6091 20.1441C17.3663 20.0435 17.1457 19.896 16.96 19.71L16.9 19.65C16.6643 19.4195 16.365 19.2648 16.0406 19.206C15.7162 19.1472 15.3816 19.1869 15.08 19.32C14.7842 19.4468 14.532 19.6572 14.3543 19.9255C14.1766 20.1938 14.0813 20.5082 14.08 20.83V21C14.08 21.5304 13.8693 22.0391 13.4942 22.4142C13.1191 22.7893 12.6104 23 12.08 23C11.5496 23 11.0409 22.7893 10.6658 22.4142C10.2907 22.0391 10.08 21.5304 10.08 21V20.91C10.0723 20.579 9.96512 20.258 9.77251 19.9887C9.5799 19.7194 9.31074 19.5143 9 19.4C8.69838 19.2669 8.36381 19.2272 8.03941 19.286C7.71502 19.3448 7.41568 19.4995 7.18 19.73L7.12 19.79C6.93425 19.976 6.71368 20.1235 6.47088 20.2241C6.22808 20.3248 5.96783 20.3766 5.705 20.3766C5.44217 20.3766 5.18192 20.3248 4.93912 20.2241C4.69632 20.1235 4.47575 19.976 4.29 19.79C4.10405 19.6043 3.95653 19.3837 3.85588 19.1409C3.75523 18.8981 3.70343 18.6378 3.70343 18.375C3.70343 18.1122 3.75523 17.8519 3.85588 17.6091C3.95653 17.3663 4.10405 17.1457 4.29 16.96L4.35 16.9C4.58054 16.6643 4.73519 16.365 4.794 16.0406C4.85282 15.7162 4.81312 15.3816 4.68 15.08C4.55324 14.7842 4.34276 14.532 4.07447 14.3543C3.80618 14.1766 3.49179 14.0813 3.17 14.08H3C2.46957 14.08 1.96086 13.8693 1.58579 13.4942C1.21071 13.1191 1 12.6104 1 12.08C1 11.5496 1.21071 11.0409 1.58579 10.6658C1.96086 10.2907 2.46957 10.08 3 10.08H3.09C3.42099 10.0723 3.742 9.96512 4.0113 9.77251C4.28059 9.5799 4.48572 9.31074 4.6 9C4.73312 8.69838 4.77282 8.36381 4.714 8.03941C4.65519 7.71502 4.50054 7.41568 4.27 7.18L4.21 7.12C4.02405 6.93425 3.87653 6.71368 3.77588 6.47088C3.67523 6.22808 3.62343 5.96783 3.62343 5.705C3.62343 5.44217 3.67523 5.18192 3.77588 4.93912C3.87653 4.69632 4.02405 4.47575 4.21 4.29C4.39575 4.10405 4.61632 3.95653 4.85912 3.85588C5.10192 3.75523 5.36217 3.70343 5.625 3.70343C5.88783 3.70343 6.14808 3.75523 6.39088 3.85588C6.63368 3.95653 6.85425 4.10405 7.04 4.29L7.1 4.35C7.33568 4.58054 7.63502 4.73519 7.95941 4.794C8.28381 4.85282 8.61838 4.81312 8.92 4.68H9C9.29577 4.55324 9.54802 4.34276 9.72569 4.07447C9.90337 3.80618 9.99872 3.49179 10 3.17V3C10 2.46957 10.2107 1.96086 10.5858 1.58579C10.9609 1.21071 11.4696 1 12 1C12.5304 1 13.0391 1.21071 13.4142 1.58579C13.7893 1.96086 14 2.46957 14 3V3.09C14.0013 3.41179 14.0966 3.72618 14.2743 3.99447C14.452 4.26276 14.7042 4.47324 15 4.6C15.3016 4.73312 15.6362 4.77282 15.9606 4.714C16.285 4.65519 16.5843 4.50054 16.82 4.27L16.88 4.21C17.0657 4.02405 17.2863 3.87653 17.5291 3.77588C17.7719 3.67523 18.0322 3.62343 18.295 3.62343C18.5578 3.62343 18.8181 3.67523 19.0609 3.77588C19.3037 3.87653 19.5243 4.02405 19.71 4.21C19.896 4.39575 20.0435 4.61632 20.1441 4.85912C20.2448 5.10192 20.2966 5.36217 20.2966 5.625C20.2966 5.88783 20.2448 6.14808 20.1441 6.39088C20.0435 6.63368 19.896 6.85425 19.71 7.04L19.65 7.1C19.4195 7.33568 19.2648 7.63502 19.206 7.95941C19.1472 8.28381 19.1869 8.61838 19.32 8.92V9C19.4468 9.29577 19.6572 9.54802 19.9255 9.72569C20.1938 9.90337 20.5082 9.99872 20.83 10H21C21.5304 10 22.0391 10.2107 22.4142 10.5858C22.7893 10.9609 23 11.4696 23 12C23 12.5304 22.7893 13.0391 22.4142 13.4142C22.0391 13.7893 21.5304 14 21 14H20.91C20.5882 14.0013 20.2738 14.0966 20.0055 14.2743C19.7372 14.452 19.5268 14.7042 19.4 15Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
<defs>
<clipPath id="clip0_1027_7210">
<rect width="24" height="24" fill="white"/>
<rect
width="24"
height="24"
fill="white"
/>
</clipPath>
</defs>
</svg>
@@ -150,14 +261,22 @@
</draggable>
<v-button
class="w-full mt-3" color="light-gray"
class="w-full mt-3"
color="light-gray"
@click="openAddFieldSidebar"
>
<svg class="w-4 h-4 text-nt-blue inline mr-1 -mt-1" viewBox="0 0 14 14" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="w-4 h-4 text-nt-blue inline mr-1 -mt-1"
viewBox="0 0 14 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M7.00001 1.1665V12.8332M1.16667 6.99984H12.8333" stroke="currentColor" stroke-width="1.67"
stroke-linecap="round" stroke-linejoin="round"
<path
d="M7.00001 1.1665V12.8332M1.16667 6.99984H12.8333"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Add block
@@ -166,20 +285,17 @@
</template>
<script>
import draggable from 'vuedraggable'
import ProTag from '~/components/global/ProTag.vue'
import clonedeep from 'clone-deep'
import EditableDiv from '~/components/global/EditableDiv.vue'
import VButton from '~/components/global/VButton.vue'
import draggable from "vuedraggable"
import EditableDiv from "~/components/global/EditableDiv.vue"
import VButton from "~/components/global/VButton.vue"
draggable.compatConfig = {MODE: 3}
draggable.compatConfig = { MODE: 3 }
export default {
name: 'FormFieldsEditor',
name: "FormFieldsEditor",
components: {
VButton,
ProTag,
draggable,
EditableDiv
EditableDiv,
},
setup() {
@@ -193,7 +309,7 @@ export default {
data() {
return {
removing: null
removing: null,
}
},
@@ -229,20 +345,20 @@ export default {
field.placeholder = field.placeholder || null
field.prefill = field.prefill || null
field.help = field.help || null
field.help_position = field.help_position || 'below_input'
field.help_position = field.help_position || "below_input"
return field
})
},
formatType(field) {
let type = field.type.replace('_', ' ')
if (!type.startsWith('nf')) {
type = type + ' Input'
let type = field.type.replace("_", " ")
if (!type.startsWith("nf")) {
type = type + " Input"
} else {
type = type.replace('nf-', '')
type = type.replace("nf-", "")
}
if (field.generates_uuid || field.generates_auto_increment_id) {
type = type + ' - Auto ID'
type = type + " - Auto ID"
}
return type
},
@@ -258,7 +374,7 @@ export default {
},
openAddFieldSidebar() {
this.workingFormStore.openAddFieldSidebar(null)
}
}
},
},
}
</script>

View File

@@ -1,34 +1,44 @@
<template>
<div class="border border-nt-blue-light bg-blue-50 dark:bg-notion-dark-light rounded-md p-4 mb-5 w-full mx-auto mt-4 select-all">
<div v-if="false" class="relative">
<div
class="border border-nt-blue-light bg-blue-50 dark:bg-notion-dark-light rounded-md p-4 mb-5 w-full mx-auto mt-4 select-all"
>
<div
v-if="false"
class="relative"
>
<div class="absolute inset-0 z-10">
<div class="p-5 max-w-md mx-auto mt-5">
<p class="text-center">
You need a <pro-tag class="mx-1" /> subscription to access your form analytics.
You need a <pro-tag class="mx-1" /> subscription to access your form
analytics.
</p>
<p class="mt-5 text-center">
<v-button :to="{name:'pricing'}">
<v-button :to="{ name: 'pricing' }">
Subscribe
</v-button>
</p>
</div>
</div>
<img src="/img/pages/forms/blurred_graph.png"
alt="Sample Graph"
class="mx-auto filter blur-md z-0"
/>
<img
src="/img/pages/forms/blurred_graph.png"
alt="Sample Graph"
class="mx-auto filter blur-md z-0"
>
</div>
<Loader v-else-if="isLoading" class="h-6 w-6 text-nt-blue mx-auto" />
<LineChart v-else
:options="chartOptions"
:data="chartData"
<Loader
v-else-if="isLoading"
class="h-6 w-6 text-nt-blue mx-auto"
/>
<LineChart
v-else
:options="chartOptions"
:data="chartData"
/>
</div>
</template>
<script>
import { Line as LineChart } from 'vue-chartjs'
import { Line as LineChart } from "vue-chartjs"
import {
Chart as ChartJS,
Title,
@@ -37,9 +47,9 @@ import {
LineElement,
LinearScale,
CategoryScale,
PointElement
} from 'chart.js'
import ProTag from '~/components/global/ProTag.vue'
PointElement,
} from "chart.js"
import ProTag from "~/components/global/ProTag.vue"
ChartJS.register(
Title,
@@ -48,63 +58,70 @@ ChartJS.register(
LineElement,
LinearScale,
CategoryScale,
PointElement
PointElement,
)
export default {
name: 'FormStats',
name: "FormStats",
components: {
ProTag,
LineChart
LineChart,
},
props: {
form: {
type: Object,
required: true
}
required: true,
},
},
data () {
data() {
return {
isLoading: true,
chartData: {
labels: [],
datasets: [
{
label: 'Form Views',
backgroundColor: 'rgba(59, 130, 246, 1)',
borderColor: 'rgba(59, 130, 246, 1)',
data: []
label: "Form Views",
backgroundColor: "rgba(59, 130, 246, 1)",
borderColor: "rgba(59, 130, 246, 1)",
data: [],
},
{
label: 'Form Submissions',
backgroundColor: 'rgba(16, 185, 129, 1)',
borderColor: 'rgba(16, 185, 129, 1)',
data: []
}
]
label: "Form Submissions",
backgroundColor: "rgba(16, 185, 129, 1)",
borderColor: "rgba(16, 185, 129, 1)",
data: [],
},
],
},
chartOptions: {
scales: {
y: {
beginAtZero: true,
ticks: {
precision: 0
}
}
precision: 0,
},
},
},
responsive: true,
maintainAspectRatio: true
}
maintainAspectRatio: true,
},
}
},
mounted () {
mounted() {
this.getChartData()
},
methods: {
getChartData () {
if (!this.form) { return null }
getChartData() {
if (!this.form) {
return null
}
this.isLoading = true
opnFetch('/open/workspaces/' + this.form.workspace_id + '/form-stats/' + this.form.id).then((statsData) => {
opnFetch(
"/open/workspaces/" +
this.form.workspace_id +
"/form-stats/" +
this.form.id,
).then((statsData) => {
if (statsData && statsData.views !== undefined) {
this.chartData.labels = Object.keys(statsData.views)
this.chartData.datasets[0].data = statsData.views
@@ -112,7 +129,7 @@ export default {
this.isLoading = false
}
})
}
}
},
},
}
</script>

View File

@@ -1,5 +1,6 @@
<template>
<div id="table-page"
<div
id="table-page"
class="w-full flex flex-col"
>
<div class="w-full md:w-4/5 lg:w-3/5 md:mx-auto md:max-w-4xl px-4 pt-4">
@@ -8,15 +9,31 @@
</h3>
<!-- Table columns modal -->
<modal :show="showColumnsModal" @close="showColumnsModal=false">
<modal
:show="showColumnsModal"
@close="showColumnsModal=false"
>
<template #icon>
<svg class="w-8 h-8" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-8 h-8"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M16 5H8C4.13401 5 1 8.13401 1 12C1 15.866 4.13401 19 8 19H16C19.866 19 23 15.866 23 12C23 8.13401 19.866 5 16 5Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M8 15C9.65685 15 11 13.6569 11 12C11 10.3431 9.65685 9 8 9C6.34315 9 5 10.3431 5 12C5 13.6569 6.34315 15 8 15Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<template #title>
@@ -29,14 +46,20 @@
Form Fields
</h4>
<div class="border border-gray-300 rounded-md">
<div v-for="(field,index) in candidatesProperties" :key="field.id"
class="p-2 border-gray-300 flex items-center"
:class="{'border-t':index!=0}">
<div
v-for="(field,index) in candidatesProperties"
:key="field.id"
class="p-2 border-gray-300 flex items-center"
:class="{'border-t':index!=0}"
>
<p class="flex-grow truncate">
{{ field.name }}
</p>
<v-switch v-model="displayColumns[field.id]" class="float-right"
@update:model-value="onChangeDisplayColumns"/>
<v-switch
v-model="displayColumns[field.id]"
class="float-right"
@update:model-value="onChangeDisplayColumns"
/>
</div>
</div>
</template>
@@ -45,40 +68,65 @@
Removed Fields
</h4>
<div class="border border-gray-300 rounded-md">
<div v-for="(field,index) in removed_properties" :key="field.id"
class="p-2 border-gray-300 flex items-center" :class="{'border-t':index!=0}">
<div
v-for="(field,index) in removed_properties"
:key="field.id"
class="p-2 border-gray-300 flex items-center"
:class="{'border-t':index!=0}"
>
<p class="flex-grow truncate">
{{ field.name }}
</p>
<v-switch v-model="displayColumns[field.id]" class="float-right"
@update:model-value="onChangeDisplayColumns"/>
<v-switch
v-model="displayColumns[field.id]"
class="float-right"
@update:model-value="onChangeDisplayColumns"
/>
</div>
</div>
</template>
</div>
</modal>
<Loader v-if="!form" class="h-6 w-6 text-nt-blue mx-auto"/>
<Loader
v-if="!form"
class="h-6 w-6 text-nt-blue mx-auto"
/>
<div v-else>
<div v-if="form && tableData.length > 0" class="flex flex-wrap items-end">
<div
v-if="form && tableData.length > 0"
class="flex flex-wrap items-end"
>
<div class="flex-grow">
<text-input class="w-64" :form="searchForm" name="search" placeholder="Search..."/>
<text-input
class="w-64"
:form="searchForm"
name="search"
placeholder="Search..."
/>
</div>
<div class="font-semibold flex gap-4">
<p class="float-right text-xs uppercase mb-2">
<a
href="javascript:void(0);" class="text-gray-500" @click="showColumnsModal=true"
href="javascript:void(0);"
class="text-gray-500"
@click="showColumnsModal=true"
>Display columns</a>
</p>
<p class="text-right cursor-pointer text-xs uppercase">
<a v-if="!exportLoading"
@click.prevent="downloadAsCsv" href="#"
<p
v-if="!exportLoading"
class="text-right cursor-pointer text-xs uppercase"
>
<a
href="#"
@click.prevent="downloadAsCsv"
>Export as CSV</a>
<p v-else><loader class="w-3 h-3 text-blue-500" /></p>
</p>
<p v-else>
<loader class="w-3 h-3 text-blue-500" />
</p>
</div>
</div>
</div>
</div>
<div class="px-4 pb-4 flex justify-center">
@@ -88,7 +136,8 @@
:shadow-top-offset="0"
:hide-scrollbar="true"
>
<open-table v-if="form"
<open-table
v-if="form"
ref="table"
class="max-h-full"
:columns="properties"
@@ -247,7 +296,7 @@ export default {
this.recordStore.stopLoading()
this.fullyLoaded = true
}
}).catch((error) => {
}).catch(() => {
this.recordStore.startLoading()
})
},
@@ -268,11 +317,11 @@ export default {
})
},
onUpdateRecord(submission) {
this.recordStore.save(submission);
this.recordStore.save(submission)
this.dataChanged()
},
onDeleteRecord(submission) {
this.recordStore.remove(submission);
this.recordStore.remove(submission)
this.dataChanged()
},
downloadAsCsv() {
@@ -283,7 +332,7 @@ export default {
opnFetch(this.exportUrl, {responseType: "blob"})
.then(blob => {
const filename = `${this.form.slug}-${Date.now()}-submissions.csv`
let a = document.createElement("a")
const a = document.createElement("a")
document.body.appendChild(a)
a.style = "display: none"
const url = window.URL.createObjectURL(blob)

View File

@@ -3,13 +3,26 @@
class="border border-nt-blue-light bg-blue-50 dark:bg-notion-dark-light shadow rounded-md p-4 mb-5 w-full mx-auto mt-4 select-all"
>
<div class="flex items-center">
<p class="select-all flex-grow break-all" v-html="preFillUrl" />
<div class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer" @click="copyToClipboard">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-nt-blue" fill="none" viewBox="0 0 24 24"
stroke="currentColor"
<p
class="select-all flex-grow break-all"
v-html="preFillUrl"
/>
<div
class="hover:bg-nt-blue-lighter rounded transition-colors cursor-pointer"
@click="copyToClipboard"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-nt-blue"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M8 5H6a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2v-1M8 5a2 2 0 002 2h2a2 2 0 002-2M8 5a2 2 0 012-2h2a2 2 0 012 2m0 0h2a2 2 0 012 2v3m2 4H10m0 0l3-3m-3 3l3 3"
/>
</svg>
</div>
@@ -18,50 +31,57 @@
</template>
<script setup>
import { defineProps, computed } from 'vue'
import { default as _has } from 'lodash/has'
import { defineProps, computed } from "vue"
import { default as _has } from "lodash/has"
const { copy } = useClipboard()
const props = defineProps({
form: {
type: Object,
required: true
required: true,
},
formData: {
type: Object,
required: true
required: true,
},
extraQueryParam: {
type: String,
default: ''
}
default: "",
},
})
const preFillUrl = computed(() => {
const url = props.form.share_url
const uriComponents = new URLSearchParams()
props.form.properties.filter((property) => {
return _has(props.formData, property.id) && props.formData[property.id] !== null
}).forEach((property) => {
if (Array.isArray(props.formData[property.id])) {
props.formData[property.id].forEach((value) => {
uriComponents.append(property.id + '[]', value)
})
} else {
uriComponents.append(property.id, props.formData[property.id])
}
})
props.form.properties
.filter((property) => {
return (
_has(props.formData, property.id) &&
props.formData[property.id] !== null
)
})
.forEach((property) => {
if (Array.isArray(props.formData[property.id])) {
props.formData[property.id].forEach((value) => {
uriComponents.append(property.id + "[]", value)
})
} else {
uriComponents.append(property.id, props.formData[property.id])
}
})
if(uriComponents.toString() !== ""){
return (props.extraQueryParam) ? url + '?' + uriComponents + '&' + props.extraQueryParam : url + '?' + uriComponents
}else{
return (props.extraQueryParam) ? url + '?' + props.extraQueryParam : url
if (uriComponents.toString() !== "") {
return props.extraQueryParam
? url + "?" + uriComponents + "&" + props.extraQueryParam
: url + "?" + uriComponents
} else {
return props.extraQueryParam ? url + "?" + props.extraQueryParam : url
}
})
const copyToClipboard = () => {
if (import.meta.server) return
copy(preFillUrl.value)
useAlert().success('Copied!')
useAlert().success("Copied!")
}
</script>

View File

@@ -1,103 +1,141 @@
<template>
<modal :show="show" @close="emit('close')">
<template #icon>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-8 h-8">
<path stroke-linecap="round" stroke-linejoin="round" d="M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 3h12m-.75 4.5H21m-3.75 3.75h.008v.008h-.008v-.008Zm0 3h.008v.008h-.008v-.008Zm0 3h.008v.008h-.008v-.008Z" />
</svg>
</template>
<template #title>
Change form workspace
</template>
<div class="p-4">
<div class="flex space-x-4 items-center">
<p>Current workspace:</p>
<div class="flex items-center cursor group p-2 rounded border">
<div class="rounded-full h-8 8">
<img v-if="isUrl(workspace.icon)"
:src="workspace.icon"
:alt="workspace.name + ' icon'" class="flex-shrink-0 h-8 w-8 rounded-full shadow"
/>
<div v-else class="rounded-full pt-2 text-xs truncate bg-nt-blue-lighter h-8 w-8 text-center shadow"
v-text="workspace.icon"
/>
</div>
<p class="lg:block max-w-10 truncate ml-2 text-gray-800 dark:text-gray-200">
{{ workspace.name }}
</p>
</div>
</div>
<form @submit.prevent="onSubmit">
<div class=" my-4">
<select-input name="workspace" class=""
:options="workspacesSelectOptions"
v-model="selectedWorkspace"
:required="true"
label="Select workspace"
/>
</div>
<div class="flex justify-end mt-4 pb-5">
<v-button class="mr-2" :loading="loading">
Change workspace
</v-button>
<v-button color="white" @click.prevent="emit('close')">
Close
</v-button>
</div>
</form>
<modal
:show="show"
@close="emit('close')"
>
<template #icon>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-8 h-8"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 21h19.5m-18-18v18m10.5-18v18m6-13.5V21M6.75 6.75h.75m-.75 3h.75m-.75 3h.75m3-6h.75m-.75 3h.75m-.75 3h.75M6.75 21v-3.375c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21M3 3h12m-.75 4.5H21m-3.75 3.75h.008v.008h-.008v-.008Zm0 3h.008v.008h-.008v-.008Zm0 3h.008v.008h-.008v-.008Z"
/>
</svg>
</template>
<template #title>
Change form workspace
</template>
<div class="p-4">
<div class="flex space-x-4 items-center">
<p>Current workspace:</p>
<div class="flex items-center cursor group p-2 rounded border">
<div class="rounded-full h-8 8">
<img
v-if="isUrl(workspace.icon)"
:src="workspace.icon"
:alt="workspace.name + ' icon'"
class="flex-shrink-0 h-8 w-8 rounded-full shadow"
>
<div
v-else
class="rounded-full pt-2 text-xs truncate bg-nt-blue-lighter h-8 w-8 text-center shadow"
v-text="workspace.icon"
/>
</div>
<p
class="lg:block max-w-10 truncate ml-2 text-gray-800 dark:text-gray-200"
>
{{ workspace.name }}
</p>
</div>
</modal>
</div>
<form @submit.prevent="onSubmit">
<div class="my-4">
<select-input
v-model="selectedWorkspace"
name="workspace"
class=""
:options="workspacesSelectOptions"
:required="true"
label="Select workspace"
/>
</div>
<div class="flex justify-end mt-4 pb-5">
<v-button
class="mr-2"
:loading="loading"
>
Change workspace
</v-button>
<v-button
color="white"
@click.prevent="emit('close')"
>
Close
</v-button>
</div>
</form>
</div>
</modal>
</template>
<script setup>
import { ref, defineProps, defineEmits, computed } from 'vue'
const emit = defineEmits(['close'])
import { ref, defineProps, defineEmits, computed } from "vue"
const emit = defineEmits(["close"])
const workspacesStore = useWorkspacesStore()
const formsStore = useFormsStore()
const selectedWorkspace = ref(null);
const selectedWorkspace = ref(null)
const props = defineProps({
show: { type: Boolean, required: true },
form: { type: Object, required: true },
show: { type: Boolean, required: true },
form: { type: Object, required: true },
})
const workspaces = computed(() => workspacesStore.getAll)
const workspace = computed(() => workspacesStore.getByKey(props.form?.workspace_id))
const workspace = computed(() =>
workspacesStore.getByKey(props.form?.workspace_id),
)
const loading = ref(false)
const workspacesSelectOptions = computed(()=> workspaces.value.filter((w)=>{
return w.id !== workspace.value.id
}).map(workspace => ({ name: workspace.name, value: workspace.id })))
const workspacesSelectOptions = computed(() =>
workspaces.value
.filter((w) => {
return w.id !== workspace.value.id
})
.map((workspace) => ({ name: workspace.name, value: workspace.id })),
)
const onSubmit = () => {
const endpoint = '/open/forms/' + props.form.id + '/workspace/' + selectedWorkspace.value
if(! selectedWorkspace.value) {
useAlert().error('Please select a workspace!')
return;
}
opnFetch(endpoint, { method: 'POST' }).then(data => {
loading.value = false;
emit('close')
useAlert().success('Form workspace updated successfully.')
workspacesStore.setCurrentId(selectedWorkspace.value)
formsStore.resetState()
formsStore.loadAll(selectedWorkspace.value)
const router = useRouter()
const route = useRoute()
if (route.name !== 'home') {
router.push({ name: 'home' })
}
formsStore.loadAll(selectedWorkspace.value)
}).catch((error) => {
useAlert().error(error?.data?.message ?? 'Something went wrong, please try again!')
loading.value = false;
const endpoint =
"/open/forms/" + props.form.id + "/workspace/" + selectedWorkspace.value
if (!selectedWorkspace.value) {
useAlert().error("Please select a workspace!")
return
}
opnFetch(endpoint, { method: "POST" })
.then(() => {
loading.value = false
emit("close")
useAlert().success("Form workspace updated successfully.")
workspacesStore.setCurrentId(selectedWorkspace.value)
formsStore.resetState()
formsStore.loadAll(selectedWorkspace.value)
const router = useRouter()
const route = useRoute()
if (route.name !== "home") {
router.push({ name: "home" })
}
formsStore.loadAll(selectedWorkspace.value)
})
.catch((error) => {
useAlert().error(
error?.data?.message ?? "Something went wrong, please try again!",
)
loading.value = false
})
}
const isUrl = (str) => {
try {
new URL(str)
} catch (_) {
return false
}
return true
try {
new URL(str)
} catch (_) {
return false
}
return true
}
</script>
</script>

View File

@@ -2,10 +2,23 @@
<div>
<div class="p-4 border-b sticky top-0 z-10 bg-white">
<div class="flex">
<button class="text-gray-500 hover:text-gray-900 cursor-pointer" @click.prevent="closeSidebar">
<svg class="h-6 w-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round" />
<button
class="text-gray-500 hover:text-gray-900 cursor-pointer"
@click.prevent="closeSidebar"
>
<svg
class="h-6 w-6"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18 6L6 18M6 6L18 18"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</button>
<div class="font-semibold inline ml-2 truncate flex-grow truncate">
@@ -20,14 +33,27 @@
Input Blocks
</p>
<div class="grid grid-cols-2 gap-2">
<div v-for="(block, i) in inputBlocks" :key="block.name"
<div
v-for="(block) in inputBlocks"
:key="block.name"
class="bg-gray-50 border hover:bg-gray-100 dark:bg-gray-900 rounded-md dark:hover:bg-gray-800 py-2 flex flex-col"
role="button" @click.prevent="addBlock(block.name)">
role="button"
@click.prevent="addBlock(block.name)"
>
<div class="mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2" v-html="block.icon"></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-gray-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
v-html="block.icon"
/>
</div>
<p class="w-full text-xs text-gray-500 uppercase text-center font-semibold mt-1">
<p
class="w-full text-xs text-gray-500 uppercase text-center font-semibold mt-1"
>
{{ block.title }}
</p>
</div>
@@ -38,14 +64,27 @@
Layout Blocks
</p>
<div class="grid grid-cols-2 gap-2">
<div v-for="(block, i) in layoutBlocks" :key="block.name"
<div
v-for="(block) in layoutBlocks"
:key="block.name"
class="bg-gray-50 border hover:bg-gray-100 dark:bg-gray-900 rounded-md dark:hover:bg-gray-800 py-2 flex flex-col"
role="button" @click.prevent="addBlock(block.name)">
role="button"
@click.prevent="addBlock(block.name)"
>
<div class="mx-auto">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-500" fill="none" viewBox="0 0 24 24"
stroke="currentColor" stroke-width="2" v-html="block.icon"></svg>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 text-gray-500"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
v-html="block.icon"
/>
</div>
<p class="w-full text-xs text-gray-500 uppercase text-center font-semibold mt-1">
<p
class="w-full text-xs text-gray-500 uppercase text-center font-semibold mt-1"
>
{{ block.title }}
</p>
</div>
@@ -56,11 +95,11 @@
</template>
<script>
import clonedeep from 'clone-deep'
import { computed } from 'vue'
import clonedeep from "clone-deep"
import { computed } from "vue"
export default {
name: 'AddFormBlock',
name: "AddFormBlock",
components: {},
props: {},
@@ -70,140 +109,139 @@ export default {
return {
form,
workingFormStore,
selectedFieldIndex: computed(() => workingFormStore.selectedFieldIndex)
selectedFieldIndex: computed(() => workingFormStore.selectedFieldIndex),
}
},
data() {
return {
blockForm: null,
inputBlocks: [
{
name: 'text',
title: 'Text Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h7"/>'
name: "text",
title: "Text Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h7"/>',
},
{
name: 'date',
title: 'Date Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>'
name: "date",
title: "Date Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>',
},
{
name: 'url',
title: 'URL Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" 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"/>'
name: "url",
title: "URL Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" 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"/>',
},
{
name: 'phone_number',
title: 'Phone Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>'
name: "phone_number",
title: "Phone Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M3 5a2 2 0 012-2h3.28a1 1 0 01.948.684l1.498 4.493a1 1 0 01-.502 1.21l-2.257 1.13a11.042 11.042 0 005.516 5.516l1.13-2.257a1 1 0 011.21-.502l4.493 1.498a1 1 0 01.684.949V19a2 2 0 01-2 2h-1C9.716 21 3 14.284 3 6V5z"/>',
},
{
name: 'email',
title: 'Email Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"/>'
name: "email",
title: "Email Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"/>',
},
{
name: 'checkbox',
title: 'Checkbox Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>'
name: "checkbox",
title: "Checkbox Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>',
},
{
name: 'select',
title: 'Select Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 9l4-4 4 4m0 6l-4 4-4-4"/>'
name: "select",
title: "Select Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 9l4-4 4 4m0 6l-4 4-4-4"/>',
},
{
name: 'multi_select',
title: 'Multi-select Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 9l4-4 4 4m0 6l-4 4-4-4"/>'
name: "multi_select",
title: "Multi-select Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M8 9l4-4 4 4m0 6l-4 4-4-4"/>',
},
{
name: 'number',
title: 'Number Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"/>'
name: "number",
title: "Number Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M7 20l4-16m2 16l4-16M6 9h14M4 15h14"/>',
},
{
name: 'rating',
title: 'Rating Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" />'
name: "rating",
title: "Rating Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M11.48 3.499a.562.562 0 0 1 1.04 0l2.125 5.111a.563.563 0 0 0 .475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 0 0-.182.557l1.285 5.385a.562.562 0 0 1-.84.61l-4.725-2.885a.562.562 0 0 0-.586 0L6.982 20.54a.562.562 0 0 1-.84-.61l1.285-5.386a.562.562 0 0 0-.182-.557l-4.204-3.602a.562.562 0 0 1 .321-.988l5.518-.442a.563.563 0 0 0 .475-.345L11.48 3.5Z" />',
},
{
name: 'scale',
title: 'Scale Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z" />'
name: "scale",
title: "Scale Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0 0 20.25 18V6A2.25 2.25 0 0 0 18 3.75H6A2.25 2.25 0 0 0 3.75 6v12A2.25 2.25 0 0 0 6 20.25Z" />',
},
{
name: 'slider',
title: 'Slider Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75" />'
name: "slider",
title: "Slider Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 6h9.75M10.5 6a1.5 1.5 0 1 1-3 0m3 0a1.5 1.5 0 1 0-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 0 1-3 0m3 0a1.5 1.5 0 0 0-3 0m-9.75 0h9.75" />',
},
{
name: 'files',
title: 'File Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />'
name: "files",
title: "File Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />',
},
{
name: 'signature',
title: 'Signature Input',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125" />'
}
name: "signature",
title: "Signature Input",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L6.832 19.82a4.5 4.5 0 01-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 011.13-1.897L16.863 4.487zm0 0L19.5 7.125" />',
},
],
layoutBlocks: [
{
name: 'nf-text',
title: 'Text Block',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h8m-8 6h16" />'
name: "nf-text",
title: "Text Block",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h8m-8 6h16" />',
},
{
name: 'nf-page-break',
title: 'Page-break Block',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />'
name: "nf-page-break",
title: "Page-break Block",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M9 13h6m-3-3v6m5 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />',
},
{
name: 'nf-divider',
title: 'Divider Block',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M20 12H4" />'
name: "nf-divider",
title: "Divider Block",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M20 12H4" />',
},
{
name: 'nf-image',
title: 'Image Block',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />'
name: "nf-image",
title: "Image Block",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />',
},
{
name: 'nf-code',
title: 'Code Block',
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5" />'
}
]
name: "nf-code",
title: "Code Block",
icon: '<path stroke-linecap="round" stroke-linejoin="round" d="M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5" />',
},
],
}
},
computed: {
defaultBlockNames() {
return {
text: 'Your name',
date: 'Date',
url: 'Link',
phone_number: 'Phone Number',
number: 'Number',
rating: 'Rating',
scale: 'Scale',
slider: 'Slider',
email: 'Email',
checkbox: 'Checkbox',
select: 'Select',
multi_select: 'Multi Select',
files: 'Files',
signature: 'Signature',
'nf-text': 'Text Block',
'nf-page-break': 'Page Break',
'nf-divider': 'Divider',
'nf-image': 'Image',
'nf-code': 'Code Block'
text: "Your name",
date: "Date",
url: "Link",
phone_number: "Phone Number",
number: "Number",
rating: "Rating",
scale: "Scale",
slider: "Slider",
email: "Email",
checkbox: "Checkbox",
select: "Select",
multi_select: "Multi Select",
files: "Files",
signature: "Signature",
"nf-text": "Text Block",
"nf-page-break": "Page Break",
"nf-divider": "Divider",
"nf-image": "Image",
"nf-code": "Code Block",
}
}
},
},
watch: {},
@@ -219,7 +257,7 @@ export default {
reset() {
this.blockForm = useForm({
type: null,
name: null
name: null,
})
},
addBlock(type) {
@@ -228,28 +266,33 @@ export default {
const newBlock = this.prefillDefault(this.blockForm.data())
newBlock.id = this.generateUUID()
newBlock.hidden = false
if (['select', 'multi_select'].includes(this.blockForm.type)) {
if (["select", "multi_select"].includes(this.blockForm.type)) {
newBlock[this.blockForm.type] = { options: [] }
}
if (this.blockForm.type === 'rating') {
if (this.blockForm.type === "rating") {
newBlock.rating_max_value = 5
}
if (this.blockForm.type === 'scale') {
if (this.blockForm.type === "scale") {
newBlock.scale_min_value = 1
newBlock.scale_max_value = 5
newBlock.scale_step_value = 1
}
if (this.blockForm.type === 'slider') {
if (this.blockForm.type === "slider") {
newBlock.slider_min_value = 0
newBlock.slider_max_value = 50
newBlock.slider_step_value = 1
}
newBlock.help_position = 'below_input'
if (this.selectedFieldIndex === null || this.selectedFieldIndex === undefined) {
newBlock.help_position = "below_input"
if (
this.selectedFieldIndex === null ||
this.selectedFieldIndex === undefined
) {
const newFields = clonedeep(this.form.properties)
newFields.push(newBlock)
this.form.properties = newFields
this.workingFormStore.openSettingsForField(this.form.properties.length - 1)
this.workingFormStore.openSettingsForField(
this.form.properties.length - 1,
)
} else {
const newFields = clonedeep(this.form.properties)
newFields.splice(this.selectedFieldIndex + 1, 0, newBlock)
@@ -259,33 +302,43 @@ export default {
this.reset()
},
generateUUID() {
let d = new Date().getTime()// Timestamp
let d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0// Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
let r = Math.random() * 16// random number between 0 and 16
if (d > 0) { // Use timestamp until depleted
r = (d + r) % 16 | 0
d = Math.floor(d / 16)
} else { // Use microseconds since page-load if supported
r = (d2 + r) % 16 | 0
d2 = Math.floor(d2 / 16)
}
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
})
let d = new Date().getTime() // Timestamp
let d2 =
(typeof performance !== "undefined" &&
performance.now &&
performance.now() * 1000) ||
0 // Time in microseconds since page-load or 0 if unsupported
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
let r = Math.random() * 16 // random number between 0 and 16
if (d > 0) {
// Use timestamp until depleted
r = (d + r) % 16 | 0
d = Math.floor(d / 16)
} else {
// Use microseconds since page-load if supported
r = (d2 + r) % 16 | 0
d2 = Math.floor(d2 / 16)
}
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16)
},
)
},
prefillDefault(data) {
if (data.type === 'nf-text') {
data.content = '<p>This is a text block.</p>'
} else if (data.type === 'nf-page-break') {
data.next_btn_text = 'Next'
data.previous_btn_text = 'Previous'
} else if (data.type === 'nf-code') {
data.content = '<div class="text-blue-500 italic">This is a code block.</div>'
} else if (data.type === 'signature') {
data.help = 'Draw your signature above'
if (data.type === "nf-text") {
data.content = "<p>This is a text block.</p>"
} else if (data.type === "nf-page-break") {
data.next_btn_text = "Next"
data.previous_btn_text = "Previous"
} else if (data.type === "nf-code") {
data.content =
'<div class="text-blue-500 italic">This is a code block.</div>'
} else if (data.type === "signature") {
data.help = "Draw your signature above"
}
return data
}
}
},
},
}
</script>

View File

@@ -1,55 +1,91 @@
<template>
<editor-options-panel name="About Submissions" :already-opened="true">
<editor-options-panel
name="About Submissions"
:already-opened="true"
>
<template #icon>
<svg class="h-5 w-5" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="h-5 w-5"
viewBox="0 0 18 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M4.83333 6.08333H9M4.83333 9H11.5M4.83333 14V15.9463C4.83333 16.3903 4.83333 16.6123 4.92436 16.7263C5.00352 16.8255 5.12356 16.8832 5.25045 16.8831C5.39636 16.8829 5.56973 16.7442 5.91646 16.4668L7.90434 14.8765C8.31043 14.5517 8.51347 14.3892 8.73957 14.2737C8.94017 14.1712 9.15369 14.0963 9.37435 14.051C9.62306 14 9.88308 14 10.4031 14H12.5C13.9001 14 14.6002 14 15.135 13.7275C15.6054 13.4878 15.9878 13.1054 16.2275 12.635C16.5 12.1002 16.5 11.4001 16.5 10V5.5C16.5 4.09987 16.5 3.3998 16.2275 2.86502C15.9878 2.39462 15.6054 2.01217 15.135 1.77248C14.6002 1.5 13.9001 1.5 12.5 1.5H5.5C4.09987 1.5 3.3998 1.5 2.86502 1.77248C2.39462 2.01217 2.01217 2.39462 1.77248 2.86502C1.5 3.3998 1.5 4.09987 1.5 5.5V10.6667C1.5 11.4416 1.5 11.8291 1.58519 12.147C1.81635 13.0098 2.49022 13.6836 3.35295 13.9148C3.67087 14 4.05836 14 4.83333 14Z"
stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<text-input name="submit_button_text" class="mt-4"
:form="form"
label="Text of Submit Button"
:required="true"
<text-input
name="submit_button_text"
class="mt-4"
:form="form"
label="Text of Submit Button"
:required="true"
/>
<toggle-switch-input name="editable_submissions" :form="form" class="mt-4"
help="Gives user a unique url to update their submission"
<toggle-switch-input
name="editable_submissions"
:form="form"
class="mt-4"
help="Gives user a unique url to update their submission"
>
<template #label>
Editable submissions
<pro-tag class="ml-1" />
</template>
</toggle-switch-input>
<text-input v-if="form.editable_submissions" name="editable_submissions_button_text"
:form="form"
label="Text of editable submissions button"
:required="true"
<text-input
v-if="form.editable_submissions"
name="editable_submissions_button_text"
:form="form"
label="Text of editable submissions button"
:required="true"
/>
<flat-select-input :form="submissionOptions" name="databaseAction" label="Database Submission Action"
:options="[
{name:'Create new record (default)', value:'create'},
{name:'Update Record (or create if no match)', value:'update'}
]" :required="true" help="Create a new record or update an existing one"
<flat-select-input
:form="submissionOptions"
name="databaseAction"
label="Database Submission Action"
:options="[
{ name: 'Create new record (default)', value: 'create' },
{ name: 'Update Record (or create if no match)', value: 'update' },
]"
:required="true"
help="Create a new record or update an existing one"
>
<template #selected="{option,optionName}">
<template #selected="{ option, optionName }">
<div class="flex items-center truncate mr-6">
{{ optionName }}
<pro-tag v-if="option === 'update'" class="ml-2" />
<pro-tag
v-if="option === 'update'"
class="ml-2"
/>
</div>
</template>
<template #option="{option, selected}">
<template #option="{ option, selected }">
<span class="flex hover:text-white">
<p class="flex-grow hover:text-white">
{{ option.name }} <template v-if="option.value === 'update'"><pro-tag /></template>
{{ option.name }}
<template v-if="option.value === 'update'"><pro-tag /></template>
</p>
<span v-if="selected" class="absolute inset-y-0 right-0 flex items-center pr-4 dark:text-white">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clip-rule="evenodd"
<span
v-if="selected"
class="absolute inset-y-0 right-0 flex items-center pr-4 dark:text-white"
>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clip-rule="evenodd"
/>
</svg>
</span>
@@ -58,45 +94,77 @@
</flat-select-input>
<v-transition>
<div v-if="submissionOptions.databaseAction == 'update' && filterableFields.length">
<select-input v-if="filterableFields.length" :form="form" name="database_fields_update"
label="Properties to check on update" :options="filterableFields" :required="true"
:multiple="true"
<div
v-if="
submissionOptions.databaseAction == 'update' &&
filterableFields.length
"
>
<select-input
v-if="filterableFields.length"
:form="form"
name="database_fields_update"
label="Properties to check on update"
:options="filterableFields"
:required="true"
:multiple="true"
/>
<div class="-mt-3 mb-3 text-gray-400 dark:text-gray-500">
<small>If the submission has the same value(s) as a previous one for the selected
column(s), we will update it, instead of creating a new one.
<a href="#"
@click.prevent="crisp.openHelpdeskArticle('how-to-update-a-page-on-form-submission-1t1jwmn')"
>More
info here.</a>
<small>If the submission has the same value(s) as a previous one for the
selected column(s), we will update it, instead of creating a new
one.
<a
href="#"
@click.prevent="
crisp.openHelpdeskArticle(
'how-to-update-a-page-on-form-submission-1t1jwmn',
)
"
>More info here.</a>
</small>
</div>
</div>
</v-transition>
<select-input :form="submissionOptions" name="submissionMode" label="Post Submission Action"
:options="[
{name:'Show Success page', value:'default'},
{name:'Redirect', value:'redirect'}
]" :required="true" help="Show a message, or redirect to a URL"
<select-input
:form="submissionOptions"
name="submissionMode"
label="Post Submission Action"
:options="[
{ name: 'Show Success page', value: 'default' },
{ name: 'Redirect', value: 'redirect' },
]"
:required="true"
help="Show a message, or redirect to a URL"
>
<template #selected="{option,optionName}">
<template #selected="{ option, optionName }">
<div class="flex items-center truncate mr-6">
{{ optionName }}
<pro-tag v-if="option === 'redirect'" class="ml-2" />
<pro-tag
v-if="option === 'redirect'"
class="ml-2"
/>
</div>
</template>
<template #option="{option, selected}">
<template #option="{ option, selected }">
<span class="flex hover:text-white">
<p class="flex-grow hover:text-white">
{{ option.name }} <template v-if="option.value === 'redirect'"><pro-tag /></template>
{{ option.name }}
<template v-if="option.value === 'redirect'"><pro-tag /></template>
</p>
<span v-if="selected" class="absolute inset-y-0 right-0 flex items-center pr-4">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clip-rule="evenodd"
<span
v-if="selected"
class="absolute inset-y-0 right-0 flex items-center pr-4"
>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clip-rule="evenodd"
/>
</svg>
</span>
@@ -104,105 +172,111 @@
</template>
</select-input>
<template v-if="submissionOptions.submissionMode === 'redirect'">
<text-input name="redirect_url"
:form="form"
label="Redirect URL"
:required="true" help="On submit, redirects to that URL"
<text-input
name="redirect_url"
:form="form"
label="Redirect URL"
:required="true"
help="On submit, redirects to that URL"
/>
</template>
<template v-else>
<toggle-switch-input name="re_fillable" :form="form" class="mt-4"
label="Allow users to fill the form again"
<toggle-switch-input
name="re_fillable"
:form="form"
class="mt-4"
label="Allow users to fill the form again"
/>
<text-input v-if="form.re_fillable" name="re_fill_button_text"
:form="form"
label="Text of re-start button"
:required="true"
<text-input
v-if="form.re_fillable"
name="re_fill_button_text"
:form="form"
label="Text of re-start button"
:required="true"
/>
<rich-text-area-input name="submitted_text"
:form="form"
label="Text After Submission"
:required="false"
<rich-text-area-input
name="submitted_text"
:form="form"
label="Text After Submission"
:required="false"
/>
</template>
</editor-options-panel>
</template>
<script>
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import ProTag from '~/components/global/ProTag.vue'
import VTransition from '~/components/global/transitions/VTransition.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
import ProTag from "~/components/global/ProTag.vue"
import VTransition from "~/components/global/transitions/VTransition.vue"
export default {
components: {EditorOptionsPanel, ProTag, VTransition},
components: { EditorOptionsPanel, ProTag, VTransition },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
const {content: form} = storeToRefs(workingFormStore)
const { content: form } = storeToRefs(workingFormStore)
return {
form,
workingFormStore,
crisp: useCrisp()
crisp: useCrisp(),
}
},
data () {
data() {
return {
submissionOptions: {}
submissionOptions: {},
}
},
computed: {
form: {
get () {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
this.workingFormStore.set(value)
}
},
/**
* Used for the update record on submission. Lists all visible fields on which you can filter records to update
* on submission instead of creating
*/
filterableFields () {
if (this.submissionOptions.databaseAction !== 'update') return []
return this.form.properties.filter((field) => {
return !field.hidden && !['files', 'signature', 'multi_select'].includes(field.type)
}).map((field) => {
return {
name: field.name,
value: field.id
}
})
}
filterableFields() {
if (this.submissionOptions.databaseAction !== "update") return []
return this.form.properties
.filter((field) => {
return (
!field.hidden &&
!["files", "signature", "multi_select"].includes(field.type)
)
})
.map((field) => {
return {
name: field.name,
value: field.id,
}
})
},
},
watch: {
form: {
handler () {
handler() {
if (this.form) {
this.submissionOptions = {
submissionMode: this.form.redirect_url ? 'redirect' : 'default',
databaseAction: this.form.database_fields_update ? 'update' : 'create'
submissionMode: this.form.redirect_url ? "redirect" : "default",
databaseAction: this.form.database_fields_update
? "update"
: "create",
}
}
},
deep: true
deep: true,
},
submissionOptions: {
deep: true,
handler: function (val) {
if (val.submissionMode === 'default') {
if (val.submissionMode === "default") {
this.form.redirect_url = null
}
if (val.databaseAction === 'create') {
if (val.databaseAction === "create") {
this.form.database_fields_update = null
}
}
}
}
},
},
},
}
</script>

View File

@@ -1,73 +1,101 @@
<template>
<editor-options-panel name="Form Access" :already-opened="false">
<editor-options-panel
name="Form Access"
:already-opened="false"
>
<template #icon>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"
<svg
class="h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M15.75 5.25a3 3 0 013 3m3 0a6 6 0 01-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1121.75 8.25z"
/>
</svg>
</template>
<text-input name="password" :form="form" class="mt-4"
label="Form Password" help="Leave empty to disable password"
<text-input
name="password"
:form="form"
class="mt-4"
label="Form Password"
help="Leave empty to disable password"
/>
<date-input :with-time="true" name="closes_at" class="mt-4"
:form="form"
label="Close form on a scheduled date"
help="Leave empty to keep the form open"
:required="false"
<date-input
:with-time="true"
name="closes_at"
class="mt-4"
:form="form"
label="Close form on a scheduled date"
help="Leave empty to keep the form open"
:required="false"
/>
<rich-text-area-input v-if="form.closes_at || form.visibility=='closed'" name="closed_text"
:form="form" class="mt-4"
label="Closed form text"
help="This message will be shown when the form will be closed"
:required="false"
<rich-text-area-input
v-if="form.closes_at || form.visibility == 'closed'"
name="closed_text"
:form="form"
class="mt-4"
label="Closed form text"
help="This message will be shown when the form will be closed"
:required="false"
/>
<text-input name="max_submissions_count" native-type="number" :min="1" :form="form"
label="Limit number of submissions" placeholder="Max submissions" class="mt-4"
help="Leave empty for unlimited submissions"
:required="false"
<text-input
name="max_submissions_count"
native-type="number"
:min="1"
:form="form"
label="Limit number of submissions"
placeholder="Max submissions"
class="mt-4"
help="Leave empty for unlimited submissions"
:required="false"
/>
<rich-text-area-input v-if="form.max_submissions_count && form.max_submissions_count > 0"
name="max_submissions_reached_text" class="mt-4"
:form="form"
label="Max Submissions reached text"
help="This message will be shown when the form will have the maximum number of submissions"
:required="false"
<rich-text-area-input
v-if="form.max_submissions_count && form.max_submissions_count > 0"
name="max_submissions_reached_text"
class="mt-4"
:form="form"
label="Max Submissions reached text"
help="This message will be shown when the form will have the maximum number of submissions"
:required="false"
/>
</editor-options-panel>
</template>
<script>
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
export default {
components: { EditorOptionsPanel },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore
workingFormStore,
}
},
data () {
return {
}
data() {
return {}
},
computed: {
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
}
},
},
},
watch: {},
mounted () {
},
methods: {}
mounted() {},
methods: {},
}
</script>

View File

@@ -1,51 +1,58 @@
<template>
<editor-options-panel name="Custom Code" :already-opened="false" :has-pro-tag="true">
<editor-options-panel
name="Custom Code"
:already-opened="false"
:has-pro-tag="true"
>
<template #icon>
<svg class="h-5 w-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="h-5 w-5"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M14 2.26953V6.40007C14 6.96012 14 7.24015 14.109 7.45406C14.2049 7.64222 14.3578 7.7952 14.546 7.89108C14.7599 8.00007 15.0399 8.00007 15.6 8.00007H19.7305M14 17.5L16.5 15L14 12.5M10 12.5L7.5 15L10 17.5M20 9.98822V17.2C20 18.8802 20 19.7202 19.673 20.362C19.3854 20.9265 18.9265 21.3854 18.362 21.673C17.7202 22 16.8802 22 15.2 22H8.8C7.11984 22 6.27976 22 5.63803 21.673C5.07354 21.3854 4.6146 20.9265 4.32698 20.362C4 19.7202 4 18.8802 4 17.2V6.8C4 5.11984 4 4.27976 4.32698 3.63803C4.6146 3.07354 5.07354 2.6146 5.63803 2.32698C6.27976 2 7.11984 2 8.8 2H12.0118C12.7455 2 13.1124 2 13.4577 2.08289C13.7638 2.15638 14.0564 2.27759 14.3249 2.44208C14.6276 2.6276 14.887 2.88703 15.4059 3.40589L18.5941 6.59411C19.113 7.11297 19.3724 7.3724 19.5579 7.67515C19.7224 7.94356 19.8436 8.2362 19.9171 8.5423C20 8.88757 20 9.25445 20 9.98822Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<p class="mt-4">
The code will be injected in the <span class="font-semibold">head</span> section of your form page.
The code will be injected in the
<span class="font-semibold">head</span> section of your form page.
</p>
<code-input name="custom_code" class="mt-4"
:form="form" help="Custom code cannot be previewed in our editor. Please test your code using
<code-input
name="custom_code"
class="mt-4"
:form="form"
help="Custom code cannot be previewed in our editor. Please test your code using
your actual form page (save changes beforehand)."
label="Custom Code"
label="Custom Code"
/>
</editor-options-panel>
</template>
<script>
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
export default {
components: {EditorOptionsPanel},
components: { EditorOptionsPanel },
props: {},
setup() {
const workingFormStore = useWorkingFormStore()
const {content: form} = storeToRefs(workingFormStore)
const { content: form } = storeToRefs(workingFormStore)
return {
form,
workingFormStore
workingFormStore,
}
},
data() {
return {}
},
computed: {
form: {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set(value) {
this.workingFormStore.set(value)
}
}
},
computed: {},
}
</script>

View File

@@ -1,44 +1,75 @@
<template>
<editor-options-panel name="Link Settings - SEO" :already-opened="false" :has-pro-tag="true">
<editor-options-panel
name="Link Settings - SEO"
:already-opened="false"
:has-pro-tag="true"
>
<template #icon>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round"
d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
<svg
class="h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"
/>
</svg>
</template>
<p class="mt-4 text-gray-500 text-sm">
Customize the link, images and text that appear when you share your form on other sites (Open Graph).
Customize the link, images and text that appear when you share your form
on other sites (Open Graph).
</p>
<select-input v-if="customDomainAllowed" v-model="form.custom_domain" :disabled="customDomainOptions.length <= 0"
:options="customDomainOptions" name="type"
class="mt-4" label="Form Domain" placeholder="yourdomain.com"
<select-input
v-if="customDomainAllowed"
v-model="form.custom_domain"
:disabled="customDomainOptions.length <= 0"
:options="customDomainOptions"
name="type"
class="mt-4"
label="Form Domain"
placeholder="yourdomain.com"
/>
<text-input v-model="form.seo_meta.page_title" name="page_title" class="mt-4"
label="Page Title" help="Under or approximately 60 characters"
<text-input
v-model="form.seo_meta.page_title"
name="page_title"
class="mt-4"
label="Page Title"
help="Under or approximately 60 characters"
/>
<text-area-input v-model="form.seo_meta.page_description" name="page_description" class="mt-4"
label="Page Description" help="Between 150 and 160 characters"
<text-area-input
v-model="form.seo_meta.page_description"
name="page_description"
class="mt-4"
label="Page Description"
help="Between 150 and 160 characters"
/>
<image-input v-model="form.seo_meta.page_thumbnail" name="page_thumbnail" class="mt-4"
label="Page Thumbnail Image" help="Also know as og:image - 1200 X 630"
<image-input
v-model="form.seo_meta.page_thumbnail"
name="page_thumbnail"
class="mt-4"
label="Page Thumbnail Image"
help="Also know as og:image - 1200 X 630"
/>
</editor-options-panel>
</template>
<script>
import {useWorkingFormStore} from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
export default {
components: {EditorOptionsPanel},
components: { EditorOptionsPanel },
props: {},
setup() {
const workingFormStore = useWorkingFormStore()
return {
workspacesStore: useWorkspacesStore(),
workingFormStore
workingFormStore,
}
},
data() {
@@ -52,31 +83,33 @@ export default {
/* We add a setter */
set(value) {
this.workingFormStore.set(value)
}
},
},
workspace() {
return this.workspacesStore.getCurrent
},
customDomainOptions() {
return this.workspace.custom_domains ? this.workspace.custom_domains.map((domain) => {
return {
name: domain,
value: domain
}
}) : []
return this.workspace.custom_domains
? this.workspace.custom_domains.map((domain) => {
return {
name: domain,
value: domain,
}
})
: []
},
customDomainAllowed() {
return useRuntimeConfig().public.customDomainsEnabled
}
},
},
watch: {},
mounted() {
['page_title', 'page_description', 'page_thumbnail'].forEach((keyname) => {
["page_title", "page_description", "page_thumbnail"].forEach((keyname) => {
if (this.form.seo_meta[keyname] === undefined) {
this.form.seo_meta[keyname] = null
}
})
},
methods: {}
methods: {},
}
</script>

View File

@@ -1,93 +1,166 @@
<template>
<editor-options-panel name="Customization" :already-opened="true">
<editor-options-panel
name="Customization"
:already-opened="true"
>
<template #icon>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M1.66667 9.99984C1.66667 14.6022 5.39763 18.3332 10 18.3332C11.3807 18.3332 12.5 17.2139 12.5 15.8332V15.4165C12.5 15.0295 12.5 14.836 12.5214 14.6735C12.6691 13.5517 13.5519 12.6689 14.6737 12.5212C14.8361 12.4998 15.0297 12.4998 15.4167 12.4998H15.8333C17.214 12.4998 18.3333 11.3805 18.3333 9.99984C18.3333 5.39746 14.6024 1.6665 10 1.6665C5.39763 1.6665 1.66667 5.39746 1.66667 9.99984Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M5.83333 10.8332C6.29357 10.8332 6.66667 10.4601 6.66667 9.99984C6.66667 9.5396 6.29357 9.1665 5.83333 9.1665C5.3731 9.1665 5 9.5396 5 9.99984C5 10.4601 5.3731 10.8332 5.83333 10.8332Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.3333 7.49984C13.7936 7.49984 14.1667 7.12674 14.1667 6.6665C14.1667 6.20627 13.7936 5.83317 13.3333 5.83317C12.8731 5.83317 12.5 6.20627 12.5 6.6665C12.5 7.12674 12.8731 7.49984 13.3333 7.49984Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M8.33333 6.6665C8.79357 6.6665 9.16667 6.29341 9.16667 5.83317C9.16667 5.37293 8.79357 4.99984 8.33333 4.99984C7.8731 4.99984 7.5 5.37293 7.5 5.83317C7.5 6.29341 7.8731 6.6665 8.33333 6.6665Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M1.66667 9.99984C1.66667 14.6022 5.39763 18.3332 10 18.3332C11.3807 18.3332 12.5 17.2139 12.5 15.8332V15.4165C12.5 15.0295 12.5 14.836 12.5214 14.6735C12.6691 13.5517 13.5519 12.6689 14.6737 12.5212C14.8361 12.4998 15.0297 12.4998 15.4167 12.4998H15.8333C17.214 12.4998 18.3333 11.3805 18.3333 9.99984C18.3333 5.39746 14.6024 1.6665 10 1.6665C5.39763 1.6665 1.66667 5.39746 1.66667 9.99984Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M5.83333 10.8332C6.29357 10.8332 6.66667 10.4601 6.66667 9.99984C6.66667 9.5396 6.29357 9.1665 5.83333 9.1665C5.3731 9.1665 5 9.5396 5 9.99984C5 10.4601 5.3731 10.8332 5.83333 10.8332Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M13.3333 7.49984C13.7936 7.49984 14.1667 7.12674 14.1667 6.6665C14.1667 6.20627 13.7936 5.83317 13.3333 5.83317C12.8731 5.83317 12.5 6.20627 12.5 6.6665C12.5 7.12674 12.8731 7.49984 13.3333 7.49984Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M8.33333 6.6665C8.79357 6.6665 9.16667 6.29341 9.16667 5.83317C9.16667 5.37293 8.79357 4.99984 8.33333 4.99984C7.8731 4.99984 7.5 5.37293 7.5 5.83317C7.5 6.29341 7.8731 6.6665 8.33333 6.6665Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<select-input name="theme" class="mt-4"
:options="[
{name:'Default',value:'default'},
{name:'Simple',value:'simple'},
{name:'Notion',value:'notion'},
]"
:form="form" label="Form Theme"
<select-input
name="theme"
class="mt-4"
:options="[
{ name: 'Default', value: 'default' },
{ name: 'Simple', value: 'simple' },
{ name: 'Notion', value: 'notion' },
]"
:form="form"
label="Form Theme"
/>
<select-input name="dark_mode" class="mt-4"
help="To see changes, save your form and open it"
:options="[
{name:'Auto - use Device System Preferences',value:'auto'},
{name:'Light Mode',value:'light'},
{name:'Dark Mode',value:'dark'}
]"
:form="form" label="Dark Mode"
<select-input
name="dark_mode"
class="mt-4"
help="To see changes, save your form and open it"
:options="[
{ name: 'Auto - use Device System Preferences', value: 'auto' },
{ name: 'Light Mode', value: 'light' },
{ name: 'Dark Mode', value: 'dark' },
]"
:form="form"
label="Dark Mode"
/>
<select-input name="width" class="mt-4"
:options="[
{name:'Centered',value:'centered'},
{name:'Full Width',value:'full'},
]"
:form="form" label="Form Width" help="Useful when embedding your form"
<select-input
name="width"
class="mt-4"
:options="[
{ name: 'Centered', value: 'centered' },
{ name: 'Full Width', value: 'full' },
]"
:form="form"
label="Form Width"
help="Useful when embedding your form"
/>
<image-input name="cover_picture" class="mt-4"
:form="form" label="Cover Picture" help="Not visible when form is embedded"
:required="false"
<image-input
name="cover_picture"
class="mt-4"
:form="form"
label="Cover Picture"
help="Not visible when form is embedded"
:required="false"
/>
<image-input name="logo_picture" class="mt-4"
:form="form" label="Logo" help="Not visible when form is embedded"
:required="false"
<image-input
name="logo_picture"
class="mt-4"
:form="form"
label="Logo"
help="Not visible when form is embedded"
:required="false"
/>
<color-input name="color" class="mt-4"
:form="form"
label="Color (for buttons & inputs border)"
<color-input
name="color"
class="mt-4"
:form="form"
label="Color (for buttons & inputs border)"
/>
<toggle-switch-input name="hide_title" :form="form" class="mt-4"
label="Hide Title"
<toggle-switch-input
name="hide_title"
:form="form"
class="mt-4"
label="Hide Title"
/>
<toggle-switch-input name="no_branding" :form="form" class="mt-4">
<toggle-switch-input
name="no_branding"
:form="form"
class="mt-4"
>
<template #label>
Remove OpnForm Branding
<pro-tag class="ml-1" />
</template>
</toggle-switch-input>
<toggle-switch-input name="show_progress_bar" :form="form" class="mt-4"
label="Show progress bar"
<toggle-switch-input
name="show_progress_bar"
:form="form"
class="mt-4"
label="Show progress bar"
/>
<toggle-switch-input name="uppercase_labels" :form="form" class="mt-4"
label="Uppercase Input Labels"
<toggle-switch-input
name="uppercase_labels"
:form="form"
class="mt-4"
label="Uppercase Input Labels"
/>
<toggle-switch-input name="transparent_background" :form="form" class="mt-4"
label="Transparent Background" help="Only applies when form is embedded"
<toggle-switch-input
name="transparent_background"
:form="form"
class="mt-4"
label="Transparent Background"
help="Only applies when form is embedded"
/>
<toggle-switch-input name="confetti_on_submission" :form="form" class="mt-4"
label="Confetti on successful submisison"
@update:model-value="onChangeConfettiOnSubmission"
<toggle-switch-input
name="confetti_on_submission"
:form="form"
class="mt-4"
label="Confetti on successful submisison"
@update:model-value="onChangeConfettiOnSubmission"
/>
<toggle-switch-input name="auto_save" :form="form"
label="Auto save form response"
help="Will save data in browser, if user not submit the form then next time will auto prefill last entered data"
<toggle-switch-input
name="auto_save"
:form="form"
label="Auto save form response"
help="Will save data in browser, if user not submit the form then next time will auto prefill last entered data"
/>
</editor-options-panel>
</template>
<script setup>
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import ProTag from '~/components/global/ProTag.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
import ProTag from "~/components/global/ProTag.vue"
const workingFormStore = useWorkingFormStore()
const form = storeToRefs(workingFormStore).content
const isMounted = ref(false)
const crisp = useCrisp()
const isMounted = ref(false)
const confetti = useConfetti()
onMounted(() => {

View File

@@ -1,56 +1,78 @@
<template>
<!-- Form Preview (desktop only) -->
<div ref="parent"
<div
ref="parent"
class="bg-gray-50 dark:bg-notion-dark-light hidden md:flex flex-grow p-5 flex-col items-center overflow-y-scroll"
>
<div class="border rounded-lg bg-white dark:bg-notion-dark w-full block transition-all max-w-5xl">
<transition enter-active-class="linear duration-100 overflow-hidden"
enter-from-class="max-h-0"
enter-to-class="max-h-56"
leave-active-class="linear duration-100 overflow-hidden"
leave-from-class="max-h-56"
leave-to-class="max-h-0"
<transition
enter-active-class="linear duration-100 overflow-hidden"
enter-from-class="max-h-0"
enter-to-class="max-h-56"
leave-active-class="linear duration-100 overflow-hidden"
leave-from-class="max-h-56"
leave-to-class="max-h-0"
>
<div v-if="(form.logo_picture || form.cover_picture)">
<div v-if="form.cover_picture">
<div id="cover-picture"
class="max-h-56 rounded-t-lg w-full overflow-hidden flex items-center justify-center"
<div
id="cover-picture"
class="max-h-56 rounded-t-lg w-full overflow-hidden flex items-center justify-center"
>
<img alt="Cover Picture" :src="coverPictureSrc(form.cover_picture)" class="w-full"/>
<img
alt="Cover Picture"
:src="coverPictureSrc(form.cover_picture)"
class="w-full"
>
</div>
</div>
<div v-if="form.logo_picture" class="w-full mx-auto p-5 relative"
:class="{'pt-20':!form.cover_picture, 'max-w-lg': form && (form.width === 'centered')}"
<div
v-if="form.logo_picture"
class="w-full mx-auto p-5 relative"
:class="{'pt-20':!form.cover_picture, 'max-w-lg': form && (form.width === 'centered')}"
>
<img alt="Logo Picture" :src="coverPictureSrc(form.logo_picture)"
:class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
class="max-w-60 h-20 object-contain absolute left-5 transition-all"
/>
<img
alt="Logo Picture"
:src="coverPictureSrc(form.logo_picture)"
:class="{'top-5':!form.cover_picture, '-top-10':form.cover_picture}"
class="max-w-60 h-20 object-contain absolute left-5 transition-all"
>
</div>
</div>
</transition>
<open-complete-form ref="form-preview" class="w-full mx-auto py-5 px-3" :class="{'max-w-lg': form && (form.width === 'centered')}"
:creating="creating"
:form="form"
:dark-mode="darkMode"
:admin-preview="true"
@restarted="previewFormSubmitted=false"
@submitted="previewFormSubmitted=true"
<open-complete-form
ref="form-preview"
class="w-full mx-auto py-5 px-3"
:class="{'max-w-lg': form && (form.width === 'centered')}"
:creating="creating"
:form="form"
:dark-mode="darkMode"
:admin-preview="true"
@restarted="previewFormSubmitted=false"
@submitted="previewFormSubmitted=true"
/>
</div>
<p class="text-center text-xs text-gray-400 dark:text-gray-600 mt-1">
Form Preview <span v-if="creating"
class="font-normal text-gray-400 dark:text-gray-600 text-xs"
Form Preview <span
v-if="creating"
class="font-normal text-gray-400 dark:text-gray-600 text-xs"
>- Answers won't be saved</span>
<br>
<span v-if="previewFormSubmitted && !form.re_fillable">
<a href="#" @click.prevent="$refs['form-preview'].restart()">Restart Form
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-nt-blue inline" viewBox="0 0 20 20"
fill="currentColor"
<a
href="#"
@click.prevent="$refs['form-preview'].restart()"
>Restart Form
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 text-nt-blue inline"
viewBox="0 0 20 20"
fill="currentColor"
>
<path fill-rule="evenodd"
d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z"
clip-rule="evenodd"
<path
fill-rule="evenodd"
d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z"
clip-rule="evenodd"
/>
</svg>
</a>
@@ -60,13 +82,12 @@
</template>
<script>
import VSwitch from '../../../../forms/components/VSwitch.vue'
import OpenCompleteForm from '../../OpenCompleteForm.vue'
import {handleDarkMode, useDarkMode} from "~/lib/forms/public-page.js"
import { default as _has } from 'lodash/has'
export default {
components: { OpenCompleteForm, VSwitch },
components: { OpenCompleteForm },
props: {},
setup () {
const workingFormStore = useWorkingFormStore()

View File

@@ -1,49 +1,59 @@
<template>
<editor-right-sidebar :show="form && (showEditFieldSidebar || showAddFieldSidebar)">
<editor-right-sidebar
:show="form && (showEditFieldSidebar || showAddFieldSidebar)"
>
<transition mode="out-in">
<form-field-edit v-if="showEditFieldSidebar" :key="editFieldIndex" v-motion-fade="'fade'" />
<add-form-block v-else-if="showAddFieldSidebar" v-motion-fade="'fade'" />
<form-field-edit
v-if="showEditFieldSidebar"
:key="editFieldIndex"
v-motion-fade="'fade'"
/>
<add-form-block
v-else-if="showAddFieldSidebar"
v-motion-fade="'fade'"
/>
</transition>
</editor-right-sidebar>
</template>
<script>
import { computed } from 'vue'
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorRightSidebar from '../../../editors/EditorRightSidebar.vue'
import FormFieldEdit from '../../fields/FormFieldEdit.vue'
import AddFormBlock from './AddFormBlock.vue'
import { computed } from "vue"
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorRightSidebar from "../../../editors/EditorRightSidebar.vue"
import FormFieldEdit from "../../fields/FormFieldEdit.vue"
import AddFormBlock from "./AddFormBlock.vue"
export default {
name: 'FormEditorSidebar',
name: "FormEditorSidebar",
components: { EditorRightSidebar, AddFormBlock, FormFieldEdit },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore,
editFieldIndex: computed(() => workingFormStore.selectedFieldIndex),
showEditFieldSidebar: computed(() => workingFormStore.showEditFieldSidebar),
showAddFieldSidebar: computed(() => workingFormStore.showAddFieldSidebar)
showEditFieldSidebar: computed(
() => workingFormStore.showEditFieldSidebar,
),
showAddFieldSidebar: computed(() => workingFormStore.showAddFieldSidebar),
}
},
data () {
data() {
return {}
},
computed: {
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
}
},
},
},
watch: {},
mounted () {
},
methods: {}
mounted() {},
methods: {},
}
</script>

View File

@@ -1,21 +1,37 @@
<template>
<modal :show="show" @close="$emit('close')">
<modal
:show="show"
@close="$emit('close')"
>
<div class="-mx-5">
<h2 class="text-red-400 text-2xl font-bold mb-4 px-4">
Error saving your form
</h2>
<div v-if="form.errors" class="p-4 border-b border-t">
<p v-if="form.errors.message" v-text="form.errors.message" />
<div
v-if="form.errors"
class="p-4 border-b border-t"
>
<p
v-if="form.errors.message"
v-text="form.errors.message"
/>
<ul class="list-disc list-inside">
<li v-for="err, key in form.errors.errors" :key="key">
{{ Array.isArray(err)?err[0]:err }}
<li
v-for="(err, key) in form.errors.errors"
:key="key"
>
{{ Array.isArray(err) ? err[0] : err }}
</li>
</ul>
</div>
<div class="px-4 pt-4 text-right">
<v-button color="gray" shade="light" @click="$emit('close')">
<v-button
color="gray"
shade="light"
@click="$emit('close')"
>
Close
</v-button>
</div>
@@ -25,16 +41,17 @@
<script>
export default {
name: 'FormErrorModal',
name: "FormErrorModal",
components: {},
props: {
show: { type: Boolean, required: true },
form: { type: Object, required: false }
form: { type: Object, required: false },
},
emits: ['close'],
data: () => ({}),
computed: {},
methods: {}
methods: {},
}
</script>

View File

@@ -1,41 +1,100 @@
<template>
<editor-options-panel name="Information" :already-opened="true">
<editor-options-panel
name="Information"
:already-opened="true"
>
<template #icon>
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 13.3332V9.99984M10 6.6665H10.0083M18.3333 9.99984C18.3333 14.6022 14.6024 18.3332 10 18.3332C5.39763 18.3332 1.66667 14.6022 1.66667 9.99984C1.66667 5.39746 5.39763 1.6665 10 1.6665C14.6024 1.6665 18.3333 5.39746 18.3333 9.99984Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M10 13.3332V9.99984M10 6.6665H10.0083M18.3333 9.99984C18.3333 14.6022 14.6024 18.3332 10 18.3332C5.39763 18.3332 1.66667 14.6022 1.66667 9.99984C1.66667 5.39746 5.39763 1.6665 10 1.6665C14.6024 1.6665 18.3333 5.39746 18.3333 9.99984Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<text-input name="title" class="mt-4"
:form="form"
label="Form Title"
:required="true"
<text-input
name="title"
class="mt-4"
:form="form"
label="Form Title"
:required="true"
/>
<rich-text-area-input name="description"
:form="form"
label="Description"
:required="false"
<rich-text-area-input
name="description"
:form="form"
label="Description"
:required="false"
/>
<select-input name="tags" label="Tags" :form="form" class="mt-4"
help="To organize your forms (hidden to respondents)"
placeholder="Select Tag(s)" :multiple="true" :allow-creation="true"
:options="allTagsOptions"
<select-input
name="tags"
label="Tags"
:form="form"
class="mt-4"
help="To organize your forms (hidden to respondents)"
placeholder="Select Tag(s)"
:multiple="true"
:allow-creation="true"
:options="allTagsOptions"
/>
<select-input name="visibility" label="Visibility" :form="form" class="mt-4"
help="Only public form will be accessible"
placeholder="Select Visibility" :required="true"
:options="visibilityOptions"
<select-input
name="visibility"
label="Visibility"
:form="form"
class="mt-4"
help="Only public form will be accessible"
placeholder="Select Visibility"
:required="true"
:options="visibilityOptions"
/>
<v-button v-if="copyFormOptions.length > 0" color="light-gray" class="w-full mt-4" @click="showCopyFormSettingsModal=true">
<svg class="h-5 w-5 -mt-1 text-nt-blue inline mr-2" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4.16667 12.4998C3.3901 12.4998 3.00182 12.4998 2.69553 12.373C2.28715 12.2038 1.9627 11.8794 1.79354 11.471C1.66667 11.1647 1.66667 10.7764 1.66667 9.99984V4.33317C1.66667 3.39975 1.66667 2.93304 1.84833 2.57652C2.00812 2.26292 2.26308 2.00795 2.57669 1.84816C2.93321 1.6665 3.39992 1.6665 4.33334 1.6665H10C10.7766 1.6665 11.1649 1.6665 11.4711 1.79337C11.8795 1.96253 12.204 2.28698 12.3731 2.69536C12.5 3.00165 12.5 3.38993 12.5 4.1665M10.1667 18.3332H15.6667C16.6001 18.3332 17.0668 18.3332 17.4233 18.1515C17.7369 17.9917 17.9919 17.7368 18.1517 17.4232C18.3333 17.0666 18.3333 16.5999 18.3333 15.6665V10.1665C18.3333 9.23308 18.3333 8.76637 18.1517 8.40985C17.9919 8.09625 17.7369 7.84128 17.4233 7.68149C17.0668 7.49984 16.6001 7.49984 15.6667 7.49984H10.1667C9.23325 7.49984 8.76654 7.49984 8.41002 7.68149C8.09642 7.84128 7.84145 8.09625 7.68166 8.40985C7.50001 8.76637 7.50001 9.23308 7.50001 10.1665V15.6665C7.50001 16.5999 7.50001 17.0666 7.68166 17.4232C7.84145 17.7368 8.09642 17.9917 8.41002 18.1515C8.76654 18.3332 9.23325 18.3332 10.1667 18.3332Z" stroke="currentColor" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round" />
<v-button
v-if="copyFormOptions.length > 0"
color="light-gray"
class="w-full mt-4"
@click="showCopyFormSettingsModal = true"
>
<svg
class="h-5 w-5 -mt-1 text-nt-blue inline mr-2"
viewBox="0 0 20 20"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M4.16667 12.4998C3.3901 12.4998 3.00182 12.4998 2.69553 12.373C2.28715 12.2038 1.9627 11.8794 1.79354 11.471C1.66667 11.1647 1.66667 10.7764 1.66667 9.99984V4.33317C1.66667 3.39975 1.66667 2.93304 1.84833 2.57652C2.00812 2.26292 2.26308 2.00795 2.57669 1.84816C2.93321 1.6665 3.39992 1.6665 4.33334 1.6665H10C10.7766 1.6665 11.1649 1.6665 11.4711 1.79337C11.8795 1.96253 12.204 2.28698 12.3731 2.69536C12.5 3.00165 12.5 3.38993 12.5 4.1665M10.1667 18.3332H15.6667C16.6001 18.3332 17.0668 18.3332 17.4233 18.1515C17.7369 17.9917 17.9919 17.7368 18.1517 17.4232C18.3333 17.0666 18.3333 16.5999 18.3333 15.6665V10.1665C18.3333 9.23308 18.3333 8.76637 18.1517 8.40985C17.9919 8.09625 17.7369 7.84128 17.4233 7.68149C17.0668 7.49984 16.6001 7.49984 15.6667 7.49984H10.1667C9.23325 7.49984 8.76654 7.49984 8.41002 7.68149C8.09642 7.84128 7.84145 8.09625 7.68166 8.40985C7.50001 8.76637 7.50001 9.23308 7.50001 10.1665V15.6665C7.50001 16.5999 7.50001 17.0666 7.68166 17.4232C7.84145 17.7368 8.09642 17.9917 8.41002 18.1515C8.76654 18.3332 9.23325 18.3332 10.1667 18.3332Z"
stroke="currentColor"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Copy another form's settings
</v-button>
<modal :show="showCopyFormSettingsModal" max-width="md" @close="showCopyFormSettingsModal=false">
<modal
:show="showCopyFormSettingsModal"
max-width="md"
@close="showCopyFormSettingsModal = false"
>
<template #icon>
<svg class="w-10 h-10 text-blue" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17 27C16.0681 27 15.6022 27 15.2346 26.8478C14.7446 26.6448 14.3552 26.2554 14.1522 25.7654C14 25.3978 14 24.9319 14 24V17.2C14 16.0799 14 15.5198 14.218 15.092C14.4097 14.7157 14.7157 14.4097 15.092 14.218C15.5198 14 16.0799 14 17.2 14H24C24.9319 14 25.3978 14 25.7654 14.1522C26.2554 14.3552 26.6448 14.7446 26.8478 15.2346C27 15.6022 27 16.0681 27 17M24.2 34H30.8C31.9201 34 32.4802 34 32.908 33.782C33.2843 33.5903 33.5903 33.2843 33.782 32.908C34 32.4802 34 31.9201 34 30.8V24.2C34 23.0799 34 22.5198 33.782 22.092C33.5903 21.7157 33.2843 21.4097 32.908 21.218C32.4802 21 31.9201 21 30.8 21H24.2C23.0799 21 22.5198 21 22.092 21.218C21.7157 21.4097 21.4097 21.7157 21.218 22.092C21 22.5198 21 23.0799 21 24.2V30.8C21 31.9201 21 32.4802 21.218 32.908C21.4097 33.2843 21.7157 33.5903 22.092 33.782C22.5198 34 23.0799 34 24.2 34Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<svg
class="w-10 h-10 text-blue"
viewBox="0 0 48 48"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M17 27C16.0681 27 15.6022 27 15.2346 26.8478C14.7446 26.6448 14.3552 26.2554 14.1522 25.7654C14 25.3978 14 24.9319 14 24V17.2C14 16.0799 14 15.5198 14.218 15.092C14.4097 14.7157 14.7157 14.4097 15.092 14.218C15.5198 14 16.0799 14 17.2 14H24C24.9319 14 25.3978 14 25.7654 14.1522C26.2554 14.3552 26.6448 14.7446 26.8478 15.2346C27 15.6022 27 16.0681 27 17M24.2 34H30.8C31.9201 34 32.4802 34 32.908 33.782C33.2843 33.5903 33.5903 33.2843 33.782 32.908C34 32.4802 34 31.9201 34 30.8V24.2C34 23.0799 34 22.5198 33.782 22.092C33.5903 21.7157 33.2843 21.4097 32.908 21.218C32.4802 21 31.9201 21 30.8 21H24.2C23.0799 21 22.5198 21 22.092 21.218C21.7157 21.4097 21.4097 21.7157 21.218 22.092C21 22.5198 21 23.0799 21 24.2V30.8C21 31.9201 21 32.4802 21.218 32.908C21.4097 33.2843 21.7157 33.5903 22.092 33.782C22.5198 34 23.0799 34 24.2 34Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<template #title>
@@ -43,20 +102,33 @@
</template>
<div class="p-4 min-h-[450px]">
<p class="text-gray-600">
If you already have another form that you like to use as a base for this form, you can do that here.
Select another form, confirm, and we will copy all of the other form settings (except the form structure)
If you already have another form that you like to use as a base for
this form, you can do that here. Select another form, confirm, and we
will copy all of the other form settings (except the form structure)
to this form.
</p>
<select-input v-model="copyFormId" name="copy_form_id"
label="Copy Settings From" class="mt-3 mb-6"
placeholder="Choose a form" :searchable="copyFormOptions.length > 5"
:options="copyFormOptions"
<select-input
v-model="copyFormId"
name="copy_form_id"
label="Copy Settings From"
class="mt-3 mb-6"
placeholder="Choose a form"
:searchable="copyFormOptions.length > 5"
:options="copyFormOptions"
/>
<div class="flex">
<v-button color="white" class="w-full mr-2" @click="showCopyFormSettingsModal=false">
<v-button
color="white"
class="w-full mr-2"
@click="showCopyFormSettingsModal = false"
>
Cancel
</v-button>
<v-button color="blue" class="w-full" @click="copySettings">
<v-button
color="blue"
class="w-full"
@click="copySettings"
>
Confirm & Copy
</v-button>
</div>
@@ -66,19 +138,19 @@
</template>
<script>
import clonedeep from 'clone-deep'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import SelectInput from '../../../../forms/SelectInput.vue'
import { default as _has } from 'lodash/has'
import clonedeep from "clone-deep"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
import SelectInput from "../../../../forms/SelectInput.vue"
import { default as _has } from "lodash/has"
export default {
components: { SelectInput, EditorOptionsPanel },
props: {},
setup () {
setup() {
const formsStore = useFormsStore()
const workingFormStore = useWorkingFormStore()
const {getAll: forms} = storeToRefs(formsStore)
const { getAll: forms } = storeToRefs(formsStore)
return {
forms,
formsStore,
@@ -86,72 +158,93 @@ export default {
}
},
data () {
data() {
return {
showCopyFormSettingsModal: false,
copyFormId: null,
visibilityOptions: [
{
name: "Published",
value: "public"
value: "public",
},
{
name: "Draft - not publicly accessible",
value: "draft"
value: "draft",
},
{
name: "Closed - won\'t accept new submissions",
value: "closed"
}
]
name: "Closed - won't accept new submissions",
value: "closed",
},
],
}
},
computed: {
copyFormOptions () {
return this.forms.filter((form) => {
return this.form.id !== form.id
}).map((form) => {
return {
name: form.title,
value: form.id
}
})
copyFormOptions() {
return this.forms
.filter((form) => {
return this.form.id !== form.id
})
.map((form) => {
return {
name: form.title,
value: form.id,
}
})
},
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
},
},
allTagsOptions () {
allTagsOptions() {
return this.formsStore.allTags.map((tagname) => {
return {
name: tagname,
value: tagname
value: tagname,
}
})
}
},
},
watch: {},
mounted () {
},
mounted() {},
methods: {
copySettings () {
copySettings() {
if (this.copyFormId == null) return
const copyForm = clonedeep(this.forms.find((form) => form.id === this.copyFormId))
if (!copyForm) return
const copyForm = clonedeep(
this.forms.find((form) => form.id === this.copyFormId),
)
if (!copyForm) return;
// Clean copy from form
['title', 'description', 'properties', 'cleanings', 'views_count', 'submissions_count', 'workspace', 'workspace_id', 'updated_at',
'share_url', 'slug', 'notion_database_url', 'id', 'database_id', 'database_fields_update', 'creator',
'created_at', 'deleted_at', 'last_edited_human'].forEach((property) => {
[
"title",
"description",
"properties",
"cleanings",
"views_count",
"submissions_count",
"workspace",
"workspace_id",
"updated_at",
"share_url",
"slug",
"notion_database_url",
"id",
"database_id",
"database_fields_update",
"creator",
"created_at",
"deleted_at",
"last_edited_human",
].forEach((property) => {
if (_has(copyForm, property)) {
delete copyForm[property]
}
@@ -162,7 +255,7 @@ export default {
this.form[property] = copyForm[property]
})
this.showCopyFormSettingsModal = false
}
}
},
},
}
</script>

View File

@@ -1,48 +1,67 @@
<template>
<editor-options-panel name="Security & Privacy" :already-opened="false">
<editor-options-panel
name="Security & Privacy"
:already-opened="false"
>
<template #icon>
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
<svg
class="h-5 w-5"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"
/>
</svg>
</template>
<toggle-switch-input name="can_be_indexed" :form="form" class="mt-4"
label="Indexable by Google"
help="If enabled, your form can appear in the search results of Google"
<toggle-switch-input
name="can_be_indexed"
:form="form"
class="mt-4"
label="Indexable by Google"
help="If enabled, your form can appear in the search results of Google"
/>
<toggle-switch-input name="use_captcha" :form="form" class="mt-4"
label="Protect your form with a Captcha"
help="If enabled we will make sure respondant is a human"
<toggle-switch-input
name="use_captcha"
:form="form"
class="mt-4"
label="Protect your form with a Captcha"
help="If enabled we will make sure respondant is a human"
/>
</editor-options-panel>
</template>
<script>
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
export default {
components: { EditorOptionsPanel },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore
workingFormStore,
}
},
data () {
return {
}
data() {
return {}
},
computed: {
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
}
},
},
},
}
</script>

View File

@@ -1,9 +1,29 @@
<template>
<editor-options-panel name="Form Structure" :already-opened="true">
<editor-options-panel
name="Form Structure"
:already-opened="true"
>
<template #icon>
<svg class="h-5 w-5" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M13.8333 7.33333C14.7668 7.33333 15.2335 7.33333 15.59 7.15168C15.9036 6.99189 16.1586 6.73692 16.3183 6.42332C16.5 6.0668 16.5 5.60009 16.5 4.66667V4.16667C16.5 3.23325 16.5 2.76654 16.3183 2.41002C16.1586 2.09641 15.9036 1.84145 15.59 1.68166C15.2335 1.5 14.7668 1.5 13.8333 1.5L4.16667 1.5C3.23325 1.5 2.76654 1.5 2.41002 1.68166C2.09641 1.84144 1.84144 2.09641 1.68166 2.41002C1.5 2.76654 1.5 3.23325 1.5 4.16667L1.5 4.66667C1.5 5.60009 1.5 6.0668 1.68166 6.42332C1.84144 6.73692 2.09641 6.99189 2.41002 7.15168C2.76654 7.33333 3.23325 7.33333 4.16667 7.33333L13.8333 7.33333Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M13.8333 16.5C14.7668 16.5 15.2335 16.5 15.59 16.3183C15.9036 16.1586 16.1586 15.9036 16.3183 15.59C16.5 15.2335 16.5 14.7668 16.5 13.8333V13.3333C16.5 12.3999 16.5 11.9332 16.3183 11.5767C16.1586 11.2631 15.9036 11.0081 15.59 10.8483C15.2335 10.6667 14.7668 10.6667 13.8333 10.6667L4.16667 10.6667C3.23325 10.6667 2.76654 10.6667 2.41002 10.8483C2.09641 11.0081 1.84144 11.2631 1.68166 11.5767C1.5 11.9332 1.5 12.3999 1.5 13.3333L1.5 13.8333C1.5 14.7668 1.5 15.2335 1.68166 15.59C1.84144 15.9036 2.09641 16.1586 2.41002 16.3183C2.76654 16.5 3.23325 16.5 4.16667 16.5H13.8333Z" stroke="currentColor" stroke-width="1.67" stroke-linecap="round" stroke-linejoin="round"/>
<svg
class="h-5 w-5"
viewBox="0 0 18 18"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M13.8333 7.33333C14.7668 7.33333 15.2335 7.33333 15.59 7.15168C15.9036 6.99189 16.1586 6.73692 16.3183 6.42332C16.5 6.0668 16.5 5.60009 16.5 4.66667V4.16667C16.5 3.23325 16.5 2.76654 16.3183 2.41002C16.1586 2.09641 15.9036 1.84145 15.59 1.68166C15.2335 1.5 14.7668 1.5 13.8333 1.5L4.16667 1.5C3.23325 1.5 2.76654 1.5 2.41002 1.68166C2.09641 1.84144 1.84144 2.09641 1.68166 2.41002C1.5 2.76654 1.5 3.23325 1.5 4.16667L1.5 4.66667C1.5 5.60009 1.5 6.0668 1.68166 6.42332C1.84144 6.73692 2.09641 6.99189 2.41002 7.15168C2.76654 7.33333 3.23325 7.33333 4.16667 7.33333L13.8333 7.33333Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M13.8333 16.5C14.7668 16.5 15.2335 16.5 15.59 16.3183C15.9036 16.1586 16.1586 15.9036 16.3183 15.59C16.5 15.2335 16.5 14.7668 16.5 13.8333V13.3333C16.5 12.3999 16.5 11.9332 16.3183 11.5767C16.1586 11.2631 15.9036 11.0081 15.59 10.8483C15.2335 10.6667 14.7668 10.6667 13.8333 10.6667L4.16667 10.6667C3.23325 10.6667 2.76654 10.6667 2.41002 10.8483C2.09641 11.0081 1.84144 11.2631 1.68166 11.5767C1.5 11.9332 1.5 12.3999 1.5 13.3333L1.5 13.8333C1.5 14.7668 1.5 15.2335 1.68166 15.59C1.84144 15.9036 2.09641 16.1586 2.41002 16.3183C2.76654 16.5 3.23325 16.5 4.16667 16.5H13.8333Z"
stroke="currentColor"
stroke-width="1.67"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
<form-fields-editor class="mt-5" />
@@ -11,34 +31,33 @@
</template>
<script>
import { useWorkingFormStore } from '../../../../../stores/working_form'
import EditorOptionsPanel from '../../../editors/EditorOptionsPanel.vue'
import FormFieldsEditor from '../FormFieldsEditor.vue'
import { useWorkingFormStore } from "../../../../../stores/working_form"
import EditorOptionsPanel from "../../../editors/EditorOptionsPanel.vue"
import FormFieldsEditor from "../FormFieldsEditor.vue"
export default {
components: { EditorOptionsPanel, FormFieldsEditor },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore
workingFormStore,
}
},
data () {
return {
}
data() {
return {}
},
computed: {
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
}
}
},
},
},
}
</script>

View File

@@ -1,47 +1,64 @@
<template>
<div v-if="content" class="flex flex-wrap">
<div
v-if="content"
class="flex flex-wrap"
>
<div class="w-full font-semibold text-gray-700 dark:text-gray-300 mb-2">
{{ property.name }}
</div>
<SelectInput v-model="content.operator" class="w-full" :options="operators" :name="'operator_' + property.id"
placeholder="Comparison operator" @update:model-value="operatorChanged()" />
<SelectInput
v-model="content.operator"
class="w-full"
:options="operators"
:name="'operator_' + property.id"
placeholder="Comparison operator"
@update:model-value="operatorChanged()"
/>
<template v-if="needsInput">
<component v-bind="inputComponentData" :is="inputComponentData.component" v-model="content.value" class="w-full"
:name="'value_' + property.id" placeholder="Filter Value" @update:model-value="emitInput()" />
<component
v-bind="inputComponentData"
:is="inputComponentData.component"
v-model="content.value"
class="w-full"
:name="'value_' + property.id"
placeholder="Filter Value"
@update:model-value="emitInput()"
/>
</template>
</div>
</template>
<script>
import OpenFilters from '../../../../../data/open_filters.json'
import OpenFilters from "../../../../../data/open_filters.json"
export default {
components: {},
props: {
modelValue: { required: true }
modelValue: { type: Object, required: true },
},
emits: ['update:modelValue'],
data() {
return {
content: { ...this.modelValue },
available_filters: OpenFilters,
hasInput: false,
inputComponent: {
text: 'TextInput',
number: 'TextInput',
rating: 'TextInput',
scale: 'TextInput',
slider: 'TextInput',
select: 'SelectInput',
multi_select: 'SelectInput',
date: 'DateInput',
files: 'FileInput',
checkbox: 'CheckboxInput',
url: 'TextInput',
email: 'TextInput',
phone_number: 'TextInput'
}
text: "TextInput",
number: "TextInput",
rating: "TextInput",
scale: "TextInput",
slider: "TextInput",
select: "SelectInput",
multi_select: "SelectInput",
date: "DateInput",
files: "FileInput",
checkbox: "CheckboxInput",
url: "TextInput",
email: "TextInput",
phone_number: "TextInput",
},
}
},
@@ -51,34 +68,41 @@ export default {
const componentData = {
component: this.inputComponent[this.property.type],
name: this.property.id,
required: true
required: true,
}
if (this.property.type === 'phone_number' && !this.property.use_simple_text_input) {
componentData.component = 'PhoneInput'
if (
this.property.type === "phone_number" &&
!this.property.use_simple_text_input
) {
componentData.component = "PhoneInput"
}
if (['select', 'multi_select'].includes(this.property.type)) {
if (["select", "multi_select"].includes(this.property.type)) {
componentData.multiple = false
componentData.options = this.property[this.property.type].options.map(option => {
return {
name: option.name,
value: option.name
}
})
} else if (this.property.type === 'date') {
componentData.options = this.property[this.property.type].options.map(
(option) => {
return {
name: option.name,
value: option.name,
}
},
)
} else if (this.property.type === "date") {
// componentData.withTime = true
} else if (this.property.type === 'checkbox') {
} else if (this.property.type === "checkbox") {
componentData.label = this.property.name
}
return componentData
},
operators() {
return Object.keys(this.available_filters[this.property.type].comparators).map(key => {
return Object.keys(
this.available_filters[this.property.type].comparators,
).map((key) => {
return {
value: key,
name: this.optionFilterNames(key, this.property.type)
name: this.optionFilterNames(key, this.property.type),
}
})
},
@@ -90,9 +114,17 @@ export default {
const operatorFormat = operator.format
if (!operatorFormat) return true
if (operator.expected_type === 'boolean' && operatorFormat.type === 'enum' && operatorFormat.values.length === 1) {
if (
operator.expected_type === "boolean" &&
operatorFormat.type === "enum" &&
operatorFormat.values.length === 1
) {
return false
} else if (operator.expected_type === 'object' && operatorFormat.type === 'empty' && operatorFormat.values === '{}') {
} else if (
operator.expected_type === "object" &&
operatorFormat.type === "empty" &&
operatorFormat.values === "{}"
) {
return false
}
@@ -104,21 +136,28 @@ export default {
modelValue() {
this.refreshContent()
},
'content.operator': function (val) {
"content.operator": function (val) {
if (val) {
this.operatorChanged()
}
}
},
},
mounted() {
this.refreshContent()
},
methods: {
castContent(content) {
if (['number', 'rating', 'scale', 'slider'].includes(this.property.type) && content.value) {
if (
["number", "rating", "scale", "slider"].includes(this.property.type) &&
content.value
) {
content.value = Number(content.value)
}
const operator = this.selectedOperator()
if (operator.expected_type === 'boolean') {
if (operator.expected_type === "boolean") {
content.value = Boolean(content.value)
}
@@ -132,11 +171,22 @@ export default {
const operator = this.selectedOperator()
const operatorFormat = operator.format
if (operator.expected_type === 'boolean' && operatorFormat.type === 'enum' && operatorFormat.values.length === 1) {
if (
operator.expected_type === "boolean" &&
operatorFormat.type === "enum" &&
operatorFormat.values.length === 1
) {
this.content.value = operator.format.values[0]
} else if (operator.expected_type === 'object' && operatorFormat.type === 'empty' && operatorFormat.values === '{}') {
} else if (
operator.expected_type === "object" &&
operatorFormat.type === "empty" &&
operatorFormat.values === "{}"
) {
this.content.value = {}
} else if (typeof this.content.value === 'boolean' || typeof this.content.value === 'object') {
} else if (
typeof this.content.value === "boolean" ||
typeof this.content.value === "object"
) {
this.content.value = null
}
this.emitInput()
@@ -145,21 +195,26 @@ export default {
if (!this.content.operator) {
return null
}
return this.available_filters[this.property.type].comparators[this.content.operator]
return this.available_filters[this.property.type].comparators[
this.content.operator
]
},
optionFilterNames(key, propertyType) {
if (propertyType === 'checkbox') {
if (propertyType === "checkbox") {
return {
equals: 'Is checked',
does_not_equal: 'Is not checked'
equals: "Is checked",
does_not_equal: "Is not checked",
}[key]
}
return key.split('_').map(function (item) {
return item.charAt(0).toUpperCase() + item.substring(1)
}).join(' ')
return key
.split("_")
.map(function (item) {
return item.charAt(0).toUpperCase() + item.substring(1)
})
.join(" ")
},
emitInput() {
this.$emit('update:modelValue', this.castContent(this.content))
this.$emit("update:modelValue", this.castContent(this.content))
},
refreshContent() {
this.content = {
@@ -167,14 +222,10 @@ export default {
...this.modelValue,
property_meta: {
id: this.property.id,
type: this.property.type
}
type: this.property.type,
},
}
}
},
},
mounted() {
this.refreshContent()
}
}
</script>

View File

@@ -1,7 +1,14 @@
<template>
<query-builder v-model="query" :rules="rules" :config="config" @update:model-value="onChange">
<query-builder
v-model="query"
:rules="rules"
:config="config"
@update:model-value="onChange"
>
<template #groupOperator="props">
<div class="query-builder-group-slot__group-selection flex items-center px-5 border-b py-1 mb-1 flex">
<div
class="query-builder-group-slot__group-selection flex items-center px-5 border-b py-1 mb-1 flex"
>
<p class="mr-2 font-semibold">
Operator
</p>
@@ -30,91 +37,100 @@
</query-builder>
</template>
<style src="query-builder-vue-3/dist/style.css" />
<script>
import { defineComponent } from 'vue'
import QueryBuilder from 'query-builder-vue-3'
import ColumnCondition from './ColumnCondition.vue'
import GroupControlSlot from './GroupControlSlot.vue'
/* eslint-disable vue/one-component-per-file */
import { defineComponent } from "vue"
import QueryBuilder from "query-builder-vue-3"
import ColumnCondition from "./ColumnCondition.vue"
import GroupControlSlot from "./GroupControlSlot.vue"
export default {
components: {
GroupControlSlot,
QueryBuilder,
ColumnCondition
ColumnCondition,
},
props: {
form: { type: Object, required: true },
modelValue: { required: false }
modelValue: { type: Object, required: false },
},
emits: ['update:modelValue'],
data () {
data() {
return {
query: this.modelValue
query: this.modelValue,
}
},
computed: {
rules () {
return this.form.properties.filter((property) => {
return !property.type.startsWith('nf-')
}).map((property) => {
const workspaceId = this.form.workspace_id
const formSlug = this.form.slug
return {
identifier: property.id,
name: property.name,
component: (function () {
return defineComponent({
extends: ColumnCondition,
computed: {
property () {
return property
rules() {
return this.form.properties
.filter((property) => {
return !property.type.startsWith("nf-")
})
.map((property) => {
const workspaceId = this.form.workspace_id
const formSlug = this.form.slug
return {
identifier: property.id,
name: property.name,
component: (function () {
return defineComponent({
extends: ColumnCondition,
computed: {
property() {
return property
},
viewContext() {
return {
form_slug: formSlug,
workspace_id: workspaceId,
}
},
},
viewContext () {
return {
form_slug: formSlug,
workspace_id: workspaceId
}
}
}
})
})()
}
})
})
})(),
}
})
},
config () {
config() {
return {
operators: [
{
name: 'And',
identifier: 'and'
name: "And",
identifier: "and",
},
{
name: 'Or',
identifier: 'or'
}
name: "Or",
identifier: "or",
},
],
rules: this.rules,
colors: ['#ef4444', '#22c55e', '#f97316', '#0ea5e9', '#8b5cf6', '#ec4899']
colors: [
"#ef4444",
"#22c55e",
"#f97316",
"#0ea5e9",
"#8b5cf6",
"#ec4899",
],
}
}
},
},
watch: {
modelValue () {
modelValue() {
this.query = this.modelValue
}
},
},
methods: {
onChange () {
this.$emit('update:modelValue', this.query)
}
}
onChange() {
this.$emit("update:modelValue", this.query)
},
},
}
</script>
<style src="query-builder-vue-3/dist/style.css" />

View File

@@ -1,24 +1,60 @@
<template>
<div v-if="logic" :key="resetKey">
<div
v-if="logic"
:key="resetKey"
>
<h3 class="font-semibold block text-lg">
Logic
</h3>
<p class="text-gray-400 text-xs mb-3">
Add some logic to this block. Start by adding some conditions, and then add some actions.
Add some logic to this block. Start by adding some conditions, and then
add some actions.
</p>
<div class="relative flex">
<div>
<v-button color="light-gray" size="small" @click="showCopyFormModal=true">
<svg class="h-4 w-4 text-blue-600 inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5 15H4C3.46957 15 2.96086 14.7893 2.58579 14.4142C2.21071 14.0391 2 13.5304 2 13V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2H13C13.5304 2 14.0391 2.21071 14.4142 2.58579C14.7893 2.96086 15 3.46957 15 4V5M11 9H20C21.1046 9 22 9.89543 22 11V20C22 21.1046 21.1046 22 20 22H11C9.89543 22 9 21.1046 9 20V11C9 9.89543 9.89543 9 11 9Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<v-button
color="light-gray"
size="small"
@click="showCopyFormModal = true"
>
<svg
class="h-4 w-4 text-blue-600 inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5 15H4C3.46957 15 2.96086 14.7893 2.58579 14.4142C2.21071 14.0391 2 13.5304 2 13V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2H13C13.5304 2 14.0391 2.21071 14.4142 2.58579C14.7893 2.96086 15 3.46957 15 4V5M11 9H20C21.1046 9 22 9.89543 22 11V20C22 21.1046 21.1046 22 20 22H11C9.89543 22 9 21.1046 9 20V11C9 9.89543 9.89543 9 11 9Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Copy from
</v-button>
</div>
<div>
<v-button color="light-gray" shade="light" size="small" class="ml-1" @click="clearAll">
<svg class="text-red-600 h-4 w-4 inline -mt-1 mr-1" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 9L12 15M12 9L18 15M21 4H8L1 12L8 20H21C21.5304 20 22.0391 19.7893 22.4142 19.4142C22.7893 19.0391 23 18.5304 23 18V6C23 5.46957 22.7893 4.96086 22.4142 4.58579C22.0391 4.21071 21.5304 4 21 4Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
<v-button
color="light-gray"
shade="light"
size="small"
class="ml-1"
@click="clearAll"
>
<svg
class="text-red-600 h-4 w-4 inline -mt-1 mr-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18 9L12 15M12 9L18 15M21 4H8L1 12L8 20H21C21.5304 20 22.0391 19.7893 22.4142 19.4142C22.7893 19.0391 23 18.5304 23 18V6C23 5.46957 22.7893 4.96086 22.4142 4.58579C22.0391 4.21071 21.5304 4 21 4Z"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Clear All
@@ -29,35 +65,64 @@
<h5 class="font-semibold mt-3">
1. Conditions
</h5>
<condition-editor ref="filter-editor" v-model="logic.conditions" class="mt-1 border-t border rounded-md" :form="form" />
<condition-editor
ref="filter-editor"
v-model="logic.conditions"
class="mt-1 border-t border rounded-md"
:form="form"
/>
<h5 class="font-semibold mt-3">
2. Actions
</h5>
<select-input :key="resetKey" v-model="logic.actions" name="actions"
:multiple="true" class="mt-1" placeholder="Actions..."
help="Action(s) triggered when above conditions are true"
:options="actionOptions"
@update:model-value="onActionInput"
<select-input
:key="resetKey"
v-model="logic.actions"
name="actions"
:multiple="true"
class="mt-1"
placeholder="Actions..."
help="Action(s) triggered when above conditions are true"
:options="actionOptions"
@update:model-value="onActionInput"
/>
<modal :show="showCopyFormModal" @close="showCopyFormModal = false">
<modal
:show="showCopyFormModal"
@close="showCopyFormModal = false"
>
<div class="min-h-[450px]">
<h3 class="font-semibold block text-lg">
Copy logic from another field
</h3>
<p class="text-gray-400 text-xs mb-5">
Select another field/block to copy its logic and apply it to "{{ field.name }}".
Select another field/block to copy its logic and apply it to "{{
field.name
}}".
</p>
<select-input v-model="copyFrom" name="copy_from" emit-key="value"
label="Copy logic from" placeholder="Choose a field/block..."
:options="copyFromOptions" :searchable="copyFromOptions && copyFromOptions.options > 5"
<select-input
v-model="copyFrom"
name="copy_from"
emit-key="value"
label="Copy logic from"
placeholder="Choose a field/block..."
:options="copyFromOptions"
:searchable="copyFromOptions && copyFromOptions.options > 5"
/>
<div class="flex justify-between mb-6">
<v-button color="blue" shade="light" @click="copyLogic">
<v-button
color="blue"
shade="light"
@click="copyLogic"
>
Confirm & Copy
</v-button>
<v-button color="gray" shade="light" class="ml-1" @click="showCopyFormModal=false">
<v-button
color="gray"
shade="light"
class="ml-1"
@click="showCopyFormModal = false"
>
Close
</v-button>
</div>
@@ -67,136 +132,161 @@
</template>
<script>
import ConditionEditor from './ConditionEditor.client.vue'
import Modal from '../../../../global/Modal.vue'
import clonedeep from 'clone-deep'
import { default as _has } from 'lodash/has'
import ConditionEditor from "./ConditionEditor.client.vue"
import Modal from "../../../../global/Modal.vue"
import clonedeep from "clone-deep"
import { default as _has } from "lodash/has"
export default {
name: 'FormBlockLogicEditor',
name: "FormBlockLogicEditor",
components: { Modal, ConditionEditor },
props: {
field: {
type: Object,
required: false
required: false,
},
form: {
type: Object,
required: false
}
required: false,
},
},
data () {
data() {
return {
resetKey: 0,
logic: this.field.logic || {
conditions: null,
actions: []
actions: [],
},
showCopyFormModal: false,
copyFrom: null
copyFrom: null,
}
},
computed: {
copyFromOptions () {
return this.form.properties.filter((field) => {
return field.id !== this.field.id && _has(field, 'logic') && field.logic !== null && field.logic !== {}
}).map((field) => {
return { name: field.name, value: field.id }
})
copyFromOptions() {
return this.form.properties
.filter((field) => {
return (
field.id !== this.field.id &&
_has(field, "logic") &&
field.logic !== null &&
field.logic !== {}
)
})
.map((field) => {
return { name: field.name, value: field.id }
})
},
actionOptions () {
if (['nf-text', 'nf-code', 'nf-page-break', 'nf-divider', 'nf-image'].includes(this.field.type)) {
actionOptions() {
if (
[
"nf-text",
"nf-code",
"nf-page-break",
"nf-divider",
"nf-image",
].includes(this.field.type)
) {
if (this.field.hidden) {
return [{ name: 'Show Block', value: 'show-block' }]
return [{ name: "Show Block", value: "show-block" }]
} else {
return [{ name: 'Hide Block', value: 'hide-block' }]
return [{ name: "Hide Block", value: "hide-block" }]
}
}
if (this.field.hidden) {
return [
{ name: 'Show Block', value: 'show-block' },
{ name: 'Require answer', value: 'require-answer' }
{ name: "Show Block", value: "show-block" },
{ name: "Require answer", value: "require-answer" },
]
} else if (this.field.disabled) {
return [
{ name: 'Enable Block', value: 'enable-block' },
(this.field.required
? { name: 'Make it optional', value: 'make-it-optional' }
{ name: "Enable Block", value: "enable-block" },
this.field.required
? { name: "Make it optional", value: "make-it-optional" }
: {
name: 'Require answer',
value: 'require-answer'
})
name: "Require answer",
value: "require-answer",
},
]
} else {
return [
{ name: 'Hide Block', value: 'hide-block' },
{ name: 'Disable Block', value: 'disable-block' },
(this.field.required
? { name: 'Make it optional', value: 'make-it-optional' }
{ name: "Hide Block", value: "hide-block" },
{ name: "Disable Block", value: "disable-block" },
this.field.required
? { name: "Make it optional", value: "make-it-optional" }
: {
name: 'Require answer',
value: 'require-answer'
})
name: "Require answer",
value: "require-answer",
},
]
}
}
},
},
watch: {
logic: {
handler () {
handler() {
this.field.logic = this.logic
},
deep: true
deep: true,
},
'field.id': {
handler (field, oldField) {
"field.id": {
handler() {
// On field change, reset logic
this.logic = this.field.logic || {
conditions: null,
actions: []
actions: [],
}
}
},
},
'field.required': 'cleanConditions',
'field.disabled': 'cleanConditions',
'field.hidden': 'cleanConditions'
"field.required": "cleanConditions",
"field.disabled": "cleanConditions",
"field.hidden": "cleanConditions",
},
mounted () {
if (!_has(this.field, 'logic')) {
mounted() {
if (!_has(this.field, "logic")) {
this.field.logic = this.logic
}
},
methods: {
clearAll () {
clearAll() {
this.logic.conditions = null
this.logic.actions = []
this.refreshActions()
},
onActionInput () {
onActionInput() {
if (this.logic.actions.length >= 2) {
if (this.logic.actions[1] === 'require-answer' && this.logic.actions[0] === 'hide-block') {
this.logic.actions = ['require-answer']
} else if (this.logic.actions[1] === 'hide-block' && this.logic.actions[0] === 'require-answer') {
this.logic.actions = ['hide-block']
if (
this.logic.actions[1] === "require-answer" &&
this.logic.actions[0] === "hide-block"
) {
this.logic.actions = ["require-answer"]
} else if (
this.logic.actions[1] === "hide-block" &&
this.logic.actions[0] === "require-answer"
) {
this.logic.actions = ["hide-block"]
}
this.refreshActions()
}
},
cleanConditions () {
const availableActions = this.actionOptions.map(function (op) { return op.value })
this.logic.actions = availableActions.filter(value => this.logic.actions.includes(value))
cleanConditions() {
const availableActions = this.actionOptions.map(function (op) {
return op.value
})
this.logic.actions = availableActions.filter((value) =>
this.logic.actions.includes(value),
)
this.refreshActions()
},
refreshActions () {
refreshActions() {
this.resetKey++
},
copyLogic () {
copyLogic() {
if (this.copyFrom) {
const property = this.form.properties.find((property) => {
return property.id === this.copyFrom
@@ -207,7 +297,7 @@ export default {
}
}
this.showCopyFormModal = false
}
}
},
},
}
</script>

View File

@@ -1,16 +1,33 @@
<template>
<div class="flex flex-wrap px-4 py-1 -ml-1 -mt-1">
<select-input ref="ruleSelect" v-model="selectedRule" class="flex-grow ml-1 mr-1 mt-1"
wrapper-class="relative" placeholder="Add condition on input field"
:options="groupCtrl.rules" margin-bottom="" :searchable="groupCtrl.rules.length > 5"
emit-key="identifier"
option-key="identifier"
name="group-control-slot-rule"
<select-input
ref="ruleSelect"
v-model="selectedRule"
class="flex-grow ml-1 mr-1 mt-1"
wrapper-class="relative"
placeholder="Add condition on input field"
:options="groupCtrl.rules"
margin-bottom=""
:searchable="groupCtrl.rules.length > 5"
emit-key="identifier"
option-key="identifier"
name="group-control-slot-rule"
/>
<v-button class="ml-1 mt-1" color="blue" size="small" :disabled="(selectedRule === '')?true:null" @click="addRule">
<v-button
class="ml-1 mt-1"
color="blue"
size="small"
:disabled="selectedRule === '' ? true : null"
@click="addRule"
>
Add Condition
</v-button>
<v-button class="ml-1 mt-1" color="outline-blue" size="small" @click="groupCtrl.newGroup">
<v-button
class="ml-1 mt-1"
color="outline-blue"
size="small"
@click="groupCtrl.newGroup"
>
Add Group
</v-button>
</div>
@@ -20,20 +37,19 @@
export default {
components: {},
props: { groupCtrl: { type: Object, required: true } },
data () {
data() {
return {
selectedRule: null
selectedRule: null,
}
},
methods: {
addRule () {
addRule() {
if (this.selectedRule) {
this.groupCtrl.addRule(this.selectedRule)
this.$refs.ruleSelect.content = null
this.selectedRule = null
}
}
}
},
},
}
</script>

View File

@@ -1,10 +1,21 @@
<template>
<modal :show="show" @close="emit('close')">
<modal
:show="show"
@close="emit('close')"
>
<template #icon>
<svg class="w-10 h-10 text-blue" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<svg
class="w-10 h-10 text-blue"
viewBox="0 0 48 48"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M17 27C16.0681 27 15.6022 27 15.2346 26.8478C14.7446 26.6448 14.3552 26.2554 14.1522 25.7654C14 25.3978 14 24.9319 14 24V17.2C14 16.0799 14 15.5198 14.218 15.092C14.4097 14.7157 14.7157 14.4097 15.092 14.218C15.5198 14 16.0799 14 17.2 14H24C24.9319 14 25.3978 14 25.7654 14.1522C26.2554 14.3552 26.6448 14.7446 26.8478 15.2346C27 15.6022 27 16.0681 27 17M24.2 34H30.8C31.9201 34 32.4802 34 32.908 33.782C33.2843 33.5903 33.5903 33.2843 33.782 32.908C34 32.4802 34 31.9201 34 30.8V24.2C34 23.0799 34 22.5198 33.782 22.092C33.5903 21.7157 33.2843 21.4097 32.908 21.218C32.4802 21 31.9201 21 30.8 21H24.2C23.0799 21 22.5198 21 22.092 21.218C21.7157 21.4097 21.4097 21.7157 21.218 22.092C21 22.5198 21 23.0799 21 24.2V30.8C21 31.9201 21 32.4802 21.218 32.908C21.4097 33.2843 21.7157 33.5903 22.092 33.782C22.5198 34 23.0799 34 24.2 34Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</template>
@@ -18,37 +29,99 @@
</template>
<div class="p-4">
<p v-if="!template">
New template will be create from your form: <span class="font-semibold">{{ form.title }}</span>.
New template will be create from your form:
<span class="font-semibold">{{ form.title }}</span>.
</p>
<form v-if="templateForm" class="mt-6" @submit.prevent="onSubmit" @keydown="templateForm.onKeydown($event)">
<form
v-if="templateForm"
class="mt-6"
@submit.prevent="onSubmit"
@keydown="templateForm.onKeydown($event)"
>
<div class="-m-6">
<div class="border-t py-4 px-6">
<toggle-switch-input v-if="user && (user.admin || user.template_editor)" name="publicly_listed" :form="templateForm" class="mt-4" label="Publicly Listed?" />
<text-input name="name" :form="templateForm" class="mt-4" label="Title" :required="true" />
<text-input name="slug" :form="templateForm" class="mt-4" label="Slug" :required="true" />
<text-area-input name="short_description" :form="templateForm" class="mt-4" label="Short Description"
:required="true"
<toggle-switch-input
v-if="user && (user.admin || user.template_editor)"
name="publicly_listed"
:form="templateForm"
class="mt-4"
label="Publicly Listed?"
/>
<rich-text-area-input name="description" :form="templateForm" class="mt-4" label="Description"
:required="true"
<text-input
name="name"
:form="templateForm"
class="mt-4"
label="Title"
:required="true"
/>
<text-input name="image_url" :form="templateForm" class="mt-4" label="Image" :required="true" />
<select-input name="types" :form="templateForm" class="mt-4" label="Types" :options="typesOptions"
:multiple="true" :searchable="true"
<text-input
name="slug"
:form="templateForm"
class="mt-4"
label="Slug"
:required="true"
/>
<select-input name="industries" :form="templateForm" class="mt-4" label="Industries"
:options="industriesOptions" :multiple="true" :searchable="true"
<text-area-input
name="short_description"
:form="templateForm"
class="mt-4"
label="Short Description"
:required="true"
/>
<select-input name="related_templates" :form="templateForm" class="mt-4" label="Related Templates"
:options="templatesOptions" :multiple="true" :searchable="true"
<rich-text-area-input
name="description"
:form="templateForm"
class="mt-4"
label="Description"
:required="true"
/>
<questions-editor name="questions" :questions="templateForm.questions" class="mt-4"
label="Frequently asked questions"
<text-input
name="image_url"
:form="templateForm"
class="mt-4"
label="Image"
:required="true"
/>
<select-input
name="types"
:form="templateForm"
class="mt-4"
label="Types"
:options="typesOptions"
:multiple="true"
:searchable="true"
/>
<select-input
name="industries"
:form="templateForm"
class="mt-4"
label="Industries"
:options="industriesOptions"
:multiple="true"
:searchable="true"
/>
<select-input
name="related_templates"
:form="templateForm"
class="mt-4"
label="Related Templates"
:options="templatesOptions"
:multiple="true"
:searchable="true"
/>
<questions-editor
name="questions"
:questions="templateForm.questions"
class="mt-4"
label="Frequently asked questions"
/>
</div>
<div class="flex justify-end mt-4 pb-5 px-6">
<v-button class="mr-2" :loading="templateForm.busy">
<v-button
class="mr-2"
:loading="templateForm.busy"
>
<template v-if="template">
Update
</template>
@@ -56,12 +129,23 @@
Create
</template>
</v-button>
<v-button v-if="template" color="red" class="mr-2"
@click.prevent="useAlert().confirm('Do you really want to delete this template?', deleteFormTemplate)"
<v-button
v-if="template"
color="red"
class="mr-2"
@click.prevent="
useAlert().confirm(
'Do you really want to delete this template?',
deleteFormTemplate,
)
"
>
Delete
</v-button>
<v-button color="white" @click.prevent="emit('close')">
<v-button
color="white"
@click.prevent="emit('close')"
>
Close
</v-button>
</div>
@@ -72,68 +156,73 @@
</template>
<script setup>
import { ref, defineProps, defineEmits, computed } from 'vue'
import QuestionsEditor from './QuestionsEditor.vue'
import { ref, defineProps, defineEmits, computed } from "vue"
import QuestionsEditor from "./QuestionsEditor.vue"
const props = defineProps({
show: { type: Boolean, required: true },
form: { type: Object, required: true },
template: { type: Object, required: false, default: () => {} }
template: { type: Object, required: false, default: () => {} },
})
const authStore = useAuthStore()
const templatesStore = useTemplatesStore()
const router = useRouter()
let user = computed(() => authStore.user)
let templates = computed(() => [...templatesStore.content.values()])
let industries = computed(() => [...templatesStore.industries.values()])
let types = computed(() => [...templatesStore.types.values()])
const user = computed(() => authStore.user)
const templates = computed(() => [...templatesStore.content.values()])
const industries = computed(() => [...templatesStore.industries.values()])
const types = computed(() => [...templatesStore.types.values()])
let templateForm = ref(null)
const emit = defineEmits(['close'])
const templateForm = ref(null)
const emit = defineEmits(["close"])
onMounted(() => {
templateForm.value = useForm(props.template ?? {
publicly_listed: false,
name: '',
slug: '',
short_description: '',
description: '',
image_url: '',
types: null,
industries: null,
related_templates: null,
questions: []
})
templateForm.value = useForm(
props.template ?? {
publicly_listed: false,
name: "",
slug: "",
short_description: "",
description: "",
image_url: "",
types: null,
industries: null,
related_templates: null,
questions: [],
},
)
})
watch(() => props.show, () => {
if (props.show) {
loadAllTemplates(templatesStore)
}
})
watch(
() => props.show,
() => {
if (props.show) {
loadAllTemplates(templatesStore)
}
},
)
let typesOptions = computed(() => {
const typesOptions = computed(() => {
return Object.values(types.value).map((type) => {
return {
name: type.name,
value: type.slug
value: type.slug,
}
})
})
let industriesOptions = computed(() => {
const industriesOptions = computed(() => {
return Object.values(industries.value).map((industry) => {
return {
name: industry.name,
value: industry.slug
value: industry.slug,
}
})
})
let templatesOptions = computed(() => {
const templatesOptions = computed(() => {
return Object.values(templates.value).map((template) => {
return {
name: template.name,
value: template.slug
value: template.slug,
}
})
})
@@ -147,33 +236,37 @@ const onSubmit = () => {
}
const createFormTemplate = async () => {
templateForm.value.form = props.form
await templateForm.value.post('/templates').then((data) => {
await templateForm.value.post("/templates").then((data) => {
if (data.message) {
useAlert().success(data.message)
}
templatesStore.save(data.data)
emit('close')
emit("close")
})
}
const updateFormTemplate = async () => {
templateForm.value.form = props.form
await templateForm.value.put('/templates/' + props.template.id).then((data) => {
if (data.message) {
useAlert().success(data.message)
}
templatesStore.save(data.data)
emit('close')
})
await templateForm.value
.put("/templates/" + props.template.id)
.then((data) => {
if (data.message) {
useAlert().success(data.message)
}
templatesStore.save(data.data)
emit("close")
})
}
const deleteFormTemplate = async () => {
if (!props.template) return
opnFetch('/templates/' + props.template.id, {method:'DELETE'}).then((data) => {
if (data.message) {
useAlert().success(data.message)
}
router.push({ name: 'templates' })
templatesStore.remove(props.template)
emit('close')
})
opnFetch("/templates/" + props.template.id, { method: "DELETE" }).then(
(data) => {
if (data.message) {
useAlert().success(data.message)
}
router.push({ name: "templates" })
templatesStore.remove(props.template)
emit("close")
},
)
}
</script>

View File

@@ -1,77 +1,148 @@
<template>
<div :class="wrapperClass">
<label v-if="label" :for="id?id:name"
:class="[theme.default.label,{'uppercase text-xs':uppercaseLabels, 'text-sm':!uppercaseLabels}]"
<label
v-if="label"
:for="id ? id : name"
:class="[
theme.default.label,
{ 'uppercase text-xs': uppercaseLabels, 'text-sm': !uppercaseLabels },
]"
>
{{ label }}
<span v-if="required" class="text-red-500 required-dot">*</span>
<span
v-if="required"
class="text-red-500 required-dot"
>*</span>
</label>
<Loader v-if="loading" key="loader" class="h-6 w-6 text-nt-blue mx-auto" />
<div v-else class="my-3">
<div v-for="(questionForm, quesKey) in allQuestions" :key="quesKey" class="bg-gray-100 p-2 mb-4">
<v-button color="red" size="small" class="mb-2" @click.prevent="onRemove(quesKey)">
<svg class="h-4 w-4 text-white inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3 6H5M5 6H21M5 6V20C5 20.5304 5.21071 21.0391 5.58579 21.4142C5.96086 21.7893 6.46957 22 7 22H17C17.5304 22 18.0391 21.7893 18.4142 21.4142C18.7893 21.0391 19 20.5304 19 20V6H5ZM8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M10 11V17M14 11V17" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
Remove
</v-button>
<text-input name="question" :form="questionForm" placeholder="Question title" />
<rich-text-area-input name="answer" :form="questionForm" class="mt-4" placeholder="Question response" />
<Loader
v-if="loading"
key="loader"
class="h-6 w-6 text-nt-blue mx-auto"
/>
<div
v-else
class="my-3"
>
<div
v-for="(questionForm, quesKey) in allQuestions"
:key="quesKey"
class="bg-gray-100 p-2 mb-4"
>
<v-button
color="red"
size="small"
class="mb-2"
@click.prevent="onRemove(quesKey)"
>
<svg
class="h-4 w-4 text-white inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3 6H5M5 6H21M5 6V20C5 20.5304 5.21071 21.0391 5.58579 21.4142C5.96086 21.7893 6.46957 22 7 22H17C17.5304 22 18.0391 21.7893 18.4142 21.4142C18.7893 21.0391 19 20.5304 19 20V6H5ZM8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M10 11V17M14 11V17"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Remove
</v-button>
<text-input
name="question"
:form="questionForm"
placeholder="Question title"
/>
<rich-text-area-input
name="answer"
:form="questionForm"
class="mt-4"
placeholder="Question response"
/>
</div>
<v-button v-if="addNew" color="green" size="small" nativeType="button" class="mt-2 flex" @click.prevent="onAdd">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-1 inline" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z" />
<v-button
v-if="addNew"
color="green"
size="small"
native-type="button"
class="mt-2 flex"
@click.prevent="onAdd"
>
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6 mr-1 inline"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 9v6m3-3H9m12 0a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
Add New
</v-button>
</div>
<small v-if="help" :class="theme.SelectInput.help">
<small
v-if="help"
:class="theme.SelectInput.help"
>
<slot name="help">{{ help }}</slot>
</small>
<has-error v-if="hasValidation" :form="form" :field="name" />
<has-error
v-if="hasValidation"
:form="form"
:field="name"
/>
</div>
</template>
<script>
import inputMixin from '~/mixins/forms/input.js'
import inputMixin from "~/mixins/forms/input.js"
export default {
name: 'QuestionsEditor',
name: "QuestionsEditor",
mixins: [inputMixin],
props: {
loading: { type: Boolean, default: false },
addNew: { type: Boolean, default: true },
questions: { type: Array, default: [] },
questions: { type: Array, default: ()=>[] },
},
data () {
data() {
return {
allQuestions: null,
newQuestion: {
question: '',
answer: '',
}
question: "",
answer: "",
},
}
},
mounted () {
this.allQuestions = (this.questions.length > 0) ? this.questions : [this.newQuestion]
computed: {},
watch: {},
mounted() {
this.allQuestions =
this.questions.length > 0 ? this.questions : [this.newQuestion]
},
watch: { },
computed: { },
methods: {
onAdd() {
this.allQuestions.push(this.newQuestion)
},
onRemove(key){
onRemove(key) {
this.allQuestions.splice(key, 1)
}
}
},
},
}
</script>

View File

@@ -1,19 +1,44 @@
<template>
<div>
<div class="p-4 border-b sticky top-0 z-10 bg-white">
<button v-if="!field" class="text-gray-500 hover:text-gray-900 cursor-pointer" @click.prevent="closeSidebar">
<svg class="h-6 w-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"
<button
v-if="!field"
class="text-gray-500 hover:text-gray-900 cursor-pointer"
@click.prevent="closeSidebar"
>
<svg
class="h-6 w-6"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18 6L6 18M6 6L18 18"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</button>
<template v-else>
<div class="flex">
<button class="text-gray-500 hover:text-gray-900 cursor-pointer" @click.prevent="closeSidebar">
<svg class="h-6 w-6" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M18 6L6 18M6 6L18 18" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round"
<button
class="text-gray-500 hover:text-gray-900 cursor-pointer"
@click.prevent="closeSidebar"
>
<svg
class="h-6 w-6"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M18 6L6 18M6 6L18 18"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</button>
@@ -22,120 +47,162 @@
</div>
</div>
<div class="flex mt-2">
<v-button color="light-gray" class="border-r-0 rounded-r-none text-xs hover:bg-red-50" size="small"
@click="removeBlock"
<v-button
color="light-gray"
class="border-r-0 rounded-r-none text-xs hover:bg-red-50"
size="small"
@click="removeBlock"
>
<svg class="h-4 w-4 text-red-600 inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="h-4 w-4 text-red-600 inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3 6H5M5 6H21M5 6V20C5 20.5304 5.21071 21.0391 5.58579 21.4142C5.96086 21.7893 6.46957 22 7 22H17C17.5304 22 18.0391 21.7893 18.4142 21.4142C18.7893 21.0391 19 20.5304 19 20V6H5ZM8 6V4C8 3.46957 8.21071 2.96086 8.58579 2.58579C8.96086 2.21071 9.46957 2 10 2H14C14.5304 2 15.0391 2.21071 15.4142 2.58579C15.7893 2.96086 16 3.46957 16 4V6M10 11V17M14 11V17"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Remove
</v-button>
<v-button size="small" class="text-xs" :class="{
'rounded-none border-r-0':!isBlockField && typeCanBeChanged,
'rounded-l-none':isBlockField || !typeCanBeChanged
}" color="light-gray" @click="duplicateBlock"
<v-button
size="small"
class="text-xs"
:class="{
'rounded-none border-r-0': !isBlockField && typeCanBeChanged,
'rounded-l-none': isBlockField || !typeCanBeChanged,
}"
color="light-gray"
@click="duplicateBlock"
>
<svg class="h-4 w-4 text-blue-600 inline mr-1 -mt-1" viewBox="0 0 24 24" fill="none"
xmlns="http://www.w3.org/2000/svg"
<svg
class="h-4 w-4 text-blue-600 inline mr-1 -mt-1"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M5 15H4C3.46957 15 2.96086 14.7893 2.58579 14.4142C2.21071 14.0391 2 13.5304 2 13V4C2 3.46957 2.21071 2.96086 2.58579 2.58579C2.96086 2.21071 3.46957 2 4 2H13C13.5304 2 14.0391 2.21071 14.4142 2.58579C14.7893 2.96086 15 3.46957 15 4V5M11 9H20C21.1046 9 22 9.89543 22 11V20C22 21.1046 21.1046 22 20 22H11C9.89543 22 9 21.1046 9 20V11C9 9.89543 9.89543 9 11 9Z"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
Duplicate
</v-button>
<change-field-type v-if="!isBlockField" btn-classes="rounded-l-none text-xs" :field="field"
@changeType="onChangeType"
<change-field-type
v-if="!isBlockField"
btn-classes="rounded-l-none text-xs"
:field="field"
@change-type="onChangeType"
/>
</div>
</template>
</div>
<template v-if="field">
<field-options v-if="!isBlockField" :form="form" :field="field" />
<block-options v-if="isBlockField" :form="form" :field="field" />
<field-options
v-if="!isBlockField"
:form="form"
:field="field"
/>
<block-options
v-if="isBlockField"
:form="form"
:field="field"
/>
</template>
<div v-else class="text-center p-10">
<div
v-else
class="text-center p-10"
>
Click on field's setting icon in your form to modify it
</div>
</div>
</template>
<script>
import { computed } from 'vue'
import clonedeep from 'clone-deep'
import { useWorkingFormStore } from '../../../../stores/working_form'
import ChangeFieldType from './components/ChangeFieldType.vue'
import FieldOptions from './components/FieldOptions.vue'
import BlockOptions from './components/BlockOptions.vue'
import { computed } from "vue"
import clonedeep from "clone-deep"
import { useWorkingFormStore } from "../../../../stores/working_form"
import ChangeFieldType from "./components/ChangeFieldType.vue"
import FieldOptions from "./components/FieldOptions.vue"
import BlockOptions from "./components/BlockOptions.vue"
export default {
name: 'FormFieldEdit',
name: "FormFieldEdit",
components: { ChangeFieldType, FieldOptions, BlockOptions },
props: {},
setup () {
setup() {
const workingFormStore = useWorkingFormStore()
return {
workingFormStore,
selectedFieldIndex : computed(() => workingFormStore.selectedFieldIndex)
selectedFieldIndex: computed(() => workingFormStore.selectedFieldIndex),
}
},
data () {
return {
}
data() {
return {}
},
computed: {
form: {
get () {
get() {
return this.workingFormStore.content
},
/* We add a setter */
set (value) {
set(value) {
this.workingFormStore.set(value)
}
},
},
field () {
return (this.form && this.selectedFieldIndex !== null) ? this.form.properties[this.selectedFieldIndex] : null
field() {
return this.form && this.selectedFieldIndex !== null
? this.form.properties[this.selectedFieldIndex]
: null
},
isBlockField () {
return this.field && this.field.type.startsWith('nf')
isBlockField() {
return this.field && this.field.type.startsWith("nf")
},
typeCanBeChanged() {
return [
"text",
"email",
"phone_number",
"number",
"select",
"multi_select",
"rating",
"scale",
"slider",
].includes(this.field.type)
},
typeCanBeChanged () {
return ['text', 'email', 'phone_number', 'number', 'select', 'multi_select', 'rating', 'scale', 'slider'].includes(this.field.type)
}
},
watch: {},
created () {
},
created() {},
mounted () {
},
mounted() {},
methods: {
onChangeType (newType) {
if (['select', 'multi_select'].includes(this.field.type)) {
onChangeType(newType) {
if (["select", "multi_select"].includes(this.field.type)) {
this.field[newType] = this.field[this.field.type] // Set new options with new type
delete this.field[this.field.type] // remove old type options
}
this.field.type = newType
},
removeBlock () {
removeBlock() {
const newFields = clonedeep(this.form.properties)
newFields.splice(this.selectedFieldIndex, 1)
this.form.properties = newFields
this.closeSidebar()
},
duplicateBlock () {
duplicateBlock() {
const newFields = clonedeep(this.form.properties)
const newField = clonedeep(this.form.properties[this.selectedFieldIndex])
newField.id = this.generateUUID()
@@ -143,24 +210,33 @@ export default {
this.form.properties = newFields
this.closeSidebar()
},
closeSidebar () {
closeSidebar() {
this.workingFormStore.closeEditFieldSidebar()
},
generateUUID () {
let d = new Date().getTime()// Timestamp
let d2 = ((typeof performance !== 'undefined') && performance.now && (performance.now() * 1000)) || 0// Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
let r = Math.random() * 16// random number between 0 and 16
if (d > 0) { // Use timestamp until depleted
r = (d + r) % 16 | 0
d = Math.floor(d / 16)
} else { // Use microseconds since page-load if supported
r = (d2 + r) % 16 | 0
d2 = Math.floor(d2 / 16)
}
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
})
}
}
generateUUID() {
let d = new Date().getTime() // Timestamp
let d2 =
(typeof performance !== "undefined" &&
performance.now &&
performance.now() * 1000) ||
0 // Time in microseconds since page-load or 0 if unsupported
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
/[xy]/g,
function (c) {
let r = Math.random() * 16 // random number between 0 and 16
if (d > 0) {
// Use timestamp until depleted
r = (d + r) % 16 | 0
d = Math.floor(d / 16)
} else {
// Use microseconds since page-load if supported
r = (d2 + r) % 16 | 0
d2 = Math.floor(d2 / 16)
}
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16)
},
)
},
},
}
</script>

View File

@@ -8,153 +8,196 @@
<p class="text-gray-400 mb-3 text-xs">
Exclude this field or make it required.
</p>
<v-checkbox v-model="field.hidden" class="mb-3"
:name="field.id+'_hidden'"
@update:model-value="onFieldHiddenChange"
<v-checkbox
v-model="field.hidden"
class="mb-3"
:name="field.id + '_hidden'"
@update:model-value="onFieldHiddenChange"
>
Hidden
</v-checkbox>
<select-input name="width" class="mt-3"
:options="[
{name:'Full',value:'full'},
{name:'1/2 (half width)',value:'1/2'},
{name:'1/3 (a third of the width)',value:'1/3'},
{name:'2/3 (two thirds of the width)',value:'2/3'},
{name:'1/4 (a quarter of the width)',value:'1/4'},
{name:'3/4 (three quarters of the width)',value:'3/4'}
]"
:form="field" label="Field Width"
<select-input
name="width"
class="mt-3"
:options="[
{ name: 'Full', value: 'full' },
{ name: '1/2 (half width)', value: '1/2' },
{ name: '1/3 (a third of the width)', value: '1/3' },
{ name: '2/3 (two thirds of the width)', value: '2/3' },
{ name: '1/4 (a quarter of the width)', value: '1/4' },
{ name: '3/4 (three quarters of the width)', value: '3/4' },
]"
:form="field"
label="Field Width"
/>
<select-input v-if="['nf-text','nf-image'].includes(field.type)" name="align" class="mt-3"
:options="[
{name:'Left',value:'left'},
{name:'Center',value:'center'},
{name:'Right',value:'right'},
{name:'Justify',value:'justify'}
]"
:form="field" label="Field Alignment"
<select-input
v-if="['nf-text', 'nf-image'].includes(field.type)"
name="align"
class="mt-3"
:options="[
{ name: 'Left', value: 'left' },
{ name: 'Center', value: 'center' },
{ name: 'Right', value: 'right' },
{ name: 'Justify', value: 'justify' },
]"
:form="field"
label="Field Alignment"
/>
</div>
<div v-if="field.type == 'nf-text'" class="border-b py-2 px-4">
<rich-text-area-input name="content"
:form="field"
label="Content"
:required="false"
<div
v-if="field.type == 'nf-text'"
class="border-b py-2 px-4"
>
<rich-text-area-input
name="content"
:form="field"
label="Content"
:required="false"
/>
</div>
<div v-else-if="field.type == 'nf-page-break'" class="border-b py-2 px-4">
<text-input name="next_btn_text"
:form="field"
label="Text of next button"
:required="true"
<div
v-else-if="field.type == 'nf-page-break'"
class="border-b py-2 px-4"
>
<text-input
name="next_btn_text"
:form="field"
label="Text of next button"
:required="true"
/>
<text-input name="previous_btn_text"
:form="field"
label="Text of previous button"
help="Shown on the next page"
:required="true"
<text-input
name="previous_btn_text"
:form="field"
label="Text of previous button"
help="Shown on the next page"
:required="true"
/>
</div>
<div v-else-if="field.type == 'nf-divider'" class="border-b py-2 px-4">
<text-input name="name"
:form="field" :required="true"
label="Field Name"
<div
v-else-if="field.type == 'nf-divider'"
class="border-b py-2 px-4"
>
<text-input
name="name"
:form="field"
:required="true"
label="Field Name"
/>
</div>
<div v-else-if="field.type == 'nf-image'" class="border-b py-2 px-4">
<text-input name="name"
:form="field" :required="true"
label="Field Name"
<div
v-else-if="field.type == 'nf-image'"
class="border-b py-2 px-4"
>
<text-input
name="name"
:form="field"
:required="true"
label="Field Name"
/>
<image-input name="image_block" class="mt-3"
:form="field" label="Upload Image" :required="false"
<image-input
name="image_block"
class="mt-3"
:form="field"
label="Upload Image"
:required="false"
/>
</div>
<div v-else-if="field.type == 'nf-code'" class="border-b py-2 px-4">
<code-input name="content" :form="field" label="Content"
help="You can add any html code, including iframes"
<div
v-else-if="field.type == 'nf-code'"
class="border-b py-2 px-4"
>
<code-input
name="content"
:form="field"
label="Content"
help="You can add any html code, including iframes"
/>
</div>
<div v-else class="border-b py-2 px-4">
<div
v-else
class="border-b py-2 px-4"
>
<p>No settings found.</p>
</div>
<!-- Logic Block -->
<form-block-logic-editor class="py-2 px-4 border-b" :form="form" :field="field" />
<form-block-logic-editor
class="py-2 px-4 border-b"
:form="form"
:field="field"
/>
</div>
</template>
<script>
import FormBlockLogicEditor from '../../components/form-logic-components/FormBlockLogicEditor.vue'
import FormBlockLogicEditor from "../../components/form-logic-components/FormBlockLogicEditor.vue"
export default {
name: 'BlockOptions',
components: {FormBlockLogicEditor},
name: "BlockOptions",
components: { FormBlockLogicEditor },
props: {
field: {
type: Object,
required: false
required: false,
},
form: {
type: Object,
required: false
}
required: false,
},
},
data () {
data() {
return {
editorToolbarCustom: [
['bold', 'italic', 'underline', 'link']
]
editorToolbarCustom: [["bold", "italic", "underline", "link"]],
}
},
computed: {},
watch: {
'field.width': {
handler (val) {
"field.width": {
handler(val) {
if (val === undefined || val === null) {
this.field.width = 'full'
this.field.width = "full"
}
},
immediate: true
immediate: true,
},
'field.align': {
handler (val) {
"field.align": {
handler(val) {
if (val === undefined || val === null) {
this.field.align = 'left'
this.field.align = "left"
}
},
immediate: true
}
immediate: true,
},
},
created () {
created() {
if (this.field?.width === undefined || this.field?.width === null) {
this.field.width = 'full'
this.field.width = "full"
}
},
mounted () {},
mounted() {},
methods: {
onFieldHiddenChange (val) {
onFieldHiddenChange(val) {
this.field.hidden = val
if (this.field.hidden) {
this.field.required = false
}
},
onFieldHelpPositionChange (val) {
onFieldHelpPositionChange(val) {
if (!val) {
this.field.help_position = 'below_input'
this.field.help_position = "below_input"
}
}
}
},
},
}
</script>

View File

@@ -1,17 +1,41 @@
<template>
<dropdown ref="newTypeDropdown" v-if="changeTypeOptions.length > 0" dusk="nav-dropdown">
<template #trigger="{toggle}">
<v-button class="relative" :class="btnClasses" size="small" color="light-gray" @click.stop="toggle">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" class="h-4 w-4 text-blue-600 inline mr-1 -mt-1">
<path stroke-linecap="round" stroke-linejoin="round" d="M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5" />
<dropdown
v-if="changeTypeOptions.length > 0"
ref="newTypeDropdown"
dusk="nav-dropdown"
>
<template #trigger="{ toggle }">
<v-button
class="relative"
:class="btnClasses"
size="small"
color="light-gray"
@click.stop="toggle"
>
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="2"
stroke="currentColor"
class="h-4 w-4 text-blue-600 inline mr-1 -mt-1"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5"
/>
</svg>
<span class="whitespace-nowrap">Change Type</span>
</v-button>
</template>
<a v-for="(op, index) in changeTypeOptions" :key="index" href="#"
class="block px-4 py-2 text-md text-gray-700 dark:text-white hover:bg-gray-100 hover:text-gray-900 dark:text-gray-100 dark:hover:text-white dark:hover:bg-gray-600 flex items-center"
@click.prevent="changeType(op.value)"
<a
v-for="(op, index) in changeTypeOptions"
:key="index"
href="#"
class="block px-4 py-2 text-md text-gray-700 dark:text-white hover:bg-gray-100 hover:text-gray-900 dark:text-gray-100 dark:hover:text-white dark:hover:bg-gray-600 flex items-center"
@click.prevent="changeType(op.value)"
>
{{ op.name }}
</a>
@@ -19,68 +43,80 @@
</template>
<script>
import Dropdown from '~/components/global/Dropdown.vue'
import Dropdown from "~/components/global/Dropdown.vue"
export default {
name: 'ChangeFieldType',
name: "ChangeFieldType",
components: { Dropdown },
props: {
field: {
type: Object,
required: true
required: true,
},
btnClasses: {
type: String,
required: true
}
required: true,
},
},
data () {
emits: ['changeType'],
data() {
return {}
},
computed: {
changeTypeOptions () {
changeTypeOptions() {
let newTypes = []
if (['text', 'email', 'phone_number', 'number','slider','rating','scale'].includes(this.field.type)) {
if (
[
"text",
"email",
"phone_number",
"number",
"slider",
"rating",
"scale",
].includes(this.field.type)
) {
newTypes = [
{ name: 'Text Input', value: 'text' },
{ name: 'Email Input', value: 'email' },
{ name: 'Phone Input', value: 'phone_number' },
{ name: 'Number Input', value: 'number' },
{ name: 'Slider Input', value: 'slider' },
{ name: 'Rating Input', value: 'rating' },
{ name: 'Scale Input', value: 'scale' },
{ name: "Text Input", value: "text" },
{ name: "Email Input", value: "email" },
{ name: "Phone Input", value: "phone_number" },
{ name: "Number Input", value: "number" },
{ name: "Slider Input", value: "slider" },
{ name: "Rating Input", value: "rating" },
{ name: "Scale Input", value: "scale" },
]
}
if (['select', 'multi_select'].includes(this.field.type)) {
if (["select", "multi_select"].includes(this.field.type)) {
newTypes = [
{ name: 'Select Input', value: 'select' },
{ name: 'Multi-Select Input', value: 'multi_select' }
{ name: "Select Input", value: "select" },
{ name: "Multi-Select Input", value: "multi_select" },
]
}
return newTypes.filter((item) => {
return item.value !== this.field.type
}).map((item) => {
return {
name: item.name,
value: item.value
}
})
}
return newTypes
.filter((item) => {
return item.value !== this.field.type
})
.map((item) => {
return {
name: item.name,
value: item.value,
}
})
},
},
watch: {},
mounted () {
},
mounted() {},
methods: {
changeType (newType) {
changeType(newType) {
if (newType) {
this.$emit('changeType', newType)
this.$emit("changeType", newType)
this.$refs.newTypeDropdown.close()
}
}
}
},
},
}
</script>

View File

@@ -1,5 +1,8 @@
<template>
<div v-if="field" class="py-2">
<div
v-if="field"
class="py-2"
>
<!-- General -->
<div class="border-b px-4">
<h3 class="font-semibold block text-lg">
@@ -8,23 +11,43 @@
<p class="text-gray-400 mb-2 text-xs">
Exclude this field or make it required.
</p>
<toggle-switch-input :form="field" name="required" label="Required"
@update:model-value="onFieldRequiredChange"/>
<toggle-switch-input :form="field" name="hidden" label="Hidden"
@update:model-value="onFieldHiddenChange"/>
<toggle-switch-input :form="field" name="disabled" label="Disabled"
@update:model-value="onFieldDisabledChange"/>
<toggle-switch-input
:form="field"
name="required"
label="Required"
@update:model-value="onFieldRequiredChange"
/>
<toggle-switch-input
:form="field"
name="hidden"
label="Hidden"
@update:model-value="onFieldHiddenChange"
/>
<toggle-switch-input
:form="field"
name="disabled"
label="Disabled"
@update:model-value="onFieldDisabledChange"
/>
</div>
<!-- Checkbox -->
<div v-if="field.type === 'checkbox'" class="border-b py-2 px-4">
<div
v-if="field.type === 'checkbox'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Checkbox
</h3>
<p class="text-gray-400 mb-3 text-xs">
Advanced options for checkbox.
</p>
<v-checkbox v-model="field.use_toggle_switch" class="mt-3" name="use_toggle_switch" help="">
<v-checkbox
v-model="field.use_toggle_switch"
class="mt-3"
name="use_toggle_switch"
help=""
>
Use toggle switch
</v-checkbox>
<p class="text-gray-400 mb-3 text-xs">
@@ -33,83 +56,172 @@
</div>
<!-- File Uploads -->
<div v-if="field.type === 'files'" class="border-b py-2 px-4">
<div
v-if="field.type === 'files'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
File uploads
</h3>
<v-checkbox v-model="field.multiple" class="mt-3" :name="field.id + '_multiple'">
<v-checkbox
v-model="field.multiple"
class="mt-3"
:name="field.id + '_multiple'"
>
Allow multiple files
</v-checkbox>
<v-checkbox v-model="field.camera_upload" class="mt-3"
:name="field.id+'_camera_upload'"
<v-checkbox
v-model="field.camera_upload"
class="mt-3"
:name="field.id+'_camera_upload'"
>
Allow Camera uploads
</v-checkbox>
<text-input name="allowed_file_types" class="mt-3" :form="field" label="Allowed file types"
placeholder="jpg,jpeg,png,gif" help="Comma separated values, leave blank to allow all file types" />
<text-input
name="allowed_file_types"
class="mt-3"
:form="field"
label="Allowed file types"
placeholder="jpg,jpeg,png,gif"
help="Comma separated values, leave blank to allow all file types"
/>
<text-input name="max_file_size" class="mt-3" :form="field" native-type="number" :min="1" :max="mbLimit"
label="Maximum file size (in MB)" :placeholder="`1MB - ${mbLimit}MB`"
help="Set the maximum file size that can be uploaded" />
<text-input
name="max_file_size"
class="mt-3"
:form="field"
native-type="number"
:min="1"
:max="mbLimit"
label="Maximum file size (in MB)"
:placeholder="`1MB - ${mbLimit}MB`"
help="Set the maximum file size that can be uploaded"
/>
</div>
<div v-if="field.type === 'rating'" class="border-b py-2 px-4">
<div
v-if="field.type === 'rating'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Rating
</h3>
<p class="text-gray-400 mb-3 text-xs">
Advanced options for rating.
</p>
<text-input name="rating_max_value" native-type="number" :min="1" class="mt-3" :form="field" required
label="Max rating value" />
<text-input
name="rating_max_value"
native-type="number"
:min="1"
class="mt-3"
:form="field"
required
label="Max rating value"
/>
</div>
<div v-if="field.type === 'scale'" class="border-b py-2 px-4">
<div
v-if="field.type === 'scale'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Scale
</h3>
<p class="text-gray-400 mb-3 text-xs">
Advanced options for scale.
</p>
<text-input name="scale_min_value" native-type="number" class="mt-4" :form="field" required
label="Min scale value" />
<text-input name="scale_max_value" native-type="number" :min="1" class="mt-4" :form="field" required
label="Max scale value" />
<text-input name="scale_step_value" native-type="number" :min="1" class="mt-4" :form="field" required
label="Scale steps value" />
<text-input
name="scale_min_value"
native-type="number"
class="mt-4"
:form="field"
required
label="Min scale value"
/>
<text-input
name="scale_max_value"
native-type="number"
:min="1"
class="mt-4"
:form="field"
required
label="Max scale value"
/>
<text-input
name="scale_step_value"
native-type="number"
:min="1"
class="mt-4"
:form="field"
required
label="Scale steps value"
/>
</div>
<div v-if="field.type === 'slider'" class="border-b py-2 px-4">
<div
v-if="field.type === 'slider'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Slider
</h3>
<p class="text-gray-400 mb-3 text-xs">
Advanced options for slider.
</p>
<text-input name="slider_min_value" native-type="number" class="mt-4" :form="field" required
label="Min slider value" />
<text-input name="slider_max_value" native-type="number" :min="1" class="mt-4" :form="field" required
label="Max slider value" />
<text-input name="slider_step_value" native-type="number" :min="1" class="mt-4" :form="field" required
label="Slider steps value" />
<text-input
name="slider_min_value"
native-type="number"
class="mt-4"
:form="field"
required
label="Min slider value"
/>
<text-input
name="slider_max_value"
native-type="number"
:min="1"
class="mt-4"
:form="field"
required
label="Max slider value"
/>
<text-input
name="slider_step_value"
native-type="number"
:min="1"
class="mt-4"
:form="field"
required
label="Slider steps value"
/>
</div>
<!-- Text Options -->
<div v-if="field.type === 'text' && displayBasedOnAdvanced" class="border-b py-2 px-4">
<div
v-if="field.type === 'text' && displayBasedOnAdvanced"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Text Options
</h3>
<p class="text-gray-400 mb-3 text-xs">
Keep it simple or make it a multi-lines input.
</p>
<v-checkbox v-model="field.multi_lines" class="mb-2" :name="field.id + '_multi_lines'"
@update:model-value="field.multi_lines = $event">
<v-checkbox
v-model="field.multi_lines"
class="mb-2"
:name="field.id + '_multi_lines'"
@update:model-value="field.multi_lines = $event"
>
Multi-lines input
</v-checkbox>
</div>
<!-- Date Options -->
<div v-if="field.type === 'date'" class="border-b py-2 px-4">
<div
v-if="field.type === 'date'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Date Options
</h3>
@@ -163,21 +275,39 @@
</div>
<!-- select/multiselect Options -->
<div v-if="['select', 'multi_select'].includes(field.type)" class="border-b py-2 px-4">
<div
v-if="['select', 'multi_select'].includes(field.type)"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Select Options
</h3>
<p class="text-gray-400 mb-3 text-xs">
Advanced options for your select/multiselect fields.
</p>
<text-area-input v-model="optionsText" :name="field.id + '_options_text'" class="mt-3"
label="Set selection options" help="Add one option per line" @update:model-value="onFieldOptionsChange" />
<v-checkbox v-model="field.allow_creation" name="allow_creation" help=""
@update:model-value="onFieldAllowCreationChange">
<text-area-input
v-model="optionsText"
:name="field.id + '_options_text'"
class="mt-3"
label="Set selection options"
help="Add one option per line"
@update:model-value="onFieldOptionsChange"
/>
<v-checkbox
v-model="field.allow_creation"
name="allow_creation"
help=""
@update:model-value="onFieldAllowCreationChange"
>
Allow respondent to create new options
</v-checkbox>
<v-checkbox v-model="field.without_dropdown" class="mt-3" name="without_dropdown" help=""
@update:model-value="onFieldWithoutDropdownChange">
<v-checkbox
v-model="field.without_dropdown"
class="mt-3"
name="without_dropdown"
help=""
@update:model-value="onFieldWithoutDropdownChange"
>
Always show all select options
</v-checkbox>
<p class="text-gray-400 mb-3 text-xs">
@@ -186,7 +316,10 @@
</div>
<!-- Customization - Placeholder, Prefill, Relabel, Field Help -->
<div v-if="displayBasedOnAdvanced" class="border-b py-2 px-4">
<div
v-if="displayBasedOnAdvanced"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg">
Customization
</h3>
@@ -195,110 +328,243 @@
Change your form field name, pre-fill a value, add hints, etc.
</p>
<text-input name="name" class="mt-3" :form="field" :required="true" label="Field Name" />
<text-input
name="name"
class="mt-3"
:form="field"
:required="true"
label="Field Name"
/>
<v-checkbox v-model="field.hide_field_name" class="mt-3" :name="field.id + '_hide_field_name'">
<v-checkbox
v-model="field.hide_field_name"
class="mt-3"
:name="field.id + '_hide_field_name'"
>
Hide field name
</v-checkbox>
<v-checkbox v-if="field.type === 'phone_number'" v-model="field.use_simple_text_input" class="mt-3"
:name="field.id + '_use_simple_text_input'">
<v-checkbox
v-if="field.type === 'phone_number'"
v-model="field.use_simple_text_input"
class="mt-3"
:name="field.id + '_use_simple_text_input'"
>
Use simple text input
</v-checkbox>
<template v-if="field.type === 'phone_number' && !field.use_simple_text_input">
<select-input v-model="field.unavailable_countries" class="mt-4" wrapper-class="relative"
:options="allCountries" :multiple="true" :searchable="true" :search-keys="['name']" :option-key="'code'"
:emit-key="'code'" label="Disabled countries" :placeholder="'Select a country'"
help="Remove countries from the phone input">
<template #selected="{ option, selected }">
<select-input
v-model="field.unavailable_countries"
class="mt-4"
wrapper-class="relative"
:options="allCountries"
:multiple="true"
:searchable="true"
:search-keys="['name']"
:option-key="'code'"
:emit-key="'code'"
label="Disabled countries"
:placeholder="'Select a country'"
help="Remove countries from the phone input"
>
<template #selected="{ option }">
<div class="flex items-center space-x-2 justify-center overflow-hidden">
{{ option.length }} selected
</div>
</template>
<template #option="{ option, selected }">
<div class="flex items-center space-x-2 hover:text-white">
<country-flag size="normal" class="!-mt-[9px]" :country="option.code" />
<country-flag
size="normal"
class="!-mt-[9px]"
:country="option.code"
/>
<span class="grow">{{ option.name }}</span>
<span>{{ option.dial_code }}</span>
</div>
<span v-if="selected" class="absolute inset-y-0 right-0 flex items-center pr-2 dark:text-white">
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd"
<span
v-if="selected"
class="absolute inset-y-0 right-0 flex items-center pr-2 dark:text-white"
>
<svg
class="h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
fill-rule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clip-rule="evenodd" />
clip-rule="evenodd"
/>
</svg>
</span>
</template>
</select-input>
<small class="flex -mt-2">
<a href="#" class="grow" @click.prevent="selectAllCountries">Select All</a>
<a href="#" @click.prevent="field.unavailable_countries = null">Un-select All</a>
<a
href="#"
class="grow"
@click.prevent="selectAllCountries"
>Select All</a>
<a
href="#"
@click.prevent="field.unavailable_countries = null"
>Un-select All</a>
</small>
</template>
<!-- Pre-fill depends on type -->
<v-checkbox v-if="field.type == 'checkbox'" v-model="field.prefill" class="mt-3" :name="field.id + '_prefill'"
@update:model-value="field.prefill = $event">
<v-checkbox
v-if="field.type == 'checkbox'"
v-model="field.prefill"
class="mt-3"
:name="field.id + '_prefill'"
@update:model-value="field.prefill = $event"
>
Pre-filled value
</v-checkbox>
<select-input v-else-if="['select', 'multi_select'].includes(field.type)" name="prefill" class="mt-3"
:form="field" :options="prefillSelectsOptions" label="Pre-filled value"
:multiple="field.type === 'multi_select'" />
<date-input v-else-if="field.type === 'date' && field.prefill_today !== true" name="prefill" class="mt-3"
:form="field" :with-time="field.with_time === true" :date-range="field.date_range === true"
label="Pre-filled value" />
<phone-input v-else-if="field.type === 'phone_number' && !field.use_simple_text_input" name="prefill" class="mt-3"
:form="field" :can-only-country="true" :unavailable-countries="field.unavailable_countries ?? []"
label="Pre-filled value" />
<text-area-input v-else-if="field.type === 'text' && field.multi_lines" name="prefill" class="mt-3" :form="field"
label="Pre-filled value" />
<file-input v-else-if="field.type === 'files'" name="prefill" class="mt-4" :form="field" label="Pre-filled file"
:multiple="field.multiple === true" :move-to-form-assets="true" />
<text-input v-else-if="!['files', 'signature'].includes(field.type)" name="prefill" class="mt-3" :form="field"
label="Pre-filled value" />
<div v-if="['select', 'multi_select'].includes(field.type)" class="-mt-3 mb-3 text-gray-400 dark:text-gray-500">
<select-input
v-else-if="['select', 'multi_select'].includes(field.type)"
name="prefill"
class="mt-3"
:form="field"
:options="prefillSelectsOptions"
label="Pre-filled value"
:multiple="field.type === 'multi_select'"
/>
<date-input
v-else-if="field.type === 'date' && field.prefill_today !== true"
name="prefill"
class="mt-3"
:form="field"
:with-time="field.with_time === true"
:date-range="field.date_range === true"
label="Pre-filled value"
/>
<phone-input
v-else-if="field.type === 'phone_number' && !field.use_simple_text_input"
name="prefill"
class="mt-3"
:form="field"
:can-only-country="true"
:unavailable-countries="field.unavailable_countries ?? []"
label="Pre-filled value"
/>
<text-area-input
v-else-if="field.type === 'text' && field.multi_lines"
name="prefill"
class="mt-3"
:form="field"
label="Pre-filled value"
/>
<file-input
v-else-if="field.type === 'files'"
name="prefill"
class="mt-4"
:form="field"
label="Pre-filled file"
:multiple="field.multiple === true"
:move-to-form-assets="true"
/>
<text-input
v-else-if="!['files', 'signature'].includes(field.type)"
name="prefill"
class="mt-3"
:form="field"
label="Pre-filled value"
/>
<div
v-if="['select', 'multi_select'].includes(field.type)"
class="-mt-3 mb-3 text-gray-400 dark:text-gray-500"
>
<small>
A problem? <a href="#" @click.prevent="field.prefill = null">Click here to clear your pre-fill</a>
A problem? <a
href="#"
@click.prevent="field.prefill = null"
>Click here to clear your pre-fill</a>
</small>
</div>
<!-- Placeholder -->
<text-input v-if="hasPlaceholder" name="placeholder" class="mt-3" :form="field"
label="Empty Input Text (Placeholder)" />
<text-input
v-if="hasPlaceholder"
name="placeholder"
class="mt-3"
:form="field"
label="Empty Input Text (Placeholder)"
/>
<select-input name="width" class="mt-3" :options="[
{ name: 'Full', value: 'full' },
{ name: '1/2 (half width)', value: '1/2' },
{ name: '1/3 (a third of the width)', value: '1/3' },
{ name: '2/3 (two thirds of the width)', value: '2/3' },
{ name: '1/4 (a quarter of the width)', value: '1/4' },
{ name: '3/4 (three quarters of the width)', value: '3/4' },
]" :form="field" label="Field Width" />
<select-input
name="width"
class="mt-3"
:options="[
{ name: 'Full', value: 'full' },
{ name: '1/2 (half width)', value: '1/2' },
{ name: '1/3 (a third of the width)', value: '1/3' },
{ name: '2/3 (two thirds of the width)', value: '2/3' },
{ name: '1/4 (a quarter of the width)', value: '1/4' },
{ name: '3/4 (three quarters of the width)', value: '3/4' },
]"
:form="field"
label="Field Width"
/>
<!-- Help -->
<rich-text-area-input name="help" class="mt-3" :form="field" :editor-toolbar="editorToolbarCustom"
label="Field Help" help="Your field help will be shown below/above the field, just like this text."
:help-position="field.help_position" />
<select-input name="help_position" class="mt-3" :options="[
{ name: 'Below input', value: 'below_input' },
{ name: 'Above input', value: 'above_input' },
]" :form="field" label="Field Help Position" @update:model-value="onFieldHelpPositionChange" />
<rich-text-area-input
name="help"
class="mt-3"
:form="field"
:editor-toolbar="editorToolbarCustom"
label="Field Help"
help="Your field help will be shown below/above the field, just like this text."
:help-position="field.help_position"
/>
<select-input
name="help_position"
class="mt-3"
:options="[
{ name: 'Below input', value: 'below_input' },
{ name: 'Above input', value: 'above_input' },
]"
:form="field"
label="Field Help Position"
@update:model-value="onFieldHelpPositionChange"
/>
<template v-if="['text', 'number', 'url', 'email'].includes(field.type)">
<text-input name="max_char_limit" native-type="number" :min="1" :max="2000" :form="field"
label="Max character limit" help="Maximum character limit of 2000" :required="false" />
<checkbox-input name="show_char_limit" :form="field" class="mt-3" label="Always show character limit" />
<text-input
name="max_char_limit"
native-type="number"
:min="1"
:max="2000"
:form="field"
label="Max character limit"
help="Maximum character limit of 2000"
:required="false"
/>
<checkbox-input
name="show_char_limit"
:form="field"
class="mt-3"
label="Always show character limit"
/>
</template>
</div>
<!-- Advanced Options -->
<div v-if="field.type === 'text'" class="border-b py-2 px-4">
<div
v-if="field.type === 'text'"
class="border-b py-2 px-4"
>
<h3 class="font-semibold block text-lg mb-3">
Advanced Options
</h3>
<v-checkbox v-model="field.generates_uuid" :name="field.id + '_generates_uuid'"
@update:model-value="onFieldGenUIdChange">
<v-checkbox
v-model="field.generates_uuid"
:name="field.id + '_generates_uuid'"
@update:model-value="onFieldGenUIdChange"
>
Generates a unique id
</v-checkbox>
<p class="text-gray-400 mb-3 text-xs">
@@ -306,8 +572,11 @@
submission
</p>
<v-checkbox v-model="field.generates_auto_increment_id" :name="field.id + '_generates_auto_increment_id'"
@update:model-value="onFieldGenAutoIdChange">
<v-checkbox
v-model="field.generates_auto_increment_id"
:name="field.id + '_generates_auto_increment_id'"
@update:model-value="onFieldGenAutoIdChange"
>
Generates an auto-incremented id
</v-checkbox>
<p class="text-gray-400 mb-3 text-xs">
@@ -316,7 +585,11 @@
</div>
<!-- Logic Block -->
<form-block-logic-editor class="py-2 px-4 border-b" :form="form" :field="field" />
<form-block-logic-editor
class="py-2 px-4 border-b"
:form="form"
:field="field"
/>
</div>
</template>

View File

@@ -1,21 +1,37 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<text-input :form="integrationData" name="settings.discord_webhook_url"
label="Discord webhook url" help="help" required>
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<text-input
:form="integrationData"
name="settings.discord_webhook_url"
label="Discord webhook url"
help="help"
required
>
<template #help>
<InputHelp>
<template #help>
<span>
Receive a discord message on each form submission.
<a href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks" target="_blank"> Click
here </a> to learn how to get a discord webhook url.
Receive a discord message on each form submission.
<a
href="https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks"
target="_blank"
>
Click here
</a>
to learn how to get a discord webhook url.
</span>
</template>
</InputHelp>
</template>
</text-input>
<h4 class="font-bold mt-4">Discord message options</h4>
<notifications-message-actions v-model="integrationData.settings"/>
<h4 class="font-bold mt-4">
Discord message options
</h4>
<notifications-message-actions v-model="integrationData.settings" />
</IntegrationWrapper>
</template>
@@ -24,9 +40,9 @@ import IntegrationWrapper from "./components/IntegrationWrapper.vue"
import NotificationsMessageActions from "./components/NotificationsMessageActions.vue"
const props = defineProps({
integration: {type: Object, required: true},
form: {type: Object, required: true},
integrationData: {type: Object, required: true},
formIntegrationId: {type: Number, required: false, default: null}
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null },
})
</script>

View File

@@ -1,25 +1,38 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<text-area-input :form="integrationData" name="settings.notification_emails" required
label="Notification Emails" help="Add one email per line" />
<text-input :form="integrationData" name="settings.notification_reply_to"
label="Notification Reply To" :help="notifiesHelp" />
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<text-area-input
:form="integrationData"
name="settings.notification_emails"
required
label="Notification Emails"
help="Add one email per line"
/>
<text-input
:form="integrationData"
name="settings.notification_reply_to"
label="Notification Reply To"
:help="notifiesHelp"
/>
</IntegrationWrapper>
</template>
<script setup>
import IntegrationWrapper from './components/IntegrationWrapper.vue'
import IntegrationWrapper from "./components/IntegrationWrapper.vue"
const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null }
formIntegrationId: { type: Number, required: false, default: null },
})
const replayToEmailField = computed(() => {
const emailFields = props.form.properties.filter((field) => {
return field.type === 'email' && !field.hidden
return field.type === "email" && !field.hidden
})
if (emailFields.length === 1) return emailFields[0]
return null
@@ -27,8 +40,12 @@ const replayToEmailField = computed(() => {
const notifiesHelp = computed(() => {
if (replayToEmailField.value) {
return 'If empty, Reply-to for this notification will be the email filled in the field "' + replayToEmailField.value.name + '".'
return (
'If empty, Reply-to for this notification will be the email filled in the field "' +
replayToEmailField.value.name +
'".'
)
}
return 'If empty, Reply-to for this notification will be your own email. Add a single email field to your form, and it will automatically become the reply to value.'
return "If empty, Reply-to for this notification will be your own email. Add a single email field to your form, and it will automatically become the reply to value."
})
</script>

View File

@@ -1,5 +1,9 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<div class="my-5">
Coming Soon...
</div>
@@ -7,12 +11,12 @@
</template>
<script setup>
import IntegrationWrapper from './components/IntegrationWrapper.vue'
import IntegrationWrapper from "./components/IntegrationWrapper.vue"
const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null }
formIntegrationId: { type: Number, required: false, default: null },
})
</script>

View File

@@ -1,20 +1,37 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<text-input :form="integrationData" name="settings.slack_webhook_url"
label="Slack webhook url" help="help" required>
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<text-input
:form="integrationData"
name="settings.slack_webhook_url"
label="Slack webhook url"
help="help"
required
>
<template #help>
<InputHelp>
<template #help>
<span>
Receive slack message on each form submission. <a href="https://api.slack.com/messaging/webhooks" target="_blank"> Click here </a>
to learn how to get a slack webhook url
</span>
Receive slack message on each form submission.
<a
href="https://api.slack.com/messaging/webhooks"
target="_blank"
>
Click here
</a>
to learn how to get a slack webhook url
</span>
</template>
</InputHelp>
</template>
</text-input>
<h4 class="font-bold mt-4">Slack message actions</h4>
<notifications-message-actions v-model="integrationData.settings"/>
<h4 class="font-bold mt-4">
Slack message actions
</h4>
<notifications-message-actions v-model="integrationData.settings" />
</IntegrationWrapper>
</template>
@@ -23,9 +40,9 @@ import IntegrationWrapper from "./components/IntegrationWrapper.vue"
import NotificationsMessageActions from "./components/NotificationsMessageActions.vue"
const props = defineProps({
integration: {type: Object, required: true},
form: {type: Object, required: true},
integrationData: {type: Object, required: true},
formIntegrationId: {type: Number, required: false, default: null}
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null },
})
</script>

View File

@@ -1,19 +1,50 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<div>{{ emailSubmissionConfirmationHelp }}</div>
<div v-if="emailSubmissionConfirmationField">
<text-input :form="integrationData" name="settings.notification_sender" class="mt-4" required
<text-input
:form="integrationData"
name="settings.notification_sender"
class="mt-4"
required
label="Confirmation Email Sender Name"
help="Emails will be sent from our email address but you can customize the name of the Sender" />
<text-input :form="integrationData" name="settings.notification_subject" class="mt-4" required
label="Confirmation email subject" help="Subject of the confirmation email that will be sent" />
<rich-text-area-input :form="integrationData" name="settings.notification_body" class="mt-4" required
label="Confirmation email content" help="Content of the confirmation email that will be sent" />
<text-input :form="integrationData" name="settings.confirmation_reply_to" class="mt-4"
label="Confirmation Reply To" help="If empty, Reply-to will be your own email."/>
<toggle-switch-input :form="integrationData" name="settings.notifications_include_submission" class="mt-4"
label="Include submission data" help="If enabled the confirmation email will contain form submission answers" />
help="Emails will be sent from our email address but you can customize the name of the Sender"
/>
<text-input
:form="integrationData"
name="settings.notification_subject"
class="mt-4"
required
label="Confirmation email subject"
help="Subject of the confirmation email that will be sent"
/>
<rich-text-area-input
:form="integrationData"
name="settings.notification_body"
class="mt-4"
required
label="Confirmation email content"
help="Content of the confirmation email that will be sent"
/>
<text-input
:form="integrationData"
name="settings.confirmation_reply_to"
class="mt-4"
label="Confirmation Reply To"
help="If empty, Reply-to will be your own email."
/>
<toggle-switch-input
:form="integrationData"
name="settings.notifications_include_submission"
class="mt-4"
label="Include submission data"
help="If enabled the confirmation email will contain form submission answers"
/>
</div>
</IntegrationWrapper>
</template>
@@ -25,30 +56,36 @@ const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null }
formIntegrationId: { type: Number, required: false, default: null },
})
const emailSubmissionConfirmationField = computed(() => {
if (!props.form.properties || !Array.isArray(props.form.properties)) return null
if (!props.form.properties || !Array.isArray(props.form.properties))
return null
const emailFields = props.form.properties.filter((field) => {
return field.type === 'email' && !field.hidden
return field.type === "email" && !field.hidden
})
if (emailFields.length === 1) return emailFields[0]
return null
})
const emailSubmissionConfirmationHelp = computed(() => {
if (emailSubmissionConfirmationField.value) {
return 'Confirmation will be sent to the email in the "' + emailSubmissionConfirmationField.value.name + '" field.'
return (
'Confirmation will be sent to the email in the "' +
emailSubmissionConfirmationField.value.name +
'" field.'
)
}
return 'Only available if your form contains 1 email field.'
return "Only available if your form contains 1 email field."
})
onBeforeMount(() => {
for (const [keyname, defaultValue] of Object.entries({
'notification_sender': 'OpnForm',
'notification_subject': 'We saved your answers',
'notification_body': 'Hello there 👋 <br>This is a confirmation that your submission was successfully saved.',
'notifications_include_submission': true,
notification_sender: "OpnForm",
notification_subject: "We saved your answers",
notification_body:
"Hello there 👋 <br>This is a confirmation that your submission was successfully saved.",
notifications_include_submission: true,
})) {
if (props.integrationData.settings[keyname] === undefined) {
props.integrationData.settings[keyname] = defaultValue

View File

@@ -1,7 +1,17 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<text-input :form="integrationData" name="settings.webhook_url" class="mt-4" label="Webhook url"
help="We will post form submissions to this endpoint" required />
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<text-input
:form="integrationData"
name="settings.webhook_url"
class="mt-4"
label="Webhook url"
help="We will post form submissions to this endpoint"
required
/>
</IntegrationWrapper>
</template>
@@ -12,6 +22,6 @@ const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null }
formIntegrationId: { type: Number, required: false, default: null },
})
</script>

View File

@@ -1,5 +1,9 @@
<template>
<IntegrationWrapper :integration="props.integration" :form="form" v-model="props.integrationData">
<IntegrationWrapper
v-model="props.integrationData"
:integration="props.integration"
:form="form"
>
<div class="my-5">
Coming Soon...
</div>
@@ -7,12 +11,12 @@
</template>
<script setup>
import IntegrationWrapper from './components/IntegrationWrapper.vue'
import IntegrationWrapper from "./components/IntegrationWrapper.vue"
const props = defineProps({
integration: { type: Object, required: true },
form: { type: Object, required: true },
integrationData: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null }
formIntegrationId: { type: Number, required: false, default: null },
})
</script>

View File

@@ -1,106 +1,194 @@
<template>
<div class="text-gray-500 border shadow rounded-md p-5 mt-4 relative flex items-center">
<div
class="text-gray-500 border shadow rounded-md p-5 mt-4 relative flex items-center"
>
<div class="flex-grow flex items-center">
<div class="mr-4"
:class="{ 'text-blue-500': integration.status === 'active', 'text-gray-400': integration.status !== 'active' }">
<Icon :name="integrationTypeInfo.icon" size="32px"/>
<div
class="mr-4"
:class="{
'text-blue-500': integration.status === 'active',
'text-gray-400': integration.status !== 'active',
}"
>
<Icon
:name="integrationTypeInfo.icon"
size="32px"
/>
</div>
<div>
<div class="flex space-x-3 font-semibold mr-2">{{ integrationTypeInfo.name }}</div>
<Badge :color="integration.status === 'active' ? 'green' : 'gray'"
:before-icon="integration.status === 'active' ? 'solar:play-bold' : 'solar:pause-bold'"
<div class="flex space-x-3 font-semibold mr-2">
{{ integrationTypeInfo.name }}
</div>
<Badge
:color="integration.status === 'active' ? 'green' : 'gray'"
:before-icon="
integration.status === 'active'
? 'solar:play-bold'
: 'solar:pause-bold'
"
>
{{ integration.status === 'active' ? 'Active' : 'Paused' }}
{{ integration.status === "active" ? "Active" : "Paused" }}
</Badge>
</div>
</div>
<div v-if="loadingDelete" class="pr-4 pt-2">
<Loader class="h-6 w-6 mx-auto"/>
<div
v-if="loadingDelete"
class="pr-4 pt-2"
>
<Loader class="h-6 w-6 mx-auto" />
</div>
<dropdown v-else class="inline">
<dropdown
v-else
class="inline"
>
<template #trigger="{ toggle }">
<v-button color="white" @click="toggle">
<svg class="w-4 h-4 inline -mt-1" viewBox="0 0 16 4" fill="none" xmlns="http://www.w3.org/2000/svg">
<v-button
color="white"
@click="toggle"
>
<svg
class="w-4 h-4 inline -mt-1"
viewBox="0 0 16 4"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8.00016 2.83366C8.4604 2.83366 8.8335 2.46056 8.8335 2.00033C8.8335 1.54009 8.4604 1.16699 8.00016 1.16699C7.53993 1.16699 7.16683 1.54009 7.16683 2.00033C7.16683 2.46056 7.53993 2.83366 8.00016 2.83366Z"
stroke="#344054" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
stroke="#344054"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M13.8335 2.83366C14.2937 2.83366 14.6668 2.46056 14.6668 2.00033C14.6668 1.54009 14.2937 1.16699 13.8335 1.16699C13.3733 1.16699 13.0002 1.54009 13.0002 2.00033C13.0002 2.46056 13.3733 2.83366 13.8335 2.83366Z"
stroke="#344054" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
stroke="#344054"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M2.16683 2.83366C2.62707 2.83366 3.00016 2.46056 3.00016 2.00033C3.00016 1.54009 2.62707 1.16699 2.16683 1.16699C1.70659 1.16699 1.3335 1.54009 1.3335 2.00033C1.3335 2.46056 1.70659 2.83366 2.16683 2.83366Z"
stroke="#344054" stroke-width="1.66667" stroke-linecap="round" stroke-linejoin="round"/>
stroke="#344054"
stroke-width="1.66667"
stroke-linecap="round"
stroke-linejoin="round"
/>
</svg>
</v-button>
</template>
<a v-track.edit_form_integration_click="{ form_slug: form.slug, form_integration_id: integration.id }" href="#"
@click.prevent="showIntegrationModal = true"
class="flex px-4 py-2 text-md text-gray-700 hover:bg-gray-100 hover:no-underline hover:text-gray-900 items-center">
<Icon name="heroicons:pencil" class="w-5 h-5 mr-2"/>
<a
v-track.edit_form_integration_click="{
form_slug: form.slug,
form_integration_id: integration.id,
}"
href="#"
class="flex px-4 py-2 text-md text-gray-700 hover:bg-gray-100 hover:no-underline hover:text-gray-900 items-center"
@click.prevent="showIntegrationModal = true"
>
<Icon
name="heroicons:pencil"
class="w-5 h-5 mr-2"
/>
Edit
</a>
<a v-track.past_events_form_integration_click="{ form_slug: form.slug, form_integration_id: integration.id }"
href="#"
@click.prevent="showIntegrationEventsModal = true"
class="flex px-4 py-2 text-md text-gray-700 hover:bg-gray-100 hover:no-underline hover:text-gray-900 items-center">
<Icon name="heroicons:clock" class="w-5 h-5 mr-2"/>
<a
v-track.past_events_form_integration_click="{
form_slug: form.slug,
form_integration_id: integration.id,
}"
href="#"
class="flex px-4 py-2 text-md text-gray-700 hover:bg-gray-100 hover:no-underline hover:text-gray-900 items-center"
@click.prevent="showIntegrationEventsModal = true"
>
<Icon
name="heroicons:clock"
class="w-5 h-5 mr-2"
/>
Past Events
</a>
<a v-track.delete_form_integration_click="{ form_integration_id: integration.id }" href="#"
class="flex px-4 py-2 text-md text-red-600 hover:bg-red-50 hover:no-underline items-center"
@click.prevent="deleteFormIntegration(integration.id)">
<Icon name="heroicons:trash" class="w-5 h-5 mr-2"/>
<a
v-track.delete_form_integration_click="{
form_integration_id: integration.id,
}"
href="#"
class="flex px-4 py-2 text-md text-red-600 hover:bg-red-50 hover:no-underline items-center"
@click.prevent="deleteFormIntegration(integration.id)"
>
<Icon
name="heroicons:trash"
class="w-5 h-5 mr-2"
/>
Delete Integration
</a>
</dropdown>
<IntegrationModal v-if="form && integration && integrationTypeInfo" :form="form" :integration="integrationTypeInfo"
:integrationKey="integration.integration_id" :formIntegrationId="integration.id"
:show="showIntegrationModal"
@close="showIntegrationModal = false"/>
<IntegrationModal
v-if="form && integration && integrationTypeInfo"
:form="form"
:integration="integrationTypeInfo"
:integration-key="integration.integration_id"
:form-integration-id="integration.id"
:show="showIntegrationModal"
@close="showIntegrationModal = false"
/>
<IntegrationEventsModal v-if="form && integration" :form="form" :formIntegrationId="integration.id"
:show="showIntegrationEventsModal"
@close="showIntegrationEventsModal = false"/>
<IntegrationEventsModal
v-if="form && integration"
:form="form"
:form-integration-id="integration.id"
:show="showIntegrationEventsModal"
@close="showIntegrationEventsModal = false"
/>
</div>
</template>
<script setup>
import {computed} from "vue";
import { computed } from "vue"
const props = defineProps({
integration: {
type: Object,
required: true
required: true,
},
form: {
type: Object,
required: true
}
required: true,
},
})
const alert = useAlert()
const formIntegrationsStore = useFormIntegrationsStore()
const integrations = computed(() => formIntegrationsStore.availableIntegrations)
const integrationTypeInfo = computed(() => integrations.value.get(props.integration.integration_id))
const integrations = computed(
() => formIntegrationsStore.availableIntegrations,
)
const integrationTypeInfo = computed(() =>
integrations.value.get(props.integration.integration_id),
)
let showIntegrationModal = ref(false)
let showIntegrationEventsModal = ref(false)
let loadingDelete = ref(false)
const showIntegrationModal = ref(false)
const showIntegrationEventsModal = ref(false)
const loadingDelete = ref(false)
const deleteFormIntegration = (integrationid) => {
alert.confirm('Do you really want to delete this form integration?', () => {
opnFetch('/open/forms/{formid}/integration/{integrationid}'.replace('{formid}', props.form.id).replace('{integrationid}', integrationid), {method: 'DELETE'}).then((data) => {
if (data.type === 'success') {
alert.success(data.message)
formIntegrationsStore.remove(integrationid)
} else {
alert.error('Something went wrong!')
}
}).catch((error) => {
alert.error(error.data.message)
})
alert.confirm("Do you really want to delete this form integration?", () => {
opnFetch(
"/open/forms/{formid}/integration/{integrationid}"
.replace("{formid}", props.form.id)
.replace("{integrationid}", integrationid),
{ method: "DELETE" },
)
.then((data) => {
if (data.type === "success") {
alert.success(data.message)
formIntegrationsStore.remove(integrationid)
} else {
alert.error("Something went wrong!")
}
})
.catch((error) => {
alert.error(error.data.message)
})
})
}
</script>

View File

@@ -1,27 +1,48 @@
<template>
<modal :show="show" @close="emit('close')" compact-header inner-padding="">
<modal
:show="show"
compact-header
inner-padding=""
@close="emit('close')"
>
<template #icon>
<Icon name="heroicons:clock" size="40px"/>
<Icon
name="heroicons:clock"
size="40px"
/>
</template>
<template #title>
Past Events
</template>
<UTable :loading="integrationEventsLoading" :columns="columns" :rows="integrationEvents">
<UTable
:loading="integrationEventsLoading"
:columns="columns"
:rows="integrationEvents"
>
<template #status-data="{ row }">
<Badge :color="(row.status==='Success') ? 'green' : 'red'">
{{row.status}}
<Badge :color="row.status === 'Success' ? 'green' : 'red'">
{{ row.status }}
</Badge>
</template>
<template #data-data="{ row }">
<vue-json-pretty v-if="row.data && Object.keys(row.data).length > 0" :data="row.data" :collapsedNodeLength="0" :showLength="true" :showIcon="true" />
<vue-json-pretty
v-if="row.data && Object.keys(row.data).length > 0"
:data="row.data"
:collapsed-node-length="0"
:show-length="true"
:show-icon="true"
/>
<span v-else>-</span>
</template>
</UTable>
<template #footer>
<div class="flex justify-center gap-x-2">
<v-button color="white" @click.prevent="emit('close')">
<v-button
color="white"
@click.prevent="emit('close')"
>
Close
</v-button>
</div>
@@ -30,35 +51,43 @@
</template>
<script setup>
import VueJsonPretty from 'vue-json-pretty'
import 'vue-json-pretty/lib/styles.css'
import VueJsonPretty from "vue-json-pretty"
import "vue-json-pretty/lib/styles.css"
const props = defineProps({
show: { type: Boolean, required: true },
form: {type: Object, required: true},
formIntegrationId: {type: Number, required: true}
form: { type: Object, required: true },
formIntegrationId: { type: Number, required: true },
})
const emit = defineEmits(['close'])
const formIntegrationEventEndpoint = '/open/forms/{formid}/integration/{integrationid}/events'
const emit = defineEmits(["close"])
const formIntegrationEventEndpoint =
"/open/forms/{formid}/integration/{integrationid}/events"
const columns = [
{ key: 'date', label: 'Date', sortable: true },
{ key: 'status', label: 'Status', sortable: true },
{ key: 'data', label: 'Info'}
{ key: "date", label: "Date", sortable: true },
{ key: "status", label: "Status", sortable: true },
{ key: "data", label: "Info" },
]
let integrationEvents = ref([])
let integrationEventsLoading = ref(false)
const integrationEvents = ref([])
const integrationEventsLoading = ref(false)
watch(() => props.show, () => {
fetchEvents()
})
watch(
() => props.show,
() => {
fetchEvents()
},
)
const fetchEvents = () => {
if (props.show) {
nextTick(() => {
integrationEventsLoading.value = true
integrationEvents.value = []
opnFetch(formIntegrationEventEndpoint.replace('{formid}', props.form.id).replace('{integrationid}', props.formIntegrationId)).then((data) => {
opnFetch(
formIntegrationEventEndpoint
.replace("{formid}", props.form.id)
.replace("{integrationid}", props.formIntegrationId),
).then((data) => {
integrationEvents.value = data
integrationEventsLoading.value = false
})

View File

@@ -1,49 +1,72 @@
<template>
<UTooltip :text="tooltipText" :prevent="!unavailable">
<div role="button" @click="onClick"
v-track.new_integration_click="{ name: integration.id }"
:class="{'hover:bg-blue-50 group cursor-pointer': !unavailable, 'cursor-not-allowed': unavailable}"
class="bg-gray-50 border border-gray-200 rounded-md transition-colors p-4 pb-2 items-center justify-center w-[170px] h-[110px] flex flex-col relative">
<UTooltip
:text="tooltipText"
:prevent="!unavailable"
>
<div
v-track.new_integration_click="{ name: integration.id }"
role="button"
:class="{
'hover:bg-blue-50 group cursor-pointer': !unavailable,
'cursor-not-allowed': unavailable,
}"
class="bg-gray-50 border border-gray-200 rounded-md transition-colors p-4 pb-2 items-center justify-center w-[170px] h-[110px] flex flex-col relative"
@click="onClick"
>
<div class="flex justify-center">
<div class="h-10 w-10 text-gray-500 group-hover:text-blue-500 transition-colors flex items-center">
<Icon :name="integration.icon" size="40px"/>
<div
class="h-10 w-10 text-gray-500 group-hover:text-blue-500 transition-colors flex items-center"
>
<Icon
:name="integration.icon"
size="40px"
/>
</div>
</div>
<div class="flex-grow flex items-center">
<div class="text-gray-400 font-medium text-sm text-center">
{{ integration.name }}<span class="text-xs" v-if="integration.coming_soon"> (coming soon)</span>
{{ integration.name
}}<span
v-if="integration.coming_soon"
class="text-xs"
>
(coming soon)</span>
</div>
</div>
<pro-tag v-if="integration?.is_pro === true" class="absolute top-0 right-1"/>
<pro-tag
v-if="integration?.is_pro === true"
class="absolute top-0 right-1"
/>
</div>
</UTooltip>
</template>
<script setup>
const emit = defineEmits(['select'])
const emit = defineEmits(["select"])
const props = defineProps({
integration: {
type: Object,
required: true
}
required: true,
},
})
const unavailable = computed(() => {
return props.integration.coming_soon || props.integration.requires_subscription
return (
props.integration.coming_soon || props.integration.requires_subscription
)
})
const tooltipText = computed(() => {
if (props.integration.coming_soon) return 'This integration is coming soon'
if (props.integration.requires_subscription) return 'You need a subscription to use this integration.'
return ''
if (props.integration.coming_soon) return "This integration is coming soon"
if (props.integration.requires_subscription)
return "You need a subscription to use this integration."
return ""
})
const onClick = () => {
if (props.integration.coming_soon || props.integration.requires_subscription) return
emit('select', props.integration.id)
if (props.integration.coming_soon || props.integration.requires_subscription)
return
emit("select", props.integration.id)
}
</script>

View File

@@ -1,22 +1,40 @@
<template>
<modal :show="show" @close="emit('close')" compact-header>
<modal
:show="show"
compact-header
@close="emit('close')"
>
<template #icon>
<Icon :name="integration?.icon" size="40px"/>
<Icon
:name="integration?.icon"
size="40px"
/>
</template>
<template #title>
{{ integration?.name }}
<pro-tag v-if="integration?.is_pro === true"/>
<pro-tag v-if="integration?.is_pro === true" />
</template>
<component v-if="integration && component" :is="component" :form="form" :integration="integration"
:integrationData="integrationData"/>
<component
:is="component"
v-if="integration && component"
:form="form"
:integration="integration"
:integration-data="integrationData"
/>
<template #footer>
<div class="flex justify-center gap-x-2">
<v-button class="px-8" @click.prevent="save">
<v-button
class="px-8"
@click.prevent="save"
>
Save
</v-button>
<v-button color="white" @click.prevent="emit('close')">
<v-button
color="white"
@click.prevent="emit('close')"
>
Close
</v-button>
</div>
@@ -25,21 +43,25 @@
</template>
<script setup>
import {computed} from 'vue'
import { computed } from "vue"
const props = defineProps({
show: {type: Boolean, required: true},
form: {type: Object, required: true},
integrationKey: {type: String, required: true},
integration: {type: Object, required: true},
formIntegrationId: {type: Number, required: false, default: null}
show: { type: Boolean, required: true },
form: { type: Object, required: true },
integrationKey: { type: String, required: true },
integration: { type: Object, required: true },
formIntegrationId: { type: Number, required: false, default: null },
})
const alert = useAlert()
const emit = defineEmits(['close'])
const emit = defineEmits(["close"])
const formIntegrationsStore = useFormIntegrationsStore()
const formIntegration = computed(() => (props.formIntegrationId) ? formIntegrationsStore.getByKey(props.formIntegrationId) : null)
const formIntegration = computed(() =>
props.formIntegrationId
? formIntegrationsStore.getByKey(props.formIntegrationId)
: null,
)
const component = computed(() => {
if (!props.integration) return null
@@ -48,35 +70,51 @@ const component = computed(() => {
const integrationData = ref(null)
watch(() => props.integrationKey, () => {
initIntegrationData()
})
watch(
() => props.integrationKey,
() => {
initIntegrationData()
},
)
const initIntegrationData = () => {
integrationData.value = useForm({
integration_id: (props.formIntegrationId) ? formIntegration.value.integration_id : props.integrationKey,
status: (props.formIntegrationId) ? formIntegration.value.status === 'active' : true,
settings: (props.formIntegrationId) ? formIntegration.value.data ?? {} : {},
logic: (props.formIntegrationId) ? (!Array.isArray(formIntegration.value.logic) && formIntegration.value.logic) ? formIntegration.value.logic : null : null
integration_id: props.formIntegrationId
? formIntegration.value.integration_id
: props.integrationKey,
status: props.formIntegrationId
? formIntegration.value.status === "active"
: true,
settings: props.formIntegrationId ? formIntegration.value.data ?? {} : {},
logic: props.formIntegrationId
? !Array.isArray(formIntegration.value.logic) &&
formIntegration.value.logic
? formIntegration.value.logic
: null
: null,
})
}
initIntegrationData()
const save = () => {
if (!integrationData.value) return
integrationData.value.submit(
(props.formIntegrationId) ? 'PUT' : 'POST',
'/open/forms/{formid}/integration'.replace('{formid}', props.form.id) + ((props.formIntegrationId) ? '/' + props.formIntegrationId : '')
).then(data => {
alert.success(data.message)
formIntegrationsStore.save(data.form_integration)
emit('close')
}).catch((error) => {
try {
alert.error(error.data.message)
} catch (e) {
alert.error('An error occurred while saving the integration')
}
})
integrationData.value
.submit(
props.formIntegrationId ? "PUT" : "POST",
"/open/forms/{formid}/integration".replace("{formid}", props.form.id) +
(props.formIntegrationId ? "/" + props.formIntegrationId : ""),
)
.then((data) => {
alert.success(data.message)
formIntegrationsStore.save(data.form_integration)
emit("close")
})
.catch((error) => {
try {
alert.error(error.data.message)
} catch (e) {
alert.error("An error occurred while saving the integration")
}
})
}
</script>

View File

@@ -1,28 +1,53 @@
<template>
<div :class="wrapperClass" :style="inputStyle">
<div
:class="wrapperClass"
:style="inputStyle"
>
<div class="flex justify-between">
<slot name="status">
<toggle-switch-input name="status" v-model="modelValue.status" label="Enabled"/>
<toggle-switch-input
v-model="modelValue.status"
name="status"
label="Enabled"
/>
</slot>
<slot name="help">
<v-button class="flex" color="white" size="small" @click="openHelp">
<Icon name="heroicons:question-mark-circle-16-solid" class="w-4 h-4 text-gray-500 -mt-[3px]"/>
<span class="text-gray-500">
Help
</span>
<v-button
class="flex"
color="white"
size="small"
@click="openHelp"
>
<Icon
name="heroicons:question-mark-circle-16-solid"
class="w-4 h-4 text-gray-500 -mt-[3px]"
/>
<span class="text-gray-500"> Help </span>
</v-button>
</slot>
</div>
<slot/>
<slot />
<slot name="logic">
<div class="-mx-6 px-6 border-t pt-6">
<collapse class="w-full" v-model="showLogic">
<collapse
v-model="showLogic"
class="w-full"
>
<template #title>
<div class="flex gap-x-3 items-start pr-8">
<div class="transition-colors" :class="{ 'text-blue-600': showLogic, 'text-gray-300': !showLogic }">
<Icon name="material-symbols:settings" size="30px"/>
<div
class="transition-colors"
:class="{
'text-blue-600': showLogic,
'text-gray-300': !showLogic,
}"
>
<Icon
name="material-symbols:settings"
size="30px"
/>
</div>
<div class="flex-grow">
<h3 class="font-semibold">
@@ -34,8 +59,12 @@
</div>
</div>
</template>
<condition-editor ref="filter-editor" v-model="modelValue.logic" class="mt-4 border-t border rounded-md integration-logic"
:form="form"/>
<condition-editor
ref="filter-editor"
v-model="modelValue.logic"
class="mt-4 border-t border rounded-md integration-logic"
:form="form"
/>
</collapse>
</div>
</slot>
@@ -43,18 +72,18 @@
</template>
<script setup>
import ConditionEditor from '~/components/open/forms/components/form-logic-components/ConditionEditor.client.vue'
import ConditionEditor from "~/components/open/forms/components/form-logic-components/ConditionEditor.client.vue"
const props = defineProps({
integration: {type: Object, required: true},
modelValue: {required: false},
wrapperClass: {type: String, required: false},
inputStyle: {type: Object, required: false},
form: {type: Object, required: false}
integration: { type: Object, required: true },
modelValue: { type: Object, required: false },
wrapperClass: { type: String, required: false },
inputStyle: { type: Object, required: false },
form: { type: Object, required: false },
})
const crisp = useCrisp()
const emit = defineEmits(['close'])
defineEmits(["close"])
const showLogic = ref(!!props.modelValue.logic)
const openHelp = () => {

View File

@@ -1,68 +1,91 @@
<template>
<div>
<toggle-switch-input name="include_submission_data" v-model="compVal.include_submission_data" class="mt-4"
label="Include submission data"
help="With form submission answers"
<toggle-switch-input
v-model="compVal.include_submission_data"
name="include_submission_data"
class="mt-4"
label="Include submission data"
help="With form submission answers"
/>
<toggle-switch-input name="link_open_form" v-model="compVal.link_open_form" class="mt-4"
label="'Open Form' Link"
help="Link to the form public page"
<toggle-switch-input
v-model="compVal.link_open_form"
name="link_open_form"
class="mt-4"
label="'Open Form' Link"
help="Link to the form public page"
/>
<toggle-switch-input name="link_edit_form" v-model="compVal.link_edit_form" class="mt-4"
label="'Edit Form' Link"
help="Link to the form admin page"
<toggle-switch-input
v-model="compVal.link_edit_form"
name="link_edit_form"
class="mt-4"
label="'Edit Form' Link"
help="Link to the form admin page"
/>
<toggle-switch-input name="views_submissions_count" v-model="compVal.views_submissions_count" class="mt-4"
label="Form Analytics" help="Form views and submissions count"
<toggle-switch-input
v-model="compVal.views_submissions_count"
name="views_submissions_count"
class="mt-4"
label="Form Analytics"
help="Form views and submissions count"
/>
<toggle-switch-input name="link_edit_submission" v-model="compVal.link_edit_submission" class="mt-4"
label="Edit Submission Link"
<toggle-switch-input
v-model="compVal.link_edit_submission"
name="link_edit_submission"
class="mt-4"
label="Edit Submission Link"
/>
</div>
</template>
<script>
export default {
name: 'NotificationsMessageActions',
components: { },
name: "NotificationsMessageActions",
components: {},
props: {
modelValue: { required: false }
modelValue: { type: Object, required: false },
},
data () {
emits: ['modelValue', 'input'],
data() {
return {
content: this.modelValue ?? {}
content: this.modelValue ?? {},
}
},
computed: {
compVal: {
set (val) {
set(val) {
this.content = val
this.$emit('input', this.compVal)
this.$emit("input", this.compVal)
},
get () {
get() {
return this.content
}
}
},
},
},
watch: {
modelValue (val) {
modelValue(val) {
this.content = val
}
},
},
created () {
if(this.compVal === undefined || this.compVal === null){
created() {
if (this.compVal === undefined || this.compVal === null) {
this.compVal = {}
}
['include_submission_data', 'link_open_form', 'link_edit_form', 'views_submissions_count', 'link_edit_submission'].forEach((keyname) => {
[
"include_submission_data",
"link_open_form",
"link_edit_form",
"views_submissions_count",
"link_edit_submission",
].forEach((keyname) => {
if (this.compVal[keyname] === undefined) {
this.compVal[keyname] = true
}
})
},
methods: { }
methods: {},
}
</script>

View File

@@ -1,57 +1,133 @@
<template>
<table :id="'table-' + tableHash" ref="table"
class="notion-table n-table whitespace-no-wrap bg-white dark:bg-notion-dark-light relative">
<thead :id="'table-header-' + tableHash" ref="header" class="n-table-head top-0"
:class="{ 'absolute': data.length !== 0 }" style="will-change: transform; transform: translate3d(0px, 0px, 0px)">
<table
:id="'table-' + tableHash"
ref="table"
class="notion-table n-table whitespace-no-wrap bg-white dark:bg-notion-dark-light relative"
>
<thead
:id="'table-header-' + tableHash"
ref="header"
class="n-table-head top-0"
:class="{ absolute: data.length !== 0 }"
style="will-change: transform; transform: translate3d(0px, 0px, 0px)"
>
<tr class="n-table-row overflow-x-hidden">
<resizable-th v-for="col, index in columns" :id="'table-head-cell-' + col.id" :key="col.id" scope="col"
:allow-resize="allowResize" :width="(col.cell_width ? col.cell_width + 'px' : 'auto')"
class="n-table-cell p-0 relative" @resize-width="resizeCol(col, $event)">
<resizable-th
v-for="(col) in columns"
:id="'table-head-cell-' + col.id"
:key="col.id"
scope="col"
:allow-resize="allowResize"
:width="col.cell_width ? col.cell_width + 'px' : 'auto'"
class="n-table-cell p-0 relative"
@resize-width="resizeCol(col, $event)"
>
<p
class="bg-gray-50 border-r dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs">
class="bg-gray-50 border-r dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs"
>
{{ col.name }}
</p>
</resizable-th>
<th class="n-table-cell p-0 relative" style="width: 100px">
<th
class="n-table-cell p-0 relative"
style="width: 100px"
>
<p
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs">
class="bg-gray-50 dark:bg-notion-dark truncate sticky top-0 border-b border-gray-200 dark:border-gray-800 px-4 py-2 text-gray-500 font-semibold tracking-wider uppercase text-xs"
>
Actions
</p>
</th>
</tr>
</thead>
<tbody v-if="data.length > 0" class="n-table-body bg-white dark:bg-notion-dark-light">
<tr v-if="objectHas($slots,'actions')" :id="'table-actions-' + tableHash" ref="actions-row"
class="action-row absolute w-full" style="will-change: transform; transform: translate3d(0px, 32px, 0px)">
<td :colspan="columns.length" class="p-1">
<tbody
v-if="data.length > 0"
class="n-table-body bg-white dark:bg-notion-dark-light"
>
<tr
v-if="objectHas($slots, 'actions')"
:id="'table-actions-' + tableHash"
ref="actions-row"
class="action-row absolute w-full"
style="will-change: transform; transform: translate3d(0px, 32px, 0px)"
>
<td
:colspan="columns.length"
class="p-1"
>
<slot name="actions" />
</td>
</tr>
<tr v-for="row, index in data" :key="row.id" class="n-table-row" :class="{ 'first': index === 0 }">
<td v-for="col, colIndex in columns" :key="col.id" :style="{ width: col.cell_width + 'px' }"
class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 overflow-hidden" :class="[{ 'border-b': index !== data.length - 1, 'border-r': colIndex !== columns.length - 1 || hasActions },
colClasses(col)]">
<component :is="fieldComponents[col.type]" class="border-gray-100 dark:border-gray-900" :property="col"
:value="row[col.id]" />
<tr
v-for="(row, index) in data"
:key="row.id"
class="n-table-row"
:class="{ first: index === 0 }"
>
<td
v-for="(col, colIndex) in columns"
:key="col.id"
:style="{ width: col.cell_width + 'px' }"
class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 overflow-hidden"
:class="[
{
'border-b': index !== data.length - 1,
'border-r': colIndex !== columns.length - 1 || hasActions,
},
colClasses(col),
]"
>
<component
:is="fieldComponents[col.type]"
class="border-gray-100 dark:border-gray-900"
:property="col"
:value="row[col.id]"
/>
</td>
<td v-if="hasActions" class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 border-b"
style="width: 100px">
<record-operations :form="form" :structure="columns" :submission="row"
<td
v-if="hasActions"
class="n-table-cell border-gray-100 dark:border-gray-900 text-sm p-2 border-b"
style="width: 100px"
>
<record-operations
:form="form"
:structure="columns"
:submission="row"
@deleted="(submission) => $emit('deleted', submission)"
@updated="(submission) => $emit('updated', submission)" />
@updated="(submission) => $emit('updated', submission)"
/>
</td>
</tr>
<tr v-if="loading" class="n-table-row border-t bg-gray-50 dark:bg-gray-900">
<td :colspan="columns.length" class="p-8 w-full">
<tr
v-if="loading"
class="n-table-row border-t bg-gray-50 dark:bg-gray-900"
>
<td
:colspan="columns.length"
class="p-8 w-full"
>
<Loader class="w-4 h-4 mx-auto" />
</td>
</tr>
</tbody>
<tbody v-else key="body-content" class="n-table-body">
<tbody
v-else
key="body-content"
class="n-table-body"
>
<tr class="n-table-row loader w-full">
<td :colspan="columns.length" class="n-table-cell w-full p-8">
<Loader v-if="loading" class="w-4 h-4 mx-auto" />
<p v-else class="text-gray-500 text-center">
<td
:colspan="columns.length"
class="n-table-cell w-full p-8"
>
<Loader
v-if="loading"
class="w-4 h-4 mx-auto"
/>
<p
v-else
class="text-gray-500 text-center"
>
No data found.
</p>
</td>
@@ -61,41 +137,43 @@
</template>
<script>
import OpenText from './components/OpenText.vue'
import OpenUrl from './components/OpenUrl.vue'
import OpenSelect from './components/OpenSelect.vue'
import OpenDate from './components/OpenDate.vue'
import OpenFile from './components/OpenFile.vue'
import OpenCheckbox from './components/OpenCheckbox.vue'
import ResizableTh from './components/ResizableTh.vue'
import RecordOperations from '../components/RecordOperations.vue'
import clonedeep from 'clone-deep'
import { hash } from "~/lib/utils.js";
import { default as _has } from 'lodash/has'
import OpenText from "./components/OpenText.vue"
import OpenUrl from "./components/OpenUrl.vue"
import OpenSelect from "./components/OpenSelect.vue"
import OpenDate from "./components/OpenDate.vue"
import OpenFile from "./components/OpenFile.vue"
import OpenCheckbox from "./components/OpenCheckbox.vue"
import ResizableTh from "./components/ResizableTh.vue"
import RecordOperations from "../components/RecordOperations.vue"
import clonedeep from "clone-deep"
import { hash } from "~/lib/utils.js"
import { default as _has } from "lodash/has"
export default {
components: { ResizableTh, RecordOperations },
emits: ["updated", "deleted", "resize", "update-columns"],
props: {
columns: {
type: Array,
default: () => []
default: () => [],
},
data: {
type: Array,
default: () => []
default: () => [],
},
loading: {
type: Boolean,
default: false
default: false,
},
allowResize: {
required: false,
default: true,
type: Boolean
type: Boolean,
},
scrollParent: {
type: [Boolean]
},
scrollParent: {},
},
emits: ["updated", "deleted", "resize", "update-columns"],
setup() {
const workingFormStore = useWorkingFormStore()
@@ -126,68 +204,68 @@ export default {
url: shallowRef(OpenUrl),
email: shallowRef(OpenText),
phone_number: shallowRef(OpenText),
signature: shallowRef(OpenFile)
}
signature: shallowRef(OpenFile),
},
}
},
watch: {
'columns': {
columns: {
handler() {
this.internalColumns = clonedeep(this.columns)
this.onStructureChange()
},
deep: true
deep: true,
},
data() {
this.$nextTick(() => {
this.handleScroll()
})
}
},
},
mounted() {
this.internalColumns = clonedeep(this.columns)
const parent = this.scrollParent ?? document.getElementById('table-page')
const parent = this.scrollParent ?? document.getElementById("table-page")
this.tableHash = hash(JSON.stringify(this.form.properties))
if (parent) {
parent.addEventListener('scroll', this.handleScroll, { passive: false })
parent.addEventListener("scroll", this.handleScroll, { passive: false })
}
window.addEventListener('resize', this.handleScroll)
window.addEventListener("resize", this.handleScroll)
this.onStructureChange()
this.handleScroll()
},
beforeUnmount() {
const parent = this.scrollParent ?? document.getElementById('table-page')
const parent = this.scrollParent ?? document.getElementById("table-page")
if (parent) {
parent.removeEventListener('scroll', this.handleScroll)
parent.removeEventListener("scroll", this.handleScroll)
}
window.removeEventListener('resize', this.handleScroll)
window.removeEventListener("resize", this.handleScroll)
},
methods: {
colClasses(col) {
let colAlign, colColor, colFontWeight, colWrap
let colColor, colFontWeight, colWrap
// Column align
colAlign = `text-${col.alignment ? col.alignment : 'left'}`
const colAlign = `text-${col.alignment ? col.alignment : "left"}`
// Column color
colColor = null
if (!_has(col, 'color') || col.color === 'default') {
colColor = 'text-gray-700 dark:text-gray-300'
if (!_has(col, "color") || col.color === "default") {
colColor = "text-gray-700 dark:text-gray-300"
}
colColor = `text-${col.color}`
// Column font weight
if (_has(col, 'bold') && col.bold) {
colFontWeight = 'font-semibold'
if (_has(col, "bold") && col.bold) {
colFontWeight = "font-semibold"
}
// Column wrapping
if (!_has(col, 'wrap_text') || !col.wrap_text) {
colWrap = 'truncate'
if (!_has(col, "wrap_text") || !col.wrap_text) {
colWrap = "truncate"
}
return [colAlign, colColor, colWrap, colFontWeight]
@@ -195,11 +273,19 @@ export default {
onStructureChange() {
if (this.internalColumns) {
this.$nextTick(() => {
this.internalColumns.forEach(col => {
if (!_has(col, 'cell_width')) {
if (this.allowResize && this.internalColumns.length && document.getElementById('table-head-cell-' + col.id)) {
this.internalColumns.forEach((col) => {
if (!_has(col, "cell_width")) {
if (
this.allowResize &&
this.internalColumns.length &&
document.getElementById("table-head-cell-" + col.id)
) {
// Within editor
this.resizeCol(col, document.getElementById('table-head-cell-' + col.id).offsetWidth)
this.resizeCol(
col,
document.getElementById("table-head-cell-" + col.id)
.offsetWidth,
)
}
}
})
@@ -208,60 +294,65 @@ export default {
},
resizeCol(col, width) {
if (!this.form) return
const index = this.internalColumns.findIndex(c => c.id === col.id)
const index = this.internalColumns.findIndex((c) => c.id === col.id)
this.internalColumns[index].cell_width = width
this.setColumns(this.internalColumns)
this.$nextTick(() => {
this.$emit('resize')
this.$emit("resize")
})
},
handleScroll() {
if (this.rafId) {
cancelAnimationFrame(this.rafId);
cancelAnimationFrame(this.rafId)
}
this.rafId = requestAnimationFrame(() => {
const table = this.$refs.table;
const tableHeader = document.getElementById('table-header-' + this.tableHash);
const tableActionsRow = document.getElementById('table-actions-' + this.tableHash);
const table = this.$refs.table
const tableHeader = document.getElementById(
"table-header-" + this.tableHash,
)
const tableActionsRow = document.getElementById(
"table-actions-" + this.tableHash,
)
if (!table || !tableHeader) return;
if (!table || !tableHeader) return
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
const tableRect = table.getBoundingClientRect();
const scrollTop =
window.pageYOffset || document.documentElement.scrollTop
const tableRect = table.getBoundingClientRect()
// The starting point of the table relative to the viewport
const tableStart = tableRect.top + scrollTop;
const tableStart = tableRect.top + scrollTop
// The end point of the table relative to the viewport
const tableEnd = tableStart + tableRect.height;
const tableEnd = tableStart + tableRect.height
let headerY = scrollTop - tableStart;
let actionsY = scrollTop + window.innerHeight - tableEnd;
let headerY = scrollTop - tableStart
let actionsY = scrollTop + window.innerHeight - tableEnd
if (headerY < 0) headerY = 0;
if (headerY < 0) headerY = 0
if (scrollTop + window.innerHeight > tableEnd) {
actionsY = tableRect.height - (scrollTop + window.innerHeight - tableEnd);
actionsY =
tableRect.height - (scrollTop + window.innerHeight - tableEnd)
} else {
actionsY = tableRect.height;
actionsY = tableRect.height
}
if (tableHeader) {
tableHeader.style.transform = `translate3d(0px, ${headerY}px, 0px)`;
tableHeader.style.transform = `translate3d(0px, ${headerY}px, 0px)`
}
if (tableActionsRow) {
tableActionsRow.style.transform = `translate3d(0px, ${actionsY}px, 0px)`;
tableActionsRow.style.transform = `translate3d(0px, ${actionsY}px, 0px)`
}
});
})
},
setColumns(val) {
this.$emit('update-columns', val)
this.$emit("update-columns", val)
},
objectHas(object, key) {
return _has(object, key)
}
}
},
},
}
</script>

View File

@@ -1,11 +1,33 @@
<template>
<svg v-if="value===true" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mx-auto" fill="none"
viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7"/>
<svg
v-if="value === true"
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 mx-auto"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M5 13l4 4L19 7"
/>
</svg>
<svg v-else-if="value===false" xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mx-auto" fill="none"
viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
<svg
v-else-if="value === false"
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 mx-auto"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
stroke-width="2"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
d="M6 18L18 6M6 6l12 12"
/>
</svg>
</template>
@@ -14,19 +36,17 @@ export default {
components: {},
props: {
value: {
required: true
type: Boolean,
required: true,
},
},
mounted() {
},
data() {
return {}
},
computed: {
},
computed: {},
mounted() {},
methods: {},
}

View File

@@ -1,22 +1,44 @@
<template>
<p class="text-xs">
<span v-for="file in parsedFiles" :key="file.file_url"
class="whitespace-nowrap rounded-md transition-colors hover:decoration-none"
:class="{'open-file text-gray-700 dark:text-gray-300 truncate':!file.is_image, 'open-file-img':file.is_image}"
<span
v-for="file in parsedFiles"
:key="file.file_url"
class="whitespace-nowrap rounded-md transition-colors hover:decoration-none"
:class="{
'open-file text-gray-700 dark:text-gray-300 truncate': !file.is_image,
'open-file-img': file.is_image,
}"
>
<a class="text-gray-700 dark:text-gray-300" :href="file.file_url" target="_blank"
rel="nofollow"
<a
class="text-gray-700 dark:text-gray-300"
:href="file.file_url"
target="_blank"
rel="nofollow"
>
<div v-if="file.is_image" class="w-8 h-8">
<img class="object-cover h-full w-full rounded" :src="file.file_url" @error="failedImages.push(file.file_url)"/>
</div>
<span v-else
class="py-1 px-2"
>
<a :href="file.file_url" target="_blank" download>{{ file.displayed_file_name }}</a>
<div
v-if="file.is_image"
class="w-8 h-8"
>
<img
class="object-cover h-full w-full rounded"
:src="file.file_url"
@error="failedImages.push(file.file_url)"
>
</div>
<span
v-else
class="py-1 px-2"
>
<a
:href="file.file_url"
target="_blank"
download
>{{
file.displayed_file_name
}}</a>
</span>
</a>
</span>
</a>
</span>
</p>
</template>
@@ -26,32 +48,36 @@ export default {
props: {
value: {
type: Array,
required: false
}
required: false,
},
},
data() {
return {
failedImages: []
failedImages: [],
}
},
computed: {
parsedFiles() {
return this.value ? this.value.map((file) => {
return {
file_name: file.file_name,
file_url: file.file_url,
displayed_file_name: this.displayedFileName(file.file_name),
is_image: !this.failedImages.includes(file.file_url) && this.isImage(file.file_name)
}
}): []
}
return this.value
? this.value.map((file) => {
return {
file_name: file.file_name,
file_url: file.file_url,
displayed_file_name: this.displayedFileName(file.file_name),
is_image:
!this.failedImages.includes(file.file_url) &&
this.isImage(file.file_name),
}
})
: []
},
},
methods: {
isImage(fileName) {
return ['png', 'gif', 'jpg', 'jpeg', 'tif'].some((suffix) => {
return ["png", "gif", "jpg", "jpeg", "tif"].some((suffix) => {
return fileName && fileName.endsWith(suffix)
})
},
@@ -60,11 +86,11 @@ export default {
const filename = fileName.substr(0, fileName.lastIndexOf("."))
if (filename.length > 10) {
return filename.substr(0, 10) + '[...].' + extension
return filename.substr(0, 10) + "[...]." + extension
}
return filename + '.' + extension
}
}
return filename + "." + extension
},
},
}
</script>

View File

@@ -1,32 +1,44 @@
<template>
<span v-if="value" class="-mb-2">
<span
v-if="value"
class="-mb-2"
>
<template v-if="valueIsObject">
<open-tag v-for="(val,index) in value" :key="index+val" :opt="val" />
<open-tag
v-for="(val, index) in value"
:key="index + val"
:opt="val"
/>
</template>
<open-tag v-else :opt="value" />
<open-tag
v-else
:opt="value"
/>
</span>
</template>
<script>
import OpenTag from './OpenTag.vue'
import OpenTag from "./OpenTag.vue"
export default {
components: { OpenTag },
props: {
value: {}
value: {
type: Object,
},
},
data () {
data() {
return {}
},
computed: {
valueIsObject () {
if (typeof this.value === 'object' && this.value !== null) {
valueIsObject() {
if (typeof this.value === "object" && this.value !== null) {
return true
}
return false
}
},
},
}
</script>

View File

@@ -1,6 +1,7 @@
<template>
<span :id="opt"
class="py-1 px-2 mb-1 open-tag default mr-2 text-gray-700 dark:text-gray-300 text-xs whitespace-nowrap rounded-md transition-colors"
<span
:id="opt"
class="py-1 px-2 mb-1 open-tag default mr-2 text-gray-700 dark:text-gray-300 text-xs whitespace-nowrap rounded-md transition-colors"
>
{{ opt }}
</span>
@@ -12,20 +13,18 @@ export default {
props: {
opt: {
type: String,
required: true
}
required: true,
},
},
data () {
data() {
return {}
},
computed: {
},
mounted () {
},
computed: {},
mounted() {},
methods: {}
methods: {},
}
</script>
@@ -35,7 +34,8 @@ export default {
&.gray {
background-color: #e3e2e0;
}
&.light-gray,&.default {
&.light-gray,
&.default {
background-color: #e3e2e080;
}
&.brown {
@@ -69,7 +69,8 @@ export default {
&.gray {
background-color: #5a5a5a;
}
&.light-gray,&.default {
&.light-gray,
&.default {
background-color: #ffffff21;
}
&.brown {
@@ -98,4 +99,4 @@ export default {
}
}
}
</style>
</style>

View File

@@ -9,8 +9,9 @@ export default {
components: {},
props: {
value: {
required: true
}
type: String,
required: true,
},
},
}
</script>

View File

@@ -1,5 +1,10 @@
<template>
<a class="text-gray-700 dark:text-gray-300 hover:underline" :href="value" target="_blank" rel="nofollow">{{ value }}</a>
<a
class="text-gray-700 dark:text-gray-300 hover:underline"
:href="value"
target="_blank"
rel="nofollow"
>{{ value }}</a>
</template>
<script>
@@ -7,19 +12,17 @@ export default {
components: {},
props: {
value: {
required: true
type: String,
required: true,
},
},
mounted() {
},
data() {
return {}
},
computed: {
},
computed: {},
mounted() {},
methods: {},
}

View File

@@ -1,9 +1,16 @@
<template>
<th ref="th" :style="{width: width}">
<slot/>
<div v-if="allowResize" class="absolute right-0 top-0 w-0 z-10">
<div class="resize-handler bg-transparent cursor-move hover:bg-blue-500 opacity-80 transition-colors"
@mousedown="mouseDownHandler"
<th
ref="th"
:style="{ width: width }"
>
<slot />
<div
v-if="allowResize"
class="absolute right-0 top-0 w-0 z-10"
>
<div
class="resize-handler bg-transparent cursor-move hover:bg-blue-500 opacity-80 transition-colors"
@mousedown="mouseDownHandler"
/>
</div>
</th>
@@ -14,19 +21,22 @@ export default {
components: {},
props: {
allowResize: {
required: true
type: Boolean,
required: true,
},
width: {
required: true
}
type: [String, Number],
required: true,
},
},
emits: ['resize-width'],
data() {
return {
x: 0,
w: 0,
lastEmit: Date.now(),
throttlePeriod: 50 // milliseconds
throttlePeriod: 50, // milliseconds
}
},
@@ -41,22 +51,22 @@ export default {
this.w = parseInt(styles.width, 10)
// Attach the listeners to `document`
document.addEventListener('mousemove', this.mouseMoveHandler)
document.addEventListener('mouseup', this.mouseUpHandler)
document.addEventListener("mousemove", this.mouseMoveHandler)
document.addEventListener("mouseup", this.mouseUpHandler)
},
mouseMoveHandler(e) {
const now = Date.now()
if (now - this.lastEmit > this.throttlePeriod) {
const dx = e.clientX - this.x
this.$emit('resize-width', this.w + dx)
this.$emit("resize-width", this.w + dx)
this.lastEmit = now
}
},
mouseUpHandler() {
// Remove the handlers of `mousemove` and `mouseup`
document.removeEventListener('mousemove', this.mouseMoveHandler)
document.removeEventListener('mouseup', this.mouseUpHandler)
}
}
document.removeEventListener("mousemove", this.mouseMoveHandler)
document.removeEventListener("mouseup", this.mouseUpHandler)
},
},
}
</script>