mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-23 06:45:46 +00:00
refactor(FE): Restrict row selection to specific approval criteria
This commit is contained in:
@@ -384,7 +384,13 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
id: 'select',
|
id: 'select',
|
||||||
header: ({ table }) => {
|
header: ({ table }) => {
|
||||||
const allRows = table.getRowModel().rows;
|
const allRows = table.getRowModel().rows;
|
||||||
const selectableRows = allRows;
|
const selectableRows = allRows.filter((row) => {
|
||||||
|
const projectFlock = row.original;
|
||||||
|
return (
|
||||||
|
projectFlock.approval?.step_number === 1 &&
|
||||||
|
projectFlock.approval?.action !== 'REJECTED'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const allSelected =
|
const allSelected =
|
||||||
selectableRows.every((row) => row.getIsSelected()) &&
|
selectableRows.every((row) => row.getIsSelected()) &&
|
||||||
@@ -398,6 +404,8 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
selectableRows.forEach((row) => row.toggleSelected(shouldSelect));
|
selectableRows.forEach((row) => row.toggleSelected(shouldSelect));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const hasNoSelectableRows = selectableRows.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='w-full flex flex-row justify-center'>
|
<div className='w-full flex flex-row justify-center'>
|
||||||
<CheckboxInput
|
<CheckboxInput
|
||||||
@@ -405,6 +413,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
checked={allSelected}
|
checked={allSelected}
|
||||||
indeterminate={someSelected}
|
indeterminate={someSelected}
|
||||||
onChange={toggleSelectableRows}
|
onChange={toggleSelectableRows}
|
||||||
|
disabled={hasNoSelectableRows}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -845,6 +854,13 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
|||||||
setSorting={setSorting}
|
setSorting={setSorting}
|
||||||
rowSelection={rowSelection}
|
rowSelection={rowSelection}
|
||||||
setRowSelection={setRowSelection}
|
setRowSelection={setRowSelection}
|
||||||
|
enableRowSelection={(row) => {
|
||||||
|
const projectFlock = row.original;
|
||||||
|
return (
|
||||||
|
projectFlock.approval?.step_number === 1 &&
|
||||||
|
projectFlock.approval?.action !== 'REJECTED'
|
||||||
|
);
|
||||||
|
}}
|
||||||
withCheckbox
|
withCheckbox
|
||||||
className={{
|
className={{
|
||||||
containerClassName: cn('p-3', {
|
containerClassName: cn('p-3', {
|
||||||
|
|||||||
Reference in New Issue
Block a user