- fixed filter for calls table;
- implemented call table async on all pages; - added applications table async;
This commit is contained in:
9
src/helpers/getFormattedDateString.js
Normal file
9
src/helpers/getFormattedDateString.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const getFormattedDateString = (value) => {
|
||||||
|
return value.toLocaleDateString('it-IT', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default getFormattedDateString;
|
||||||
@@ -1,23 +1,28 @@
|
|||||||
import React, { useEffect, useState, useCallback } from 'react';
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { FilterMatchMode } from 'primereact/api';
|
import { isEmpty, pathOr } from 'ramda';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import translationStrings from '../../../../translationStringsForComponents';
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
// api
|
// api
|
||||||
import BandoService from '../../../../service/bando-service';
|
import BandoService from '../../../../service/bando-service';
|
||||||
|
|
||||||
|
// tools
|
||||||
|
import getTimeParsedFromString from '../../../../helpers/getTimeParsedFromString';
|
||||||
|
import getTimeFromISOstring from '../../../../helpers/getTimeFromISOstring';
|
||||||
|
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||||
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import { DataTable } from 'primereact/datatable';
|
import { DataTable } from 'primereact/datatable';
|
||||||
import { Column } from 'primereact/column';
|
import { Column } from 'primereact/column';
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { Tag } from 'primereact/tag';
|
import { Tag } from 'primereact/tag';
|
||||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
import { Calendar } from 'primereact/calendar';
|
||||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
|
||||||
import { isEmpty, pathOr } from 'ramda';
|
|
||||||
|
|
||||||
const LatestBandiTableAsync = () => {
|
const LatestBandiTableAsync = () => {
|
||||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
@@ -30,55 +35,54 @@ const LatestBandiTableAsync = () => {
|
|||||||
sortField: null,
|
sortField: null,
|
||||||
sortOrder: null,
|
sortOrder: null,
|
||||||
filters: {
|
filters: {
|
||||||
name: { value: '', matchMode: 'contains' },
|
name: { value: null, matchMode: 'contains' },
|
||||||
status: { value: '', matchMode: 'equals' }
|
startDate: { value: null, matchMode: 'date_is' },
|
||||||
|
endDate: { value: null, matchMode: 'date_is' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const statuses = ['PUBLISH'];
|
const statuses = ['PUBLISH'];
|
||||||
|
|
||||||
const getPaginationQuery = useCallback(() => {
|
const getPaginationQuery = useCallback(() => {
|
||||||
let sortBy = {
|
let sortBy = {
|
||||||
"columnName": "ID",
|
columnName: "ID",
|
||||||
"sortDesc": true
|
sortDesc: true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (lazyState.sortField) {
|
if (lazyState.sortField) {
|
||||||
sortBy = {
|
sortBy = {
|
||||||
"columnName": lazyState.sortField,
|
columnName: lazyState.sortField,
|
||||||
"sortDesc": lazyState.sortOrder === -1
|
sortDesc: lazyState.sortOrder === -1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
globalFilters: {
|
globalFilters: {
|
||||||
page: lazyState.page ? lazyState.page + 1 : 1,
|
page: lazyState.page ? lazyState.page + 1 : 1,
|
||||||
limit: lazyState.rows,
|
limit: lazyState.rows,
|
||||||
filters: Object.keys(lazyState.filters).reduce((acc, cur) => {
|
|
||||||
const value = pathOr('', ['filters', cur, 'value'], lazyState);
|
|
||||||
if (!isEmpty(value)) {
|
|
||||||
acc[cur] = lazyState.filters[cur];
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, {}),
|
|
||||||
sortBy
|
sortBy
|
||||||
},
|
},
|
||||||
status: statuses
|
status: statuses,
|
||||||
|
filters: Object.keys(lazyState.filters).reduce((acc, cur) => {
|
||||||
|
const value = pathOr('', ['filters', cur, 'value'], lazyState);
|
||||||
|
if (!isEmpty(value)) {
|
||||||
|
acc[cur] = lazyState.filters[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
}
|
}
|
||||||
}, [lazyState]);
|
}, [lazyState]);
|
||||||
|
|
||||||
const onPage = (event) => {
|
const onPage = (event) => {
|
||||||
//console.log('onPage', event);
|
|
||||||
setLazyState(event);
|
setLazyState(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSort = (event) => {
|
const onSort = (event) => {
|
||||||
//console.log('onSort', event);
|
|
||||||
event['first'] = 0;
|
event['first'] = 0;
|
||||||
event['page'] = 0;
|
event['page'] = 0;
|
||||||
setLazyState(event);
|
setLazyState(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFilter = useCallback((event) => {
|
const onFilter = useCallback((event) => {
|
||||||
//console.log('onFilter', event);
|
|
||||||
event['first'] = 0;
|
event['first'] = 0;
|
||||||
event['page'] = 0;
|
event['page'] = 0;
|
||||||
setLazyState(event);
|
setLazyState(event);
|
||||||
@@ -90,7 +94,7 @@ const LatestBandiTableAsync = () => {
|
|||||||
//currentPage, totalPages, pageSize
|
//currentPage, totalPages, pageSize
|
||||||
} = resp.data;
|
} = resp.data;
|
||||||
setTotalRecordsNum(totalRecords);
|
setTotalRecordsNum(totalRecords);
|
||||||
setItems(getFormattedBandiData(body));
|
setItems(getFormattedData(body));
|
||||||
}
|
}
|
||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
@@ -99,10 +103,10 @@ const LatestBandiTableAsync = () => {
|
|||||||
setLocalAsyncRequest(false);
|
setLocalAsyncRequest(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const getFormattedBandiData = (data) => {
|
const getFormattedData = (data) => {
|
||||||
return [...(data || [])].map((d) => {
|
return [...(data || [])].map((d) => {
|
||||||
d.start_date = new Date(d.dates[0]);
|
d.startDate = new Date(d.dates[0]);
|
||||||
d.end_date = new Date(d.dates[1]);
|
d.endDate = new Date(d.dates[1]);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
@@ -138,39 +142,28 @@ const LatestBandiTableAsync = () => {
|
|||||||
showClear/>;
|
showClear/>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const dateFilterTemplate = (options) => {
|
||||||
|
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
|
dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>;
|
||||||
|
};
|
||||||
|
|
||||||
const dateStartBodyTemplate = (rowData) => {
|
const dateStartBodyTemplate = (rowData) => {
|
||||||
return formatDate(rowData.start_date);
|
const startTimeObj = getTimeParsedFromString(rowData.startTime);
|
||||||
|
return getFormattedDateString(rowData.startDate) + ' ' + getTimeFromISOstring(startTimeObj);
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateEndBodyTemplate = (rowData) => {
|
const dateEndBodyTemplate = (rowData) => {
|
||||||
return formatDate(rowData.end_date);
|
const endTimeObg = getTimeParsedFromString(rowData.endTime);
|
||||||
};
|
return getFormattedDateString(rowData.endDate) + ' ' + getTimeFromISOstring(endTimeObg);
|
||||||
|
|
||||||
const formatDate = (value) => {
|
|
||||||
return value.toLocaleDateString('it-IT', {
|
|
||||||
day: '2-digit',
|
|
||||||
month: '2-digit',
|
|
||||||
year: 'numeric'
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//console.log('lazyState', lazyState)
|
|
||||||
setLocalAsyncRequest(true);
|
setLocalAsyncRequest(true);
|
||||||
const paginationQuery = getPaginationQuery();
|
const paginationQuery = getPaginationQuery();
|
||||||
//console.log('paginationQuery', paginationQuery)
|
|
||||||
|
|
||||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||||
}, [lazyState]);
|
}, [lazyState]);
|
||||||
|
|
||||||
/*useEffect(() => {
|
|
||||||
if (!localAsyncRequest) {
|
|
||||||
setLocalAsyncRequest(true);
|
|
||||||
const paginationQuery = getPaginationQuery();
|
|
||||||
BandoService.getBandiPaginated(paginationQuery, getCallback, errGetCallbacks);
|
|
||||||
}
|
|
||||||
}, []);*/
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="appPageSection__table">
|
<div className="appPageSection__table">
|
||||||
<DataTable
|
<DataTable
|
||||||
@@ -183,18 +176,24 @@ const LatestBandiTableAsync = () => {
|
|||||||
<Column field="name"
|
<Column field="name"
|
||||||
sortable
|
sortable
|
||||||
filterField="name" filter
|
filterField="name" filter
|
||||||
filterMatchModeOptions={[{ label: 'Contiene', value: FilterMatchMode.CONTAINS }]}
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
header={__('Nome Bando', 'gepafin')}
|
header={__('Nome Bando', 'gepafin')}
|
||||||
style={{ minWidth: '8rem' }}/>
|
style={{ minWidth: '8rem' }}/>
|
||||||
<Column header={__('Data Pubblicazione', 'gepafin')}
|
<Column header={__('Data Pubblicazione', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="startDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
style={{ minWidth: '8rem' }}
|
style={{ minWidth: '8rem' }}
|
||||||
body={dateStartBodyTemplate}/>
|
body={dateStartBodyTemplate}/>
|
||||||
<Column header={__('Data Scadenza', 'gepafin')}
|
<Column header={__('Data Scadenza', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="endDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
style={{ minWidth: '8rem' }}
|
style={{ minWidth: '8rem' }}
|
||||||
body={dateEndBodyTemplate}/>
|
body={dateEndBodyTemplate}/>
|
||||||
<Column field="status"
|
<Column field="status"
|
||||||
filterElement={statusFilterTemplate} filter
|
filterElement={statusFilterTemplate} filter
|
||||||
filterMatchModeOptions={[{ label: 'Uguale a', value: FilterMatchMode.EQUALS }]}
|
filterMatchModeOptions={translationStrings.statusFilterOptions}
|
||||||
header={__('Stato', 'gepafin')}
|
header={__('Stato', 'gepafin')}
|
||||||
style={{ minWidth: '7rem' }}
|
style={{ minWidth: '7rem' }}
|
||||||
body={statusBodyTemplate} />
|
body={statusBodyTemplate} />
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import DashboardService from '../../service/dashboard-service';
|
|||||||
|
|
||||||
// components
|
// components
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import AllDomandeTable from '../Domande/components/AllDomandeTable';
|
|
||||||
import DraftApplicationsTable from './components/DraftApplicationsTable';
|
import DraftApplicationsTable from './components/DraftApplicationsTable';
|
||||||
import ChartDomandePerBando from '../../components/ChartDomandePerBando';
|
import ChartDomandePerBando from '../../components/ChartDomandePerBando';
|
||||||
import ChartStatoDomande from '../../components/ChartStatoDomande';
|
import ChartStatoDomande from '../../components/ChartStatoDomande';
|
||||||
import LatestBandiTableAsync from './components/LatestBandiTableAsync';
|
import LatestBandiTableAsync from './components/LatestBandiTableAsync';
|
||||||
|
import AllDomandeTableAsync from '../Domande/components/AllDomandeTableAsync';
|
||||||
|
|
||||||
const Dashboard = () => {
|
const Dashboard = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -137,14 +137,13 @@ const Dashboard = () => {
|
|||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Ultimi bandi pubblicati', 'gepafin')}</h2>
|
<h2>{__('Ultimi bandi pubblicati', 'gepafin')}</h2>
|
||||||
<LatestBandiTableAsync/>
|
<LatestBandiTableAsync/>
|
||||||
{/*<LatestBandiTable/>*/}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Ultime domande pubblicate', 'gepafin')}</h2>
|
<h2>{__('Ultime domande pubblicate', 'gepafin')}</h2>
|
||||||
<AllDomandeTable/>
|
<AllDomandeTableAsync/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import { useStore } from '../../store';
|
|||||||
import DashboardService from '../../service/dashboard-service';
|
import DashboardService from '../../service/dashboard-service';
|
||||||
|
|
||||||
// components
|
// components
|
||||||
import LatestBandiTable from './components/LatestBandiTable';
|
|
||||||
import MyLatestSubmissionsTable from './components/MyLatestSubmissionsTable';
|
import MyLatestSubmissionsTable from './components/MyLatestSubmissionsTable';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import ErrorBoundary from '../../components/ErrorBoundary';
|
import ErrorBoundary from '../../components/ErrorBoundary';
|
||||||
|
import LatestBandiTableAsync from '../Dashboard/components/LatestBandiTableAsync';
|
||||||
|
|
||||||
const DashboardBeneficiario = () => {
|
const DashboardBeneficiario = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -108,7 +108,7 @@ const DashboardBeneficiario = () => {
|
|||||||
|
|
||||||
<div className="appPageSection">
|
<div className="appPageSection">
|
||||||
<h2>{__('Bandi disponibili', 'gepafin')}</h2>
|
<h2>{__('Bandi disponibili', 'gepafin')}</h2>
|
||||||
<ErrorBoundary><LatestBandiTable/></ErrorBoundary>
|
<ErrorBoundary><LatestBandiTableAsync/></ErrorBoundary>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="appPage__spacer"></div>
|
<div className="appPage__spacer"></div>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import ApplicationService from '../../../../service/application-service';
|
|||||||
// tools
|
// tools
|
||||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||||
|
|
||||||
// translation
|
// translation
|
||||||
import translationStrings from '../../../../translationStringsForComponents';
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
@@ -60,14 +61,6 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const formatDate = (value) => {
|
|
||||||
return value.toLocaleDateString('it-IT', {
|
|
||||||
day: '2-digit',
|
|
||||||
month: '2-digit',
|
|
||||||
year: 'numeric'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const clearFilter = () => {
|
const clearFilter = () => {
|
||||||
initFilters();
|
initFilters();
|
||||||
};
|
};
|
||||||
@@ -105,7 +98,7 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const dateAppliedBodyTemplate = (rowData) => {
|
const dateAppliedBodyTemplate = (rowData) => {
|
||||||
return formatDate(rowData.submissionDate);
|
return getFormattedDateString(rowData.submissionDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
const statusFilterTemplate = (options) => {
|
const statusFilterTemplate = (options) => {
|
||||||
|
|||||||
219
src/pages/Domande/components/AllDomandeTableAsync/index.js
Normal file
219
src/pages/Domande/components/AllDomandeTableAsync/index.js
Normal file
@@ -0,0 +1,219 @@
|
|||||||
|
import React, { useEffect, useState, useCallback } from 'react';
|
||||||
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { is, isEmpty, pathOr } from 'ramda';
|
||||||
|
import { Link, useLocation } from 'react-router-dom';
|
||||||
|
|
||||||
|
import translationStrings from '../../../../translationStringsForComponents';
|
||||||
|
|
||||||
|
// api
|
||||||
|
import ApplicationService from '../../../../service/application-service';
|
||||||
|
|
||||||
|
//
|
||||||
|
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||||
|
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||||
|
import getFormattedDateString from '../../../../helpers/getFormattedDateString';
|
||||||
|
|
||||||
|
// components
|
||||||
|
import { DataTable } from 'primereact/datatable';
|
||||||
|
import { Column } from 'primereact/column';
|
||||||
|
import { Button } from 'primereact/button';
|
||||||
|
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||||
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
|
import { Tag } from 'primereact/tag';
|
||||||
|
import { Calendar } from 'primereact/calendar';
|
||||||
|
|
||||||
|
const AllDomandeTableAsync = ({ openDialogFn, updaterString = '' }) => {
|
||||||
|
const location = useLocation();
|
||||||
|
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||||
|
const [items, setItems] = useState(null);
|
||||||
|
const [totalRecordsNum, setTotalRecordsNum] = useState(0);
|
||||||
|
const [lazyState, setLazyState] = useState({
|
||||||
|
first: 0,
|
||||||
|
rows: 5,
|
||||||
|
page: 0,
|
||||||
|
sortField: null,
|
||||||
|
sortOrder: null,
|
||||||
|
filters: {
|
||||||
|
id: { value: null, matchMode: 'contains' },
|
||||||
|
callTitle: { value: null, matchMode: 'contains' },
|
||||||
|
companyName: { value: null, matchMode: 'contains' },
|
||||||
|
submissionDate: { value: null, matchMode: 'date_is' },
|
||||||
|
status: { value: null, matchMode: 'equals' }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const statuses = ['SUBMIT', 'EVALUATION', 'SOCCORSO'];
|
||||||
|
|
||||||
|
const getPaginationQuery = useCallback(() => {
|
||||||
|
let sortBy = {
|
||||||
|
columnName: "ID",
|
||||||
|
sortDesc: true
|
||||||
|
};
|
||||||
|
|
||||||
|
if (lazyState.sortField) {
|
||||||
|
sortBy = {
|
||||||
|
columnName: lazyState.sortField,
|
||||||
|
sortDesc: lazyState.sortOrder === -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
globalFilters: {
|
||||||
|
page: lazyState.page ? lazyState.page + 1 : 1,
|
||||||
|
limit: lazyState.rows,
|
||||||
|
sortBy
|
||||||
|
},
|
||||||
|
status: statuses,
|
||||||
|
filters: Object.keys(lazyState.filters).reduce((acc, cur) => {
|
||||||
|
const value = pathOr('', ['filters', cur, 'value'], lazyState);
|
||||||
|
if (!isEmpty(value)) {
|
||||||
|
acc[cur] = lazyState.filters[cur];
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
}
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const onPage = (event) => {
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSort = (event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onFilter = useCallback((event) => {
|
||||||
|
event['first'] = 0;
|
||||||
|
event['page'] = 0;
|
||||||
|
setLazyState(event);
|
||||||
|
}, [lazyState]);
|
||||||
|
|
||||||
|
const getCallback = (resp) => {
|
||||||
|
if (resp.status === 'SUCCESS') {
|
||||||
|
const { body, totalRecords,
|
||||||
|
//currentPage, totalPages, pageSize
|
||||||
|
} = resp.data;
|
||||||
|
setTotalRecordsNum(totalRecords);
|
||||||
|
setItems(getFormattedData(body));
|
||||||
|
}
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const errGetCallbacks = () => {
|
||||||
|
setLocalAsyncRequest(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const getFormattedData = (data) => {
|
||||||
|
return data.map((d) => {
|
||||||
|
d.callEndDate = is(String, d.callEndDate) ? new Date(d.callEndDate) : (d.callEndDate ? d.callEndDate : '');
|
||||||
|
d.modifiedDate = is(String, d.modifiedDate) ? new Date(d.modifiedDate) : (d.modifiedDate ? d.modifiedDate : '');
|
||||||
|
d.submissionDate = is(String, d.submissionDate) ? new Date(d.submissionDate) : (d.submissionDate ? d.submissionDate : '');
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const actionsBodyTemplate = (rowData) => {
|
||||||
|
return <div className="appPageSection__tableActions lessGap">
|
||||||
|
{openDialogFn && ['SUBMIT', 'EVALUATION', 'SOCCORSO'].includes(rowData.status)
|
||||||
|
? <Button severity="info"
|
||||||
|
onClick={() => openDialogFn(rowData.id)}
|
||||||
|
label={__('Assegnare', 'gepafin')}
|
||||||
|
icon="pi pi-pencil" size="small" iconPos="right"/>
|
||||||
|
: location.pathname !== '/domande'
|
||||||
|
? <Link to={'/domande'}>
|
||||||
|
<Button severity="info" label={__('Gestire', 'gepafin')} size="small"/>
|
||||||
|
</Link> : null}
|
||||||
|
<Link to={`/domande/${rowData.id}/preview`}>
|
||||||
|
<Button severity="info" label={__('Anteprima', 'gepafin')} icon="pi pi-eye" size="small"
|
||||||
|
iconPos="right"/>
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusBodyTemplate = (rowData) => {
|
||||||
|
return <ProperBandoLabel status={rowData.status}/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusItemTemplate = (option) => {
|
||||||
|
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const statusFilterTemplate = (options) => {
|
||||||
|
return <Dropdown value={options.value} options={statuses}
|
||||||
|
onChange={(e) => {
|
||||||
|
options.filterCallback(e.value, options.index)
|
||||||
|
const filters = { ...lazyState.filters };
|
||||||
|
if (e.value) {
|
||||||
|
filters['status'] = { value: e.value, matchMode: 'equals' };
|
||||||
|
} else {
|
||||||
|
delete filters['status'];
|
||||||
|
}
|
||||||
|
setLazyState({ ...lazyState, filters, first: 0 });
|
||||||
|
}}
|
||||||
|
itemTemplate={statusItemTemplate} placeholder={translationStrings.selectOneLabel} className="p-column-filter"
|
||||||
|
showClear/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateFilterTemplate = (options) => {
|
||||||
|
return <Calendar value={options.value} onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||||
|
dateFormat="mm/dd/yy" placeholder="mm/dd/yyyy" mask="99/99/9999"/>;
|
||||||
|
};
|
||||||
|
|
||||||
|
const dateAppliedBodyTemplate = (rowData) => {
|
||||||
|
return getFormattedDateString(rowData.submissionDate);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setLocalAsyncRequest(true);
|
||||||
|
const paginationQuery = getPaginationQuery();
|
||||||
|
|
||||||
|
ApplicationService.getApplicationsPaginated(paginationQuery, getCallback, errGetCallbacks);
|
||||||
|
}, [lazyState, updaterString]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="appPageSection__table">
|
||||||
|
<DataTable
|
||||||
|
value={items} stripedRows showGridlines
|
||||||
|
lazy filterDisplay="menu" dataKey="id" paginator
|
||||||
|
first={lazyState.first} rows={lazyState.rows} totalRecords={totalRecordsNum} onPage={onPage}
|
||||||
|
onSort={onSort} sortField={lazyState.sortField} sortOrder={lazyState.sortOrder}
|
||||||
|
onFilter={onFilter} filters={lazyState.filters} loading={localAsyncRequest}
|
||||||
|
emptyMessage={translationStrings.emptyMessage}>
|
||||||
|
<Column field="id" header={__('ID domanda', 'gepafin')}
|
||||||
|
sortable
|
||||||
|
filterField="id" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="protocolNumber" header={__('Protocollo', 'gepafin')}
|
||||||
|
filterPlaceholder={__('Cerca', 'gepafin')}
|
||||||
|
style={{ minWidth: '6rem' }}/>
|
||||||
|
<Column field="callTitle" header={__('Bando', 'gepafin')}
|
||||||
|
filterField="callTitle" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
style={{ minWidth: '10rem' }}/>
|
||||||
|
<Column field="companyName" header={__('Azienda Beneficiaria', 'gepafin')}
|
||||||
|
filterField="companyName" filter
|
||||||
|
filterMatchModeOptions={translationStrings.textFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column header={__('Data Ricezione', 'gepafin')}
|
||||||
|
filterElement={dateFilterTemplate} filter
|
||||||
|
filterField="submissionDate" dataType="date"
|
||||||
|
filterMatchModeOptions={translationStrings.dateFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={dateAppliedBodyTemplate}/>
|
||||||
|
<Column field="assignedUserName" header={__('Assegnato', 'gepafin')}
|
||||||
|
style={{ minWidth: '8rem' }}/>
|
||||||
|
<Column field="status"
|
||||||
|
header={__('Stato', 'gepafin')}
|
||||||
|
filterElement={statusFilterTemplate} filter
|
||||||
|
filterMatchModeOptions={translationStrings.statusFilterOptions}
|
||||||
|
style={{ minWidth: '8rem' }}
|
||||||
|
body={statusBodyTemplate}/>
|
||||||
|
<Column header={__('Azioni', 'gepafin')}
|
||||||
|
body={actionsBodyTemplate}/>
|
||||||
|
</DataTable>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AllDomandeTableAsync;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
/* data table related */
|
/* data table related */
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { FilterMatchMode } from 'primereact/api';
|
||||||
|
|
||||||
const currentPageReportTemplate = '';
|
const currentPageReportTemplate = '';
|
||||||
|
|
||||||
@@ -7,10 +8,43 @@ const emptyMessage = __('Nessun dato disponibile', 'gepafin');
|
|||||||
|
|
||||||
const selectOneLabel = __('Seleziona', 'gepafin');
|
const selectOneLabel = __('Seleziona', 'gepafin');
|
||||||
|
|
||||||
|
const textFilterOptions = [
|
||||||
|
//{ label: 'Inizia con', value: FilterMatchMode.STARTS_WITH },
|
||||||
|
{ label: 'Contiene', value: FilterMatchMode.CONTAINS },
|
||||||
|
//{ label: 'Non contiene', value: FilterMatchMode.NOT_CONTAINS },
|
||||||
|
//{ label: 'Finisce con', value: FilterMatchMode.ENDS_WITH },
|
||||||
|
{ label: 'Uguale a', value: FilterMatchMode.EQUALS },
|
||||||
|
//{ label: 'Diverso da', value: FilterMatchMode.NOT_EQUALS }
|
||||||
|
];
|
||||||
|
|
||||||
|
const statusFilterOptions = [
|
||||||
|
{ label: 'Uguale a', value: FilterMatchMode.EQUALS }
|
||||||
|
];
|
||||||
|
|
||||||
|
const numericFilterOptions = [
|
||||||
|
{ label: 'Uguale a', value: FilterMatchMode.EQUALS },
|
||||||
|
{ label: 'Diverso da', value: FilterMatchMode.NOT_EQUALS },
|
||||||
|
{ label: 'Maggiore di', value: FilterMatchMode.GREATER_THAN },
|
||||||
|
{ label: 'Maggiore o uguale a', value: FilterMatchMode.GREATER_THAN_OR_EQUAL_TO },
|
||||||
|
{ label: 'Minore di', value: FilterMatchMode.LESS_THAN },
|
||||||
|
{ label: 'Minore o uguale a', value: FilterMatchMode.LESS_THAN_OR_EQUAL_TO }
|
||||||
|
];
|
||||||
|
|
||||||
|
const dateFilterOptions = [
|
||||||
|
{ label: 'Data uguale a', value: FilterMatchMode.DATE_IS },
|
||||||
|
{ label: 'Data diversa da', value: FilterMatchMode.DATE_IS_NOT },
|
||||||
|
{ label: 'Data prima di', value: FilterMatchMode.DATE_BEFORE },
|
||||||
|
{ label: 'Data dopo', value: FilterMatchMode.DATE_AFTER }
|
||||||
|
];
|
||||||
|
|
||||||
const translationStrings = {
|
const translationStrings = {
|
||||||
currentPageReportTemplate,
|
currentPageReportTemplate,
|
||||||
emptyMessage,
|
emptyMessage,
|
||||||
selectOneLabel
|
selectOneLabel,
|
||||||
|
textFilterOptions,
|
||||||
|
statusFilterOptions,
|
||||||
|
numericFilterOptions,
|
||||||
|
dateFilterOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
export default translationStrings;
|
export default translationStrings;
|
||||||
Reference in New Issue
Block a user