feat: enhance AssignmentIndex; implement infinite scroll and simplify pagination handling
This commit is contained in:
parent
8fb596fb32
commit
892d14c13a
@ -24,12 +24,12 @@ public function __construct(
|
||||
public function index(PaginatedRequest $request): Response
|
||||
{
|
||||
return Inertia::render('admin/academic-classes/assignments/index', [
|
||||
'assignments' => $this->service->paginated(
|
||||
'assignments' => Inertia::scroll(fn () => $this->service->paginated(
|
||||
$request->user(),
|
||||
...$request->validatedWithDefaults(),
|
||||
courseClassId: $request->validated('course_class_id'),
|
||||
academicTermId: $this->academicTermService->getActive()?->id,
|
||||
),
|
||||
)),
|
||||
'courseClasses' => $this->courseClassService->getAllForSelect($request->user()),
|
||||
'filters' => $request->only(['course_class_id']),
|
||||
]);
|
||||
|
||||
@ -192,16 +192,11 @@ export default function AssignmentIndex({
|
||||
total: assignments.total,
|
||||
};
|
||||
|
||||
const {
|
||||
search,
|
||||
handlePageChange,
|
||||
handlePerPageChange,
|
||||
handleSearchChange,
|
||||
applyFilters,
|
||||
} = useServerTable({
|
||||
const { search, handleSearchChange, applyFilters } = useServerTable({
|
||||
route: () => assignmentIndex.url(),
|
||||
pagination,
|
||||
filters,
|
||||
resetKeys: ['assignments'],
|
||||
});
|
||||
|
||||
function handleDelete() {
|
||||
@ -324,10 +319,9 @@ export default function AssignmentIndex({
|
||||
data={assignments.data}
|
||||
searchKey="title"
|
||||
pagination={pagination}
|
||||
onPageChange={handlePageChange}
|
||||
onPerPageChange={handlePerPageChange}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchValue={search}
|
||||
infiniteScroll={{ propName: 'assignments' }}
|
||||
toolbar={toolbar}
|
||||
/>
|
||||
) : (
|
||||
@ -337,10 +331,9 @@ export default function AssignmentIndex({
|
||||
getRowId={(assignment) => assignment.id}
|
||||
searchKey="title"
|
||||
pagination={pagination}
|
||||
onPageChange={handlePageChange}
|
||||
onPerPageChange={handlePerPageChange}
|
||||
onSearchChange={handleSearchChange}
|
||||
searchValue={search}
|
||||
infiniteScroll={{ propName: 'assignments' }}
|
||||
toolbar={toolbar}
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user