forge
Explore
Log in

Don't you dare go Hollow

🔎 name, class and a "what can I type here" line on every search

Browse files at this commit

fbaff64ebfcce7f846e0b5a6b8a3e39e60d92c57Burak BoduroğluParent: be0d677
  • feat
    • 🔎 name, class and a "what can I type here" line on every search
Show full message
feat: 🔎 name, class and a "what can I type here" line on every search

- student results carry their class: lib/student-classes resolves a class
  name per student from GET /classes/user/{id} (teacher+, cached per tab,
  only for a bounded list), used by the command palette people section and
  by UserSearchSelect
- UserSearchSelect rows are now two lines — display name, then
  "class · username" for a student picker and username otherwise — instead
  of the raw account uuid; the picked value reads "Name (username)"
- DataTableSearch takes a hint shown under the field while it has focus,
  threaded through DataTable (filterHint) and DataToolbar (searchHint);
  every search box in the app names the fields it really matches
- the command palette says what it takes while the query is empty, and the
  user picker says it is a type-to-search field
- ui-conventions documents both rules
.claude/skills/ui-conventions/SKILL.mdmodified+9 -0
@@ -55,6 +55,15 @@ Active project reference docs (read the relevant one before changing that area):
55 ## Shared pickers & empty states55 ## Shared pickers & empty states
56 56
57 - Dropdowns: `Select` (drop-in for `<select>` + `<option>`, renders the app menu), `DropdownSelect` (options array), `SearchableSelect` (long lists). Never a raw `<select>`, `type="date"` input (use `DatePicker`) or an ad-hoc search `Input` (use `DataTableSearch`).57 - Dropdowns: `Select` (drop-in for `<select>` + `<option>`, renders the app menu), `DropdownSelect` (options array), `SearchableSelect` (long lists). Never a raw `<select>`, `type="date"` input (use `DatePicker`) or an ad-hoc search `Input` (use `DataTableSearch`).
58+- Every search box says what it matches: pass `hint` (`DataTableSearch`),
59+ `filterHint` (`DataTable`) or `searchHint` (`DataToolbar`) — a short line
60+ shown under the field while it has focus. The text must name the fields the
61+ filter really reads; never promise a field it does not search.
62+- `UserSearchSelect` rows are two lines: display name, then `class · username`
63+ for a student picker (`role="student"`) and `username` otherwise — never the
64+ raw account uuid. Class names come from `src/lib/student-classes.ts`
65+ (`GET /classes/user/{id}`, teacher+, cached per tab); only ever call it for a
66+ bounded list of students.
58 - Confirmations and text prompts go through `ConfirmDialog`; never `window.confirm/prompt/alert`.67 - Confirmations and text prompts go through `ConfirmDialog`; never `window.confirm/prompt/alert`.
59 - Empty states: `EmptyState` (full panel, `kind` picks the unDraw scene) or `EmptyInline` (cards/charts). Scenes live in `src/assets/illustrations/` (license + slugs in its README); pixel glyphs come from `PixelIcon` (pixelarticons, MIT).68 - Empty states: `EmptyState` (full panel, `kind` picks the unDraw scene) or `EmptyInline` (cards/charts). Scenes live in `src/assets/illustrations/` (license + slugs in its README); pixel glyphs come from `PixelIcon` (pixelarticons, MIT).
60 69
src/components/layout/celebi-panel.tsxmodified+1 -1
@@ -322,7 +322,7 @@ export function CelebiPanel(props: { open: boolean; onOpenChange: (open: boolean
322 keeps writing. */}322 keeps writing. */}
323 <div class={cn("flex min-h-0 flex-1 flex-col", view() !== "chat" && "hidden")}>323 <div class={cn("flex min-h-0 flex-1 flex-col", view() !== "chat" && "hidden")}>
324 <div class="mb-3 shrink-0">324 <div class="mb-3 shrink-0">
325- <DataTableSearch value={searchQuery()} onChange={setSearchQuery} placeholder={t("ai.searchPlaceholder")} class="w-full" />325+ <DataTableSearch value={searchQuery()} onChange={setSearchQuery} placeholder={t("ai.searchPlaceholder")} hint={t("search.hint.chat")} class="w-full" />
326 </div>326 </div>
327 {/* The jump control floats over the bottom of the transcript, next to327 {/* The jump control floats over the bottom of the transcript, next to
328 the newest message it leads to, instead of sitting up by search. */}328 the newest message it leads to, instead of sitting up by search. */}
src/components/layout/command-palette.tsxmodified+13 -1
@@ -20,6 +20,7 @@ import {
20 } from "@/components/ui/icons";20 } from "@/components/ui/icons";
21 import { getUserSearch } from "@/api/users";21 import { getUserSearch } from "@/api/users";
22 import { HOME_ITEM, visibleNavGroups } from "@/components/layout/nav-items";22 import { HOME_ITEM, visibleNavGroups } from "@/components/layout/nav-items";
23+import { createStudentClassLabels } from "@/lib/student-classes";
23 import { hasMinRole } from "@/lib/roles";24 import { hasMinRole } from "@/lib/roles";
24 import { useAuth } from "@/stores/auth-context";25 import { useAuth } from "@/stores/auth-context";
25 import { useModules } from "@/stores/modules-context";26 import { useModules } from "@/stores/modules-context";
@@ -77,6 +78,9 @@ export function CommandPalette(props: CommandPaletteProps) {
77 () => (props.open && role() === "admin" && peopleQuery() ? peopleQuery() : null),78 () => (props.open && role() === "admin" && peopleQuery() ? peopleQuery() : null),
78 (q) => getUserSearch(q, undefined, "student", { limit: 6 }),79 (q) => getUserSearch(q, undefined, "student", { limit: 6 }),
79 );80 );
81+ // Two students called "Ayşe Yılmaz" are only told apart by their class, so
82+ // each visible match is resolved to one (see `student-classes`).
83+ const classLabels = createStudentClassLabels(() => (people.latest?.items ?? []).map((person) => person.id));
80 84
81 const items = createMemo<CommandItem[]>(() => {85 const items = createMemo<CommandItem[]>(() => {
82 const list: CommandItem[] = [];86 const list: CommandItem[] = [];
@@ -293,7 +297,7 @@ export function CommandPalette(props: CommandPaletteProps) {
293 category: "people",297 category: "people",
294 categoryLabel: peopleLabel,298 categoryLabel: peopleLabel,
295 title: person.display_name || person.username,299 title: person.display_name || person.username,
296- description: person.username,300+ description: classLabels()[person.id] ? `${classLabels()[person.id]} · ${person.username}` : person.username,
297 icon: IconUsers,301 icon: IconUsers,
298 onSelect: () => void navigate({ to: "/admin/users/$id", params: { id: person.id } }),302 onSelect: () => void navigate({ to: "/admin/users/$id", params: { id: person.id } }),
299 }));303 }));
@@ -435,6 +439,14 @@ export function CommandPalette(props: CommandPaletteProps) {
435 </Show>439 </Show>
436 </div>440 </div>
437 441
442+ {/* What the field accepts — the palette takes names, pages and
443+ actions, and an empty box says none of that on its own. */}
444+ <Show when={!query()}>
445+ <p class="border-b border-border/60 bg-muted/10 px-4 py-2 text-[11px] leading-snug text-muted-foreground">
446+ {role() === "admin" ? t("search.hint.commandAdmin") : t("search.hint.command")}
447+ </p>
448+ </Show>
449+
438 {/* Command Items List */}450 {/* Command Items List */}
439 <div ref={listRef} class="max-h-[min(65vh,28rem)] overflow-y-auto p-2 space-y-4">451 <div ref={listRef} class="max-h-[min(65vh,28rem)] overflow-y-auto p-2 space-y-4">
440 <Show452 <Show
src/components/ui/data-table-search.tsxmodified+28 -3
@@ -1,4 +1,4 @@
1-import { Show } from "solid-js";1+import { Show, createSignal, createUniqueId } from "solid-js";
2 import { IconSearch, IconX } from "@/components/ui/icons";2 import { IconSearch, IconX } from "@/components/ui/icons";
3 import { Input } from "@/components/ui/input";3 import { Input } from "@/components/ui/input";
4 import { cn } from "@/lib/cn";4 import { cn } from "@/lib/cn";
@@ -8,19 +8,34 @@ export type DataTableSearchProps = {
8 value: string;8 value: string;
9 onChange: (value: string) => void;9 onChange: (value: string) => void;
10 placeholder?: string;10 placeholder?: string;
11+ /**
12+ * What this particular box actually matches on, in the user's words. Shown
13+ * under the field while it has focus — a placeholder alone never says
14+ * whether a name, a code or a description is the thing to type. Keep it
15+ * honest: it must list what the filter really reads, nothing more.
16+ */
17+ hint?: string;
11 class?: string;18 class?: string;
12 };19 };
13 20
14-/** Rounded search field: leading icon + conditional clear (X) button. */21+/** Rounded search field: leading icon, conditional clear (X) button, and an
22+ * optional on-focus hint naming the fields it searches. */
15 export function DataTableSearch(props: DataTableSearchProps) {23 export function DataTableSearch(props: DataTableSearchProps) {
16 const t = useT();24 const t = useT();
25+ const [focused, setFocused] = createSignal(false);
26+ const hintId = createUniqueId();
17 return (27 return (
18- <div class={cn("relative w-full sm:max-w-xs", props.class)}>28+ <div
29+ class={cn("relative w-full sm:max-w-xs", props.class)}
30+ onFocusIn={() => setFocused(true)}
31+ onFocusOut={() => setFocused(false)}
32+ >
19 <IconSearch class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />33 <IconSearch class="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
20 <Input34 <Input
21 value={props.value}35 value={props.value}
22 onInput={(event) => props.onChange(event.currentTarget.value)}36 onInput={(event) => props.onChange(event.currentTarget.value)}
23 placeholder={props.placeholder ?? t("common.search")}37 placeholder={props.placeholder ?? t("common.search")}
38+ aria-describedby={props.hint ? hintId : undefined}
24 class={cn("h-8 rounded-lg bg-muted/40 text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")}39 class={cn("h-8 rounded-lg bg-muted/40 text-[13px] md:text-[13px]", props.value ? "pl-9 pr-8" : "pl-9")}
25 />40 />
26 <Show when={props.value}>41 <Show when={props.value}>
@@ -33,6 +48,16 @@ export function DataTableSearch(props: DataTableSearchProps) {
33 <IconX class="h-4 w-4" />48 <IconX class="h-4 w-4" />
34 </button>49 </button>
35 </Show>50 </Show>
51+ {/* Floated rather than inline: a static line would push every toolbar
52+ that carries a search box taller, on every page. */}
53+ <Show when={props.hint && focused()}>
54+ <p
55+ id={hintId}
56+ class="absolute left-0 top-full z-30 mt-1 w-full min-w-max max-w-[22rem] rounded-lg border border-border/80 bg-popover px-2.5 py-1.5 text-[11px] leading-snug text-muted-foreground shadow-md"
57+ >
58+ {props.hint}
59+ </p>
60+ </Show>
36 </div>61 </div>
37 );62 );
38 }63 }
src/components/ui/data-table.tsxmodified+3 -0
@@ -54,6 +54,8 @@ export type DataTableProps<TData, TValue = unknown> = {
54 filters?: JSX.Element;54 filters?: JSX.Element;
55 filterColumn?: string;55 filterColumn?: string;
56 filterPlaceholder?: string;56 filterPlaceholder?: string;
57+ /** On-focus hint under the search box naming the fields it matches. */
58+ filterHint?: string;
57 title?: string;59 title?: string;
58 description?: string;60 description?: string;
59 actions?: JSX.Element;61 actions?: JSX.Element;
@@ -274,6 +276,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
274 value={searchFieldValue()}276 value={searchFieldValue()}
275 onChange={handleSearch}277 onChange={handleSearch}
276 placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")}278 placeholder={props.filterPlaceholder ?? t("common.searchPlaceholder")}
279+ hint={props.filterHint}
277 />280 />
278 </Show>281 </Show>
279 <Show when={props.filters}>282 <Show when={props.filters}>
src/components/ui/data-toolbar.tsxmodified+3 -0
@@ -6,6 +6,8 @@ import { cn } from "@/lib/cn";
6 export function DataToolbar(props: {6 export function DataToolbar(props: {
7 searchValue?: string;7 searchValue?: string;
8 searchPlaceholder?: string;8 searchPlaceholder?: string;
9+ /** On-focus hint under the search box naming the fields it matches. */
10+ searchHint?: string;
9 onSearchInput?: (value: string) => void;11 onSearchInput?: (value: string) => void;
10 filters?: JSX.Element;12 filters?: JSX.Element;
11 actions?: JSX.Element;13 actions?: JSX.Element;
@@ -21,6 +23,7 @@ export function DataToolbar(props: {
21 class={cn("sm:max-w-72", props.inline && "min-w-0 flex-1")}23 class={cn("sm:max-w-72", props.inline && "min-w-0 flex-1")}
22 value={props.searchValue ?? ""}24 value={props.searchValue ?? ""}
23 placeholder={props.searchPlaceholder}25 placeholder={props.searchPlaceholder}
26+ hint={props.searchHint}
24 onChange={(value) => props.onSearchInput?.(value)}27 onChange={(value) => props.onSearchInput?.(value)}
25 />28 />
26 </Show>29 </Show>
src/components/users/user-search-select.tsxmodified+35 -6
@@ -1,6 +1,7 @@
1 import { Show, createEffect, createMemo, createSignal, onCleanup } from "solid-js";1 import { Show, createEffect, createMemo, createSignal, onCleanup } from "solid-js";
2 import { getUserSearch } from "@/api/users";2 import { getUserSearch } from "@/api/users";
3 import type { PersonRef, Role } from "@/api/client";3 import type { PersonRef, Role } from "@/api/client";
4+import type { PersonLike } from "@/lib/person";
4 import {5 import {
5 Combobox,6 Combobox,
6 ComboboxContent,7 ComboboxContent,
@@ -11,7 +12,8 @@ import {
11 ComboboxTrigger,12 ComboboxTrigger,
12 } from "@/components/ui/combobox";13 } from "@/components/ui/combobox";
13 import { Label } from "@/components/ui/label";14 import { Label } from "@/components/ui/label";
14-import { personLabelWithId } from "@/lib/person";15+import { personLabel } from "@/lib/person";
16+import { createStudentClassLabels } from "@/lib/student-classes";
15 import { hasMinRole } from "@/lib/roles";17 import { hasMinRole } from "@/lib/roles";
16 import { useAuth } from "@/stores/auth-context";18 import { useAuth } from "@/stores/auth-context";
17 import { useT } from "@/stores/preferences-context";19 import { useT } from "@/stores/preferences-context";
@@ -33,6 +35,8 @@ export function UserSearchSelect(props: {
33 placeholder?: string;35 placeholder?: string;
34 emptyMessage?: string;36 emptyMessage?: string;
35 disabled?: boolean;37 disabled?: boolean;
38+ /** Overrides the default "what can I type here" line under the field. */
39+ hint?: string;
36 role?: Role;40 role?: Role;
37 }) {41 }) {
38 const t = useT();42 const t = useT();
@@ -54,6 +58,24 @@ export function UserSearchSelect(props: {
54 return users().filter((user) => !excluded.has(user.id)).slice(0, MAX_VISIBLE_RESULTS);58 return users().filter((user) => !excluded.has(user.id)).slice(0, MAX_VISIBLE_RESULTS);
55 });59 });
56 60
61+ // A student picker shows the class next to the name: two students can share
62+ // a name, and the account id the row used to carry is a uuid nobody reads.
63+ // Only students get the extra lookup — see `student-classes`.
64+ const classLabels = createStudentClassLabels(() =>
65+ props.role === "student" ? options().map((user) => user.id) : [],
66+ );
67+ const secondaryLine = (user: PersonRef) => {
68+ const cls = classLabels()[user.id];
69+ return cls ? `${cls} · ${user.username}` : user.username;
70+ };
71+ // What the input reads after a pick — the name alone is ambiguous, the
72+ // username is the thing that is unique and short.
73+ const pickedLabel = (user: PersonLike) => {
74+ if (!user || typeof user === "string") return personLabel(user);
75+ const name = personLabel(user);
76+ return name === user.username ? name : `${name} (${user.username})`;
77+ };
78+
57 // Drop our local selection when the parent clears the bound value.79 // Drop our local selection when the parent clears the bound value.
58 createEffect(() => {80 createEffect(() => {
59 if (!props.value && selected()) setSelected(null);81 if (!props.value && selected()) setSelected(null);
@@ -130,14 +152,17 @@ export function UserSearchSelect(props: {
130 if (value.trim().length > 0) setOpen(true);152 if (value.trim().length > 0) setOpen(true);
131 }}153 }}
132 optionValue="id"154 optionValue="id"
133- optionLabel={(user) => personLabelWithId(user)}155+ optionLabel={(user) => pickedLabel(user)}
134- optionTextValue={(user) => personLabelWithId(user)}156+ optionTextValue={(user) => pickedLabel(user)}
135 defaultFilter={() => true}157 defaultFilter={() => true}
136 placeholder={props.placeholder ?? t("common.searchPlaceholder")}158 placeholder={props.placeholder ?? t("common.searchPlaceholder")}
137 disabled={props.disabled || !canSearch()}159 disabled={props.disabled || !canSearch()}
138 itemComponent={(itemProps) => (160 itemComponent={(itemProps) => (
139 <ComboboxItem item={itemProps.item}>161 <ComboboxItem item={itemProps.item}>
140- <ComboboxItemLabel>{personLabelWithId(itemProps.item.rawValue)}</ComboboxItemLabel>162+ <ComboboxItemLabel class="flex min-w-0 flex-col gap-0.5">
163+ <span class="truncate font-medium">{personLabel(itemProps.item.rawValue)}</span>
164+ <span class="truncate text-xs text-muted-foreground">{secondaryLine(itemProps.item.rawValue)}</span>
165+ </ComboboxItemLabel>
141 </ComboboxItem>166 </ComboboxItem>
142 )}167 )}
143 >168 >
@@ -151,8 +176,12 @@ export function UserSearchSelect(props: {
151 </Show>176 </Show>
152 </ComboboxContent>177 </ComboboxContent>
153 </Combobox>178 </Combobox>
154- <Show when={!canSearch()}>179+ <Show when={canSearch()} fallback={<p class="text-xs text-muted-foreground">{t("form.searchNoPermission")}</p>}>
155- <p class="text-xs text-muted-foreground">{t("form.searchNoPermission")}</p>180+ {/* An empty combobox looks like a dropdown that failed to load, so it
181+ says outright that it is a type-to-search field and what it matches. */}
182+ <p class="text-xs text-muted-foreground">
183+ {props.hint ?? (props.role === "student" ? t("search.hint.studentPicker") : props.role === "teacher" ? t("search.hint.teacherPicker") : t("search.hint.personPicker"))}
184+ </p>
156 </Show>185 </Show>
157 </div>186 </div>
158 );187 );
src/components/users/user-table.tsxmodified+1 -0
@@ -165,6 +165,7 @@ export function UserTable(props: {
165 empty={t("admin.noUsers")}165 empty={t("admin.noUsers")}
166 storageKey="admin-users"166 storageKey="admin-users"
167 searchPredicate={searchUser}167 searchPredicate={searchUser}
168+ filterHint={t("search.hint.users")}
168 enablePagination169 enablePagination
169 pageSize={20}170 pageSize={20}
170 onRowClick={props.onUserClick}171 onRowClick={props.onUserClick}
src/i18n/messages.tsmodified+54 -0
@@ -1795,6 +1795,24 @@ export type MessageKey =
1795 | "work.addEntry"1795 | "work.addEntry"
1796 | "work.planShift"1796 | "work.planShift"
1797 | "lookup.searchHint"1797 | "lookup.searchHint"
1798+ | "search.hint.command"
1799+ | "search.hint.commandAdmin"
1800+ | "search.hint.studentPicker"
1801+ | "search.hint.teacherPicker"
1802+ | "search.hint.personPicker"
1803+ | "search.hint.students"
1804+ | "search.hint.teachers"
1805+ | "search.hint.people"
1806+ | "search.hint.users"
1807+ | "search.hint.exams"
1808+ | "search.hint.events"
1809+ | "search.hint.courses"
1810+ | "search.hint.classes"
1811+ | "search.hint.bank"
1812+ | "search.hint.whiteboards"
1813+ | "search.hint.chat"
1814+ | "search.hint.deadlines"
1815+ | "search.hint.paymentsStudents"
1798 | "work.userNotFound"1816 | "work.userNotFound"
1799 | "messages.inbox"1817 | "messages.inbox"
1800 | "messages.sent"1818 | "messages.sent"
@@ -3797,6 +3815,24 @@ const en: Dict = {
3797 "work.addEntry": "Add entry",3815 "work.addEntry": "Add entry",
3798 "work.planShift": "Plan shift",3816 "work.planShift": "Plan shift",
3799 "lookup.searchHint": "Type at least 2 characters to search.",3817 "lookup.searchHint": "Type at least 2 characters to search.",
3818+ "search.hint.command": "Type a page or a quick action \u2014 e.g. \"homework\", \"exam\", \"dark theme\".",
3819+ "search.hint.commandAdmin": "Type a student name, a page or a quick action \u2014 e.g. \"Ay\u015fe\", \"homework\", \"dark theme\".",
3820+ "search.hint.studentPicker": "Type a student's name, surname or username; the list shows their class too.",
3821+ "search.hint.teacherPicker": "Type a teacher's name, surname or username.",
3822+ "search.hint.personPicker": "Type a name, surname or username.",
3823+ "search.hint.students": "Matches name, surname and username. Use the filter next to it for a class.",
3824+ "search.hint.teachers": "Matches name, surname and username.",
3825+ "search.hint.people": "Matches name, surname, username and user id.",
3826+ "search.hint.users": "Matches username, name, e-mail, user id and role.",
3827+ "search.hint.exams": "Matches exam title, description, course, exam kind and status.",
3828+ "search.hint.events": "Matches event title, description, audience and date.",
3829+ "search.hint.courses": "Matches course title, description, creator, teacher and term.",
3830+ "search.hint.classes": "Matches class name, grade and homeroom teacher.",
3831+ "search.hint.bank": "Matches a phrase inside the question text.",
3832+ "search.hint.whiteboards": "Matches board titles on the page you are viewing.",
3833+ "search.hint.chat": "Matches the text of the messages in this chat.",
3834+ "search.hint.deadlines": "Matches the title of the upcoming items.",
3835+ "search.hint.paymentsStudents": "Matches a student's name, surname or username.",
3800 "work.userNotFound": "No work log found for this user.",3836 "work.userNotFound": "No work log found for this user.",
3801 "work.show": "Show log",3837 "work.show": "Show log",
3802 "work.forUser": "Log for {user}",3838 "work.forUser": "Log for {user}",
@@ -5722,6 +5758,24 @@ const tr: Dict = {
5722 "work.addEntry": "Kayıt ekle",5758 "work.addEntry": "Kayıt ekle",
5723 "work.planShift": "Vardiya planla",5759 "work.planShift": "Vardiya planla",
5724 "lookup.searchHint": "Aramak için en az 2 karakter yaz.",5760 "lookup.searchHint": "Aramak için en az 2 karakter yaz.",
5761+ "search.hint.command": "Bir sayfa veya h\u0131zl\u0131 i\u015flem yaz\u0131n \u2014 \u00f6rn. \"\u00f6dev\", \"s\u0131nav\", \"koyu tema\".",
5762+ "search.hint.commandAdmin": "\u00d6\u011frenci ad\u0131, sayfa veya h\u0131zl\u0131 i\u015flem yaz\u0131n \u2014 \u00f6rn. \"Ay\u015fe\", \"\u00f6dev\", \"koyu tema\".",
5763+ "search.hint.studentPicker": "\u00d6\u011frencinin ad\u0131n\u0131, soyad\u0131n\u0131 veya kullan\u0131c\u0131 ad\u0131n\u0131 yaz\u0131n; listede s\u0131n\u0131f\u0131 da g\u00f6r\u00fcn\u00fcr.",
5764+ "search.hint.teacherPicker": "\u00d6\u011fretmenin ad\u0131n\u0131, soyad\u0131n\u0131 veya kullan\u0131c\u0131 ad\u0131n\u0131 yaz\u0131n.",
5765+ "search.hint.personPicker": "Ad, soyad veya kullan\u0131c\u0131 ad\u0131 yaz\u0131n.",
5766+ "search.hint.students": "Ad, soyad ve kullan\u0131c\u0131 ad\u0131nda arar. S\u0131n\u0131f i\u00e7in yan\u0131ndaki filtreyi kullan\u0131n.",
5767+ "search.hint.teachers": "Ad, soyad ve kullan\u0131c\u0131 ad\u0131nda arar.",
5768+ "search.hint.people": "Ad, soyad, kullan\u0131c\u0131 ad\u0131 ve kullan\u0131c\u0131 ID'sinde arar.",
5769+ "search.hint.users": "Kullan\u0131c\u0131 ad\u0131, ad, e-posta, kullan\u0131c\u0131 ID'si ve rolde arar.",
5770+ "search.hint.exams": "S\u0131nav ad\u0131, a\u00e7\u0131klama, ders, s\u0131nav t\u00fcr\u00fc ve durumda arar.",
5771+ "search.hint.events": "Etkinlik ad\u0131, a\u00e7\u0131klama, kat\u0131l\u0131mc\u0131 kitlesi ve tarihte arar.",
5772+ "search.hint.courses": "Ders ad\u0131, a\u00e7\u0131klama, olu\u015fturan, \u00f6\u011fretmen ve d\u00f6nemde arar.",
5773+ "search.hint.classes": "\u015eube ad\u0131, s\u0131n\u0131f d\u00fczeyi ve dan\u0131\u015fman \u00f6\u011fretmende arar.",
5774+ "search.hint.bank": "Soru metninde ge\u00e7en bir ifadeyi arar.",
5775+ "search.hint.whiteboards": "A\u00e7\u0131k olan sayfadaki tahta ba\u015fl\u0131klar\u0131nda arar.",
5776+ "search.hint.chat": "Bu sohbetteki mesajlar\u0131n metninde arar.",
5777+ "search.hint.deadlines": "Yakla\u015fan kay\u0131tlar\u0131n ba\u015fl\u0131\u011f\u0131nda arar.",
5778+ "search.hint.paymentsStudents": "\u00d6\u011frencinin ad\u0131nda, soyad\u0131nda veya kullan\u0131c\u0131 ad\u0131nda arar.",
5725 "work.userNotFound": "Bu kullanıcı için mesai kaydı bulunamadı.",5779 "work.userNotFound": "Bu kullanıcı için mesai kaydı bulunamadı.",
5726 "work.show": "Kaydı göster",5780 "work.show": "Kaydı göster",
5727 "work.forUser": "{user} için kayıtlar",5781 "work.forUser": "{user} için kayıtlar",
src/lib/student-classes.test.tsxadded+65 -0
@@ -0,0 +1,65 @@
1+import { createRoot } from "solid-js";
2+import { createStudentClassLabels } from "./student-classes";
3+
4+const calls: string[] = [];
5+const classesByUser: Record<string, string[]> = {
6+ s1: ["10-A"],
7+ s2: ["11-B", "Seçmeli Fizik"],
8+ s3: [],
9+ s9: ["9-C"],
10+};
11+
12+vi.mock("@/api/classes", () => ({
13+ getClassesByUserId: async (userId: string) => {
14+ calls.push(userId);
15+ const names = classesByUser[userId];
16+ if (!names) throw new Error("403");
17+ return { items: names.map((name, index) => ({ id: `${userId}-${index}`, name })), total: names.length, limit: null, offset: 0 };
18+ },
19+}));
20+
21+const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
22+
23+// Solid holds effects until the root's synchronous body returns, so the root
24+// is entered and left before anything is awaited.
25+function withRoot<T>(build: () => T): [T, () => void] {
26+ let value!: T;
27+ let dispose!: () => void;
28+ createRoot((disposeRoot) => {
29+ dispose = disposeRoot;
30+ value = build();
31+ });
32+ return [value, dispose];
33+}
34+
35+describe("createStudentClassLabels", () => {
36+ beforeEach(() => {
37+ calls.length = 0;
38+ });
39+
40+ it("resolves a class name per student and joins multiple memberships", async () => {
41+ const [labels, dispose] = withRoot(() => createStudentClassLabels(() => ["s1", "s2"]));
42+ await flush();
43+ expect(labels().s1).toBe("10-A");
44+ expect(labels().s2).toBe("11-B, Seçmeli Fizik");
45+ dispose();
46+ });
47+
48+ it("leaves a student with no class — or a refused lookup — unlabelled", async () => {
49+ const [labels, dispose] = withRoot(() => createStudentClassLabels(() => ["s3", "forbidden"]));
50+ await flush();
51+ expect(labels().s3).toBeUndefined();
52+ expect(labels().forbidden).toBeUndefined();
53+ dispose();
54+ });
55+
56+ it("asks the backend once per student, however often the list is read", async () => {
57+ const [, disposeFirst] = withRoot(() => createStudentClassLabels(() => ["s9"]));
58+ await flush();
59+ const [, disposeSecond] = withRoot(() => createStudentClassLabels(() => ["s9"]));
60+ await flush();
61+ expect(calls.filter((id) => id === "s9")).toHaveLength(1);
62+ disposeFirst();
63+ disposeSecond();
64+ });
65+});
src/lib/student-classes.tsadded+58 -0
@@ -0,0 +1,58 @@
1+import { createEffect, createSignal, onCleanup } from "solid-js";
2+import { getClassesByUserId } from "@/api/classes";
3+
4+/**
5+ * Class labels for people shown in a search result. `/users/search` returns
6+ * only id/username/display name, so "which class is this student in?" — the
7+ * question that tells two students with the same name apart — needs a second
8+ * read per student (`GET /classes/user/{id}`, teacher+).
9+ *
10+ * Only call this for a list that is already bounded (a picker's visible
11+ * results, a palette page), and only for students: a caller below teacher
12+ * gets a 403, which is swallowed here as "no label".
13+ *
14+ * Answers are cached for the lifetime of the tab. Class membership does not
15+ * move during a session, and without the cache every keystroke-driven result
16+ * list would re-ask for people it just looked up.
17+ */
18+const cache = new Map<string, string>();
19+const inflight = new Map<string, Promise<string>>();
20+
21+const MAX_CLASSES_PER_STUDENT = 3;
22+
23+function load(userId: string): Promise<string> {
24+ const cached = cache.get(userId);
25+ if (cached !== undefined) return Promise.resolve(cached);
26+ const running = inflight.get(userId);
27+ if (running) return running;
28+ const request = getClassesByUserId(userId, { limit: MAX_CLASSES_PER_STUDENT })
29+ .then((page) => page.items.map((group) => group.name).join(", "))
30+ // A 403/404 (no permission, no such membership) is not an error to show —
31+ // the row simply carries no class.
32+ .catch(() => "")
33+ .then((label) => {
34+ cache.set(userId, label);
35+ inflight.delete(userId);
36+ return label;
37+ });
38+ inflight.set(userId, request);
39+ return request;
40+}
41+
42+/** Reactive `id -> class name` map that fills in as the lookups land. */
43+export function createStudentClassLabels(userIds: () => string[]) {
44+ const [labels, setLabels] = createSignal<Record<string, string>>({});
45+ createEffect(() => {
46+ let disposed = false;
47+ onCleanup(() => {
48+ disposed = true;
49+ });
50+ for (const id of userIds()) {
51+ void load(id).then((label) => {
52+ if (disposed || !label) return;
53+ setLabels((prev) => (prev[id] === label ? prev : { ...prev, [id]: label }));
54+ });
55+ }
56+ });
57+ return labels;
58+}
src/pages/classes-page.tsxmodified+1 -1
@@ -177,7 +177,7 @@ function ClassesContent() {
177 }177 }
178 >178 >
179 <div class="flex flex-wrap items-center gap-2">179 <div class="flex flex-wrap items-center gap-2">
180- <DataTableSearch value={query()} onChange={setQuery} placeholder={t("classGroups.searchPlaceholder")} />180+ <DataTableSearch value={query()} onChange={setQuery} placeholder={t("classGroups.searchPlaceholder")} hint={t("search.hint.classes")} />
181 <Show when={grades().length > 0}>181 <Show when={grades().length > 0}>
182 <Tabs value={gradeFilter()} onChange={setGradeFilter}>182 <Tabs value={gradeFilter()} onChange={setGradeFilter}>
183 <TabsList>183 <TabsList>
src/pages/courses-page.tsxmodified+1 -0
@@ -184,6 +184,7 @@ function CoursesContent() {
184 inline184 inline
185 searchValue={search()}185 searchValue={search()}
186 searchPlaceholder={t("common.searchPlaceholder")}186 searchPlaceholder={t("common.searchPlaceholder")}
187+ searchHint={t("search.hint.courses")}
187 onSearchInput={setSearch}188 onSearchInput={setSearch}
188 filters={189 filters={
189 <Select wrapperClass="w-40 shrink-0 sm:w-52" class="h-8 rounded-lg" aria-label={t("terms.term")} value={termFilter()} onChange={(e) => setTermFilter(e.currentTarget.value)}>190 <Select wrapperClass="w-40 shrink-0 sm:w-52" class="h-8 rounded-lg" aria-label={t("terms.term")} value={termFilter()} onChange={(e) => setTermFilter(e.currentTarget.value)}>
src/pages/dashboard-page.tsxmodified+1 -0
@@ -970,6 +970,7 @@ function DashboardContent() {
970 data={deadlines()}970 data={deadlines()}
971 enableColumnVisibility={false}971 enableColumnVisibility={false}
972 searchPredicate={deadlines().length > 0 ? deadlineSearch : undefined}972 searchPredicate={deadlines().length > 0 ? deadlineSearch : undefined}
973+ filterHint={t("search.hint.deadlines")}
973 empty={t("dashboard.upcomingEmpty")}974 empty={t("dashboard.upcomingEmpty")}
974 emptyIllustration="calendar-empty"975 emptyIllustration="calendar-empty"
975 onRowClick={openDeadline}976 onRowClick={openDeadline}
src/pages/events-page.tsxmodified+1 -0
@@ -206,6 +206,7 @@ function EventsContent() {
206 data={rows()}206 data={rows()}
207 tableClass="table-fixed min-w-232"207 tableClass="table-fixed min-w-232"
208 searchPredicate={searchEvent}208 searchPredicate={searchEvent}
209+ filterHint={t("search.hint.events")}
209 enablePagination210 enablePagination
210 pageSize={EVENT_PAGE_SIZE}211 pageSize={EVENT_PAGE_SIZE}
211 empty={t("events.empty")}212 empty={t("events.empty")}
src/pages/exams-page.tsxmodified+1 -0
@@ -308,6 +308,7 @@ function ExamsContent() {
308 data={rows()}308 data={rows()}
309 tableClass="table-fixed min-w-5xl"309 tableClass="table-fixed min-w-5xl"
310 filterPlaceholder={t("exams.searchPlaceholder")}310 filterPlaceholder={t("exams.searchPlaceholder")}
311+ filterHint={t("search.hint.exams")}
311 searchPredicate={searchExam}312 searchPredicate={searchExam}
312 enablePagination313 enablePagination
313 pageSize={EXAM_PAGE_SIZE}314 pageSize={EXAM_PAGE_SIZE}
src/pages/payments-page.tsxmodified+1 -0
@@ -616,6 +616,7 @@ function PaymentsContent() {
616 setStudentPage(0);616 setStudentPage(0);
617 }}617 }}
618 filterPlaceholder={t("payments.selectStudent")}618 filterPlaceholder={t("payments.selectStudent")}
619+ filterHint={t("search.hint.paymentsStudents")}
619 title={t("payments.title")}620 title={t("payments.title")}
620 description={t("payments.subtitle")}621 description={t("payments.subtitle")}
621 empty={t("payments.selectStudent")}622 empty={t("payments.selectStudent")}
src/pages/question-bank-page.tsxmodified+1 -0
@@ -241,6 +241,7 @@ function QuestionBankContent() {
241 data={list()?.items ?? []}241 data={list()?.items ?? []}
242 tableClass="min-w-[48rem]"242 tableClass="min-w-[48rem]"
243 filterPlaceholder={t("bank.search")}243 filterPlaceholder={t("bank.search")}
244+ filterHint={t("search.hint.bank")}
244 searchValue={query()}245 searchValue={query()}
245 onSearchInput={(value) => {246 onSearchInput={(value) => {
246 setQuery(value);247 setQuery(value);
src/pages/staff-work-page.tsxmodified+1 -1
@@ -302,7 +302,7 @@ function StaffWorkContent() {
302 </>302 </>
303 }303 }
304 >304 >
305- <DataTableSearch value={staffSearch()} onChange={setStaffSearch} placeholder={t("work.searchPlaceholder")} />305+ <DataTableSearch value={staffSearch()} onChange={setStaffSearch} placeholder={t("work.searchPlaceholder")} hint={t("search.hint.people")} />
306 306
307 <Show when={!peopleLoading()} fallback={<DataTableSkeleton columns={3} rows={6} />}>307 <Show when={!peopleLoading()} fallback={<DataTableSkeleton columns={3} rows={6} />}>
308 <Show when={pagedPeople().length > 0} fallback={<EmptyState kind="people" title={t("work.noTeachers")} />}>308 <Show when={pagedPeople().length > 0} fallback={<EmptyState kind="people" title={t("work.noTeachers")} />}>
src/pages/student-attendance-page.tsxmodified+1 -0
@@ -117,6 +117,7 @@ function StudentAttendanceContent() {
117 tableClass="min-w-xl"117 tableClass="min-w-xl"
118 empty={t("form.noStudents")}118 empty={t("form.noStudents")}
119 searchPredicate={searchPerson}119 searchPredicate={searchPerson}
120+ filterHint={t("search.hint.people")}
120 enablePagination121 enablePagination
121 pageSize={PAGE_SIZE}122 pageSize={PAGE_SIZE}
122 storageKey="student-attendance"123 storageKey="student-attendance"
src/pages/student-marks-page.tsxmodified+1 -0
@@ -172,6 +172,7 @@ function StudentMarksContent() {
172 tableClass="min-w-xl"172 tableClass="min-w-xl"
173 empty={t("form.noStudents")}173 empty={t("form.noStudents")}
174 searchPredicate={searchPerson}174 searchPredicate={searchPerson}
175+ filterHint={t("search.hint.people")}
175 enablePagination176 enablePagination
176 pageSize={PAGE_SIZE}177 pageSize={PAGE_SIZE}
177 storageKey="student-marks"178 storageKey="student-marks"
src/pages/student-pomodoro-page.tsxmodified+1 -0
@@ -114,6 +114,7 @@ function StudentPomodoroContent() {
114 tableClass="min-w-xl"114 tableClass="min-w-xl"
115 empty={t("form.noStudents")}115 empty={t("form.noStudents")}
116 searchPredicate={searchPerson}116 searchPredicate={searchPerson}
117+ filterHint={t("search.hint.people")}
117 enablePagination118 enablePagination
118 pageSize={PAGE_SIZE}119 pageSize={PAGE_SIZE}
119 storageKey="student-pomodoro"120 storageKey="student-pomodoro"
src/pages/students-roster-page.tsxmodified+1 -0
@@ -141,6 +141,7 @@ function StudentsRosterContent() {
141 tableClass="min-w-[940px]"141 tableClass="min-w-[940px]"
142 empty={t("form.noStudents")}142 empty={t("form.noStudents")}
143 filterPlaceholder={t("roster.searchStudents")}143 filterPlaceholder={t("roster.searchStudents")}
144+ filterHint={t("search.hint.students")}
144 searchPredicate={(row, query) =>145 searchPredicate={(row, query) =>
145 [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase())146 [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase())
146 }147 }
src/pages/teachers-roster-page.tsxmodified+1 -0
@@ -114,6 +114,7 @@ function TeachersRosterContent() {
114 tableClass="min-w-[940px]"114 tableClass="min-w-[940px]"
115 empty={t("roster.noTeachers")}115 empty={t("roster.noTeachers")}
116 filterPlaceholder={t("roster.searchTeachers")}116 filterPlaceholder={t("roster.searchTeachers")}
117+ filterHint={t("search.hint.teachers")}
117 searchPredicate={(row, query) =>118 searchPredicate={(row, query) =>
118 [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase())119 [row.person.username, row.person.display_name ?? ""].join(" ").toLocaleLowerCase().includes(query.toLocaleLowerCase())
119 }120 }
src/pages/whiteboards-page.tsxmodified+1 -1
@@ -79,7 +79,7 @@ function WhiteboardsContent() {
79 fallback={<EmptyState kind="whiteboard" title={t("whiteboard.empty")} description={t("whiteboard.subtitle")} />}79 fallback={<EmptyState kind="whiteboard" title={t("whiteboard.empty")} description={t("whiteboard.subtitle")} />}
80 >80 >
81 <div class="space-y-4">81 <div class="space-y-4">
82- <DataTableSearch value={query()} onChange={setQuery} placeholder={t("whiteboard.searchPlaceholder")} />82+ <DataTableSearch value={query()} onChange={setQuery} placeholder={t("whiteboard.searchPlaceholder")} hint={t("search.hint.whiteboards")} />
83 <Show when={visibleBoards().length > 0} fallback={<EmptyState kind="search" title={t("common.noResults")} />}>83 <Show when={visibleBoards().length > 0} fallback={<EmptyState kind="search" title={t("common.noResults")} />}>
84 <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3">84 <div class="grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3">
85 <For each={visibleBoards()}>85 <For each={visibleBoards()}>