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