diff --git a/src/pages/BandoEdit/index.js b/src/pages/BandoEdit/index.js index 9480a7b..a20a22d 100644 --- a/src/pages/BandoEdit/index.js +++ b/src/pages/BandoEdit/index.js @@ -11,6 +11,7 @@ import BandoService from '../../service/bando-service'; // tools import getBandoLabel from '../../helpers/getBandoLabel'; +import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; // components import { Button } from 'primereact/button'; @@ -20,7 +21,6 @@ import BandoEditFormStep1 from './components/BandoEditFormStep1'; import BandoEditFormStep2 from './components/BandoEditFormStep2'; import { Messages } from 'primereact/messages'; import FormsService from '../../service/forms-service'; -import set404FromErrorResponse from '../../helpers/set404FromErrorResponse'; import BlockingOverlay from '../../components/BlockingOverlay'; const BandoEdit = () => { @@ -30,8 +30,6 @@ const BandoEdit = () => { const [activeStep, setActiveStep] = useState(null) const [data, setData] = useState({}); const [forms, setForms] = useState([]); - //const [selectedTemplate, setSelectedTemplate] = useState(null); - //const [templates, setTemplate] = useState(null); const formRef = useRef(null); const bandoMsgs = useRef(null); @@ -43,23 +41,7 @@ const BandoEdit = () => { return false } bandoMsgs.current.clear(); - const isFormValid = formRef.current.isFormValid(); - //const values = formRef.current.getValues(); - //const diffData = equal(values, data); - // TODO warn about unsaved data goToStep(0); - /*if (isFormValid) { - goToStep(0) - } else { - bandoMsgs.current.show([ - { - id: '98', - sticky: true, severity: 'error', summary: '', - detail: __('Potrai andare su altro step dopo risolvere errori della forma', 'gepafin'), - closable: true - } - ]); - }*/ } }, { @@ -68,25 +50,8 @@ const BandoEdit = () => { if (activeStep === 1) { return false } - console.log('11'); bandoMsgs.current.clear(); - const isFormValid = formRef.current.isFormValid(); - //const values = formRef.current.getValues(); - //const diffData = equal(values, data); - // TODO warn about unsaved data goToStep(1); - /*if (isFormValid) { - goToStep(1); - } else { - bandoMsgs.current.show([ - { - id: '98', - sticky: true, severity: 'error', summary: '', - detail: __('Potrai andare su altro step dopo risolvere errori della forma', 'gepafin'), - closable: true - } - ]); - }*/ } } ]; @@ -271,26 +236,6 @@ const BandoEdit = () => {
- {/*!isLoading - ?
-
- - setSelectedTemplate(e.value)} - options={templates} - optionLabel="name" - placeholder={__('Seleziona template', 'gepafin')}/> -
-
: null*/} {!isEmpty(data) ? { useEffect(() => { const element = head(elements.filter(o => o.id === id)); const setting = head(element.settings.filter(o => o.name === 'label')); - if (setting.value) { + if (setting) { setLabel(setting.value); } else { setLabel(defaultLabel); diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js index 928eda3..459b741 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/components/ElementSetting/index.js @@ -16,6 +16,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn }) => { step: __('Precisione decimale', 'gepafin'), options: __('Opzioni', 'gepafin'), mime: __('Tipo di file', 'gepafin'), + text: __('Testo formattato', 'gepafin') } return
diff --git a/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js b/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js index 131c84c..ec16fa0 100644 --- a/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js +++ b/src/pages/BandoFormsEdit/components/BuilderElementSettings/index.js @@ -23,14 +23,14 @@ const BuilderElementSettings = ({ closeSettings }) => { const [validators, setValidators] = useState({}); 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'} + { 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) => { @@ -116,48 +116,49 @@ const BuilderElementSettings = ({ closeSettings }) => { updateDataFn={onUpdateOptions}/>) : null} - - {validators - ? Object.keys(validators).map((k) =>
- {k === 'isRequired' - ?
- - toggleRequired(e.value, k)}/> -
- : null} - {textBasedValidatorFields.includes(k) || 'custom' === k - ?
- - showField(e.value, k)}/> -
- : null} - {k === 'custom' && !isNil(validators[k]) - ?
- - onChangeValidator(e.value, k)} - options={customValidationOptions} - optionLabel="label" - optionValue="value" - placeholder={__('Scegli', 'gepafin')}/> -
- : null} - {textBasedValidatorFields.includes(k) && !isNil(validators[k]) - ?
- - onChangeValidator(e.target.value, k)}/> -
: null} -
) : null} -
+ {!isEmpty(validators) + ? + {validators + ? Object.keys(validators).map((k) =>
+ {k === 'isRequired' + ?
+ + toggleRequired(e.value, k)}/> +
+ : null} + {textBasedValidatorFields.includes(k) || 'custom' === k + ?
+ + showField(e.value, k)}/> +
+ : null} + {k === 'custom' && !isNil(validators[k]) + ?
+ + onChangeValidator(e.value, k)} + options={customValidationOptions} + optionLabel="label" + optionValue="value" + placeholder={__('Scegli', 'gepafin')}/> +
+ : null} + {textBasedValidatorFields.includes(k) && !isNil(validators[k]) + ?
+ + onChangeValidator(e.target.value, k)}/> +
: null} +
) : null} +
: null}