- added new role;
- added logic of statuses for amendment;
This commit is contained in:
@@ -6,6 +6,13 @@ import { Link, useLocation } from 'react-router-dom';
|
||||
// api
|
||||
import ApplicationService from '../../../../service/application-service';
|
||||
|
||||
// tools
|
||||
import getBandoLabel from '../../../../helpers/getBandoLabel';
|
||||
import getBandoSeverity from '../../../../helpers/getBandoSeverity';
|
||||
|
||||
// translation
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
|
||||
// components
|
||||
import { FilterMatchMode, FilterOperator } from 'primereact/api';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
@@ -13,14 +20,15 @@ import { Column } from 'primereact/column';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Calendar } from 'primereact/calendar';
|
||||
import ProperBandoLabel from '../../../../components/ProperBandoLabel';
|
||||
import translationStrings from '../../../../translationStringsForComponents';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { Tag } from 'primereact/tag';
|
||||
|
||||
|
||||
const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
const [items, setItems] = useState(null);
|
||||
const [filters, setFilters] = useState(null);
|
||||
const [localAsyncRequest, setLocalAsyncRequest] = useState(false);
|
||||
const [, setStatuses] = useState([]);
|
||||
const [statuses, setStatuses] = useState([]);
|
||||
const location = useLocation();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -82,7 +90,8 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
callEndDate: {
|
||||
operator: FilterOperator.AND,
|
||||
constraints: [{ value: null, matchMode: FilterMatchMode.DATE_IS }]
|
||||
}
|
||||
},
|
||||
status: { operator: FilterOperator.OR, constraints: [{ value: null, matchMode: FilterMatchMode.EQUALS }] },
|
||||
});
|
||||
};
|
||||
|
||||
@@ -99,9 +108,12 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
return formatDate(rowData.submissionDate);
|
||||
};
|
||||
|
||||
/*const dateEndBodyTemplate = (rowData) => {
|
||||
return formatDate(rowData.callEndDate);
|
||||
};*/
|
||||
const statusFilterTemplate = (options) => {
|
||||
return <Dropdown value={options.value} options={statuses}
|
||||
onChange={(e) => options.filterCallback(e.value, options.index)}
|
||||
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)}
|
||||
@@ -112,9 +124,13 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
return <ProperBandoLabel status={rowData.status}/>;
|
||||
};
|
||||
|
||||
const statusItemTemplate = (option) => {
|
||||
return <Tag value={getBandoLabel(option)} severity={getBandoSeverity(option)}/>;
|
||||
};
|
||||
|
||||
const actionsBodyTemplate = (rowData) => {
|
||||
return <div className="appPageSection__tableActions lessGap">
|
||||
{openDialogFn && rowData.status === 'SUBMIT'
|
||||
{openDialogFn && ['SUBMIT', 'EVALUATION', 'SOCCORSO'].includes(rowData.status)
|
||||
? <Button severity="info"
|
||||
onClick={() => openDialogFn(rowData.id)}
|
||||
label={__('Assegnare', 'gepafin')}
|
||||
@@ -162,7 +178,9 @@ const AllDomandeTable = ({ openDialogFn, updaterString = '' }) => {
|
||||
style={{ minWidth: '8rem' }}
|
||||
body={dateEndBodyTemplate} filter filterElement={dateFilterTemplate}/>*/}
|
||||
<Column field="status" header={__('Stato', 'gepafin')}
|
||||
style={{ minWidth: '8rem' }} body={statusBodyTemplate}/>
|
||||
style={{ minWidth: '8rem' }} body={statusBodyTemplate}
|
||||
filter
|
||||
filterElement={statusFilterTemplate}/>
|
||||
<Column header={__('Azioni', 'gepafin')}
|
||||
body={actionsBodyTemplate}/>
|
||||
</DataTable>
|
||||
|
||||
@@ -24,7 +24,7 @@ import DraftApplicationsTable from '../Dashboard/components/DraftApplicationsTab
|
||||
const Domande = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isVisibleEditDialog, setIsVisibleEditDialog] = useState(false);
|
||||
const [roleId, setRoleId] = useState(0);
|
||||
const [roleIds, setRoleIds] = useState([]);
|
||||
const [users, setUsers] = useState([]);
|
||||
const [chosenUser, setChosenUser] = useState(0);
|
||||
const [chosenApplication, setChosenApplication] = useState(0);
|
||||
@@ -34,10 +34,8 @@ const Domande = () => {
|
||||
const getRolesCallback = (data) => {
|
||||
if (data.status === 'SUCCESS') {
|
||||
const roles = data.data
|
||||
.filter(o => ['ROLE_PRE_INSTRUCTOR'].includes(o.roleType));
|
||||
if (roles.length) {
|
||||
setRoleId(roles[0].id);
|
||||
}
|
||||
.filter(o => ['ROLE_PRE_INSTRUCTOR', 'ROLE_INSTRUCTOR_MANAGER'].includes(o.roleType));
|
||||
setRoleIds(roles.map(o => o.id));
|
||||
}
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -126,11 +124,11 @@ const Domande = () => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (roleId !== 0) {
|
||||
if (roleIds.length > 0) {
|
||||
setLoading(true);
|
||||
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleId', roleId]])
|
||||
UserService.getUsers(getUsersCallback, errGetUsersCallback, [['roleIds', roleIds]])
|
||||
}
|
||||
}, [roleId]);
|
||||
}, [roleIds]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isVisibleEditDialog) {
|
||||
|
||||
Reference in New Issue
Block a user