- added table validation custom function;
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import validate from 'validate.js';
|
||||
import { match, isEmpty, is } from 'ramda';
|
||||
import { match, isEmpty, is, pathOr, isNil } from 'ramda';
|
||||
import CodiceFiscale from 'codice-fiscale-js';
|
||||
|
||||
export const isPIVA = (v) => {
|
||||
@@ -67,12 +67,31 @@ export const maxChecks = (v, num) => {
|
||||
return is(Array, v) ? v.length <= parseInt(num) : false;
|
||||
}
|
||||
|
||||
export const nonEmptyTables = (v = [], colsCfg = []) => {
|
||||
export const nonEmptyTables = (v = [], tableCfg = []) => {
|
||||
//console.log('nonEmptyTables',v)
|
||||
/*const cellValues = v.map(row => {
|
||||
const colsCfg = pathOr([], ['stateFieldData'], tableCfg);
|
||||
const nonPredefinedCells = colsCfg
|
||||
.filter(o => !o.predefined)
|
||||
.map(o => o.name);
|
||||
let isTableValid = true;
|
||||
let atLeastOneCellFilled = false
|
||||
|
||||
return isEmpty(row)
|
||||
// eslint-disable-next-line array-callback-return
|
||||
v.map((row) => {
|
||||
if (isEmpty(row)) {
|
||||
isTableValid = false;
|
||||
} else {
|
||||
// eslint-disable-next-line array-callback-return
|
||||
nonPredefinedCells.map((k) => {
|
||||
if (isNil(row[k]) || isEmpty(row[k])) {
|
||||
isTableValid = atLeastOneCellFilled;
|
||||
} else {
|
||||
atLeastOneCellFilled = true;
|
||||
isTableValid = true;
|
||||
}
|
||||
});
|
||||
console.log('cellValues', cellValues, colsCfg)*/
|
||||
return is(Array, v) ? v.length >= 1 : false;
|
||||
}
|
||||
});
|
||||
|
||||
return is(Array, v) ? v.length >= 1 && isTableValid : false;
|
||||
}
|
||||
@@ -156,6 +156,7 @@ const BandoApplication = () => {
|
||||
|
||||
const saveDraft = (saveAndMove = '') => {
|
||||
trigger();
|
||||
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
const newFormValues = Object.keys(formValues)
|
||||
|
||||
@@ -14,7 +14,6 @@ import { TabView, TabPanel } from 'primereact/tabview';
|
||||
import { InputSwitch } from 'primereact/inputswitch';
|
||||
import ElementSetting from './components/ElementSetting';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { maxChecks, minChecks } from '../../../../helpers/validators';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettings }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
|
||||
@@ -65,7 +65,7 @@ const DashboardBeneficiario = () => {
|
||||
<Button
|
||||
onClick={goToAllSubmissions}
|
||||
label={__('Nuova domanda', 'gepafin')} icon="pi pi-plus" iconPos="right"/>
|
||||
<Button
|
||||
{/*<Button
|
||||
disabled={true}
|
||||
outlined
|
||||
onClick={() => {
|
||||
@@ -76,7 +76,7 @@ const DashboardBeneficiario = () => {
|
||||
outlined
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Contatta assistenza', 'gepafin')} icon="pi pi-envelope" iconPos="right"/>
|
||||
label={__('Contatta assistenza', 'gepafin')} icon="pi pi-envelope" iconPos="right"/>*/}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user