- 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:
@@ -20,7 +20,8 @@ const FormFieldRepeater = ({
|
||||
register,
|
||||
label,
|
||||
infoText,
|
||||
config = {}
|
||||
config = {},
|
||||
disabled = false
|
||||
}) => {
|
||||
const forMenu = useRef(null);
|
||||
const [stateFieldData, setStateFieldData] = useState([]);
|
||||
@@ -72,11 +73,12 @@ const FormFieldRepeater = ({
|
||||
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, i)}/>
|
||||
: <InputText disabled={disabled} value={item.value} onInput={(e) => onInputChange(e, i)}/>
|
||||
}
|
||||
|
||||
const usedExistingValues = useCallback(() => {
|
||||
@@ -101,7 +103,7 @@ const FormFieldRepeater = ({
|
||||
const ids = pluck('lookUpDataId', prevState)
|
||||
const objectsToAdd = klona(storeFieldData)
|
||||
.filter(o => !ids.includes(o.lookUpDataId))
|
||||
.map(o => ({...o, id: null}));
|
||||
.map(o => ({ ...o, id: null }));
|
||||
return [...prevState, ...objectsToAdd];
|
||||
});
|
||||
}
|
||||
@@ -123,12 +125,13 @@ const FormFieldRepeater = ({
|
||||
{stateFieldData.map((o, i) => <div key={i} className={classNames('appForm__repeaterItem')}>
|
||||
<div className="p-inputgroup flex-1">
|
||||
{properField(o, i)}
|
||||
<Button type="button" icon="pi pi-times" className="p-button-danger" onClick={() => removeItem(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>)}
|
||||
<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