- saving progress;
This commit is contained in:
@@ -26,6 +26,7 @@ import { Dialog } from 'primereact/dialog';
|
|||||||
import FormField from '../../components/FormField';
|
import FormField from '../../components/FormField';
|
||||||
import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications';
|
import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications';
|
||||||
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
||||||
|
import { wrap } from 'object-path-immutable';
|
||||||
|
|
||||||
const DomandaBeneficiario = () => {
|
const DomandaBeneficiario = () => {
|
||||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||||
@@ -169,6 +170,11 @@ const DomandaBeneficiario = () => {
|
|||||||
storeSet.main.unsetAsyncRequest();
|
storeSet.main.unsetAsyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateNewAmendmentData = (value, path) => {
|
||||||
|
const newData = wrap(data).set(path, value).value();
|
||||||
|
setData(newData);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (formInitialData) {
|
if (formInitialData) {
|
||||||
//reset();
|
//reset();
|
||||||
@@ -277,9 +283,9 @@ const DomandaBeneficiario = () => {
|
|||||||
|
|
||||||
{data.id
|
{data.id
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
<h2>{__('Documenti richiesti', 'gepafin')}</h2>
|
<h2>{__('Comunicazioni', 'gepafin')}</h2>
|
||||||
<RepeaterFields sourceId={id} sourceName="evaluation"/>
|
<SoccorsoComunications amendmentId={data.id} soccorsoStatus={data.status}/>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{data.id
|
{data.id
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
@@ -292,7 +298,7 @@ const DomandaBeneficiario = () => {
|
|||||||
disabled={data.status === 'CLOSE'}
|
disabled={data.status === 'CLOSE'}
|
||||||
type="fileupload"
|
type="fileupload"
|
||||||
setDataFn={setValue}
|
setDataFn={setValue}
|
||||||
saveFormCallback={doUpdateAmendment}
|
/*saveFormCallback={doUpdateAmendment}*/
|
||||||
fieldName={o.fieldId}
|
fieldName={o.fieldId}
|
||||||
label={o.label}
|
label={o.label}
|
||||||
control={control}
|
control={control}
|
||||||
@@ -307,18 +313,25 @@ const DomandaBeneficiario = () => {
|
|||||||
}) : null}
|
}) : null}
|
||||||
</form>
|
</form>
|
||||||
<ol className="appPageSection__list">
|
<ol className="appPageSection__list">
|
||||||
{data.formFields
|
{data.formFields
|
||||||
? data.formFields.map((o, i) => <li key={o.fieldId}
|
? data.formFields.map((o, i) => <li key={o.fieldId}
|
||||||
style={{ flexDirection: 'row' }}>
|
style={{ flexDirection: 'row' }}>
|
||||||
<span>{o.label}</span>
|
<span>{o.label}</span>
|
||||||
</li>) : null}
|
</li>) : null}
|
||||||
</ol>
|
</ol>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{data.id
|
{data.id
|
||||||
? <div className="appPageSection">
|
? <div className="appPageSection">
|
||||||
<h2>{__('Comunicazioni', 'gepafin')}</h2>
|
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||||
<SoccorsoComunications amendmentId={data.id} soccorsoStatus={data.status}/>
|
<RepeaterFields
|
||||||
|
defaultValue={data.amendmentDocuments ?? []}
|
||||||
|
updateFn={(data) => updateNewAmendmentData(
|
||||||
|
data,
|
||||||
|
['amendmentDocuments']
|
||||||
|
)}
|
||||||
|
sourceId={data.id}
|
||||||
|
sourceName="evaluation"/>
|
||||||
</div> : null}
|
</div> : null}
|
||||||
|
|
||||||
{data.id
|
{data.id
|
||||||
@@ -337,6 +350,12 @@ const DomandaBeneficiario = () => {
|
|||||||
onClick={() => setIsVisibleEmailDialog(true)}
|
onClick={() => setIsVisibleEmailDialog(true)}
|
||||||
label={__('Invia documenti via PEC', 'gepafin')}
|
label={__('Invia documenti via PEC', 'gepafin')}
|
||||||
icon="pi pi-envelope" iconPos="right"/> : null}
|
icon="pi pi-envelope" iconPos="right"/> : null}
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
disabled={isAsyncRequest}
|
||||||
|
onClick={doUpdateAmendment}
|
||||||
|
label={__('Salva', 'gepafin')}
|
||||||
|
icon="pi pi-save" iconPos="right"/>
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
outlined
|
outlined
|
||||||
|
|||||||
@@ -11,31 +11,31 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
|||||||
{files.map((o, i) => <li key={o.id} className="appPageSection__listItem">
|
{files.map((o, i) => <li key={o.id} className="appPageSection__listItem">
|
||||||
<div className="appPageSection__listItemRow">
|
<div className="appPageSection__listItemRow">
|
||||||
<span>{o.label}</span>
|
<span>{o.label}</span>
|
||||||
<div className="appPageSection__iconActions">
|
{o.fileDetail && o.fileDetail.length === 1
|
||||||
{o.fileDetail && o.fileDetail.length === 1
|
? <div className="appPageSection__iconActions">
|
||||||
? <Button icon="pi pi-eye" rounded
|
<Button icon="pi pi-eye" rounded
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(o.fileDetail[0].filePath, '_blank').focus()
|
window.open(o.fileDetail[0].filePath, '_blank').focus()
|
||||||
}}
|
}}
|
||||||
outlined severity="info"
|
outlined severity="info"
|
||||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
aria-label={__('Mostra', 'gepafin')}/>
|
||||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||||
disabled={shouldDisableFieldFn(name)}
|
disabled={shouldDisableFieldFn(name)}
|
||||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||||
onClick={() => updateFn(
|
onClick={() => updateFn(
|
||||||
true,
|
true,
|
||||||
[name, i, 'valid']
|
[name, i, 'valid']
|
||||||
)}
|
)}
|
||||||
aria-label={__('Su', 'gepafin')}/>
|
aria-label={__('Su', 'gepafin')}/>
|
||||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||||
disabled={shouldDisableFieldFn(name)}
|
disabled={shouldDisableFieldFn(name)}
|
||||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||||
onClick={() => updateFn(
|
onClick={() => updateFn(
|
||||||
false,
|
false,
|
||||||
[name, i, 'valid']
|
[name, i, 'valid']
|
||||||
)}
|
)}
|
||||||
aria-label={__('Giu', 'gepafin')}/>
|
aria-label={__('Giu', 'gepafin')}/>
|
||||||
</div>
|
</div> : null}
|
||||||
</div>
|
</div>
|
||||||
{o.fileDetail && o.fileDetail.length > 1
|
{o.fileDetail && o.fileDetail.length > 1
|
||||||
? <ul style={{
|
? <ul style={{
|
||||||
@@ -53,7 +53,8 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
|||||||
}}>
|
}}>
|
||||||
<span>{k.name}</span>
|
<span>{k.name}</span>
|
||||||
<div className="appPageSection__iconActions">
|
<div className="appPageSection__iconActions">
|
||||||
<ArchiveDocument ndg={ndg} applicationId={applicationId} fileId={k.id} docAttachmentId={k.documentAttachmentId}/>
|
<ArchiveDocument ndg={ndg} applicationId={applicationId} fileId={k.id}
|
||||||
|
docAttachmentId={k.documentAttachmentId}/>
|
||||||
<Button icon="pi pi-eye" rounded
|
<Button icon="pi pi-eye" rounded
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.open(k.filePath, '_blank').focus()
|
window.open(k.filePath, '_blank').focus()
|
||||||
|
|||||||
@@ -13,9 +13,12 @@ import { Button } from 'primereact/button';
|
|||||||
const RepeaterFields = ({
|
const RepeaterFields = ({
|
||||||
sourceId,
|
sourceId,
|
||||||
sourceName,
|
sourceName,
|
||||||
updateFn = () => {},
|
updateFn = () => {
|
||||||
defaultValue = []
|
},
|
||||||
}) => {
|
defaultValue = [],
|
||||||
|
updateCallbackFn = () => {
|
||||||
|
}
|
||||||
|
}) => {
|
||||||
const [items, setItems] = useState([]);
|
const [items, setItems] = useState([]);
|
||||||
const [chosen, setChosen] = useState('');
|
const [chosen, setChosen] = useState('');
|
||||||
const [formInitialData, setFormInitialData] = useState({});
|
const [formInitialData, setFormInitialData] = useState({});
|
||||||
@@ -27,7 +30,8 @@ const RepeaterFields = ({
|
|||||||
register,
|
register,
|
||||||
trigger,
|
trigger,
|
||||||
reset,
|
reset,
|
||||||
watch
|
watch,
|
||||||
|
getValues
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: useMemo(() => {
|
defaultValues: useMemo(() => {
|
||||||
return formInitialData;
|
return formInitialData;
|
||||||
@@ -51,8 +55,7 @@ const RepeaterFields = ({
|
|||||||
const newItem = {
|
const newItem = {
|
||||||
fieldId: uid,
|
fieldId: uid,
|
||||||
nameValue: '',
|
nameValue: '',
|
||||||
fileValue: [],
|
fileValue: []
|
||||||
valid: true
|
|
||||||
}
|
}
|
||||||
setItems([...items, newItem]);
|
setItems([...items, newItem]);
|
||||||
setChosen(uid);
|
setChosen(uid);
|
||||||
@@ -93,7 +96,7 @@ const RepeaterFields = ({
|
|||||||
...o,
|
...o,
|
||||||
fileValue: watchFile
|
fileValue: watchFile
|
||||||
} : o;
|
} : o;
|
||||||
})
|
});
|
||||||
setItems([...updatedItems]);
|
setItems([...updatedItems]);
|
||||||
}, [watchFile]);
|
}, [watchFile]);
|
||||||
|
|
||||||
@@ -105,7 +108,6 @@ const RepeaterFields = ({
|
|||||||
setItems(defaultValue);
|
setItems(defaultValue);
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
console.log('items', items, chosen);
|
|
||||||
return (
|
return (
|
||||||
<div className="fieldsRepeater">
|
<div className="fieldsRepeater">
|
||||||
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
<form className="appForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
@@ -157,7 +159,7 @@ const RepeaterFields = ({
|
|||||||
className="fieldsRepeater__addNew"
|
className="fieldsRepeater__addNew"
|
||||||
outlined
|
outlined
|
||||||
type="button"
|
type="button"
|
||||||
/*disabled={!isEmpty(chosen.fileId) && (isEmpty(chosen.name) || isEmpty(chosen.file))}*/
|
disabled={!isEmpty(chosen.fileId) && (isEmpty(watchName) || isEmpty(watchFile))}
|
||||||
onClick={addNew}
|
onClick={addNew}
|
||||||
label={__('Aggiungi nuovo file', 'gepafin')}
|
label={__('Aggiungi nuovo file', 'gepafin')}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ const DomandaEditPreInstructor = () => {
|
|||||||
|
|
||||||
const doNewSoccorso = () => {
|
const doNewSoccorso = () => {
|
||||||
if (connectedSoccorsoId !== 0) {
|
if (connectedSoccorsoId !== 0) {
|
||||||
doSaveDraft(`/domande/${id}/soccorso/${connectedSoccorsoId}`)
|
navigate(`/domande/${id}/soccorso/${connectedSoccorsoId}`);
|
||||||
} else {
|
} else {
|
||||||
doSaveDraft(`/domande/${id}/aggiungi-soccorso/`)
|
doSaveDraft(`/domande/${id}/aggiungi-soccorso/`)
|
||||||
}
|
}
|
||||||
@@ -605,16 +605,34 @@ const DomandaEditPreInstructor = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/*<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Documenti di soccorso', 'gepafin')}</h2>
|
<h2>{__('Documenti di soccorso', 'gepafin')}</h2>
|
||||||
<ListOfFiles
|
{data.amendmentDetails
|
||||||
files={data.files}
|
.filter(o => o.amendmentDocuments && !isEmpty(o.amendmentDocuments)
|
||||||
updateFn={updateEvaluationValue}
|
|| o.formFieldDocuments && !isEmpty(o.formFieldDocuments))
|
||||||
shouldDisableFieldFn={shouldDisableField}
|
.map(o => {
|
||||||
name="files"
|
const aDocs = pathOr([],['amendmentDocuments'], o)
|
||||||
ndg={data.ndg}
|
.map(o => ({
|
||||||
applicationId={id}/>
|
id: o.fieldId,
|
||||||
</div>*/}
|
label: o.nameValue,
|
||||||
|
fileDetail: o.fileValue,
|
||||||
|
valid: o.valid
|
||||||
|
}));
|
||||||
|
const fDocs = pathOr([],['formFieldDocuments'], o);
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: o.id,
|
||||||
|
files: [...aDocs, ...fDocs]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(o => <ListOfFiles
|
||||||
|
files={o.files}
|
||||||
|
updateFn={updateEvaluationValue}
|
||||||
|
shouldDisableFieldFn={shouldDisableField}
|
||||||
|
name="files"
|
||||||
|
ndg={data.ndg}
|
||||||
|
applicationId={id}/>)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
||||||
|
|||||||
@@ -324,10 +324,7 @@ const SoccorsoEditPreInstructor = () => {
|
|||||||
AmendmentsService.getSoccorsoById(getCallback, errGetCallback, [['id', soccorsoEntityId]]);
|
AmendmentsService.getSoccorsoById(getCallback, errGetCallback, [['id', soccorsoEntityId]]);
|
||||||
}, [amendmentId]);
|
}, [amendmentId]);
|
||||||
|
|
||||||
useEffect(() => {
|
console.log('data', data.amendmentDocuments);
|
||||||
console.log(data);
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPage">
|
<div className="appPage">
|
||||||
<div className="appPage__pageHeader">
|
<div className="appPage__pageHeader">
|
||||||
@@ -426,7 +423,7 @@ const SoccorsoEditPreInstructor = () => {
|
|||||||
defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []}
|
defaultValue={formInitialData[o.fieldId] ? formInitialData[o.fieldId] : []}
|
||||||
accept={[]}
|
accept={[]}
|
||||||
source="AMENDMENT"
|
source="AMENDMENT"
|
||||||
sourceId={data.applicationId}
|
sourceId={amendmentId}
|
||||||
multiple={true}
|
multiple={true}
|
||||||
/>
|
/>
|
||||||
})}
|
})}
|
||||||
@@ -435,14 +432,15 @@ const SoccorsoEditPreInstructor = () => {
|
|||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||||
<RepeaterFields
|
{data.id
|
||||||
|
? <RepeaterFields
|
||||||
defaultValue={data.amendmentDocuments ?? []}
|
defaultValue={data.amendmentDocuments ?? []}
|
||||||
updateFn={(data) => updateNewAmendmentData(
|
updateFn={(data) => updateNewAmendmentData(
|
||||||
data,
|
data,
|
||||||
['amendmentDocuments']
|
['amendmentDocuments']
|
||||||
)}
|
)}
|
||||||
sourceId={amendmentId}
|
sourceId={amendmentId}
|
||||||
sourceName="AMENDMENT"/>
|
sourceName="AMENDMENT"/> : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appForm__field">
|
<div className="appForm__field">
|
||||||
|
|||||||
Reference in New Issue
Block a user