diff --git a/src/components/ai/note-studio-panel.tsx b/src/components/ai/note-studio-panel.tsx index 4781497..4d8ee37 100644 --- a/src/components/ai/note-studio-panel.tsx +++ b/src/components/ai/note-studio-panel.tsx @@ -7,13 +7,16 @@ import { formatApiError, type CourseNote } from "@/api/client"; import { PodcastPanel } from "@/components/notes/podcast-panel"; import { RagOutputsPanel } from "@/components/notes/rag-outputs-panel"; import { StudioOutputLibrary } from "@/components/ai/studio-output-library"; +import { Button } from "@/components/ui/button"; import { EmptyState } from "@/components/ui/empty-state"; import { ErrorAlert } from "@/components/ui/error-alert"; +import { IconChevronLeft } from "@/components/ui/icons"; import { Label } from "@/components/ui/label"; import { PageSpinner } from "@/components/ui/page-spinner"; import { SearchableSelect } from "@/components/ui/searchable-select"; import { useAuth } from "@/stores/auth-context"; import { useT } from "@/stores/preferences-context"; +import { cn } from "@/lib/cn"; import { courseNoteFiles } from "@/lib/note-source"; import { hasMinRole } from "@/lib/roles"; @@ -74,7 +77,9 @@ export function NoteStudioPanel() { everything produced so far. Flat hairline cards, no banner and no shadow stack — the work is the content, not the chrome. */}
-
+ {/* On a phone an open note needs the screen more than the page + title does; the picker below still says where you are. */} +

{t("aiHub.tab.studio")}

{t("aiStudio.heading")}

