- 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:
@@ -21,7 +21,8 @@ const FormFieldRepeaterCriteria = ({
|
||||
register,
|
||||
label,
|
||||
infoText,
|
||||
config = {}
|
||||
config = {},
|
||||
disabled = false
|
||||
}) => {
|
||||
const forMenu = useRef(null);
|
||||
const [stateFieldData, setStateFieldData] = useState([]);
|
||||
@@ -78,10 +79,12 @@ const FormFieldRepeaterCriteria = ({
|
||||
const properField = (item, i) => {
|
||||
return !isNil(item.lookUpDataId)
|
||||
? <Dropdown value={item.value}
|
||||
disabled={disabled}
|
||||
onChange={(e) => selectItem(e, i)}
|
||||
optionDisabled={(opt) => usedExistingValues().includes(opt.value)}
|
||||
options={stateOptionsData} optionLabel="value"/>
|
||||
: <InputText value={item.value} onInput={(e) => onInputChange(e.target.value, i, 'value')}/>
|
||||
: <InputText disabled={disabled} value={item.value}
|
||||
onInput={(e) => onInputChange(e.target.value, i, 'value')}/>
|
||||
}
|
||||
|
||||
const usedExistingValues = useCallback(() => {
|
||||
@@ -111,7 +114,7 @@ const FormFieldRepeaterCriteria = ({
|
||||
const ids = pluck('lookUpDataId', prevState)
|
||||
const objectsToAdd = klona(storeFieldData)
|
||||
.filter(o => !ids.includes(o.lookUpDataId))
|
||||
.map(o => ({...o, id: null, score: 0}));
|
||||
.map(o => ({ ...o, id: null, score: 0 }));
|
||||
return [...prevState, ...objectsToAdd];
|
||||
});
|
||||
}
|
||||
@@ -130,27 +133,30 @@ const FormFieldRepeaterCriteria = ({
|
||||
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] || errors['threshold'] })}>
|
||||
{label}
|
||||
</label>
|
||||
<div className="appForm__oneCol">
|
||||
<div className="appForm__col">
|
||||
<label htmlFor="criterionThreshold">{__('Punteggio minimo per l’ammissione', 'gepafin')}</label>
|
||||
<InputNumber inputId="criterionThreshold"
|
||||
disabled={disabled}
|
||||
value={threshold}
|
||||
showButtons
|
||||
onValueChange={(e) => onThresholdChange(e.value)}/>
|
||||
</div>
|
||||
{stateFieldData.map((o, i) => <div key={i}
|
||||
className={classNames('appForm__field', 'appForm__repeaterItem')}>
|
||||
<div className="appForm__twoCols">
|
||||
<div className="appForm__cols">
|
||||
<div>
|
||||
<label>{__('Nome criterio di valutazione', 'gepafin')}</label>
|
||||
<div className="p-inputgroup flex-1">
|
||||
{properField(o, i)}
|
||||
<Button type="button" icon="pi pi-times" className="p-button-danger" onClick={() => removeItem(i)}/>
|
||||
{properField(o, i)}
|
||||
<Button disabled={disabled} type="button" icon="pi pi-times" className="p-button-danger"
|
||||
onClick={() => removeItem(i)}/>
|
||||
</div>
|
||||
{isNil(o.lookUpDataId) && infoText ? <small>{infoText}</small> : null}
|
||||
</div>
|
||||
<div>
|
||||
<label htmlFor="criterionMin">{__('Punteggio', 'gepafin')}</label>
|
||||
<InputNumber inputId="criterionMin"
|
||||
disabled={disabled}
|
||||
value={o.score}
|
||||
showButtons
|
||||
onValueChange={(e) => onInputChange(e.value, i, 'score')}/>
|
||||
@@ -159,6 +165,7 @@ const FormFieldRepeaterCriteria = ({
|
||||
</div>)}
|
||||
<Menu model={menuItems} popup ref={forMenu} id="aimedForMenu"/>
|
||||
<Button type="button" iconPos="right" label={__('Aggiungi', 'gepafin')}
|
||||
disabled={disabled}
|
||||
icon="pi pi-chevron-down" onClick={(event) => forMenu.current.toggle(event)}
|
||||
aria-controls="aimedForMenu" aria-haspopup/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user