Merge pull request #54 from Kitzanos/master-sync-02-07-2025
Master sync 02 07 2025
This commit is contained in:
@@ -45,10 +45,11 @@ const AllBandiPreInstructorTableAsync = () => {
|
||||
}
|
||||
});
|
||||
const statuses = ['DRAFT', 'PUBLISH', 'EXPIRED'];
|
||||
const initialFetchStatuses = ['PUBLISH', 'EXPIRED'];
|
||||
|
||||
const role = storeGet('getRole')
|
||||
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, initialFetchStatuses, 'id'), [lazyState]);
|
||||
|
||||
const onPage = (event) => {
|
||||
setLazyState(event);
|
||||
@@ -174,7 +175,7 @@ const AllBandiPreInstructorTableAsync = () => {
|
||||
const paginationQuery = getPaginationQuery();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
|
||||
@@ -574,12 +574,17 @@ const BandoApplication = () => {
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
} catch {
|
||||
console.error('Error in formula', formula)
|
||||
context = {}
|
||||
}
|
||||
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
|
||||
@@ -288,12 +288,17 @@ const BandoApplicationPreview = () => {
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
} catch {
|
||||
console.error('Error in formula', formula)
|
||||
context = {}
|
||||
}
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
|
||||
@@ -22,6 +22,7 @@ import ElementSettingTableColumnsForCsv from '../ElementSettingTableColumnsForCs
|
||||
import { mimeTypes } from '../../../../../../configData';
|
||||
import ElementSettingReportHeader from '../ElementSettingReportHeader';
|
||||
import ElementSettingReportEnable from '../ElementSettingReportEnable';
|
||||
import getTokens from '../../../../../../helpers/getTokens';
|
||||
|
||||
|
||||
const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
@@ -72,6 +73,15 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
|
||||
const header = renderHeader();
|
||||
|
||||
const invalidFormula = (value) => {
|
||||
try {
|
||||
const context = getTokens(value)
|
||||
return false;
|
||||
} catch {
|
||||
return __('Potrebbe essere un errore nella formula!')
|
||||
}
|
||||
}
|
||||
|
||||
const getProperField = (setting) => {
|
||||
if (setting.name === 'options') {
|
||||
return <ElementSettingRepeater
|
||||
@@ -145,6 +155,14 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
name={setting.name}
|
||||
bandoStatus={bandoStatus}
|
||||
setDataFn={updateDataFn}/>
|
||||
} else if (setting.name === 'formula') {
|
||||
const isInvalid = invalidFormula(setting.value);
|
||||
return <>
|
||||
<InputText id={setting.name} aria-describedby={`${setting.name}-help`}
|
||||
value={setting.value}
|
||||
onChange={(e) => changeFn(e.target.value, setting.name)}/>
|
||||
<p style={{margiTop: 0, fontSize: '14px', color: '#df3636'}}>{isInvalid}</p>
|
||||
</>
|
||||
} else {
|
||||
return <InputText id={setting.name} aria-describedby={`${setting.name}-help`}
|
||||
value={setting.value}
|
||||
|
||||
@@ -103,12 +103,17 @@ const BandoFormsPreview = () => {
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
} catch {
|
||||
console.error('Error in formula', formula)
|
||||
context = {}
|
||||
}
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
|
||||
@@ -40,10 +40,10 @@ const LatestBandiTableAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { value: null, matchMode: 'dateIs' },
|
||||
endDate: { value: null, matchMode: 'dateIs' },
|
||||
status: { value: null, matchMode: 'equals' }
|
||||
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||
}
|
||||
});
|
||||
const statuses = ['PUBLISH', 'EXPIRED'];
|
||||
const statuses = ['PUBLISH'];
|
||||
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||
|
||||
@@ -197,7 +197,7 @@ const LatestBandiTableAsync = () => {
|
||||
const paginationQuery = getPaginationQuery();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
|
||||
@@ -39,10 +39,10 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { value: null, matchMode: 'dateIs' },
|
||||
endDate: { value: null, matchMode: 'dateIs' },
|
||||
status: { value: null, matchMode: 'equals' }
|
||||
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||
}
|
||||
});
|
||||
const statuses = ['PUBLISH', 'EXPIRED'];
|
||||
const statuses = ['PUBLISH'];
|
||||
|
||||
const getPaginationQuery = useCallback(() => getQueryParamsForPaginatedEndpoint(lazyState, statuses, 'id'), [lazyState]);
|
||||
|
||||
@@ -128,23 +128,23 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
return <div className="appPageSection__tableActions">
|
||||
<Button type="button"
|
||||
size="small"
|
||||
icon="pi pi-receipt"
|
||||
severity="info"
|
||||
icon="pi pi-download"
|
||||
iconPos="right"
|
||||
label={__('CSV', 'gepafin')}
|
||||
onClick={() => exportToCSV(rowData.id)}/>
|
||||
label={__('Scarica graduatoria', 'gepafin')}
|
||||
onClick={() => handleDownloadRanking(rowData.id)}
|
||||
/>
|
||||
</div>
|
||||
}
|
||||
|
||||
const exportToCSV = (applicationId) => {
|
||||
const handleDownloadRanking = (callId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadCsvReport(
|
||||
applicationId,
|
||||
(resp) => getCsvReportback(resp, applicationId),
|
||||
errCsvReportCallback
|
||||
)
|
||||
ApplicationService.downloadRanking(callId,
|
||||
(resp) => downloadSuccessCallback(resp, callId),
|
||||
downloadErrorCallback)
|
||||
}
|
||||
|
||||
const getCsvReportback = (resp, applicationId) => {
|
||||
const downloadSuccessCallback = (resp, applicationId) => {
|
||||
const file = new Blob([resp], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
@@ -156,7 +156,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errCsvReportCallback = (resp) => {
|
||||
const downloadErrorCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
@@ -172,7 +172,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
name: { value: null, matchMode: 'contains' },
|
||||
startDate: { value: null, matchMode: 'dateIs' },
|
||||
endDate: { value: null, matchMode: 'dateIs' },
|
||||
status: { value: null, matchMode: 'equals' }
|
||||
status: { value: 'PUBLISH', matchMode: 'equals' }
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -192,7 +192,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
const paginationQuery = getPaginationQuery();
|
||||
|
||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||
}, [lazyState]);
|
||||
}, [lazyState, getPaginationQuery]);
|
||||
|
||||
return (
|
||||
<div className="appPageSection__table">
|
||||
|
||||
@@ -940,13 +940,17 @@ const DomandaEditInstructorManager = () => {
|
||||
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);
|
||||
|
||||
try {
|
||||
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);
|
||||
} catch {
|
||||
console.error('Error in formula', formula)
|
||||
context = {}
|
||||
}
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
updatedFormValues[o.id] = evaluate(mathFormula);
|
||||
|
||||
@@ -940,12 +940,17 @@ const DomandaEditPreInstructor = () => {
|
||||
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);
|
||||
try {
|
||||
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);
|
||||
} catch {
|
||||
console.error('Error in formula', formula)
|
||||
context = {}
|
||||
}
|
||||
|
||||
const mathFormula = renderWithDataVars(formula.value, context);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user