- re enabled CSV export for super user;
This commit is contained in:
@@ -94,17 +94,52 @@ const AllBandiTableAsync = () => {
|
||||
<Button severity="info" label={__('Mostra', 'gepafin')} icon="pi pi-eye" size="small" iconPos="right"/>
|
||||
</Link>
|
||||
{['PUBLISH', 'EXPIRED'].includes(rowData.status)
|
||||
? <Button type="button"
|
||||
? <>
|
||||
<Button type="button"
|
||||
size="small"
|
||||
severity='info'
|
||||
severity="info"
|
||||
icon="pi pi-download"
|
||||
iconPos="right"
|
||||
label={__('Scarica graduatoria', 'gepafin')}
|
||||
onClick={() => handleDownloadRanking(rowData.id)}
|
||||
/> : null}
|
||||
/>
|
||||
<Button type="button"
|
||||
size="small"
|
||||
icon="pi pi-receipt"
|
||||
iconPos="right"
|
||||
label={__('CSV', 'gepafin')}
|
||||
onClick={() => exportToCSV(rowData.id)}/>
|
||||
</>
|
||||
: null}
|
||||
</div>
|
||||
}
|
||||
|
||||
const exportToCSV = (applicationId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadCsvReport(
|
||||
applicationId,
|
||||
(resp) => getCsvReportback(resp, applicationId),
|
||||
errCsvReportCallback
|
||||
)
|
||||
}
|
||||
|
||||
const getCsvReportback = (resp, applicationId) => {
|
||||
const file = new Blob([resp], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errCsvReportCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const handleDownloadRanking = (callId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadRanking(callId,
|
||||
@@ -117,7 +152,7 @@ const AllBandiTableAsync = () => {
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
@@ -75,7 +75,7 @@ const ElementSetting = ({ setting, changeFn, updateDataFn, bandoStatus }) => {
|
||||
|
||||
const invalidFormula = (value) => {
|
||||
try {
|
||||
const context = getTokens(value)
|
||||
getTokens(value)
|
||||
return false;
|
||||
} catch {
|
||||
return __('Potrebbe essere un errore nella formula!')
|
||||
|
||||
@@ -100,9 +100,41 @@ const LatestBandiTableAsync = () => {
|
||||
iconPos="right"
|
||||
label={__('Scarica graduatoria', 'gepafin')}
|
||||
onClick={() => handleDownloadRanking(rowData.id)}/>
|
||||
<Button type="button"
|
||||
size="small"
|
||||
icon="pi pi-receipt"
|
||||
iconPos="right"
|
||||
label={__('CSV', 'gepafin')}
|
||||
onClick={() => exportToCSV(rowData.id)}/>
|
||||
</div>
|
||||
}
|
||||
|
||||
const exportToCSV = (applicationId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadCsvReport(
|
||||
applicationId,
|
||||
(resp) => getCsvReportback(resp, applicationId),
|
||||
errCsvReportCallback
|
||||
)
|
||||
}
|
||||
|
||||
const getCsvReportback = (resp, applicationId) => {
|
||||
const file = new Blob([resp], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const errCsvReportCallback = (resp) => {
|
||||
set404FromErrorResponse(resp);
|
||||
setLocalAsyncRequest(false);
|
||||
}
|
||||
|
||||
const handleDownloadRanking = (callId) => {
|
||||
setLocalAsyncRequest(true);
|
||||
ApplicationService.downloadRanking(callId,
|
||||
@@ -115,7 +147,7 @@ const LatestBandiTableAsync = () => {
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
@@ -149,7 +149,7 @@ const LatestBandiTableInstructorManagerAsync = () => {
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', `call-${applicationId}-applications-report.csv`);
|
||||
link.setAttribute('download', `call-${applicationId}-graduatoria.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
|
||||
Reference in New Issue
Block a user