- added new settings for call;
- added duplciate form field functionality to form builder; - added improvements to form builder; - fixed issue with saving data in evaluation;
This commit is contained in:
@@ -53,6 +53,10 @@
|
||||
font-weight: 400;
|
||||
line-height: 21px;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -116,7 +120,7 @@
|
||||
border: 1px solid var(--button-secondary-borderColor);
|
||||
background-color: var(--button-secondary-borderColor);
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
padding: 20px 10px;
|
||||
opacity: 0.6;
|
||||
color: white;
|
||||
font-size: 11px;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { head, isNil, pathOr } from 'ramda';
|
||||
import getNumberFormatted from '../../../../../../../helpers/getNumberFormatted';
|
||||
|
||||
const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) => {
|
||||
const cellData = head(lastRowCfg.filter(o => !isNil(o[columnId])));
|
||||
@@ -8,7 +9,7 @@ const LastRowCell = ({columnId, lastRowCfg, columnMeta = {}, tableValue = []}) =
|
||||
cellValue = pathOr(0, ['total'], tableValue);
|
||||
}
|
||||
|
||||
return <td>{cellValue}</td>;
|
||||
return <td>{getNumberFormatted(cellValue)}</td>;
|
||||
};
|
||||
|
||||
export default LastRowCell;
|
||||
@@ -6,7 +6,6 @@ import { head, isEmpty, isNil, pathOr, sum } from 'ramda';
|
||||
// components
|
||||
import DefaultCell from './components/DefaultCell';
|
||||
import LastRowCell from './components/LastRowCell';
|
||||
import getNumberFormatted from '../../../../../helpers/getNumberFormatted';
|
||||
|
||||
const RenderTable = ({ tableValue = {}, columnsCfg, lastRowCfg, setTableValueFn, disabled }) => {
|
||||
const rows = pathOr([], ['rows'], tableValue)
|
||||
@@ -32,7 +31,7 @@ const RenderTable = ({ tableValue = {}, columnsCfg, lastRowCfg, setTableValueFn,
|
||||
.map(v => isEmpty(v) || isNil(v) ? 0 : v);
|
||||
|
||||
if (cellValue === 'sum') {
|
||||
total = getNumberFormatted(sum(getAllRowsValues));
|
||||
total = sum(getAllRowsValues);
|
||||
} else {
|
||||
total = 0;
|
||||
}
|
||||
|
||||
@@ -50,105 +50,195 @@ export const dynamicDataOptions = {
|
||||
export const protocolType = [
|
||||
{
|
||||
'id': 1,
|
||||
'name': 'PROTOCOLLO IN ENTRATA'
|
||||
'name': 'PROTOCOLLO ENTRATA'
|
||||
},
|
||||
{
|
||||
'id': 2,
|
||||
'name': 'PROTOCOLLO IN USCITA'
|
||||
'name': 'PROTOCOLLO USCITA'
|
||||
},
|
||||
{
|
||||
'id': 3,
|
||||
'name': 'DOCUMENTO INTERNO'
|
||||
},
|
||||
{
|
||||
/*{
|
||||
'id': 1003,
|
||||
'name': 'PROTOCOLLO INTERNO '
|
||||
}
|
||||
}*/
|
||||
];
|
||||
|
||||
export const classificationType = [
|
||||
{
|
||||
'idClassificazione': 1,
|
||||
'idClassificazione': 101,
|
||||
'name': 'BILANCIO',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 2,
|
||||
'idClassificazione': 102,
|
||||
'name': 'DICHHIARAZIONE DEI REDDITI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 3,
|
||||
'idClassificazione': 103,
|
||||
'name': 'SITUAZIONE CONTABILE',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 4,
|
||||
'idClassificazione': 104,
|
||||
'name': 'PROSPETTO CONTO ECONOMICO',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 5,
|
||||
'idClassificazione': 105,
|
||||
'name': 'CENTRALE DEI RISCHI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 6,
|
||||
'name': 'RELAZIONE AZIENDALE ILLUSTRATIVA (MOD R1C, R1I, R1R, R1R A SECONDO DEI ',
|
||||
'idClassificazione': 106,
|
||||
'name': 'RELAZIONE AZIENDALE ILLUSTRATIVA (MOD R1C, R1I, R1R, R1S A SECONDA DEI SETTORI)',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 7,
|
||||
'idClassificazione': 107,
|
||||
'name': 'DOCUMENTO IDENTITA\'',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 8,
|
||||
'idClassificazione': 108,
|
||||
'name': 'MODELLO SP1',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 9,
|
||||
'idClassificazione': 109,
|
||||
'name': 'PRIVACY',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 10,
|
||||
'name': 'DOCUMENTAZIONE CHE ATTESTA POSSIBILITA\' DI RILASCIARE GAA FAVORE',
|
||||
'idClassificazione': 110,
|
||||
'name': 'DOCUMENTAZIONE CHE ATTESTA POSSIBILITA\' DI RILASCIARE GARANZIE A FAVORE DI TERZI (ES. STATUTO, VISURA…)',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 11,
|
||||
'idClassificazione': 111,
|
||||
'name': 'MODELLO AR1 D.LG 231/2007',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 12,
|
||||
'name': 'DOCUMENTO IDENTITA\' FIRMATORIO DICHHIARAZIONE SOSTITUTIVA',
|
||||
'idClassificazione': 112,
|
||||
'name': 'DOCUMENTO IDENTITA\' FIRMATARIO DICHIARAZIONE SOSTITUTIVA',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 13,
|
||||
'name': 'PRIVACY FIRMATARIO DICHHIARAZIONE SOSTITUTIVA',
|
||||
'idClassificazione': 113,
|
||||
'name': 'PRIVACY FIRMATARIO DICHIARAZIONE SOSTITUTIVA',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 14,
|
||||
'idClassificazione': 114,
|
||||
'name': 'NULLAOSTA ANTIMAFIA',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 1,
|
||||
'name': 'LETTERA ESITO DELIBERA',
|
||||
'idTipoprotocollo': 2
|
||||
'idClassificazione': 115,
|
||||
'name': 'VISURA CRIF',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 2,
|
||||
'idClassificazione': 116,
|
||||
'name': 'DURC',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 117,
|
||||
'name': 'STATO PATRIMONIALE E CONTO ECONOMICO',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 118,
|
||||
'name': 'DOCUMENTAZIONE FISCALE E CONTABILE',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 119,
|
||||
'name': 'BILANCIO GRUPPO IMPRESE',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 121,
|
||||
'name': 'DICHIARAZIONE DEI REDDITI GARANTI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 122,
|
||||
'name': 'CENTRALE DEI RISCHI GARANTI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 123,
|
||||
'name': 'BILANCIO / DICHIARAZIONE REDDITI GARANTI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 125,
|
||||
'name': 'CONTRATTO FIRMATO DAL CLIENTE',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 126,
|
||||
'name': 'CONTRATTO FIRMATO DA GEPAFIN',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 128,
|
||||
'name': 'ALLEGATO 4',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 129,
|
||||
'name': 'ATTESTAZIONE PREGIUDIZIEVOLI',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 130,
|
||||
'name': 'DELIBERA BANCA',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 131,
|
||||
'name': 'ALTRO',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 202,
|
||||
'name': 'LETTERA DI GARANZIA',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 3,
|
||||
'idClassificazione': 127,
|
||||
'name': 'FATTURA',
|
||||
'idTipoprotocollo': 2
|
||||
},
|
||||
{
|
||||
'idClassificazione': 201,
|
||||
'name': 'LETTERA ESITO DELIBERA',
|
||||
'idTipoprotocollo': 2
|
||||
},
|
||||
{
|
||||
'idClassificazione': 204,
|
||||
'name': 'LETTERA TRASPARENZA',
|
||||
'idTipoprotocollo': 2
|
||||
},
|
||||
{
|
||||
'idClassificazione': 205,
|
||||
'name': 'CONTRATTO',
|
||||
'idTipoprotocollo': 1
|
||||
},
|
||||
{
|
||||
'idClassificazione': 124,
|
||||
'name': 'STAMPA PROPOSTA DELIBERA',
|
||||
'idTipoprotocollo': 3
|
||||
},
|
||||
{
|
||||
'idClassificazione': 203,
|
||||
'name': 'GENERICO',
|
||||
'idTipoprotocollo': 3
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString
|
||||
import formatDateString from '../../../../helpers/formatDateString';
|
||||
import EvaluationFormsService from '../../../../service/evaluation-forms-service';
|
||||
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
|
||||
const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, getFormErrors, status }, ref) {
|
||||
const navigate = useNavigate();
|
||||
const [aimedToOptions, setAimedToOptions] = useState([]);
|
||||
@@ -51,7 +53,8 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
const values = getValues();
|
||||
const toast = useRef(null);
|
||||
|
||||
const onSubmit = () => {};
|
||||
const onSubmit = () => {
|
||||
};
|
||||
|
||||
const onSaveDraft = () => {
|
||||
trigger();
|
||||
@@ -198,7 +201,7 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
![
|
||||
'descriptionShort', 'descriptionLong', 'documentationRequested', 'threshold',
|
||||
'aimedTo', 'criteria', 'docs', 'checklist', 'faq', 'amount', 'amountMin', 'amountMax',
|
||||
'email', 'phoneNumber', 'checkList', 'images'
|
||||
'email', 'phoneNumber', 'checkList', 'images', 'numberOfCheck', 'productId'
|
||||
].includes(fieldName)
|
||||
}
|
||||
|
||||
@@ -477,6 +480,35 @@ const BandoEditFormStep1 = forwardRef(function ({ initialData, setInitialData, g
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="appForm__cols">
|
||||
<FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('numberOfCheck')}
|
||||
fieldName="numberOfCheck"
|
||||
label={__('Quantità dei checklist per creare un soccorso', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['numberOfCheck']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/>
|
||||
|
||||
{APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <FormField
|
||||
type="numberinput"
|
||||
disabled={shouldDisableField('productId')}
|
||||
fieldName="productId"
|
||||
label={__('Prodotto ID dentro Odessa', 'gepafin')}
|
||||
control={control}
|
||||
errors={errors}
|
||||
defaultValue={values['productId']}
|
||||
config={{
|
||||
required: __('È obbligatorio', 'gepafin'),
|
||||
}}
|
||||
/> : null}
|
||||
</div>
|
||||
|
||||
<FormFieldRepeaterFaq
|
||||
data={values['faq']}
|
||||
disabled={shouldDisableField('faq')}
|
||||
|
||||
@@ -19,7 +19,7 @@ import set404FromErrorResponse from '../../../../helpers/set404FromErrorResponse
|
||||
import BandoEditFormActions from '../BandoEditFormActions';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import FormBuilder from '../../../BandoFormsEdit/components/FormBuilder';
|
||||
import { elementItems } from '../../../../tempData';
|
||||
//import { elementItems } from '../../../../tempData';
|
||||
|
||||
|
||||
const BandoEditFormStep3 = forwardRef(function () {
|
||||
@@ -77,8 +77,8 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -123,7 +123,7 @@ const BandoEditFormStep3 = forwardRef(function () {
|
||||
<div className="appForm">
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder bandoStatus={bandoStatus}/>
|
||||
<FormBuilder callStatus={bandoStatus} context="call"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useDrag, useDrop } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { head, isEmpty } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
|
||||
// store
|
||||
import { storeSet, useStore } from '../../../../store';
|
||||
|
||||
// tools
|
||||
import uniqid from '../../../../helpers/uniqid';
|
||||
|
||||
// components
|
||||
import { Button } from 'primereact/button';
|
||||
import { Tag } from 'primereact/tag';
|
||||
@@ -19,6 +23,8 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
const element = head(elements.filter(o => o.id === id));
|
||||
const [isVariable, setIsVariable] = useState('secondary');
|
||||
const [isFormula, setIsFormula] = useState('secondary');
|
||||
const [variableName, setVariableName] = useState('secondary');
|
||||
const [formulaName, setFormulaName] = useState('secondary');
|
||||
const [isRequestedAmount, setIsRequestedAmount] = useState(false);
|
||||
const [isDelegation, setIsDelegation] = useState(false);
|
||||
|
||||
@@ -97,6 +103,18 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
storeSet.main.activeElement(id);
|
||||
}
|
||||
|
||||
const duplicateElement = useCallback((id) => {
|
||||
const duplicatedElement = head(elements.filter(o => o.id === id));
|
||||
|
||||
if (duplicatedElement) {
|
||||
const copyElement = klona(duplicatedElement);
|
||||
copyElement.id = uniqid();
|
||||
const originalIndex = elements.map(o => o.id).indexOf(id);
|
||||
const newElements = [...elements].toSpliced(originalIndex, 0, copyElement);
|
||||
storeSet.main.formElements(newElements);
|
||||
}
|
||||
}, [elements]);
|
||||
|
||||
const remove = (id) => {
|
||||
storeSet.main.removeElement(id);
|
||||
}
|
||||
@@ -112,10 +130,12 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
setIsVariable('warning');
|
||||
setVariableName(variable.value)
|
||||
}
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
setIsFormula('warning');
|
||||
setFormulaName(formula.value)
|
||||
}
|
||||
|
||||
if (isRequestedAmount && !isEmpty(isRequestedAmount.value) && isRequestedAmount.value) {
|
||||
@@ -137,9 +157,9 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
<div className="tagHeader">
|
||||
<Tag value={label} severity="info"/>
|
||||
{['numberinput', 'criteria_table'].includes(name)
|
||||
? <Tag value="var" severity={isVariable}/> : null}
|
||||
? <Tag value="var" severity={isVariable} title={variableName}/> : null}
|
||||
{name === 'numberinput'
|
||||
? <Tag value="f(x)" severity={isFormula}/> : null}
|
||||
? <Tag value="f(x)" severity={isFormula} title={formulaName}/> : null}
|
||||
{isRequestedAmount
|
||||
? <Tag value="importo" severity={isRequestedAmount}/> : null}
|
||||
{isDelegation
|
||||
@@ -148,6 +168,7 @@ const BuilderElement = ({ id, name, label, index, bandoStatus }) => {
|
||||
<BuilderElementProperLabel id={id} defaultLabel={label}/>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button icon="pi pi-clone" onClick={() => duplicateElement(id)} outlined severity="success"/>
|
||||
<Button icon="pi pi-cog" onClick={() => openSettings(id)} outlined severity="info"/>
|
||||
<Button icon="pi pi-trash" disabled={bandoStatus === 'PUBLISH'} onClick={() => remove(id)} outlined severity="danger"/>
|
||||
</div>
|
||||
|
||||
@@ -35,12 +35,13 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
text: __('Testo formattato', 'gepafin'),
|
||||
table_columns: '',
|
||||
criteria_table_columns: '',
|
||||
variable: __('Variable (only letters and "_")', 'gepafin'),
|
||||
formula: __('Auto calculation formula', 'gepafin')
|
||||
variable: __('Variabile (lettere, cifre e "_"; il primo carattere deve essere una lettera!)', 'gepafin'),
|
||||
formula: __('Formula di calcolo automatico', 'gepafin'),
|
||||
isChecklistItem: __('Fa parte di "checklist"?', 'gepafin'),
|
||||
}
|
||||
|
||||
const settingDescription = {
|
||||
formula: __('Create formula using previously declared variables. Use these math operators: <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>. Example of formula: <code>{entrate}+{assicurazione}</code>.', 'gepafin')
|
||||
formula: __('Crea una formula usando variabili dichiarate in precedenza. Utilizza questi operatori matematici: <code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>. Esempio: <code>{entrate}+{assicurazione}</code>.', 'gepafin')
|
||||
}
|
||||
|
||||
const renderHeader = () => {
|
||||
@@ -104,7 +105,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
name={setting.name}
|
||||
bandoStatus={bandoStatus}
|
||||
setDataFn={updateDataFn}/>
|
||||
} else if (['isRequestedAmount', 'isDelegation'].includes(setting.name)) {
|
||||
} else if (['isRequestedAmount', 'isDelegation', 'isChecklistItem'].includes(setting.name)) {
|
||||
return <InputSwitch
|
||||
checked={setting.value}
|
||||
onChange={(e) => changeFn(e.value, setting.name)}/>
|
||||
|
||||
@@ -8,7 +8,7 @@ const ElementSettingChips = ({ restrictedValues = [], changeFn, value = [] }) =>
|
||||
const [lastTyped, setLastTyped] = useState([])
|
||||
|
||||
const isValidValue = (newVal) => {
|
||||
const validationRegex = /^[a-zA-Z_]+$/;
|
||||
const validationRegex = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
||||
return validationRegex.test(newVal);
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { MultiSelect } from 'primereact/multiselect';
|
||||
|
||||
import { dynamicDataOptions } from '../../../../configData';
|
||||
|
||||
const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
const BuilderElementSettings = ({ closeSettingsFn, callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
const criteriaOptions = useStore().main.bandoCriteria();
|
||||
@@ -123,6 +123,10 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
});
|
||||
}
|
||||
|
||||
settings = settings.filter(o => context === 'call'
|
||||
? !['isRequestedAmount', 'isDelegation'].includes(o.name)
|
||||
: !['isChecklistItem'].includes(o.name));
|
||||
|
||||
if (chosen) {
|
||||
setActiveElementData(klona(chosen));
|
||||
setSettings(settings);
|
||||
@@ -149,7 +153,7 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
@@ -220,7 +224,8 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
</div> : null}
|
||||
</div>) : null}
|
||||
</TabPanel> : null}
|
||||
<TabPanel header={__('Criteri', 'gepafin')}>
|
||||
{context === 'application'
|
||||
? <TabPanel header={__('Criteri', 'gepafin')}>
|
||||
<div className="formElementSettings__field">
|
||||
<label htmlFor="criteria">{__('Criteri di valutazione', 'gepafin')}</label>
|
||||
<MultiSelect
|
||||
@@ -233,26 +238,29 @@ const BuilderElementSettings = ({ closeSettingsFn, bandoStatus }) => {
|
||||
display="chip"
|
||||
placeholder={__('Scegli', 'gepafin')}/>
|
||||
</div>
|
||||
</TabPanel>
|
||||
</TabPanel> : null}
|
||||
{settings
|
||||
&& settings
|
||||
.filter(o => ['variable', 'formula'].includes(o.name)).length > 0
|
||||
? <TabPanel header={__('Calculation', 'gepafin')}>
|
||||
? <TabPanel header={__('Calcolo', 'gepafin')}>
|
||||
{settings
|
||||
? settings
|
||||
.filter(o => ['variable', 'formula'].includes(o.name))
|
||||
.map((o) => <ElementSetting
|
||||
key={o.name}
|
||||
setting={o}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
changeFn={onChange}
|
||||
updateDataFn={onUpdateOptions}/>)
|
||||
: null}
|
||||
</TabPanel> : null}
|
||||
</TabView>
|
||||
|
||||
<div style={{display: 'flex', gap: '0.5rem'}}>
|
||||
<Button label={__('Annulla', 'gepafin')} onClick={closeSettingsFn} severity="danger"/>
|
||||
<Button label={__('Salva', 'gepafin')} onClick={saveSettings}/>
|
||||
</div>
|
||||
</div>
|
||||
: null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import BuilderElementSettings from '../BuilderElementSettings';
|
||||
import BuilderDropzone from '../BuilderDropzone';
|
||||
import BlockingOverlay from '../../../../components/BlockingOverlay';
|
||||
|
||||
const FormBuilder = ({ bandoStatus }) => {
|
||||
const FormBuilder = ({ callStatus, context }) => {
|
||||
const elements = useStore().main.formElements();
|
||||
const elementItems = useStore().main.elementItems();
|
||||
const activeElement = useStore().main.activeElement();
|
||||
@@ -27,10 +27,10 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
id={field.id}
|
||||
label={field.label}
|
||||
name={field.name}
|
||||
bandoStatus={bandoStatus}
|
||||
callStatus={callStatus}
|
||||
/>
|
||||
)
|
||||
}, [bandoStatus]);
|
||||
}, [callStatus]);
|
||||
|
||||
const renderItem = useCallback((item) => {
|
||||
return (
|
||||
@@ -56,9 +56,11 @@ const FormBuilder = ({ bandoStatus }) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Sidebar visible={!isEmpty(activeElement)} onHide={closeSettings} className="formBuilder__elementSettings">
|
||||
<Sidebar visible={!isEmpty(activeElement)} onHide={closeSettings} dismissable={false} className="formBuilder__elementSettings">
|
||||
<h2>{__('Impostazioni del campo modulo', 'gepafin')}</h2>
|
||||
{!isEmpty(activeElement) ? <BuilderElementSettings closeSettingsFn={closeSettings} bandoStatus={bandoStatus}/> : null}
|
||||
{!isEmpty(activeElement)
|
||||
? <BuilderElementSettings closeSettingsFn={closeSettings} callStatus={callStatus} context={context}/>
|
||||
: null}
|
||||
</Sidebar>
|
||||
<div className="formBuilder">
|
||||
<div className="formBuilder__main">
|
||||
|
||||
@@ -24,7 +24,7 @@ import set404FromErrorResponse from '../../helpers/set404FromErrorResponse';
|
||||
import BandoService from '../../service/bando-service';
|
||||
|
||||
// TODO temp data
|
||||
import { elementItems } from '../../tempData';
|
||||
//import { elementItems } from '../../tempData';
|
||||
|
||||
const BandoFormsEdit = () => {
|
||||
const { id, formId } = useParams();
|
||||
@@ -215,8 +215,8 @@ const BandoFormsEdit = () => {
|
||||
|
||||
const getElementItemsCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
//storeSet.main.elementItems(elementItems.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
storeSet.main.elementItems(data.data.sort((a, b) => a.sortOrder - b.sortOrder));
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
@@ -317,7 +317,7 @@ const BandoFormsEdit = () => {
|
||||
|
||||
<div className="appPageSection">
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<FormBuilder bandoStatus={bandoStatus}/>
|
||||
<FormBuilder callStatus={bandoStatus} context="application"/>
|
||||
</DndProvider>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
||||
import React, { useState, useEffect, useRef, useCallback, useMemo } from 'react';
|
||||
import { __, sprintf } from '@wordpress/i18n';
|
||||
import { useNavigate, useParams } from 'react-router-dom';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head } from 'ramda';
|
||||
import { is, isEmpty, isNil, sum, pathOr, head, pluck } from 'ramda';
|
||||
import { klona } from 'klona';
|
||||
import { wrap } from 'object-path-immutable';
|
||||
|
||||
@@ -39,6 +39,25 @@ import RepeaterFields from '../DomandaEditPreInstructor/components/RepeaterField
|
||||
import getDateTimeFromISOstring from '../../helpers/getDateTimeFromISOstring';
|
||||
import ApplicationInfo from '../DomandaEditPreInstructor/components/ApplicationInfo';
|
||||
import ApplicationDownloadFiles from '../DomandaEditPreInstructor/components/ApplicationDownloadFiles';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import {
|
||||
isCAP,
|
||||
isCodiceFiscale,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isIBAN,
|
||||
isMarcaDaBollo,
|
||||
isPIVA,
|
||||
isUrl, maxChecks, minChecks, nonEmptyTables
|
||||
} from '../../helpers/validators';
|
||||
import formatDateString from '../../helpers/formatDateString';
|
||||
import getTokens from '../../helpers/getTokens';
|
||||
import parseCommaDecimal from '../../helpers/parseCommaDecimal';
|
||||
import renderWithDataVars from '../../helpers/renderWithDataVars';
|
||||
import { evaluate } from 'mathjs';
|
||||
import equal from 'fast-deep-equal';
|
||||
import renderHtmlContent from '../../helpers/renderHtmlContent';
|
||||
import FormField from '../../components/FormField';
|
||||
|
||||
const APP_EVALUATION_FLOW_ID = process.env.REACT_APP_EVALUATION_FLOW_ID;
|
||||
const APP_HUB_ID = process.env.REACT_APP_HUB_ID;
|
||||
@@ -68,6 +87,40 @@ const DomandaEditInstructorManager = () => {
|
||||
duration: 0,
|
||||
amount: 0
|
||||
});
|
||||
const [formData, setFormData] = useState([]);
|
||||
const [formId, setFormId] = useState(0);
|
||||
const [formInitialData, setFormInitialData] = useState(null);
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
formState: { errors },
|
||||
setValue,
|
||||
trigger,
|
||||
register,
|
||||
getValues,
|
||||
watch,
|
||||
reset
|
||||
} = useForm({
|
||||
defaultValues: useMemo(() => {
|
||||
return formInitialData ? formInitialData : {}
|
||||
}, [formInitialData]),
|
||||
mode: 'onChange'
|
||||
});
|
||||
const validationFns = {
|
||||
isPIVA,
|
||||
isCodiceFiscale,
|
||||
isCAP,
|
||||
isIBAN,
|
||||
isEmail,
|
||||
isEmailPEC,
|
||||
isUrl,
|
||||
isMarcaDaBollo,
|
||||
minChecks,
|
||||
maxChecks,
|
||||
nonEmptyTables
|
||||
}
|
||||
const values = getValues();
|
||||
const formValues = watch();
|
||||
|
||||
const goToEvaluationsPage = () => {
|
||||
navigate('/mie-domande');
|
||||
@@ -109,6 +162,35 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getVersion = (resp) => {
|
||||
if (resp.status === 'SUCCESS') {
|
||||
if (resp.data.evaluationVersion === 'V1') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
} else if (resp.data.evaluationVersion === 'V2') {
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationV2ByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', resp.data.applicationId]
|
||||
]);
|
||||
}
|
||||
}
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const errGetVersion = (resp) => {
|
||||
if (toast.current && data.message) {
|
||||
toast.current.show({
|
||||
severity: 'error',
|
||||
summary: '',
|
||||
detail: resp.message
|
||||
});
|
||||
}
|
||||
set404FromErrorResponse(resp);
|
||||
storeSet.main.unsetAsyncRequest();
|
||||
}
|
||||
|
||||
const getCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
setData(getFormattedData(data.data));
|
||||
@@ -168,8 +250,34 @@ const DomandaEditInstructorManager = () => {
|
||||
updateFlagsForSoccorso(newData);
|
||||
}
|
||||
|
||||
const getTransformedSubmitData = () => {
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
return Object.keys(formValues)
|
||||
.filter(v => usedFieldsIds.includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
const formField = head(formData.filter(o => o.id === cur));
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
if (formValues[cur] && formValues[cur].toISOString) {
|
||||
fieldVal = formatDateString(formValues[cur]);
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
'fieldId': cur,
|
||||
'fieldValue': fieldVal
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
const doSaveDraft = useCallback((doRedirect = '') => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
files: klona(data.files),
|
||||
@@ -180,14 +288,36 @@ const DomandaEditInstructorManager = () => {
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
};
|
||||
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
formData,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note
|
||||
}
|
||||
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
(data) => updateCallback(data, doRedirect),
|
||||
errUpdateCallback
|
||||
);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const updateCallback = (data, doRedirect = '') => {
|
||||
@@ -220,7 +350,8 @@ const DomandaEditInstructorManager = () => {
|
||||
}
|
||||
|
||||
const doApprove = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'APPROVED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -231,11 +362,42 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const doReject = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'REJECTED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -246,7 +408,37 @@ const DomandaEditInstructorManager = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updateStatusCallback = (data) => {
|
||||
@@ -433,7 +625,7 @@ const DomandaEditInstructorManager = () => {
|
||||
setIsVisibleAppointmentDialog(true);
|
||||
}
|
||||
|
||||
const setValue = (name, value) => {
|
||||
const setFieldValue = (name, value) => {
|
||||
const newData = wrap(appointmentData).set(name, value).value();
|
||||
setAppointmentData(newData);
|
||||
}
|
||||
@@ -507,11 +699,151 @@ const DomandaEditInstructorManager = () => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
const evaluationShouldBeBlocked = (data = {}) => {
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData();
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
const shouldDisableNewSoccorso = () => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const actionBtns = () => {
|
||||
return <div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE'
|
||||
|| (data.applicationStatus === 'EVALUATION' && shouldDisableNewSoccorso())
|
||||
|| evaluationBlockedForUser(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationBlockedForUser(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationBlockedForUser(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let updatedFormValues = klona(formValues);
|
||||
let context = {};
|
||||
|
||||
// eslint-disable-next-line array-callback-return
|
||||
formData.map((o) => {
|
||||
const variable = head(o.settings.filter(o => o.name === 'variable'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
|
||||
if (formula && !isEmpty(formula.value)) {
|
||||
context = getTokens(formula.value)
|
||||
.filter(v => !['false', 'null', 'true'].includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
acc[cur] = isNil(context[cur]) ? 0 : parseCommaDecimal(context[cur]);
|
||||
return acc;
|
||||
}, context);
|
||||
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
} catch (e) {
|
||||
console.log('Error in math formula: "', mathFormula, '"', e.message);
|
||||
updatedFormValues[o.id] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (variable && !isEmpty(variable.value)) {
|
||||
context[variable.value[0]] = 'criteria_table' === o.name
|
||||
? pathOr(0, [o.id, 'total'], updatedFormValues)
|
||||
: pathOr(0, [o.id], updatedFormValues);
|
||||
}
|
||||
});
|
||||
|
||||
if (!isEmpty(updatedFormValues) && !equal(updatedFormValues, formValues)) {
|
||||
reset(updatedFormValues);
|
||||
}
|
||||
}, [formValues]);
|
||||
|
||||
useEffect(() => {
|
||||
if (formInitialData) {
|
||||
//reset();
|
||||
Object.keys(formInitialData).map(k => setValue(k, formInitialData[k]));
|
||||
trigger();
|
||||
}
|
||||
}, [formInitialData]);
|
||||
|
||||
useEffect(() => {
|
||||
const maxScore = pathOr(0, ['minScore'], data);
|
||||
const criteria = pathOr([], ['criteria'], data);
|
||||
@@ -525,9 +857,7 @@ const DomandaEditInstructorManager = () => {
|
||||
const entityId = !isNaN(parsed) ? parsed : 0;
|
||||
|
||||
storeSet.main.setAsyncRequest();
|
||||
ApplicationEvaluationService.getEvaluationByApplId(getCallback, errGetCallback, [
|
||||
['applicationId', entityId]
|
||||
]);
|
||||
ApplicationEvaluationService.getEvaluationVersionByApplId(entityId, getVersion, errGetVersion);
|
||||
AmendmentsService.getSoccorsoByApplId(entityId, getAmendmentsCallback, errGetAmendmentsCallback, [
|
||||
['statuses', 'AWAITING']
|
||||
]);
|
||||
@@ -557,6 +887,14 @@ const DomandaEditInstructorManager = () => {
|
||||
? <div className="appPage__content">
|
||||
<ApplicationInfo data={data}/>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<ApplicationDownloadFiles id={id}/>
|
||||
|
||||
<div className="appPageSection">
|
||||
@@ -567,7 +905,7 @@ const DomandaEditInstructorManager = () => {
|
||||
data,
|
||||
['evaluationDocument']
|
||||
)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
sourceId={data.assignedApplicationId}
|
||||
sourceName="evaluation"/>
|
||||
</div>
|
||||
@@ -579,7 +917,7 @@ const DomandaEditInstructorManager = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -587,6 +925,82 @@ const DomandaEditInstructorManager = () => {
|
||||
</div>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <form className="appForm" onSubmit={handleSubmit(() => {
|
||||
})}>
|
||||
{formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
const placeholder = head(o.settings.filter(o => o.name === 'placeholder'));
|
||||
const options = head(o.settings.filter(o => o.name === 'options'));
|
||||
let tableColumns = head(o.settings.filter(o => o.name === 'table_columns'));
|
||||
if (!tableColumns) {
|
||||
tableColumns = head(o.settings.filter(o => o.name === 'criteria_table_columns'));
|
||||
}
|
||||
const step = head(o.settings.filter(o => o.name === 'step'));
|
||||
const mime = head(o.settings.filter(o => o.name === 'mime'));
|
||||
const formula = head(o.settings.filter(o => o.name === 'formula'));
|
||||
let mimeValue = '';
|
||||
|
||||
if (mime) {
|
||||
mimeValue = mime.value.map(o => o.code ? o.code : o.ext);
|
||||
}
|
||||
|
||||
const validations = Object.keys(o.validators).reduce((acc, cur) => {
|
||||
if (o.validators[cur]) {
|
||||
if (['min', 'max', 'minLength', 'maxLength', 'maxSize'].includes(cur)) {
|
||||
acc[cur] = parseInt(o.validators[cur]);
|
||||
} else if ('pattern' === cur) {
|
||||
acc[cur] = new RegExp(o.validators[cur]);
|
||||
} else if ('isRequired' === cur) {
|
||||
//acc[cur] = o.validators[cur];
|
||||
acc['required'] = true;
|
||||
} else if ('custom' === cur && validationFns[o.validators[cur]]) {
|
||||
if (!acc.validate) {
|
||||
acc.validate = {};
|
||||
}
|
||||
acc.validate[o.validators[cur]] = validationFns[o.validators[cur]];
|
||||
}
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
/*if (o.name === 'table') {
|
||||
console.log('value:', values[o.id] ? values[o.id] : '')
|
||||
}*/
|
||||
|
||||
return ['paragraph'].includes(o.name) && text
|
||||
? <div key={o.id}>
|
||||
<div className="ql-editor">
|
||||
{renderHtmlContent(text.value)}
|
||||
</div>
|
||||
</div>
|
||||
: <FormField
|
||||
key={o.id}
|
||||
readOnly={formula && !isEmpty(formula.value)}
|
||||
type={o.name}
|
||||
fieldName={o.id}
|
||||
label={label ? label.value : ''}
|
||||
placeholder={placeholder ? placeholder.value : ''}
|
||||
control={control}
|
||||
register={register}
|
||||
errors={errors}
|
||||
defaultValue={values[o.id] ? values[o.id] : ''}
|
||||
maxFractionDigits={step ? step.value : 0}
|
||||
accept={mimeValue}
|
||||
config={validations}
|
||||
options={options ? options.value : []}
|
||||
setDataFn={setValue}
|
||||
saveFormCallback={doSaveDraft}
|
||||
sourceId={id}
|
||||
useGrouping={false}
|
||||
tableColumns={tableColumns ? tableColumns.value : {}}
|
||||
/>
|
||||
})}
|
||||
</form>
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V1'
|
||||
? <div className="appPageSection">
|
||||
<h2>{__('Checklist Valutazione', 'gepafin')}</h2>
|
||||
@@ -597,7 +1011,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<div className="appPageSection__checklist">
|
||||
{data.checklist.map((o, i) => <div key={o.id}>
|
||||
<Checkbox
|
||||
disabled={shouldDisableField('checklist') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('checklist') || evaluationBlockedForUser(data)}
|
||||
inputId={`checklist_${o.id}`}
|
||||
onChange={(e) => updateEvaluationValue(
|
||||
e.checked,
|
||||
@@ -613,7 +1027,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<div>
|
||||
<Editor
|
||||
value={data.note}
|
||||
readOnly={shouldDisableField('note') || evaluationShouldBeBlocked(data)}
|
||||
readOnly={shouldDisableField('note') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateEvaluationValue(
|
||||
@@ -630,7 +1044,7 @@ const DomandaEditInstructorManager = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -646,7 +1060,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<ListOfFiles
|
||||
files={data.amendmentDetails}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="amendmentDetails"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -670,7 +1084,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<td>
|
||||
<div className="p-inputgroup">
|
||||
<InputNumber
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Punteggio', 'gepafin')}
|
||||
keyfilter="int"
|
||||
value={o.score}
|
||||
@@ -693,7 +1107,7 @@ const DomandaEditInstructorManager = () => {
|
||||
onClick={() => displayCriterionData(o.id)}
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
true,
|
||||
@@ -701,7 +1115,7 @@ const DomandaEditInstructorManager = () => {
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
false,
|
||||
@@ -740,86 +1154,7 @@ const DomandaEditInstructorManager = () => {
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE' || (data.applicationStatus === 'EVALUATION'
|
||||
&& (!allFilesRated || !atLeastOneChecked)) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationShouldBeBlocked(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi Domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
@@ -866,7 +1201,7 @@ const DomandaEditInstructorManager = () => {
|
||||
value={appointmentData.amount}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.amount) || appointmentData.amount === 0}
|
||||
onChange={(e) => setValue('amount', e.value)}/>
|
||||
onChange={(e) => setFieldValue('amount', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label
|
||||
@@ -877,7 +1212,7 @@ const DomandaEditInstructorManager = () => {
|
||||
value={appointmentData.duration}
|
||||
keyfilter="int"
|
||||
invalid={isEmpty(appointmentData.duration) || appointmentData.duration === 0}
|
||||
onChange={(e) => setValue('duration', e.value)}/>
|
||||
onChange={(e) => setFieldValue('duration', e.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.title) })}>
|
||||
@@ -886,7 +1221,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<InputText
|
||||
value={appointmentData.title}
|
||||
invalid={isEmpty(appointmentData.title)}
|
||||
onChange={(e) => setValue('title', e.target.value)}/>
|
||||
onChange={(e) => setFieldValue('title', e.target.value)}/>
|
||||
</div>
|
||||
<div className="appForm__field">
|
||||
<label className={classNames({ 'p-error': isEmpty(appointmentData.text) })}>
|
||||
@@ -895,7 +1230,7 @@ const DomandaEditInstructorManager = () => {
|
||||
<InputTextarea
|
||||
value={appointmentData.text}
|
||||
invalid={isEmpty(appointmentData.text)}
|
||||
onChange={(e) => setValue('text', e.target.value)}
|
||||
onChange={(e) => setFieldValue('text', e.target.value)}
|
||||
rows={3}
|
||||
cols={30}/>
|
||||
</div>
|
||||
|
||||
@@ -264,6 +264,31 @@ const DomandaEditPreInstructor = () => {
|
||||
updateFlagsForSoccorso(newData);
|
||||
}
|
||||
|
||||
const getTransformedSubmitData = () => {
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
return Object.keys(formValues)
|
||||
.filter(v => usedFieldsIds.includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
const formField = head(formData.filter(o => o.id === cur));
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
if (formValues[cur] && formValues[cur].toISOString) {
|
||||
fieldVal = formatDateString(formValues[cur]);
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
'fieldId': cur,
|
||||
'fieldValue': fieldVal
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
const doSaveDraft = useCallback((doRedirect = '') => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
@@ -286,28 +311,7 @@ const DomandaEditPreInstructor = () => {
|
||||
errUpdateCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const formValues = getValues();
|
||||
const usedFieldsIds = pluck('id', formData);
|
||||
const newFormValues = Object.keys(formValues)
|
||||
.filter(v => usedFieldsIds.includes(v))
|
||||
.reduce((acc, cur) => {
|
||||
const formField = head(formData.filter(o => o.id === cur));
|
||||
let fieldVal = formValues[cur];
|
||||
|
||||
if (formValues[cur] && formValues[cur].toISOString) {
|
||||
fieldVal = formatDateString(formValues[cur]);
|
||||
}
|
||||
|
||||
fieldVal = isEmpty(fieldVal) ? null : fieldVal;
|
||||
if (formField && formField.name === 'fileupload') {
|
||||
fieldVal = is(Array, fieldVal) ? fieldVal.map(o => o.id).join(',') : null;
|
||||
}
|
||||
acc.push({
|
||||
'fieldId': cur,
|
||||
'fieldValue': fieldVal
|
||||
});
|
||||
return acc;
|
||||
}, []);
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
@@ -360,7 +364,8 @@ const DomandaEditPreInstructor = () => {
|
||||
}
|
||||
|
||||
const doApprove = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'APPROVED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -371,11 +376,42 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const doReject = () => {
|
||||
const formData = {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
const submitData = {
|
||||
applicationStatus: 'REJECTED',
|
||||
criteria: klona(data.criteria),
|
||||
checklist: klona(data.checklist),
|
||||
@@ -386,7 +422,37 @@ const DomandaEditPreInstructor = () => {
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluation(data.assignedApplicationId, formData, updateStatusCallback, errUpdateStatusCallback);
|
||||
ApplicationEvaluationService.updateEvaluation(
|
||||
data.assignedApplicationId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
const newFormValues = getTransformedSubmitData();
|
||||
const submitData = {
|
||||
formFields: newFormValues,
|
||||
files: klona(data.files),
|
||||
evaluationDocument: klona(data.evaluationDocument.map(o => ({
|
||||
...o,
|
||||
fileValue: o.fileValue[0] ? o.fileValue[0].id : ''
|
||||
})
|
||||
)),
|
||||
amendmentDetails: klona(data.amendmentDetails),
|
||||
note: data.note,
|
||||
motivation
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setIsVisibleCompleteDialog(false);
|
||||
ApplicationEvaluationService.updateEvaluationV2(
|
||||
data.assignedApplicationId,
|
||||
formId,
|
||||
submitData,
|
||||
updateStatusCallback,
|
||||
errUpdateStatusCallback
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updateStatusCallback = (data) => {
|
||||
@@ -647,11 +713,105 @@ const DomandaEditPreInstructor = () => {
|
||||
// TODO
|
||||
}
|
||||
|
||||
const evaluationShouldBeBlocked = (data = {}) => {
|
||||
const evaluationBlockedForUser = (data = {}) => {
|
||||
const userData = storeGet.main.userData()
|
||||
return isAsyncRequest || userData.id !== data.assignedUserId;
|
||||
}
|
||||
|
||||
const shouldDisableNewSoccorso = () => {
|
||||
if (data.evaluationVersion === 'V1') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else if (data.evaluationVersion === 'V2') {
|
||||
return !allFilesRated || !atLeastOneChecked;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const actionBtns = () => {
|
||||
return <div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE'
|
||||
|| (data.applicationStatus === 'EVALUATION' && shouldDisableNewSoccorso())
|
||||
|| evaluationBlockedForUser(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationBlockedForUser(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationBlockedForUser(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationBlockedForUser(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let updatedFormValues = klona(formValues);
|
||||
let context = {};
|
||||
@@ -742,6 +902,14 @@ const DomandaEditPreInstructor = () => {
|
||||
? <div className="appPage__content">
|
||||
<ApplicationInfo data={data}/>
|
||||
|
||||
<div className="appPageSection__hr">
|
||||
<span>{__('Azioni rapide', 'gepafin')}</span>
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<ApplicationDownloadFiles id={id}/>
|
||||
|
||||
<div className="appPageSection">
|
||||
@@ -752,7 +920,7 @@ const DomandaEditPreInstructor = () => {
|
||||
data,
|
||||
['evaluationDocument']
|
||||
)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisable={['APPROVED', 'REJECTED'].includes(data.applicationStatus) || evaluationBlockedForUser(data)}
|
||||
sourceId={data.assignedApplicationId}
|
||||
sourceName="evaluation"/>
|
||||
</div>
|
||||
@@ -764,7 +932,7 @@ const DomandaEditPreInstructor = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -773,7 +941,8 @@ const DomandaEditPreInstructor = () => {
|
||||
: null}
|
||||
|
||||
{data.evaluationVersion === 'V2'
|
||||
? <form className="appForm" onSubmit={handleSubmit(() => {})}>
|
||||
? <form className="appForm" onSubmit={handleSubmit(() => {
|
||||
})}>
|
||||
{formData.map(o => {
|
||||
const label = head(o.settings.filter(o => o.name === 'label'));
|
||||
const text = head(o.settings.filter(o => o.name === 'text'));
|
||||
@@ -857,7 +1026,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<div className="appPageSection__checklist">
|
||||
{data.checklist.map((o, i) => <div key={o.id}>
|
||||
<Checkbox
|
||||
disabled={shouldDisableField('checklist') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('checklist') || evaluationBlockedForUser(data)}
|
||||
inputId={`checklist_${o.id}`}
|
||||
onChange={(e) => updateEvaluationValue(
|
||||
e.checked,
|
||||
@@ -873,7 +1042,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<div>
|
||||
<Editor
|
||||
value={data.note}
|
||||
readOnly={shouldDisableField('note') || evaluationShouldBeBlocked(data)}
|
||||
readOnly={shouldDisableField('note') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Digita qui il messagio', 'gepafin')}
|
||||
headerTemplate={header}
|
||||
onTextChange={(e) => updateEvaluationValue(
|
||||
@@ -890,7 +1059,7 @@ const DomandaEditPreInstructor = () => {
|
||||
? <ListOfFiles
|
||||
files={data.files}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="files"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -906,7 +1075,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<ListOfFiles
|
||||
files={data.amendmentDetails}
|
||||
updateFn={updateEvaluationValue}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationShouldBeBlocked(data)}
|
||||
shouldDisableFieldFn={(name) => shouldDisableField(name) || evaluationBlockedForUser(data)}
|
||||
name="amendmentDetails"
|
||||
ndg={data.ndg}
|
||||
applicationId={id}/>
|
||||
@@ -930,7 +1099,7 @@ const DomandaEditPreInstructor = () => {
|
||||
<td>
|
||||
<div className="p-inputgroup">
|
||||
<InputNumber
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
placeholder={__('Punteggio', 'gepafin')}
|
||||
keyfilter="int"
|
||||
value={o.score}
|
||||
@@ -953,7 +1122,7 @@ const DomandaEditPreInstructor = () => {
|
||||
onClick={() => displayCriterionData(o.id)}
|
||||
aria-label={__('Mostra', 'gepafin')}/> : null}
|
||||
<Button icon="pi pi-thumbs-up" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && o.valid ? 'success' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
true,
|
||||
@@ -961,7 +1130,7 @@ const DomandaEditPreInstructor = () => {
|
||||
)}
|
||||
aria-label={__('Su', 'gepafin')}/>
|
||||
<Button icon="pi pi-thumbs-down" rounded outlined
|
||||
disabled={shouldDisableField('criteria') || evaluationShouldBeBlocked(data)}
|
||||
disabled={shouldDisableField('criteria') || evaluationBlockedForUser(data)}
|
||||
severity={!isNil(o.valid) && !o.valid ? 'danger' : 'secondary'}
|
||||
onClick={() => updateEvaluationValue(
|
||||
false,
|
||||
@@ -1000,86 +1169,7 @@ const DomandaEditPreInstructor = () => {
|
||||
</div>
|
||||
|
||||
<div className="appPageSection">
|
||||
<div className="appPageSection__actions">
|
||||
{['EVALUATION', 'SOCCORSO', 'CLOSE'].includes(data.applicationStatus)
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || data.status === 'CLOSE' || (data.applicationStatus === 'EVALUATION'
|
||||
&& (!allFilesRated || !atLeastOneChecked)) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doNewSoccorso}
|
||||
outlined
|
||||
label={<>
|
||||
{data.applicationStatus === 'EVALUATION'
|
||||
? __('Richiedi soccorso istruttorio', 'gepafin')
|
||||
: __('Apri soccorso istruttorio', 'gepafin')}
|
||||
<i style={{ marginLeft: 7 }}>
|
||||
<HelpIcon/>
|
||||
</i>
|
||||
</>}
|
||||
/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={data.status === 'CLOSE' || evaluationShouldBeBlocked(data)}
|
||||
onClick={() => doSaveDraft()}
|
||||
outlined
|
||||
label={__('Salva bozza valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>
|
||||
: <Button
|
||||
type="button"
|
||||
onClick={() => doSaveDraft()}
|
||||
label={__('Crea valutazione', 'gepafin')}
|
||||
icon="pi pi-save" iconPos="right"/>}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && ['EVALUATION'].includes(data.applicationStatus)
|
||||
&& APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !allFilesRated || !allChecksChecked
|
||||
|| !['EVALUATION'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCheckNDG}
|
||||
label={__('Controlla NDG', 'gepafin')}
|
||||
/> : null}
|
||||
{APP_EVALUATION_FLOW_ID === '1' && APP_HUB_ID !== 't7jh5wfg9QXylNaTZkPoE'
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!data.id || !['NDG'].includes(data.applicationStatus) || !data.ndg || evaluationShouldBeBlocked(data)}
|
||||
onClick={doCreateAppointment}
|
||||
label={__('Crea l\'appuntamento', 'gepafin')}
|
||||
/> : null}
|
||||
<Button
|
||||
type="button"
|
||||
disabled={!data.id || !['APPOINTMENT'].includes(data.applicationStatus) || evaluationShouldBeBlocked(data)}
|
||||
onClick={doMakeAdmisible}
|
||||
label={__('Ammissibile formalmente', 'gepafin')}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
disabled={true}
|
||||
onClick={() => {
|
||||
}}
|
||||
label={__('Valutazione tecnico-finanziaria positiva', 'gepafin')}
|
||||
/>
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={!isAdmissible
|
||||
|| ['APPROVED'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data)
|
||||
|| (APP_EVALUATION_FLOW_ID === '1' && !['ADMISSIBLE'].includes(data.applicationStatus))
|
||||
}
|
||||
onClick={initiateApproving}
|
||||
label={__('Domanda deliberata', 'gepafin')}
|
||||
icon="pi pi-check" iconPos="right"/> : null}
|
||||
{data.id
|
||||
? <Button
|
||||
type="button"
|
||||
disabled={APP_EVALUATION_FLOW_ID === '1'
|
||||
&& (!['EVALUATION', 'ADMISSIBLE', 'APPOINTMENT'].includes(data.applicationStatus)
|
||||
|| evaluationShouldBeBlocked(data))}
|
||||
onClick={initiateRejecting}
|
||||
label={__('Respingi domanda', 'gepafin')}
|
||||
icon="pi pi-times" iconPos="right"/> : null}
|
||||
</div>
|
||||
{actionBtns()}
|
||||
</div>
|
||||
|
||||
<Dialog
|
||||
|
||||
@@ -185,6 +185,10 @@ export const elementItems = [
|
||||
{
|
||||
name: "label",
|
||||
value: "Casella di Spunta"
|
||||
},
|
||||
{
|
||||
name: "isChecklistItem",
|
||||
value: false
|
||||
}
|
||||
],
|
||||
validators: {
|
||||
@@ -459,5 +463,25 @@ export const elementItems = [
|
||||
validators: {
|
||||
custom: 'nonEmptyTables'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 22,
|
||||
sortOrder: 22,
|
||||
name: 'switch',
|
||||
label: 'Casella di spunta "Checklist"',
|
||||
description: 'Per selezioni binarie, accettazioni, conferme',
|
||||
settings: [
|
||||
{
|
||||
name: "label",
|
||||
value: "Casella di Spunta"
|
||||
},
|
||||
{
|
||||
name: "isChecklistItem",
|
||||
value: true
|
||||
}
|
||||
],
|
||||
validators: {
|
||||
isRequired: false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user