- added proper fields for amendment note and documents;
- rewritten logic for repeater field;
This commit is contained in:
@@ -27,6 +27,7 @@ import FormField from '../../components/FormField';
|
||||
import SoccorsoComunications from '../SoccorsoEditPreInstructor/components/SoccorsoComunications';
|
||||
import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterFields';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { Editor } from 'primereact/editor';
|
||||
|
||||
const DomandaBeneficiario = () => {
|
||||
const isAsyncRequest = useStore().main.isAsyncRequest();
|
||||
@@ -69,12 +70,16 @@ const DomandaBeneficiario = () => {
|
||||
if (data.data.length) {
|
||||
const amendmentObj = data.data[0];
|
||||
setData(getFormattedData(amendmentObj));
|
||||
const formDataInitial = amendmentObj.applicationFormFields.reduce((acc, cur) => {
|
||||
let formDataInitial = amendmentObj.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
} else {
|
||||
@@ -116,6 +121,7 @@ const DomandaBeneficiario = () => {
|
||||
trigger();
|
||||
let formValues = klona(getValues());
|
||||
const newFormValues = Object.keys(formValues)
|
||||
.filter(v => v !== 'amendmentDocuments')
|
||||
.reduce((acc, cur) => {
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
@@ -128,9 +134,12 @@ const DomandaBeneficiario = () => {
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
const newAmendDocs = formValues.amendmentDocuments.map(o => o.id).join(',');
|
||||
|
||||
const submitData = {
|
||||
applicationFormFields: newFormValues,
|
||||
amendmentDocuments: newAmendDocs,
|
||||
amendmentNotes: data.amendmentNotes
|
||||
}
|
||||
const amendmentId = data.id;
|
||||
|
||||
@@ -175,6 +184,26 @@ const DomandaBeneficiario = () => {
|
||||
setData(newData);
|
||||
}
|
||||
|
||||
const renderHeader = () => {
|
||||
return (
|
||||
<span className="ql-formats">
|
||||
<button className="ql-bold" aria-label="Bold"></button>
|
||||
<button className="ql-italic" aria-label="Italic"></button>
|
||||
<button className="ql-underline" aria-label="Underline"></button>
|
||||
<button className="ql-link" aria-label="Link"></button>
|
||||
<button className="ql-list" value="ordered"></button>
|
||||
<button className="ql-header" value="2"></button>
|
||||
<button className="ql-header" value="3"></button>
|
||||
<button className="ql-blockquote"></button>
|
||||
<button className="ql-list" value="bullet"></button>
|
||||
<button className="ql-indent" value="-1"></button>
|
||||
<button className="ql-indent" value="+1"></button>
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
const header = renderHeader();
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
@@ -189,7 +218,7 @@ const DomandaBeneficiario = () => {
|
||||
{data.id
|
||||
? <h1>
|
||||
{sprintf(__('Soccorso Istruttorio: richiesta integrazione documenti per domanda #%s', 'gepafin'), id)}
|
||||
</h1> : null}
|
||||
</h1> : null}
|
||||
{dataAppl.id
|
||||
? <h1>
|
||||
{sprintf(__('Dettagli: domanda #%s', 'gepafin'), dataAppl.id)}
|
||||
@@ -298,7 +327,7 @@ const DomandaBeneficiario = () => {
|
||||
disabled={data.status === 'CLOSE'}
|
||||
type="fileupload"
|
||||
setDataFn={setValue}
|
||||
/*saveFormCallback={doUpdateAmendment}*/
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
fieldName={o.fieldId}
|
||||
label={o.label}
|
||||
control={control}
|
||||
@@ -321,18 +350,39 @@ const DomandaBeneficiario = () => {
|
||||
</ol>
|
||||
</div> : null}
|
||||
|
||||
{data.id
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<RepeaterFields
|
||||
defaultValue={data.amendmentDocuments ?? []}
|
||||
updateFn={(data) => updateNewAmendmentData(
|
||||
data,
|
||||
['amendmentDocuments']
|
||||
)}
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<div className="appPageSection">
|
||||
<h3>{__('Notes', 'gepafin')}</h3>
|
||||
<div style={{ marginBottom: '30px', width: '100%' }}>
|
||||
<Editor
|
||||
value={data.amendmentNotes}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateNewAmendmentData(
|
||||
e.htmlValue,
|
||||
'amendmentNotes'
|
||||
)}
|
||||
style={{ height: 80 * 3, width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
<FormField
|
||||
type="fileupload"
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
fieldName="amendmentDocuments"
|
||||
label={__('I file', 'gepafin')}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={formInitialData.amendmentDocuments ? formInitialData.amendmentDocuments : []}
|
||||
accept={[]}
|
||||
source="amendment"
|
||||
sourceId={data.id}
|
||||
sourceName="evaluation"/>
|
||||
</div> : null}
|
||||
multiple={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{data.id
|
||||
? <div className="appPageSection__message warning">
|
||||
@@ -371,7 +421,10 @@ const DomandaBeneficiario = () => {
|
||||
header={__('Invia documenti via PEC', 'gepafin')}
|
||||
visible={isVisibleEmailDialog}
|
||||
style={{ width: '50vw' }}
|
||||
onHide={() => {if (!isVisibleEmailDialog) return; setIsVisibleEmailDialog(false); }}>
|
||||
onHide={() => {
|
||||
if (!isVisibleEmailDialog) return;
|
||||
setIsVisibleEmailDialog(false);
|
||||
}}>
|
||||
<p className="m-0">
|
||||
{data.callEmail}
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user