- saving progress - amendment page works for both instructor and beneficiary;
This commit is contained in:
@@ -266,7 +266,6 @@ const BandoApplicationPreview = () => {
|
||||
{activeStep < totalSteps
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={'SUBMIT' === applicationStatus}
|
||||
onClick={goForward}
|
||||
label={__('Vai avanti', 'gepafin')}
|
||||
icon="pi pi-arrow-right"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
import { findIndex, propEq } from 'ramda';
|
||||
import { pathOr } from 'ramda';
|
||||
|
||||
// components
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
@@ -14,7 +14,8 @@ import uniqid from '../../../../../../helpers/uniqid';
|
||||
const ElementSettingTableColumns = ({
|
||||
value,
|
||||
name,
|
||||
setDataFn
|
||||
setDataFn,
|
||||
bandoStatus
|
||||
}) => {
|
||||
const [stateFieldData, setStateFieldData] = useState([]);
|
||||
const [rowsData, setRowsData] = useState([]);
|
||||
@@ -28,18 +29,19 @@ const ElementSettingTableColumns = ({
|
||||
setStateFieldData([...stateFieldData, { name: uniqid('o'), label: '', predefined: false }]);
|
||||
}
|
||||
|
||||
const addNewRow = (index) => {
|
||||
const newStateFieldData = wrap(stateFieldData)
|
||||
.insert([index, 'rows'], { label: '' }, stateFieldData[index].rows.length)
|
||||
.value();
|
||||
setStateFieldData(newStateFieldData);
|
||||
const addNewRow = () => {
|
||||
const obj = stateFieldData
|
||||
.filter(o => o.predefined)
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur.name] = ''
|
||||
return acc;
|
||||
}, {});
|
||||
setRowsData([...rowsData, obj]);
|
||||
}
|
||||
|
||||
const removeRow = (index, indexK) => {
|
||||
const newStateFieldData = wrap(stateFieldData)
|
||||
.del([index, 'rows', indexK])
|
||||
.value();
|
||||
setStateFieldData(newStateFieldData);
|
||||
const removeRow = (index) => {
|
||||
const newRowsData = wrap(rowsData).del([index]).value();
|
||||
setRowsData(newRowsData);
|
||||
}
|
||||
|
||||
const onInputChange = (e, index) => {
|
||||
@@ -53,24 +55,31 @@ const ElementSettingTableColumns = ({
|
||||
setStateFieldData(newData);
|
||||
}
|
||||
|
||||
const onSubInputChange = (e, index, indexK) => {
|
||||
const onSubInputChange = (e, name, index) => {
|
||||
const { value } = e.target;
|
||||
const newStateFieldData = wrap(stateFieldData)
|
||||
.set([index, 'rows', indexK, 'label'], value)
|
||||
.value();
|
||||
setStateFieldData(newStateFieldData);
|
||||
const newRowsData = wrap(rowsData).set([index, name], value).value();
|
||||
setRowsData(newRowsData);
|
||||
}
|
||||
|
||||
const setChecked = (value, index) => {
|
||||
let name = '';
|
||||
const newData = stateFieldData.map((o, i) => {
|
||||
if (i === index) {
|
||||
o.predefined = value;
|
||||
if (value === false) {
|
||||
o.rows = [];
|
||||
}
|
||||
name = o.name;
|
||||
}
|
||||
return o;
|
||||
})
|
||||
});
|
||||
|
||||
let newRowsData = [];
|
||||
|
||||
if (value === false) {
|
||||
newRowsData = rowsData.map(o => wrap(o).set([name], '').value());
|
||||
} else {
|
||||
newRowsData = rowsData.map(o => wrap(o).set([name], '').value());
|
||||
}
|
||||
|
||||
setRowsData(newRowsData);
|
||||
setStateFieldData(newData);
|
||||
}
|
||||
|
||||
@@ -79,23 +88,31 @@ const ElementSettingTableColumns = ({
|
||||
<InputText value={item.label} onInput={(e) => onInputChange(e, i)}/>
|
||||
<div className="flex-1">
|
||||
<span>{__('Predefinito?', 'gepafin')}</span>
|
||||
<InputSwitch checked={item.predefined} onChange={(e) => setChecked(e.value, i)}/>
|
||||
<InputSwitch
|
||||
checked={item.predefined}
|
||||
disabled={bandoStatus === 'PUBLISH'}
|
||||
onChange={(e) => setChecked(e.value, i)}/>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
|
||||
const properSubField = (item, i, k) => {
|
||||
return <InputText value={item.label} onInput={(e) => onSubInputChange(e, i, k)}/>
|
||||
const properSubField = (item, i, name) => {
|
||||
return <InputText value={item[name]} onInput={(e) => onSubInputChange(e, name, i)}/>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const storeFieldData = value ?? [];
|
||||
setStateFieldData(storeFieldData);
|
||||
const stateFieldData = pathOr([], ['stateFieldData'], value);
|
||||
setStateFieldData(stateFieldData);
|
||||
const rowsData = pathOr([], ['rowsData'], value);
|
||||
setRowsData(rowsData);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setDataFn(name, [...stateFieldData]);
|
||||
}, [stateFieldData]);
|
||||
setDataFn(name, {
|
||||
stateFieldData,
|
||||
rowsData
|
||||
});
|
||||
}, [stateFieldData, rowsData]);
|
||||
|
||||
stateFieldData.filter(o => o.predefined)
|
||||
|
||||
@@ -105,10 +122,10 @@ const ElementSettingTableColumns = ({
|
||||
{stateFieldData.map((o, i) => <div key={i} className="formElementSettings__repeaterItem">
|
||||
<div className="p-inputgroup flex-1">
|
||||
{properField(o, i)}
|
||||
<Button icon="pi pi-times" className="p-button-danger" onClick={() => removeItem(i)}/>
|
||||
<Button icon="pi pi-times" disabled={bandoStatus === 'PUBLISH'} className="p-button-danger" onClick={() => removeItem(i)}/>
|
||||
</div>
|
||||
</div>)}
|
||||
<Button type="button" outlined label={__('Aggiungi', 'gepafin')} onClick={addNewItem}/>
|
||||
<Button type="button" disabled={bandoStatus === 'PUBLISH'} outlined label={__('Aggiungi', 'gepafin')} onClick={addNewItem}/>
|
||||
</div>
|
||||
{stateFieldData
|
||||
.filter(o => o.predefined)
|
||||
@@ -116,19 +133,22 @@ const ElementSettingTableColumns = ({
|
||||
<div className="formElementSettings__repeater formElementSettings__subRepeater">
|
||||
<label>{__('Righe per colonna:', 'gepafin')} <strong>{o.label}</strong></label>
|
||||
<div className="formElementSettings__repeater">
|
||||
{o.rows.map((c, k) => {
|
||||
const properIndex = findIndex(propEq(o.name, 'name'))(stateFieldData);
|
||||
{rowsData.map((c, k) => {
|
||||
return <div key={k} className="formElementSettings__repeaterItem">
|
||||
<div className="p-inputgroup flex-1">
|
||||
{properSubField(c, properIndex, k)}
|
||||
<Button icon="pi pi-times" className="p-button-danger"
|
||||
onClick={() => removeRow(properIndex, k)}/>
|
||||
{properSubField(c, k, o.name)}
|
||||
<Button icon="pi pi-times"
|
||||
disabled={bandoStatus === 'PUBLISH'}
|
||||
className="p-button-danger"
|
||||
onClick={() => removeRow(k)}/>
|
||||
</div>
|
||||
</div>
|
||||
})}
|
||||
<Button type="button" outlined
|
||||
<Button type="button"
|
||||
outlined
|
||||
disabled={bandoStatus === 'PUBLISH'}
|
||||
label={__('Aggiungi una riga', 'gepafin')}
|
||||
onClick={() => addNewRow(findIndex(propEq(o.name, 'name'))(stateFieldData))}/>
|
||||
onClick={addNewRow}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>)}
|
||||
|
||||
@@ -78,7 +78,7 @@ const DomandaBeneficiario = () => {
|
||||
}, {});
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.amendmentDocuments
|
||||
amendmentDocuments: amendmentObj.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
@@ -108,7 +108,7 @@ const DomandaBeneficiario = () => {
|
||||
}
|
||||
|
||||
const getFormattedData = (data) => {
|
||||
data.submissionDate = is(String, data.submissionDate) ? new Date(data.submissionDate) : (data.submissionDate ? data.submissionDate : '');
|
||||
data.evaluationEndDate = is(String, data.evaluationEndDate) ? new Date(data.evaluationEndDate) : (data.evaluationEndDate ? data.evaluationEndDate : '');
|
||||
data.startDate = is(String, data.startDate) ? new Date(data.startDate) : (data.startDate ? data.startDate : '');
|
||||
data.expirationDate = is(String, data.expirationDate) ? new Date(data.expirationDate) : (data.expirationDate ? data.expirationDate : '');
|
||||
return data;
|
||||
@@ -156,13 +156,17 @@ const DomandaBeneficiario = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
const newFormDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
setFormInitialData(newFormDataInitial);
|
||||
}, {});
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.data.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -350,13 +354,15 @@ const DomandaBeneficiario = () => {
|
||||
</ol>
|
||||
</div> : null}
|
||||
|
||||
<div className="appPageSection">
|
||||
{data.id
|
||||
? <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}
|
||||
readOnly={data.status === 'CLOSE'}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateNewAmendmentData(
|
||||
@@ -368,6 +374,7 @@ const DomandaBeneficiario = () => {
|
||||
</div>
|
||||
<FormField
|
||||
type="fileupload"
|
||||
disabled={data.status === 'CLOSE'}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
fieldName="amendmentDocuments"
|
||||
@@ -382,7 +389,7 @@ const DomandaBeneficiario = () => {
|
||||
multiple={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div> : null}
|
||||
|
||||
{data.id
|
||||
? <div className="appPageSection__message warning">
|
||||
@@ -400,12 +407,13 @@ const DomandaBeneficiario = () => {
|
||||
onClick={() => setIsVisibleEmailDialog(true)}
|
||||
label={__('Invia documenti via PEC', 'gepafin')}
|
||||
icon="pi pi-envelope" iconPos="right"/> : null}
|
||||
<Button
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest}
|
||||
onClick={doUpdateAmendment}
|
||||
label={__('Salva', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
icon="pi pi-save" iconPos="right"/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
outlined
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Button } from 'primereact/button';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { isNil } from 'ramda';
|
||||
import ArchiveDocument from '../ArchiveDocument';
|
||||
import renderHtmlContent from '../../../../helpers/renderHtmlContent';
|
||||
|
||||
const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applicationId }) => {
|
||||
|
||||
@@ -10,15 +11,15 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
||||
<ol className="appPageSection__list">
|
||||
{files.map((o, i) => <li key={o.id} className="appPageSection__listItem">
|
||||
<div className="appPageSection__listItemRow">
|
||||
<span>{o.label}</span>
|
||||
<div>{renderHtmlContent(o.label)}</div>
|
||||
<div className="appPageSection__iconActions">
|
||||
{o.fileDetail && o.fileDetail.length === 1
|
||||
? <div className="appPageSection__iconActions">
|
||||
<Button icon="pi pi-eye" rounded
|
||||
? <Button icon="pi pi-eye" rounded
|
||||
onClick={() => {
|
||||
window.open(o.fileDetail[0].filePath, '_blank').focus()
|
||||
}}
|
||||
outlined severity="info"
|
||||
aria-label={__('Mostra', 'gepafin')}/>
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableFieldFn(name)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
@@ -35,7 +36,7 @@ const ListOfFiles = ({ files, updateFn, shouldDisableFieldFn, name, ndg, applica
|
||||
[name, i, 'valid']
|
||||
)}
|
||||
aria-label={__('Giu', 'gepafin')}/>
|
||||
</div> : null}
|
||||
</div>
|
||||
</div>
|
||||
{o.fileDetail && o.fileDetail.length > 1
|
||||
? <ul style={{
|
||||
|
||||
@@ -605,34 +605,34 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/*<div className="appPageSection">
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti di soccorso', 'gepafin')}</h2>
|
||||
{data.amendmentDetails
|
||||
.filter(o => o.amendmentDocuments && !isEmpty(o.amendmentDocuments)
|
||||
|| o.formFieldDocuments && !isEmpty(o.formFieldDocuments))
|
||||
.map(o => {
|
||||
const aDocs = pathOr([],['amendmentDocuments'], o)
|
||||
.map(o => ({
|
||||
id: o.fieldId,
|
||||
label: o.nameValue,
|
||||
fileDetail: o.fileValue,
|
||||
valid: o.valid
|
||||
}));
|
||||
const aDocs = pathOr([],['amendmentDocuments'], o);
|
||||
const aNotes = pathOr('',['amendmentNotes'], o);
|
||||
const aValid = pathOr(null,['valid'], o);
|
||||
const aDocsObj = {
|
||||
id: o.amendmentId,
|
||||
label: aNotes,
|
||||
fileDetail: aDocs,
|
||||
valid: aValid
|
||||
}
|
||||
const fDocs = pathOr([],['formFieldDocuments'], o);
|
||||
|
||||
return {
|
||||
id: o.id,
|
||||
files: [...aDocs, ...fDocs]
|
||||
files: [aDocsObj, ...fDocs]
|
||||
}
|
||||
})
|
||||
.map(o => <ListOfFiles
|
||||
.map((o, i) => <ListOfFiles
|
||||
key={`list_${i}`}
|
||||
files={o.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={shouldDisableField}
|
||||
name="files"
|
||||
name="amendmentDetails"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>)}
|
||||
</div>*/}
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Punteggi di valutazione', 'gepafin')}</h2>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { is, uniq } from 'ramda';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
@@ -21,6 +21,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [, setStatuses] = useState([]);
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
setLocalAsyncRequest(true);
|
||||
@@ -113,14 +114,15 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
return <div className="appPageSection__tableActions lessGap">
|
||||
{openDialogFn
|
||||
{openDialogFn && rowData.applicationStatus === 'SUBMIT'
|
||||
? <Button severity="info"
|
||||
onClick={() => openDialogFn(rowData.id)}
|
||||
label={__('Assegnare', 'gepafin')}
|
||||
icon="pi pi-pencil" size="small" iconPos="right"/>
|
||||
: <Link to={'/domande'}>
|
||||
: location.pathname !== '/domande'
|
||||
? <Link to={'/domande'}>
|
||||
<Button severity="info" label={__('Gestire', 'gepafin')} size="small"/>
|
||||
</Link>}
|
||||
</Link> : null}
|
||||
<Link to={`/domande/${rowData.id}`}>
|
||||
<Button severity="info" label={__('Anteprima', 'gepafin')} icon="pi pi-eye" size="small"
|
||||
iconPos="right"/>
|
||||
|
||||
@@ -65,7 +65,7 @@ const Domande = () => {
|
||||
}
|
||||
|
||||
const headerEditDialog = () => {
|
||||
return <span>{__('Assign application', 'gepafin')}</span>
|
||||
return <span>{__('Assegni la domanda', 'gepafin')}</span>
|
||||
}
|
||||
|
||||
const hideEditDialog = () => {
|
||||
|
||||
@@ -72,7 +72,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
}, {});
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.amendmentDocuments
|
||||
amendmentDocuments: data.data.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
@@ -162,13 +162,17 @@ const SoccorsoEditPreInstructor = () => {
|
||||
detail: data.message
|
||||
});
|
||||
}
|
||||
const newFormDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
let formDataInitial = data.data.applicationFormFields.reduce((acc, cur) => {
|
||||
if (cur.fieldValue) {
|
||||
acc[cur.fieldId] = cur.fieldValue;
|
||||
}
|
||||
return acc;
|
||||
}, formInitialData);
|
||||
setFormInitialData(newFormDataInitial);
|
||||
formDataInitial = {
|
||||
...formDataInitial,
|
||||
amendmentDocuments: data.data.amendmentDocuments
|
||||
}
|
||||
setFormInitialData(formDataInitial);
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -225,7 +229,8 @@ const SoccorsoEditPreInstructor = () => {
|
||||
});
|
||||
}
|
||||
if (data.data.status) {
|
||||
updateNewAmendmentData(data.data.status, ['status'])
|
||||
updateNewAmendmentData(data.data.status, ['status']);
|
||||
setIsVisibleCloseAmendDialog(false);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
@@ -448,7 +453,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<h2>{__('Documenti aggiuntivi', 'gepafin')}</h2>
|
||||
<div className="appPageSection columns">
|
||||
<div className="appPageSection">
|
||||
{data.amendmentNotes
|
||||
? <>
|
||||
<h3>{__('Notes', 'gepafin')}</h3>
|
||||
@@ -458,6 +463,7 @@ const SoccorsoEditPreInstructor = () => {
|
||||
</> : null}
|
||||
<FormField
|
||||
type="fileupload"
|
||||
disabled={data.status === 'CLOSE'}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doUpdateAmendment}
|
||||
fieldName="amendmentDocuments"
|
||||
@@ -482,12 +488,12 @@ const SoccorsoEditPreInstructor = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
<Button
|
||||
{/*<Button
|
||||
type="button"
|
||||
disabled={isAsyncRequest}
|
||||
onClick={doUpdateAmendment}
|
||||
label={__('Salva', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
icon="pi pi-save" iconPos="right"/>*/}
|
||||
<Button
|
||||
type="button"
|
||||
onClick={sendReminder}
|
||||
|
||||
Reference in New Issue
Block a user