This commit is contained in:
Julien Nahum 2023-09-20 21:06:48 +02:00
commit 9534847a24
9 changed files with 39 additions and 11 deletions

View File

@ -190,6 +190,9 @@ class AnswerFormRequest extends FormRequest
}
return $this->getRulesForDate($property);
case 'phone_number':
if (isset($property['use_simple_text_input']) && $property['use_simple_text_input']) {
return ['string'];
}
return ['string', 'min:6', new ValidPhoneInputRule];
default:
return [];

View File

@ -13,8 +13,12 @@ class ValidPhoneInputRule implements Rule
return false;
}
try {
$phoneUtil = \libphonenumber\PhoneNumberUtil::getInstance();
return $phoneUtil->isValidNumber($phoneUtil->parse($value));
} catch (\Exception $e) {
return false;
}
}
public function message()

View File

@ -12,7 +12,7 @@
</router-link>
<workspace-dropdown class="ml-6"/>
</div>
<div class="hidden md:block ml-auto relative">
<div v-if="showAuth" class="hidden md:block ml-auto relative">
<router-link :to="{name:'templates'}" v-if="$route.name !== 'templates'"
class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1 mr-8">
Templates
@ -27,7 +27,7 @@
<span v-else>Pricing</span>
</router-link>
<a href="#" class="text-sm text-gray-600 dark:text-white hover:text-gray-800 cursor-pointer mt-1"
@click.prevent="$crisp.push(['do', 'helpdesk:search'])" v-if="hasCrisp"
@click.prevent="openCrisp" v-if="hasCrisp"
>
Help
</a>
@ -194,6 +194,10 @@ export default {
// Redirect to login.
this.$router.push({name: 'login'})
},
openCrisp () {
window.$crisp.push(['do', 'chat:show'])
window.$crisp.push(['do', 'chat:open'])
}
}
}
</script>

View File

@ -13,7 +13,7 @@
</small>
</div>
<div :id="id ? id : name" :name="name" :style="inputStyle" class="flex items-center">
<v-select class="w-[110px]" dropdown-class="w-[400px]" input-class="rounded-r-none" :data="countries"
<v-select class="w-[110px]" dropdown-class="w-[350px]" input-class="rounded-r-none" :data="countries"
v-model="selectedCountryCode"
:has-error="hasValidation && form.errors.has(name)"
:disabled="disabled" :searchable="true" :search-keys="['name']" :option-key="'code'" :color="color"

View File

@ -133,7 +133,7 @@ export default {
checkbox: 'CheckboxInput',
url: 'TextInput',
email: 'TextInput',
phone_number: 'PhoneInput'
phone_number: 'TextInput'
}
},
/**
@ -159,6 +159,9 @@ export default {
if (field.type === 'signature') {
return 'SignatureInput'
}
if (field.type === 'phone_number' && !field.use_simple_text_input) {
return 'PhoneInput'
}
return this.fieldComponents[field.type]
},
isPublicFormPage() {

View File

@ -22,7 +22,7 @@
<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="$crisp.push(['do', 'helpdesk:search'])"
@click.prevent="openCrisp"
>
Help
</a>
@ -221,6 +221,10 @@ export default {
},
methods: {
openCrisp () {
window.$crisp.push(['do', 'chat:show'])
window.$crisp.push(['do', 'chat:open'])
},
showValidationErrors() {
this.showFormErrorModal = true
},

View File

@ -43,7 +43,7 @@ export default {
checkbox: 'CheckboxInput',
url: 'TextInput',
email: 'TextInput',
phone_number: 'PhoneInput'
phone_number: 'TextInput'
}
}
},
@ -57,6 +57,10 @@ export default {
required: true
}
if (this.property.type === 'phone_number' && !this.property.use_simple_text_input) {
componentData.component = 'PhoneInput'
}
if (['select', 'multi_select'].includes(this.property.type)) {
componentData.multiple = false;
componentData.options = this.property[this.property.type].options.map(option => {

View File

@ -193,12 +193,18 @@
label="Field Name"
/>
<v-checkbox v-model="field.hide_field_name" class="mb-3"
<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-model="field.use_simple_text_input" class="mt-3"
:name="field.id+'_use_simple_text_input'"
>
Use simple text input
</v-checkbox>
<!-- Pre-fill depends on type -->
<v-checkbox v-if="field.type=='checkbox'" v-model="field.prefill" class="mt-3"
:name="field.id+'_prefill'"
@ -216,7 +222,7 @@
:date-range="field.date_range===true"
label="Pre-filled value"
/>
<phone-input v-else-if="field.type === 'phone_number'"
<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"
label="Pre-filled value"

View File

@ -1,6 +1,6 @@
<template>
<div>
<section class="bg-gradient-to-b relative from-white to-gray-100 py-12 sm:py-16 lg:py-20 xl:py-24">
<section class="bg-gradient-to-b relative from-white to-gray-100 py-8 sm:py-16 ">
<div class="absolute inset-0">
<img class="w-full h-full object-cover object-top"
:src="asset('img/pages/ai_form_builder/background-pattern.svg')" alt="">