Fixed form creation
This commit is contained in:
54
client/composables/forms/initForm.js
vendored
Normal file
54
client/composables/forms/initForm.js
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
export const initForm = (options = {}) => {
|
||||
return useForm({
|
||||
title: 'My Form',
|
||||
description: null,
|
||||
visibility: 'public',
|
||||
workspace_id: null,
|
||||
properties: [],
|
||||
|
||||
notifies: false,
|
||||
slack_notifies: false,
|
||||
send_submission_confirmation: false,
|
||||
webhook_url: null,
|
||||
notification_settings: {},
|
||||
|
||||
// Customization
|
||||
theme: 'default',
|
||||
width: 'centered',
|
||||
dark_mode: 'auto',
|
||||
color: '#3B82F6',
|
||||
hide_title: false,
|
||||
no_branding: false,
|
||||
uppercase_labels: true,
|
||||
transparent_background: false,
|
||||
closes_at: null,
|
||||
closed_text: 'This form has now been closed by its owner and does not accept submissions anymore.',
|
||||
auto_save: true,
|
||||
|
||||
// Submission
|
||||
submit_button_text: 'Submit',
|
||||
re_fillable: false,
|
||||
re_fill_button_text: 'Fill Again',
|
||||
submitted_text: 'Amazing, we saved your answers. Thank you for your time and have a great day!',
|
||||
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,
|
||||
use_captcha: false,
|
||||
is_rating: false,
|
||||
rating_max_value: 5,
|
||||
max_submissions_count: null,
|
||||
max_submissions_reached_text: 'This form has now reached the maximum number of allowed submissions and is now closed.',
|
||||
editable_submissions_button_text: 'Edit submission',
|
||||
confetti_on_submission: false,
|
||||
|
||||
// Security & Privacy
|
||||
can_be_indexed: true,
|
||||
|
||||
// Custom SEO
|
||||
seo_meta: {},
|
||||
|
||||
...options
|
||||
})
|
||||
}
|
||||
14
client/composables/forms/validatePropertiesLogic.js
vendored
Normal file
14
client/composables/forms/validatePropertiesLogic.js
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
import FormPropertyLogicRule from "~/lib/forms/FormPropertyLogicRule.js";
|
||||
|
||||
export const validatePropertiesLogic = (properties) => {
|
||||
properties.forEach((field) => {
|
||||
const isValid = (new FormPropertyLogicRule(field)).isValid()
|
||||
if (!isValid) {
|
||||
field.logic = {
|
||||
conditions: null,
|
||||
actions: []
|
||||
}
|
||||
}
|
||||
})
|
||||
return properties
|
||||
}
|
||||
20
client/composables/useCrisp.js
vendored
20
client/composables/useCrisp.js
vendored
@@ -4,6 +4,7 @@ export const useCrisp = () => {
|
||||
|
||||
function openChat() {
|
||||
if (!crisp) return
|
||||
showChat()
|
||||
crisp.chat.open()
|
||||
}
|
||||
|
||||
@@ -29,11 +30,12 @@ export const useCrisp = () => {
|
||||
if (message) sendTextMessage(message)
|
||||
}
|
||||
|
||||
function openHelpdesk(){
|
||||
function openHelpdesk() {
|
||||
if (!crisp) return
|
||||
openChat()
|
||||
crisp.chat.setHelpdeskView()
|
||||
}
|
||||
|
||||
function openHelpdeskArticle(articleSlug, locale = 'en') {
|
||||
if (!crisp) return
|
||||
crisp.chat.openHelpdeskArticle(locale, articleSlug);
|
||||
@@ -44,15 +46,15 @@ export const useCrisp = () => {
|
||||
crisp.message.send('text', message)
|
||||
}
|
||||
|
||||
function setUser (user) {
|
||||
function setUser(user) {
|
||||
if (!crisp) return
|
||||
crisp.user.setEmail(user.email);
|
||||
crisp.user.setNickname(user.name);
|
||||
crisp.session.setData({
|
||||
user_id : user.id,
|
||||
'pro-subscription' : user?.is_subscribed ?? false,
|
||||
'stripe-id' : user?.stripe_id ?? '',
|
||||
'subscription' : user?.has_enterprise_subscription ? 'enterprise' : 'pro'
|
||||
user_id: user.id,
|
||||
'pro-subscription': user?.is_subscribed ?? false,
|
||||
'stripe-id': user?.stripe_id ?? '',
|
||||
'subscription': user?.has_enterprise_subscription ? 'enterprise' : 'pro'
|
||||
});
|
||||
|
||||
if (user?.is_subscribed ?? false) {
|
||||
@@ -60,6 +62,11 @@ export const useCrisp = () => {
|
||||
}
|
||||
}
|
||||
|
||||
function pushEvent(event, data = {}) {
|
||||
if (!crisp) return
|
||||
crisp.pushEvent(event, data)
|
||||
}
|
||||
|
||||
function setSegments(segments, overwrite = false) {
|
||||
if (!crisp) return
|
||||
crisp.session.setSegments(segments, overwrite)
|
||||
@@ -75,6 +82,7 @@ export const useCrisp = () => {
|
||||
openHelpdesk,
|
||||
openHelpdeskArticle,
|
||||
sendTextMessage,
|
||||
pushEvent,
|
||||
setUser
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user