- added preview of application for beneficiary;
- added isRequestedAmount setting;
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
import { flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table';
|
||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
|
||||||
const RenderTable = ({ data, columns, setRowsFn }) => {
|
const RenderTable = ({ data, columns, setRowsFn, disabled }) => {
|
||||||
const table = useReactTable({
|
const table = useReactTable({
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
@@ -16,6 +16,7 @@ const RenderTable = ({ data, columns, setRowsFn }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
|
disabled={disabled}
|
||||||
value={initialValue ? initialValue : ''}
|
value={initialValue ? initialValue : ''}
|
||||||
onChange={(e) => table.options.meta?.updateData(index, id, e.target.value)}
|
onChange={(e) => table.options.meta?.updateData(index, id, e.target.value)}
|
||||||
onBlur={onBlur}
|
onBlur={onBlur}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ const Table = ({
|
|||||||
label,
|
label,
|
||||||
register,
|
register,
|
||||||
errors,
|
errors,
|
||||||
|
disabled = false,
|
||||||
config = {},
|
config = {},
|
||||||
defaultValue = [],
|
defaultValue = [],
|
||||||
tableColumns = []
|
tableColumns = []
|
||||||
@@ -29,6 +30,9 @@ const Table = ({
|
|||||||
const [rowIndexToDelete, rowRowIndexToDelete] = useState(null);
|
const [rowIndexToDelete, rowRowIndexToDelete] = useState(null);
|
||||||
|
|
||||||
const addNewRow = () => {
|
const addNewRow = () => {
|
||||||
|
if (disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const obj = columnsCfg
|
const obj = columnsCfg
|
||||||
.reduce((acc, cur) => {
|
.reduce((acc, cur) => {
|
||||||
acc[cur.name] = ''
|
acc[cur.name] = ''
|
||||||
@@ -94,6 +98,7 @@ const Table = ({
|
|||||||
header: () => '',
|
header: () => '',
|
||||||
footer: (props) => props.column.id,
|
footer: (props) => props.column.id,
|
||||||
cell: ({row: { index }}) => <Button
|
cell: ({row: { index }}) => <Button
|
||||||
|
disabled={disabled}
|
||||||
type="button"
|
type="button"
|
||||||
icon="pi pi-times"
|
icon="pi pi-times"
|
||||||
className="p-button-danger"
|
className="p-button-danger"
|
||||||
@@ -139,9 +144,11 @@ const Table = ({
|
|||||||
{label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
|
{label}{config.required || config.isRequired || (config.validate && config.validate.nonEmptyTables)
|
||||||
? <span className="appForm__field--required">*</span> : null}
|
? <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} disabled={disabled}/> : null}
|
||||||
{!isEmpty(columns) && !shouldDisableNewRows
|
{!isEmpty(columns) && !shouldDisableNewRows
|
||||||
? <div className="addNewTableRow" onClick={addNewRow}>{__('Aggiungi una riga', 'gepafin')}</div>
|
? <div className="addNewTableRow" onClick={addNewRow}>
|
||||||
|
{__('Aggiungi una riga', 'gepafin')}
|
||||||
|
</div>
|
||||||
: null}
|
: null}
|
||||||
</>)
|
</>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,31 +155,6 @@ const BandoApplicationPreview = () => {
|
|||||||
user: {}
|
user: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/*if (company) {
|
|
||||||
dynamicData = Object.keys(company).reduce((acc, cur) => {
|
|
||||||
if ([
|
|
||||||
'companyName', 'vatNumber', 'codiceFiscale', 'address', 'phoneNumber',
|
|
||||||
'city', 'province', 'cap', 'country', 'pec', 'email', 'contactName', 'contactEmail'
|
|
||||||
].includes(cur)) {
|
|
||||||
acc.company[cur] = company[cur];
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, dynamicData);
|
|
||||||
}
|
|
||||||
|
|
||||||
const userData = storeGet.main.userData();
|
|
||||||
Object.keys(userData).reduce((acc, cur) => {
|
|
||||||
if ([
|
|
||||||
'email', 'firstName', 'lastName', 'phoneNumber', 'codiceFiscale'
|
|
||||||
].includes(cur)) {
|
|
||||||
acc.user[cur] = userData[cur];
|
|
||||||
}
|
|
||||||
if (['dateOfBirth'].includes(cur)) {
|
|
||||||
acc.user[cur] = new Date(userData[cur]);
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, dynamicData);*/
|
|
||||||
|
|
||||||
if (data.data.applicationFormResponse.content) {
|
if (data.data.applicationFormResponse.content) {
|
||||||
// eslint-disable-next-line array-callback-return
|
// eslint-disable-next-line array-callback-return
|
||||||
data.data.applicationFormResponse.content.map((o) => {
|
data.data.applicationFormResponse.content.map((o) => {
|
||||||
@@ -252,14 +227,13 @@ const BandoApplicationPreview = () => {
|
|||||||
{activeStep > 1 && activeStep <= totalSteps
|
{activeStep > 1 && activeStep <= totalSteps
|
||||||
? <Button
|
? <Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={goBackward}
|
onClick={goBackward}
|
||||||
label={__('Vai indietro', 'gepafin')}
|
label={__('Vai indietro', 'gepafin')}
|
||||||
icon="pi pi-arrow-left"
|
icon="pi pi-arrow-left"
|
||||||
iconPos="left"/> : null}
|
iconPos="left"/> : null}
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={isAsyncRequest || 'SUBMIT' === applicationStatus}
|
disabled={isAsyncRequest}
|
||||||
onClick={saveDraft}
|
onClick={saveDraft}
|
||||||
outlined
|
outlined
|
||||||
label={__('Controlla', 'gepafin')} icon="pi pi-verified" iconPos="right"/>
|
label={__('Controlla', 'gepafin')} icon="pi pi-verified" iconPos="right"/>
|
||||||
@@ -270,14 +244,8 @@ const BandoApplicationPreview = () => {
|
|||||||
label={__('Vai avanti', 'gepafin')}
|
label={__('Vai avanti', 'gepafin')}
|
||||||
icon="pi pi-arrow-right"
|
icon="pi pi-arrow-right"
|
||||||
iconPos="right"/> : null}
|
iconPos="right"/> : null}
|
||||||
{/*<Button
|
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
label={__('Convalidare', 'gepafin')}
|
|
||||||
icon="pi pi-check"
|
|
||||||
iconPos="right"/>*/}
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={'SUBMIT' === applicationStatus}
|
|
||||||
onClick={onDownloadApplicationPdf}
|
onClick={onDownloadApplicationPdf}
|
||||||
label={__('Scarica PDF', 'gepafin')}
|
label={__('Scarica PDF', 'gepafin')}
|
||||||
icon="pi pi-download"
|
icon="pi pi-download"
|
||||||
@@ -372,7 +340,7 @@ const BandoApplicationPreview = () => {
|
|||||||
: <FormField
|
: <FormField
|
||||||
key={o.id}
|
key={o.id}
|
||||||
type={o.name}
|
type={o.name}
|
||||||
disabled={o.name === 'fileupload'}
|
disabled={o.name === 'fileupload' || 'DRAFT' !== applicationStatus}
|
||||||
fieldName={o.id}
|
fieldName={o.id}
|
||||||
label={label ? label.value : ''}
|
label={label ? label.value : ''}
|
||||||
placeholder={placeholder ? placeholder.value : ''}
|
placeholder={placeholder ? placeholder.value : ''}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
|||||||
</div>
|
</div>
|
||||||
: <div ref={ref} className="formBuilder__element" style={{ opacity }} data-handler-id={handlerId}>
|
: <div ref={ref} className="formBuilder__element" style={{ opacity }} data-handler-id={handlerId}>
|
||||||
<div className="meta">
|
<div className="meta">
|
||||||
<Tag value={name} severity="info"/>
|
<Tag value={label} severity="info"/>
|
||||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||||
</div>
|
</div>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Editor } from 'primereact/editor';
|
|||||||
|
|
||||||
import { mimeTypes } from '../../../../../../configData';
|
import { mimeTypes } from '../../../../../../configData';
|
||||||
import ElementSettingTableColumns from '../ElementSettingTableColumns';
|
import ElementSettingTableColumns from '../ElementSettingTableColumns';
|
||||||
|
import { InputSwitch } from 'primereact/inputswitch';
|
||||||
|
|
||||||
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
|||||||
label: __('Label', 'gepafin'),
|
label: __('Label', 'gepafin'),
|
||||||
placeholder: __('Segnaposto', 'gepafin'),
|
placeholder: __('Segnaposto', 'gepafin'),
|
||||||
step: __('Numero Decimali', 'gepafin'),
|
step: __('Numero Decimali', 'gepafin'),
|
||||||
|
isRequestedAmount: __('Importo richiesto', 'gepafin'),
|
||||||
options: __('Opzioni', 'gepafin'),
|
options: __('Opzioni', 'gepafin'),
|
||||||
mime: __('Tipo di file', 'gepafin'),
|
mime: __('Tipo di file', 'gepafin'),
|
||||||
text: __('Testo formattato', 'gepafin'),
|
text: __('Testo formattato', 'gepafin'),
|
||||||
@@ -78,6 +80,10 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
|||||||
name={setting.name}
|
name={setting.name}
|
||||||
bandoStatus={bandoStatus}
|
bandoStatus={bandoStatus}
|
||||||
setDataFn={updateDataFn}/>
|
setDataFn={updateDataFn}/>
|
||||||
|
} else if (setting.name === 'isRequestedAmount') {
|
||||||
|
return <InputSwitch
|
||||||
|
checked={setting.value}
|
||||||
|
onChange={(e) => changeFn(e.value, setting.name)}/>
|
||||||
} else {
|
} else {
|
||||||
return <InputText id={setting.name} aria-describedby={`${setting.name}-help`}
|
return <InputText id={setting.name} aria-describedby={`${setting.name}-help`}
|
||||||
value={setting.value}
|
value={setting.value}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { klona } from 'klona';
|
|||||||
import { wrap } from 'object-path-immutable';
|
import { wrap } from 'object-path-immutable';
|
||||||
|
|
||||||
// store
|
// store
|
||||||
import { storeSet, useStore } from '../../../../store';
|
import { storeGet, storeSet, useStore } from '../../../../store';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
@@ -128,10 +128,20 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const chosen = head(elements.filter(o => o.id === activeElement));
|
const chosen = head(elements.filter(o => o.id === activeElement));
|
||||||
|
const elementItems = storeGet.main.elementItems();
|
||||||
|
const chosenElementItemCfg = head(elementItems.filter(o => o.name === chosen.name));
|
||||||
|
let settings = [];
|
||||||
|
|
||||||
|
if (chosenElementItemCfg) {
|
||||||
|
settings = chosenElementItemCfg.settings.map((o) => {
|
||||||
|
const setting = head(chosen.settings.filter(s => s.name === o.name));
|
||||||
|
return setting ? klona(setting) : klona(o)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (chosen) {
|
if (chosen) {
|
||||||
setActiveElementData(klona(chosen));
|
setActiveElementData(klona(chosen));
|
||||||
setSettings(klona(chosen.settings));
|
setSettings(settings);
|
||||||
setValidators(klona(chosen.validators));
|
setValidators(klona(chosen.validators));
|
||||||
setDynamicData(chosen.dynamicData ? chosen.dynamicData : '');
|
setDynamicData(chosen.dynamicData ? chosen.dynamicData : '');
|
||||||
setCriteria(chosen.criteria ? chosen.criteria : []);
|
setCriteria(chosen.criteria ? chosen.criteria : []);
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ const BeneficiarioDomandeTable = () => {
|
|||||||
const statusFilterTemplate = (options) => {
|
const statusFilterTemplate = (options) => {
|
||||||
return <Dropdown value={options.value} options={statuses}
|
return <Dropdown value={options.value} options={statuses}
|
||||||
onChange={(e) => options.filterCallback(e.value, options.index)}
|
onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
itemTemplate={statusItemTemplate} placeholder={translationStrings.selectOneLabel} className="p-column-filter"
|
itemTemplate={statusItemTemplate} placeholder={translationStrings.selectOneLabel}
|
||||||
|
className="p-column-filter"
|
||||||
showClear/>;
|
showClear/>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,11 +140,17 @@ const BeneficiarioDomandeTable = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const actionsBodyTemplate = (rowData) => {
|
const actionsBodyTemplate = (rowData) => {
|
||||||
return rowData.status === 'SOCCORSO'
|
return <>
|
||||||
? <Link to={`/domande/${rowData.id}`}>
|
{rowData.status === 'SOCCORSO'
|
||||||
<Button severity="info" label={__('Dettagli', 'gepafin')} icon="pi pi-eye" size="small"
|
? <Link to={`/domande/${rowData.id}`}>
|
||||||
|
<Button severity="info" label={__('Dettagli', 'gepafin')} icon="pi pi-eye" size="small"
|
||||||
|
iconPos="right"/>
|
||||||
|
</Link> : null}
|
||||||
|
<Link to={`/domande/${rowData.id}/preview`}>
|
||||||
|
<Button severity="info" label={__('Anteprima', 'gepafin')} icon="pi pi-eye" size="small"
|
||||||
iconPos="right"/>
|
iconPos="right"/>
|
||||||
</Link> : null;
|
</Link>
|
||||||
|
</>
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = renderHeader();
|
const header = renderHeader();
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ const routes = ({ role, chosenCompanyId }) => {
|
|||||||
</DefaultLayout>}/>
|
</DefaultLayout>}/>
|
||||||
<Route path="/domande/:id/preview" element={<DefaultLayout>
|
<Route path="/domande/:id/preview" element={<DefaultLayout>
|
||||||
{'ROLE_SUPER_ADMIN' === role ? <BandoApplicationPreview/> : null}
|
{'ROLE_SUPER_ADMIN' === role ? <BandoApplicationPreview/> : null}
|
||||||
{'ROLE_BENEFICIARY' === role ? <PageNotFound/> : null}
|
{'ROLE_BENEFICIARY' === role ? <BandoApplicationPreview/> : null}
|
||||||
{'ROLE_PRE_INSTRUCTOR' === role ? <BandoApplicationPreview/> : null}
|
{'ROLE_PRE_INSTRUCTOR' === role ? <BandoApplicationPreview/> : null}
|
||||||
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandoApplicationPreview/> : null}
|
{'ROLE_INSTRUCTOR_MANAGER' === role ? <BandoApplicationPreview/> : null}
|
||||||
</DefaultLayout>}/>
|
</DefaultLayout>}/>
|
||||||
|
|||||||
@@ -88,6 +88,10 @@ export const elementItems = [
|
|||||||
{
|
{
|
||||||
name: "step",
|
name: "step",
|
||||||
value: 0
|
value: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "isRequestedAmount",
|
||||||
|
value: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
validators: {
|
validators: {
|
||||||
|
|||||||
Reference in New Issue
Block a user