@@ -102,9 +107,24 @@ export function NoteStudioPanel() { > {(note) => (
-
-

{note().title}

- {note().courseTitle} + {/* The library steps aside while a note is open; this is the + way back to it without emptying the picker by hand. */} +
+ +
+

{note().title}

+

{note().courseTitle}

+
{ expect(current.length).toBe(2); }); + it("pages a long history ten rows at a time", async () => { + podcastApi.listPodcastJobs.mockResolvedValue(page( + Array.from({ length: 12 }, (_, index) => + podcast({ job_id: `job-${index}`, source_title: `Bölüm ${index + 1}`, source_id: `other-${index}`, created_at: Date.UTC(2026, 0, 1, index), finished_at: Date.UTC(2026, 0, 1, index) }), + ), + )); + courseNotesApi.getCourseNoteRag.mockResolvedValue(page([])); + renderLibrary(); + + // Newest first: episode 12 leads page one, episode 2 closes it. + await waitFor(() => expect(screen.getByText("Bölüm 12")).toBeTruthy()); + expect(screen.getByText("Bölüm 3")).toBeTruthy(); + expect(screen.queryByText("Bölüm 2")).toBeNull(); + expect(screen.getByText("1-10 / 12")).toBeTruthy(); + + fireEvent.click(screen.getByRole("button", { name: "Sonraki" })); + expect(screen.getByText("Bölüm 2")).toBeTruthy(); + expect(screen.getByText("Bölüm 1")).toBeTruthy(); + expect(screen.queryByText("Bölüm 12")).toBeNull(); + }); + it("opens the run inspector for an episode instead of selecting its note", async () => { const onSelect = renderLibrary(); diff --git a/src/components/ai/studio-output-library.tsx b/src/components/ai/studio-output-library.tsx index 8f1aaab..288e455 100644 --- a/src/components/ai/studio-output-library.tsx +++ b/src/components/ai/studio-output-library.tsx @@ -1,4 +1,4 @@ -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; +import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; import { createResource } from "@/lib/create-resource"; import { getCourseNoteRag } from "@/api/course-notes"; import { listPodcastJobs } from "@/api/podcast"; @@ -8,7 +8,9 @@ import { Badge } from "@/components/ui/badge"; import { EmptyInline } from "@/components/ui/empty-inline"; import { IconSparkles, IconWaveform } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; +import { TablePagination } from "@/components/ui/table-pagination"; import { cn } from "@/lib/cn"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { formatDateTime } from "@/lib/format"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -34,6 +36,7 @@ type StudioArtifact = { }; const LIBRARY_LIMIT = 100; +const LIBRARY_PAGE_SIZE = 10; export function StudioOutputLibrary(props: { notes: StudioLibraryNote[]; @@ -112,6 +115,21 @@ export function StudioOutputLibrary(props: { return rows.sort((a, b) => b.at - a.at); }); + // The history is merged here from two sources, so it pages in memory. + const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(LIBRARY_PAGE_SIZE); + const total = () => items()?.length ?? 0; + const pageCount = createMemo(() => Math.max(1, Math.ceil(total() / pageSize()))); + const pageItems = createMemo(() => (items() ?? []).slice(page() * pageSize(), (page() + 1) * pageSize())); + createEffect(() => { + source(); + pageSize(); + setPage(0); + }); + createEffect(() => { + if (page() > pageCount() - 1) setPage(pageCount() - 1); + }); + const open = (item: StudioArtifact) => { // A produced episode has an artifact of its own to inspect; a summary is // rendered by the note's own producer panel, so that row opens the note. @@ -145,7 +163,7 @@ export function StudioOutputLibrary(props: { {/* A run history, the way a studio lists one: hairline dividers, a status dot, what was produced and when — no cards. */}
    - + {(item) => (
+ 1}> +
+ +
+
diff --git a/src/components/courses/course-notes-panel.tsx b/src/components/courses/course-notes-panel.tsx index 2166d59..b473e66 100644 --- a/src/components/courses/course-notes-panel.tsx +++ b/src/components/courses/course-notes-panel.tsx @@ -1,4 +1,5 @@ import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import { deleteCourseNoteById, getCourseNotes, patchCourseNoteById, postCourseNote, postCourseNoteFile } from "@/api/course-notes"; import { formatApiError } from "@/api/client"; @@ -9,7 +10,7 @@ import { Button } from "@/components/ui/button"; import { DataToolbar } from "@/components/ui/data-toolbar"; import { IconPlus } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { SidePanel } from "@/components/ui/side-panel"; import { createFlash } from "@/lib/flash"; import { courseNoteFiles } from "@/lib/note-source"; @@ -29,6 +30,7 @@ export function CourseNotesPanel(props: { const [error, setError] = createSignal(""); const [flash, setFlash] = createFlash(); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(NOTE_PAGE_SIZE); const [search, setSearch] = createSignal(""); const [list, { refetch }] = createResource( @@ -42,12 +44,13 @@ export function CourseNotesPanel(props: { return query ? allNotes().filter((note) => matchesSearch(query, note.title, note.content)) : allNotes(); }); const total = () => filteredNotes().length; - const pageItems = createMemo(() => filteredNotes().slice(page() * NOTE_PAGE_SIZE, (page() + 1) * NOTE_PAGE_SIZE)); - const totalPages = createMemo(() => Math.max(1, Math.ceil(total() / NOTE_PAGE_SIZE))); + const pageItems = createMemo(() => filteredNotes().slice(page() * pageSize(), (page() + 1) * pageSize())); + const totalPages = createMemo(() => Math.max(1, Math.ceil(total() / pageSize()))); const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); createEffect(() => { search(); + pageSize(); setPage(0); }); @@ -153,8 +156,8 @@ export function CourseNotesPanel(props: { }, t("common.deleted")) } /> - NOTE_PAGE_SIZE}> - + pageSize()}> + diff --git a/src/components/exams/bank-question-picker.tsx b/src/components/exams/bank-question-picker.tsx index da9212b..f2c0117 100644 --- a/src/components/exams/bank-question-picker.tsx +++ b/src/components/exams/bank-question-picker.tsx @@ -1,4 +1,5 @@ -import { For, Show, createSignal } from "solid-js"; +import { For, Show, createSignal, createEffect, on } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import type { BankQuestion, Subject } from "@/api/client"; import { formatApiError } from "@/api/client"; @@ -7,7 +8,7 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { Select } from "@/components/ui/select"; import { cn } from "@/lib/cn"; import { createDebouncedSignal } from "@/lib/create-debounced-signal"; @@ -25,16 +26,18 @@ export function BankQuestionPicker(props: { const t = useT(); const [query, setQuery, debouncedQuery] = createDebouncedSignal(); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(PICKER_PAGE_SIZE); + createEffect(on(pageSize, () => setPage(0), { defer: true })); const [selected, setSelected] = createSignal(null); const [subjectId, setSubjectId] = createSignal(""); const [error, setError] = createSignal(""); const [pending, setPending] = createSignal(false); const [templates] = createResource( - () => ({ page: page(), q: debouncedQuery().trim() }), + () => ({ page: page(), size: pageSize(), q: debouncedQuery().trim() }), (params) => getBankQuestions({ - limit: PICKER_PAGE_SIZE, - offset: params.page * PICKER_PAGE_SIZE, + limit: params.size, + offset: params.page * params.size, ...(params.q ? { q: params.q } : {}), }), ); @@ -113,8 +116,8 @@ export function BankQuestionPicker(props: { {t("bank.countShown", { shown: visible().length, total: total() })}

- 1}> - + 1}> + diff --git a/src/components/layout/celebi-thread-list.tsx b/src/components/layout/celebi-thread-list.tsx index d2e57f8..a7fe86b 100644 --- a/src/components/layout/celebi-thread-list.tsx +++ b/src/components/layout/celebi-thread-list.tsx @@ -4,7 +4,7 @@ import { getChatbotThreads, type ChatbotThread } from "@/api/chatbot"; import { EmptyInline } from "@/components/ui/empty-inline"; import { IconEdit, IconTrash } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { cn } from "@/lib/cn"; import { formatDateTime } from "@/lib/format"; import { usePreferences, useT } from "@/stores/preferences-context"; @@ -71,7 +71,7 @@ export function CelebiThreadList(props: {
1}>
- +
diff --git a/src/components/notes/note-files-panel.tsx b/src/components/notes/note-files-panel.tsx index 48d5c98..702e74b 100644 --- a/src/components/notes/note-files-panel.tsx +++ b/src/components/notes/note-files-panel.tsx @@ -13,7 +13,7 @@ import { FormDialog } from "@/components/ui/form-dialog"; import { createFlash } from "@/lib/flash"; import { IconDownload, IconEdit, IconEye, IconPlus, IconTrash } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { TableRowActions } from "@/components/ui/table-row-actions"; import { cn } from "@/lib/cn"; import { fileTypeMeta } from "@/lib/file-type"; @@ -253,7 +253,7 @@ export function NoteFilesPanel(props: { FILE_PAGE_SIZE}> - + setPreviewFile(null)} /> diff --git a/src/components/notes/podcast-history.tsx b/src/components/notes/podcast-history.tsx index 03f43a1..f43becc 100644 --- a/src/components/notes/podcast-history.tsx +++ b/src/components/notes/podcast-history.tsx @@ -1,4 +1,5 @@ import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import { formatApiError } from "@/api/client"; import type { MessageKey } from "@/i18n/messages"; @@ -8,7 +9,7 @@ import { Badge } from "@/components/ui/badge"; import { Button, buttonVariants } from "@/components/ui/button"; import { EmptyInline } from "@/components/ui/empty-inline"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { IconDownload, IconWaveform } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; import { podcastDownloadFilename, usePodcastDownloadT } from "@/components/notes/podcast-download"; @@ -40,19 +41,21 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet const { locale } = usePreferences(); const [playing, setPlaying] = createSignal(""); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(HISTORY_PAGE_SIZE); const active = () => props.active !== false; createEffect(() => { props.noteId; + pageSize(); setPage(0); }); // The source is the scope string, not a fresh object: an identity-stable // value keeps the resource from refetching when nothing about it changed. - const source = createMemo(() => (active() && props.noteId ? { noteId: props.noteId, page: page() } : null)); + const source = createMemo(() => (active() && props.noteId ? { noteId: props.noteId, page: page(), size: pageSize() } : null)); const [list, { refetch }] = createResource( source, - (scope) => listPodcastJobs({ limit: HISTORY_PAGE_SIZE, offset: scope.page * HISTORY_PAGE_SIZE, sourceId: scope.noteId }), + (scope) => listPodcastJobs({ limit: scope.size, offset: scope.page * scope.size, sourceId: scope.noteId }), ); // The panel bumps the key ("", then the job id) when a generation finishes; @@ -63,7 +66,7 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet }); const jobs = () => list()?.items ?? []; - const totalPages = createMemo(() => Math.max(1, Math.ceil((list()?.total ?? 0) / HISTORY_PAGE_SIZE))); + const totalPages = createMemo(() => Math.max(1, Math.ceil((list()?.total ?? 0) / pageSize()))); const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); createEffect(() => { @@ -174,8 +177,8 @@ export function PodcastHistory(props: { noteId?: string; active?: boolean; refet - HISTORY_PAGE_SIZE}> - + pageSize()}> + diff --git a/src/components/notes/podcast-panel.tsx b/src/components/notes/podcast-panel.tsx index 0d9d9eb..904978c 100644 --- a/src/components/notes/podcast-panel.tsx +++ b/src/components/notes/podcast-panel.tsx @@ -176,7 +176,7 @@ export function PodcastPanel(props: { noteId: string; active?: boolean; noteTitl
} > -
+
diff --git a/src/components/notes/rag-outputs-panel.tsx b/src/components/notes/rag-outputs-panel.tsx index 2685365..a97f002 100644 --- a/src/components/notes/rag-outputs-panel.tsx +++ b/src/components/notes/rag-outputs-panel.tsx @@ -199,19 +199,21 @@ export function RagOutputsPanel(props: { }; return ( -
+

{t("courseNotes.ragTitle")}

{t("courseNotes.ragHint")}

-
+ {/* Phones: the actions take the full row at touch size, the main one + stretching, instead of a cluster of 32px targets. */} +
-
+
diff --git a/src/components/rag/rag-composer.tsx b/src/components/rag/rag-composer.tsx index f82270b..52770b0 100644 --- a/src/components/rag/rag-composer.tsx +++ b/src/components/rag/rag-composer.tsx @@ -72,7 +72,8 @@ export function RagComposer(props: {
-

{props.hint}

+ {/* Enter / Shift+Enter means nothing on a touch keyboard. */} +

{props.hint}

); } diff --git a/src/components/rag/rag-copy.ts b/src/components/rag/rag-copy.ts index 27ee8bd..8b58eeb 100644 --- a/src/components/rag/rag-copy.ts +++ b/src/components/rag/rag-copy.ts @@ -19,6 +19,8 @@ const copy = { title: "Ask your notes", newThread: "New chat", history: "Chat history", + openHistory: "Open chat history", + closeHistory: "Close chat history", untitled: "Untitled chat", emptyThreads: "No chats yet", emptyThreadsHint: "Start a new chat to ask the course corpus a question.", @@ -78,6 +80,8 @@ const copy = { title: "Notlarına sor", newThread: "Yeni sohbet", history: "Sohbet geçmişi", + openHistory: "Sohbet geçmişini aç", + closeHistory: "Sohbet geçmişini kapat", untitled: "Başlıksız sohbet", emptyThreads: "Henüz sohbet yok", emptyThreadsHint: "Ders arşivine soru sormak için yeni bir sohbet başlat.", diff --git a/src/components/rag/rag-study-panel.tsx b/src/components/rag/rag-study-panel.tsx index b278f84..d206608 100644 --- a/src/components/rag/rag-study-panel.tsx +++ b/src/components/rag/rag-study-panel.tsx @@ -19,7 +19,7 @@ import { RagThreadList } from "@/components/rag/rag-thread-list"; import { Alert } from "@/components/ui/alert"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; -import { IconChevronDown, IconPlus } from "@/components/ui/icons"; +import { IconChevronDown, IconMenu, IconPlus, IconX } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; import { scopeFromCitations } from "@/lib/rag-study-scope"; import { usePreferences } from "@/stores/preferences-context"; @@ -45,6 +45,18 @@ export function RagStudyPanel() { const [studyUnavailable, setStudyUnavailable] = createSignal(false); const [renaming, setRenaming] = createSignal(null); const [removing, setRemoving] = createSignal(null); + // Below lg the history is a drawer from the left edge, the way a chat app + // on a phone keeps its conversations one tap away without spending the + // screen on them. From lg it is the fixed column beside the transcript. + const [historyOpen, setHistoryOpen] = createSignal(false); + createEffect(() => { + if (!historyOpen()) return; + const onKey = (event: KeyboardEvent) => { + if (event.key === "Escape") setHistoryOpen(false); + }; + window.addEventListener("keydown", onKey); + onCleanup(() => window.removeEventListener("keydown", onKey)); + }); let pollTimer: number | undefined; let stream: EventSource | undefined; @@ -223,21 +235,65 @@ export function RagStudyPanel() { }; return ( -
-
diff --git a/src/components/ui/coming-soon.tsx b/src/components/ui/coming-soon.tsx index 3cd8729..2d86972 100644 --- a/src/components/ui/coming-soon.tsx +++ b/src/components/ui/coming-soon.tsx @@ -6,7 +6,9 @@ import { useT } from "@/stores/preferences-context"; export function ComingSoonBadge(props: { class?: string }) { const t = useT(); return ( - + // `data-coming-soon` lets a toolbar find the control carrying it — phones + // drop a button that can only say "not yet" (see DataTable's toolbar). + {t("comingSoon.title")} ); diff --git a/src/components/ui/data-table-search.tsx b/src/components/ui/data-table-search.tsx index 56c7587..9ab95a0 100644 --- a/src/components/ui/data-table-search.tsx +++ b/src/components/ui/data-table-search.tsx @@ -49,7 +49,9 @@ export function DataTableSearch(props: DataTableSearchProps) { }} placeholder={props.placeholder ?? t("common.search")} aria-describedby={props.hint ? hintId : undefined} - class={cn("h-8 rounded-lg bg-muted/40 text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")} + // Phones get a touch-sized box at 16px: below that iOS Safari zooms + // the page into a focused field. Compact from `sm` up. + class={cn("h-10 rounded-lg bg-muted/40 text-base sm:h-8 sm:text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")} /> - - {t("common.pageOf", { page: props.page + 1, total: props.totalPages })} - - -
- ); -} diff --git a/src/components/ui/table-pagination.tsx b/src/components/ui/table-pagination.tsx index 5717174..a26dbd3 100644 --- a/src/components/ui/table-pagination.tsx +++ b/src/components/ui/table-pagination.tsx @@ -1,55 +1,78 @@ +import { Show } from "solid-js"; import { Button } from "@/components/ui/button"; import { IconChevronLeft, IconChevronRight } from "@/components/ui/icons"; +import { cn } from "@/lib/cn"; import { useT } from "@/stores/preferences-context"; export type TablePaginationProps = { /** Zero-based current page index. */ pageIndex: number; pageCount: number; - pageSize: number; + /** With `total`, prints "a-b / total"; without either only the page counter shows. */ + pageSize?: number; /** Total row count (across all pages). */ - total: number; + total?: number; onPageChange: (pageIndex: number) => void; + class?: string; }; -/** Footer: "X kayıttan a-b arası" + prev/next + "page / total". */ +/** + * Footer: "a-b / total" + prev / "page / count" / next, on one row at every + * width. The buttons are full touch targets on phones and compact from `sm` + * up. A single page keeps the row count but drops the buttons — two disabled + * arrows around "1 / 1" only take room. + */ export function TablePagination(props: TablePaginationProps) { const t = useT(); - const start = () => (props.total === 0 ? 0 : props.pageIndex * props.pageSize + 1); - const end = () => Math.min((props.pageIndex + 1) * props.pageSize, props.total); + const hasRange = () => props.total != null && props.pageSize != null; + const start = () => (!props.total || !props.pageSize ? 0 : props.pageIndex * props.pageSize + 1); + const end = () => Math.min((props.pageIndex + 1) * (props.pageSize ?? 0), props.total ?? 0); + const navButton = "h-10 w-10 gap-1 px-0 text-xs sm:h-7 sm:w-auto sm:px-1.5 sm:text-[11px]"; return ( -
- - {t("common.pageRange", { start: start(), end: end(), total: props.total })} + // Nothing to count and nowhere to go: an empty frame would only take room. + 1}> +
+ + {t("common.pageRange", { start: start(), end: end(), total: props.total ?? 0 })} -
- - - {t("common.pageOf", { page: props.pageIndex + 1, total: props.pageCount })} - - -
+ 1}> + +
+
); } diff --git a/src/components/ui/table-row-actions.tsx b/src/components/ui/table-row-actions.tsx index 637afd2..57aa46b 100644 --- a/src/components/ui/table-row-actions.tsx +++ b/src/components/ui/table-row-actions.tsx @@ -34,10 +34,11 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[ class={props.compact ? "inline-flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent text-muted-foreground outline-hidden transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring data-expanded:bg-muted data-expanded:text-foreground" : "inline-flex h-8 min-w-[78px] cursor-pointer items-center justify-center gap-1.5 rounded-lg border border-border/80 bg-muted/45 px-2 text-xs font-semibold text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary-text focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary-text"} + data-row-actions-trigger aria-label={props.label} title={props.label} > - {!props.compact && {props.triggerLabel ?? t("common.action")}} + {!props.compact && {props.triggerLabel ?? t("common.action")}} @@ -64,6 +65,7 @@ export function TableRowActions(props: { label: string; actions: TableRowAction[ {(action) => (
- + diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index 3d9e5d3..80e6529 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -1,5 +1,6 @@ import { Link, useLocation, useNavigate } from "@tanstack/solid-router"; -import { For, Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; +import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import type { ColumnDef } from "@tanstack/solid-table"; import { deleteExamById } from "@/api/exams"; @@ -33,7 +34,6 @@ import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { EmptyState } from "@/components/ui/empty-state"; import { IconCalendarDays, IconChart, IconChevronDown, IconClipboardCheck, IconClock, IconEdit, IconExam, IconEye, IconRefresh, IconSchool, IconTrash } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; -import { PaginationControls } from "@/components/ui/pagination-controls"; import { PageSpinner } from "@/components/ui/page-spinner"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { SidePanel } from "@/components/ui/side-panel"; @@ -116,6 +116,8 @@ function ExamDetailContent() { const [removeUserId, setRemoveUserId] = createSignal(null); const [gradeOpen, setGradeOpen] = createSignal(false); const [resultPage, setResultPage] = createSignal(0); + const resultPageSize = createResponsivePageSize(RESULT_PAGE_SIZE); + createEffect(on(resultPageSize, () => setResultPage(0), { defer: true })); const [answerSheetUserId, setAnswerSheetUserId] = createSignal(null); const answerSheetOpen = () => answerSheetUserId() != null; const [answerMark, setAnswerMark] = createSignal("0"); @@ -153,11 +155,11 @@ function ExamDetailContent() { ); const [results, { refetch: refetchResults }] = createResource( - () => (hasCourseManagementRights() ? [id(), resultPage()] as const : null), + () => (hasCourseManagementRights() ? [id(), resultPage(), resultPageSize()] as const : null), async (source) => { if (!source) return { items: [], total: 0, limit: RESULT_PAGE_SIZE, offset: 0 }; - const [examId, page] = source; - return getExamResults(examId, { limit: RESULT_PAGE_SIZE, offset: page * RESULT_PAGE_SIZE }); + const [examId, page, size] = source; + return getExamResults(examId, { limit: size, offset: page * size }); }, ); const [gradeResults, { refetch: refetchGradeResults }] = createResource( @@ -258,7 +260,7 @@ function ExamDetailContent() { async (examId) => examId ? getExamLive(examId) : null, ); const resultTotal = () => results()?.total ?? 0; - const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / RESULT_PAGE_SIZE)); + const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / resultPageSize())); const setClampedAnswerMark = (value: string) => { if (value === "") { setAnswerMark(value); @@ -735,10 +737,20 @@ function ExamDetailContent() { when={(results()?.items ?? []).length > 0} fallback={} > - - RESULT_PAGE_SIZE}> - - + {/* Server-paged: the table's own pager drives the fetch, so a + phone's smaller page never shows up as a second pager + slicing the fetched page again. */} + diff --git a/src/pages/meals-page.tsx b/src/pages/meals-page.tsx index 0dbc048..98ac31f 100644 --- a/src/pages/meals-page.tsx +++ b/src/pages/meals-page.tsx @@ -1,4 +1,5 @@ -import { For, Show, Suspense, createMemo, createSignal } from "solid-js"; +import { For, Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import { getLimits } from "@/api/limits"; import { getMealMenuBookings, getMealMenus, postMealMenu } from "@/api/meals"; @@ -16,7 +17,7 @@ import { IconPlus } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { Select } from "@/components/ui/select"; import { SidePanel } from "@/components/ui/side-panel"; import { inputDateToIso, isoDateToInput } from "@/lib/datetime-input"; @@ -38,6 +39,8 @@ function MealsContent() { const { locale } = usePreferences(); const canManage = () => hasMinRole(auth.user()?.role, "manager"); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(PAGE_SIZE); + createEffect(on(pageSize, () => setPage(0), { defer: true })); const [from, setFrom] = createSignal(today()); const [slot, setSlot] = createSignal("all"); const [showCreate, setShowCreate] = createSignal(false); @@ -50,11 +53,11 @@ function MealsContent() { const [settings] = createResource(() => getSettings()); const [limits, { refetch: refetchLimits }] = createResource(() => canManage() ? getLimits() : null); const [menus, { refetch }] = createResource( - () => [from(), page()] as const, - async ([start, index]) => getMealMenus({ from: start || undefined, limit: PAGE_SIZE, offset: index * PAGE_SIZE }), + () => [from(), page(), pageSize()] as const, + async ([start, index, size]) => getMealMenus({ from: start || undefined, limit: size, offset: index * size }), ); const visible = createMemo(() => slot() === "all" ? menus()?.items ?? [] : (menus()?.items ?? []).filter((menu) => menu.slot === slot())); - const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / PAGE_SIZE))); + const totalPages = createMemo(() => Math.max(1, Math.ceil((menus()?.total ?? 0) / pageSize()))); // Real occupancy = confirmed bookings / capacity, both true fields — not the // fabricated İyi/Takipte/Risk badge Figma shows. `getMealMenuBookings` is @@ -111,7 +114,7 @@ function MealsContent() { void refetch()} /> 0} fallback={}>
{(menu) => }
- +
diff --git a/src/pages/messages-page.tsx b/src/pages/messages-page.tsx index d570d1f..68165c5 100644 --- a/src/pages/messages-page.tsx +++ b/src/pages/messages-page.tsx @@ -8,7 +8,7 @@ import { } from "solid-js"; import { createResource } from "@/lib/create-resource"; import { RouteGuard } from "@/components/layout/route-guard"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { Button } from "@/components/ui/button"; import { IconArchive, @@ -421,10 +421,10 @@ export default function MessagesPage() { limit}>
-
diff --git a/src/pages/notes-page.tsx b/src/pages/notes-page.tsx index 03235fc..c946ffa 100644 --- a/src/pages/notes-page.tsx +++ b/src/pages/notes-page.tsx @@ -1,4 +1,5 @@ -import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; +import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import { useLocation, useNavigate } from "@tanstack/solid-router"; import { deleteNoteById } from "@/api/notes"; @@ -13,7 +14,7 @@ import { NoteList } from "@/components/notes/note-list"; import { Button } from "@/components/ui/button"; import { IconPlus, IconUploadCloud } from "@/components/ui/icons"; import { PageSpinner } from "@/components/ui/page-spinner"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { SidePanel } from "@/components/ui/side-panel"; import { createFlash } from "@/lib/flash"; import { loadListPage, totalPages as pagesOf } from "@/lib/list-page"; @@ -43,13 +44,15 @@ function NotesContent() { if (location().searchStr.includes("action=import")) setImportOpen(true); }); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(NOTE_PAGE_SIZE); + createEffect(on(pageSize, () => setPage(0), { defer: true })); const [list, { refetch }] = createResource( - () => page(), - async (currentPage) => + () => ({ page: page(), size: pageSize() }), + async (source) => loadListPage({ - page: currentPage, - pageSize: NOTE_PAGE_SIZE, + page: source.page, + pageSize: source.size, clientMode: false, fetch: getNotes, }), @@ -57,7 +60,7 @@ function NotesContent() { const total = () => list()?.total ?? 0; const pageItems = () => list()?.items ?? []; - const totalPages = createMemo(() => pagesOf(total(), NOTE_PAGE_SIZE)); + const totalPages = createMemo(() => pagesOf(total(), pageSize())); const safePage = createMemo(() => Math.min(page(), totalPages() - 1)); const wrap = async (fn: () => Promise, okMessage: string) => { @@ -129,8 +132,8 @@ function NotesContent() { }, t("common.deleted")) } /> - NOTE_PAGE_SIZE}> - + pageSize()}> + diff --git a/src/pages/payments-page.tsx b/src/pages/payments-page.tsx index 7fde63d..5b02df7 100644 --- a/src/pages/payments-page.tsx +++ b/src/pages/payments-page.tsx @@ -1,5 +1,6 @@ import { useLocation, useNavigate } from "@tanstack/solid-router"; import { For, Index, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import type { ColumnDef } from "@tanstack/solid-table"; import { @@ -118,10 +119,12 @@ function PaymentsContent() { onCleanup(() => clearTimeout(queryTimer)); const [studentPage, setStudentPage] = createSignal(0); - // Reset to page 1 whenever the query or plan filter changes underneath it. + const studentPageSize = createResponsivePageSize(STUDENT_PAGE_SIZE); + // Reset to page 1 whenever the query, plan filter or page size changes underneath it. createEffect(() => { debouncedQuery(); planFilter(); + studentPageSize(); setStudentPage(0); }); @@ -134,7 +137,7 @@ function PaymentsContent() { // (already name-resolved) plan roster and filters/pages it client-side — // a plan's assignees are a small, bounded list on their own. const [studentsPage, { refetch: refetchStudents }] = createResource( - () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: STUDENT_PAGE_SIZE }), + () => ({ plan: planFilter(), q: debouncedQuery(), page: studentPage(), size: studentPageSize() }), async ({ plan, q, page, size }): Promise<{ items: PersonRef[]; total: number }> => { if (plan) { const assignments = await getPlanAssignments(plan, { limit: 500 }); @@ -650,7 +653,7 @@ function PaymentsContent() { enablePagination manualPagination={{ pageIndex: studentPage(), - pageSize: STUDENT_PAGE_SIZE, + pageSize: studentPageSize(), total: studentsTotal(), onPageChange: setStudentPage, }} diff --git a/src/pages/question-bank-page.tsx b/src/pages/question-bank-page.tsx index a50ec7e..4b40f97 100644 --- a/src/pages/question-bank-page.tsx +++ b/src/pages/question-bank-page.tsx @@ -1,5 +1,6 @@ import { useNavigate } from "@tanstack/solid-router"; -import { Show, Suspense, createEffect, createMemo, createSignal } from "solid-js"; +import { Show, Suspense, createEffect, createMemo, createSignal, on } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import type { ColumnDef } from "@tanstack/solid-table"; import { deleteBankQuestionById, getBankQuestions } from "@/api/bank-questions"; @@ -45,6 +46,8 @@ function QuestionBankContent() { const visibilityFilter = () => (bankTab() === "school" ? "school" : "all") as "all" | "private" | "school"; const [subjectFilter, setSubjectFilter] = createSignal("all"); const [page, setPage] = createSignal(0); + const pageSize = createResponsivePageSize(BANK_PAGE_SIZE); + createEffect(on(pageSize, () => setPage(0), { defer: true })); const [query, setQuery, debouncedQuery] = createDebouncedSignal(); const [createOpen, setCreateOpen] = createSignal(false); const [editing, setEditing] = createSignal(null); @@ -58,6 +61,7 @@ function QuestionBankContent() { const [list, { refetch }] = createResource( () => ({ page: page(), + size: pageSize(), owner: ownerFilter(), subject: subjectFilter(), visibility: visibilityFilter(), @@ -65,8 +69,8 @@ function QuestionBankContent() { }), async (filters) => { const result = await getBankQuestions({ - limit: BANK_PAGE_SIZE, - offset: filters.page * BANK_PAGE_SIZE, + limit: filters.size, + offset: filters.page * filters.size, ...(filters.owner === "me" ? { owner: "me" } : {}), ...(filters.subject !== "all" ? { subject: filters.subject } : {}), ...(filters.visibility !== "all" ? { visibility: filters.visibility } : {}), @@ -84,7 +88,7 @@ function QuestionBankContent() { // Deleting the last row of the last page shrinks the page count under the // current page; the table then hides its pagination bar entirely and the user // is stranded with no control to get back. Same clamp as exam-questions-panel. - const pageCount = () => Math.max(1, Math.ceil(total() / BANK_PAGE_SIZE)); + const pageCount = () => Math.max(1, Math.ceil(total() / pageSize())); createEffect(() => { if (page() >= pageCount()) setPage(pageCount() - 1); }); @@ -267,7 +271,7 @@ function QuestionBankContent() { setPage(0); }} enablePagination - manualPagination={{ pageIndex: page(), pageSize: BANK_PAGE_SIZE, total: total(), onPageChange: setPage }} + manualPagination={{ pageIndex: page(), pageSize: pageSize(), total: total(), onPageChange: setPage }} empty={t("bank.empty")} storageKey="question-bank" onRowClick={(question) => navigate({ to: "/question-bank/$id", params: { id: question.id } })} diff --git a/src/pages/staff-work-page.tsx b/src/pages/staff-work-page.tsx index d0c6d10..f17c94c 100644 --- a/src/pages/staff-work-page.tsx +++ b/src/pages/staff-work-page.tsx @@ -1,4 +1,5 @@ import { For, Show, createEffect, createMemo, createSignal } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import type { ColumnDef } from "@tanstack/solid-table"; import { deleteWorkEntryById } from "@/api/work"; @@ -23,7 +24,7 @@ import { DatePicker } from "@/components/ui/date-picker"; import { IconChevronRight, IconEdit, IconTrash } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; -import { PaginationControls } from "@/components/ui/pagination-controls"; +import { TablePagination } from "@/components/ui/table-pagination"; import { SidePanel } from "@/components/ui/side-panel"; import { TableRowActions } from "@/components/ui/table-row-actions"; import { formatDateTime, formatDurationMinutes } from "@/lib/format"; @@ -145,6 +146,7 @@ function StaffWorkContent() { const [staffSearch, setStaffSearch] = createSignal(""); const [staffPage, setStaffPage] = createSignal(0); + const peoplePageSize = createResponsivePageSize(PEOPLE_PAGE_SIZE); const entryRows = () => entries().items; const peopleLoading = () => people.loading; @@ -155,10 +157,11 @@ function StaffWorkContent() { const q = staffSearch().trim(); return q ? people().filter((person) => searchPerson(person, q)) : people(); }); - const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / PEOPLE_PAGE_SIZE))); - const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * PEOPLE_PAGE_SIZE, staffPage() * PEOPLE_PAGE_SIZE + PEOPLE_PAGE_SIZE)); + const staffPageCount = createMemo(() => Math.max(1, Math.ceil(filteredPeople().length / peoplePageSize()))); + const pagedPeople = createMemo(() => filteredPeople().slice(staffPage() * peoplePageSize(), (staffPage() + 1) * peoplePageSize())); createEffect(() => { staffSearch(); + peoplePageSize(); setStaffPage(0); }); @@ -326,7 +329,7 @@ function StaffWorkContent() { )} - + diff --git a/src/pages/students-roster-page.tsx b/src/pages/students-roster-page.tsx index c81bd29..e06cf0e 100644 --- a/src/pages/students-roster-page.tsx +++ b/src/pages/students-roster-page.tsx @@ -15,7 +15,7 @@ import { ComingSoonBadge, ComingSoonValue } from "@/components/ui/coming-soon"; import { DataTable, DataTableSkeleton } from "@/components/ui/data-table"; import { ErrorAlert } from "@/components/ui/error-alert"; import { IconEye, IconPlus, IconUploadCloud } from "@/components/ui/icons"; -import { Select } from "@/components/ui/select"; +import { DropdownSelect } from "@/components/ui/select"; import { TableRowActions } from "@/components/ui/table-row-actions"; import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { useT } from "@/stores/preferences-context"; @@ -154,14 +154,18 @@ function StudentsRosterContent() { } filters={ <> - - + ({ value: cls.id, label: cls.name }))]} + /> + ({ value: year.id, label: year.name }))]} + /> } enablePagination diff --git a/src/pages/whiteboards-page.tsx b/src/pages/whiteboards-page.tsx index 6f7ba15..2ccb6e5 100644 --- a/src/pages/whiteboards-page.tsx +++ b/src/pages/whiteboards-page.tsx @@ -1,5 +1,6 @@ import { useNavigate } from "@tanstack/solid-router"; -import { For, Show, Suspense, createEffect, createMemo, createSignal, onCleanup } from "solid-js"; +import { For, Show, Suspense, createEffect, createMemo, createSignal, on, onCleanup } from "solid-js"; +import { createResponsivePageSize } from "@/lib/create-page-size"; import { createResource } from "@/lib/create-resource"; import { getBoards, postBoard, type Board } from "@/api/boards"; import { getUserSearch } from "@/api/users"; @@ -38,14 +39,15 @@ function WhiteboardsContent() { const auth = useAuth(); const navigate = useNavigate(); - const PAGE_SIZE = 12; + const pageSize = createResponsivePageSize(12); const [page, setPage] = createSignal(0); + createEffect(on(pageSize, () => setPage(0), { defer: true })); const [boards, { refetch }] = createResource( - page, - (pageIndex) => getBoards({ limit: PAGE_SIZE, offset: pageIndex * PAGE_SIZE }), + () => ({ page: page(), size: pageSize() }), + (source) => getBoards({ limit: source.size, offset: source.page * source.size }), ); const [createOpen, setCreateOpen] = createSignal(false); - const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / PAGE_SIZE))); + const pageCount = createMemo(() => Math.max(1, Math.ceil((boards.latest?.total ?? 0) / pageSize()))); const [query, setQuery] = createSignal(""); // The board list endpoint has no server-side text filter, so this narrows // only the current page's real titles — a client-side search over real @@ -98,11 +100,11 @@ function WhiteboardsContent() { - PAGE_SIZE}> + pageSize()}>