- added registartion page;
- implemented validation helper-functions; - fixed form fields datepicker and datepicker range; - updated routes logic; - fixed FAQ items editing/submission;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { head, isNil } from 'ramda';
|
||||
import { head, isEmpty, isNil } from 'ramda';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { klona } from 'klona';
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Tag } from 'primereact/tag';
|
||||
import { TabView, TabPanel } from 'primereact/tabview';
|
||||
import { InputSwitch } from 'primereact/inputswitch';
|
||||
import ElementSetting from './components/ElementSetting';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettings }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
@@ -20,7 +21,17 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
const [activeElementData, setActiveElementData] = useState({});
|
||||
const [settings, setSettings] = useState([]);
|
||||
const [validators, setValidators] = useState({});
|
||||
const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern', 'custom'];
|
||||
const textBasedValidatorFields = ['min', 'max', 'minLength', 'maxLength', 'pattern'];
|
||||
const customValidationOptions = [
|
||||
{value: 'isPIVA', label: 'isPIVA'},
|
||||
{value: 'isCodiceFiscale', label: 'isCodiceFiscale'},
|
||||
{value: 'isCAP', label: 'isCAP'},
|
||||
{value: 'isIBAN', label: 'isIBAN'},
|
||||
{value: 'isEmail', label: 'isEmail'},
|
||||
{value: 'isEmailPEC', label: 'isEmailPEC'},
|
||||
{value: 'isUrl', label: 'isUrl'},
|
||||
{value: 'isMarcaDaBollo', label: 'isMarcaDaBollo'}
|
||||
]
|
||||
|
||||
const onChange = (value, name) => {
|
||||
const newSettings = settings
|
||||
@@ -89,7 +100,7 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
setSettings([]);
|
||||
setValidators({})
|
||||
}
|
||||
}, [activeElement])
|
||||
}, [activeElement]);
|
||||
|
||||
return (activeElementData
|
||||
? <div className="formElementSettings">
|
||||
@@ -110,13 +121,13 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
className="formElementSettings__field" key={k}>
|
||||
{k === 'isRequired'
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={k}>{__('Required?', 'gepafin')}</label>
|
||||
<label htmlFor={k}>{__('Obligatorio?', 'gepafin')}</label>
|
||||
<InputSwitch
|
||||
checked={validators[k]}
|
||||
onChange={(e) => toggleRequired(e.value, k)}/>
|
||||
</div>
|
||||
: null}
|
||||
{textBasedValidatorFields.includes(k)
|
||||
{textBasedValidatorFields.includes(k) || 'custom' === k
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={`enable_${k}`}>{sprintf(__('Set %s', 'gepafin'), k)}</label>
|
||||
<InputSwitch
|
||||
@@ -124,6 +135,19 @@ const BuilderElementSettings = ({ closeSettings }) => {
|
||||
onChange={(e) => showField(e.value, k)}/>
|
||||
</div>
|
||||
: null}
|
||||
{k === 'custom' && !isNil(validators[k])
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={k}>{__('Personalizzato', 'gepafin')}</label>
|
||||
<Dropdown
|
||||
id={`enable_${k}`}
|
||||
value={validators[k]}
|
||||
onChange={(e) => onChangeValidator(e.value, k)}
|
||||
options={customValidationOptions}
|
||||
optionLabel="label"
|
||||
optionValue="value"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
</div>
|
||||
: null}
|
||||
{textBasedValidatorFields.includes(k) && !isNil(validators[k])
|
||||
? <div className="formElementSettings__field">
|
||||
<label htmlFor={k}>{k}</label>
|
||||
|
||||
Reference in New Issue
Block a user