- merged with master;

This commit is contained in:
Vitalii Kiiko
2024-10-22 14:41:28 +02:00
6 changed files with 32 additions and 24 deletions

View File

@@ -136,7 +136,8 @@ const Table = ({
return ( return (
<> <>
<label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}> <label htmlFor={fieldName} className={classNames({ 'p-error': errors[fieldName] })}>
{label}{config.required || config.isRequired ? <span className="appForm__field--required">*</span> : null} {label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
? <span className="appForm__field--required">*</span> : null}
</label> </label>
{rows ? <RenderTable columns={columns} data={rows} setRowsFn={updateRows}/> : null} {rows ? <RenderTable columns={columns} data={rows} setRowsFn={updateRows}/> : null}
{!isEmpty(columns) && !shouldDisableNewRows {!isEmpty(columns) && !shouldDisableNewRows

View File

@@ -1,5 +1,6 @@
import parse from 'html-react-parser'; import parse from 'html-react-parser';
import { isNil } from 'ramda';
const renderHtmlContent = (content) => parse(content); const renderHtmlContent = (content = '') => !isNil(content) ? parse(content) : '';
export default renderHtmlContent; export default renderHtmlContent;

View File

@@ -68,7 +68,6 @@ export const maxChecks = (v, num) => {
} }
export const nonEmptyTables = (v = [], tableCfg = []) => { export const nonEmptyTables = (v = [], tableCfg = []) => {
//console.log('nonEmptyTables',v)
const colsCfg = pathOr([], ['stateFieldData'], tableCfg); const colsCfg = pathOr([], ['stateFieldData'], tableCfg);
const nonPredefinedCells = colsCfg const nonPredefinedCells = colsCfg
.filter(o => !o.predefined) .filter(o => !o.predefined)
@@ -76,22 +75,24 @@ export const nonEmptyTables = (v = [], tableCfg = []) => {
let isTableValid = true; let isTableValid = true;
let atLeastOneCellFilled = false let atLeastOneCellFilled = false
// eslint-disable-next-line array-callback-return if (is(Array, v)) {
v.map((row) => { // eslint-disable-next-line array-callback-return
if (isEmpty(row)) { v.map((row) => {
isTableValid = false; if (isEmpty(row)) {
} else { isTableValid = false;
// eslint-disable-next-line array-callback-return } else {
nonPredefinedCells.map((k) => { // eslint-disable-next-line array-callback-return
if (isNil(row[k]) || isEmpty(row[k])) { nonPredefinedCells.map((k) => {
isTableValid = atLeastOneCellFilled; if (isNil(row[k]) || isEmpty(row[k])) {
} else { isTableValid = atLeastOneCellFilled;
atLeastOneCellFilled = true; } else {
isTableValid = true; atLeastOneCellFilled = true;
} isTableValid = true;
}); }
} });
}); }
});
}
return is(Array, v) ? v.length >= 1 && isTableValid : false; return is(Array, v) ? v.length >= 1 && isTableValid : false;
} }

View File

@@ -96,7 +96,7 @@ const BandoApplication = () => {
const submitApplicationCallback = (data) => { const submitApplicationCallback = (data) => {
if (data.status === 'SUCCESS') { if (data.status === 'SUCCESS') {
if (data.data.applicationStatus) { if (data.data.status) {
setApplicationStatus(data.data.status); // ask why not 'applicationStatus'? setApplicationStatus(data.data.status); // ask why not 'applicationStatus'?
} }
} }
@@ -275,7 +275,7 @@ const BandoApplication = () => {
acc[cur.fieldId] = cur.fieldValue; acc[cur.fieldId] = cur.fieldValue;
return acc; return acc;
}, {}); }, {});
reset();
setFormInitialData(formDataInitial); setFormInitialData(formDataInitial);
} }
} }
@@ -394,7 +394,7 @@ const BandoApplication = () => {
useEffect(() => { useEffect(() => {
if (formInitialData) { if (formInitialData) {
reset(); //reset();
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k])) Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]))
} }
}, [formInitialData]); }, [formInitialData]);
@@ -483,6 +483,7 @@ const BandoApplication = () => {
return acc; return acc;
}, {}); }, {});
//console.log('validations', validations, o.name)
return ['paragraph'].includes(o.name) && text return ['paragraph'].includes(o.name) && text
? <div className="appForm__content" key={o.id}>{renderHtmlContent(text.value)}</div> ? <div className="appForm__content" key={o.id}>{renderHtmlContent(text.value)}</div>

View File

@@ -176,7 +176,9 @@ const BandoView = () => {
<h2>{__('Allegati', 'gepafin')}</h2> <h2>{__('Allegati', 'gepafin')}</h2>
<div className="row rowContent"> <div className="row rowContent">
<ul> <ul>
{data.docs.map((o, i) => <li key={i}> {data.docs
.filter(o => o.source === 'CALL')
.map((o, i) => <li key={i}>
<a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a> <a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a>
</li>)} </li>)}
</ul> </ul>

View File

@@ -324,7 +324,9 @@ const BandoViewBeneficiario = () => {
<h2>{__('Allegati', 'gepafin')}</h2> <h2>{__('Allegati', 'gepafin')}</h2>
<div className="row rowContent"> <div className="row rowContent">
<ul> <ul>
{data.docs.map((o, i) => <li key={i}> {data.docs
.filter(o => o.source === 'CALL')
.map((o, i) => <li key={i}>
<a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a> <a href={o.filePath} target="_blank" rel="noreferrer">{o.name}</a>
</li>)} </li>)}
</ul> </ul>