mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +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',
|
||||
header: ({ table }) => {
|
||||
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 =
|
||||
selectableRows.every((row) => row.getIsSelected()) &&
|
||||
@@ -398,6 +404,8 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
selectableRows.forEach((row) => row.toggleSelected(shouldSelect));
|
||||
};
|
||||
|
||||
const hasNoSelectableRows = selectableRows.length === 0;
|
||||
|
||||
return (
|
||||
<div className='w-full flex flex-row justify-center'>
|
||||
<CheckboxInput
|
||||
@@ -405,6 +413,7 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
checked={allSelected}
|
||||
indeterminate={someSelected}
|
||||
onChange={toggleSelectableRows}
|
||||
disabled={hasNoSelectableRows}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
@@ -845,6 +854,13 @@ const ProjectFlockTable = ({ refresh }: { refresh?: () => void }) => {
|
||||
setSorting={setSorting}
|
||||
rowSelection={rowSelection}
|
||||
setRowSelection={setRowSelection}
|
||||
enableRowSelection={(row) => {
|
||||
const projectFlock = row.original;
|
||||
return (
|
||||
projectFlock.approval?.step_number === 1 &&
|
||||
projectFlock.approval?.action !== 'REJECTED'
|
||||
);
|
||||
}}
|
||||
withCheckbox
|
||||
className={{
|
||||
containerClassName: cn('p-3', {
|
||||
|
||||
Reference in New Issue
Block a user