feat: enhance lesson plan handling with new parser and color-coded room assignments
This commit is contained in:
8
shared/lessons.d.ts
vendored
8
shared/lessons.d.ts
vendored
@@ -13,6 +13,14 @@ interface LessonLike {
|
||||
groups: string[];
|
||||
subgroups: { group: string; label: string }[];
|
||||
}
|
||||
/** Rooms and teachers of a lesson for some weeks, by number or colour (parser's `plan`). */
|
||||
export interface PlanEntry {
|
||||
weeks: [number, number | null][] | null;
|
||||
color: "white" | "green" | null;
|
||||
rooms: string[];
|
||||
teachers: string[];
|
||||
}
|
||||
export function planFor(plan: PlanEntry[] | null | undefined, week: { n: number | null; color: string } | null | undefined): PlanEntry[];
|
||||
export interface FieldChange {
|
||||
field: string;
|
||||
label: string;
|
||||
|
||||
@@ -95,6 +95,14 @@ export function personalFilter(lesson, group, prefs) {
|
||||
if (prefs?.hidden?.includes(lessonKey(lesson, group))) return "hidden";
|
||||
return "shown";
|
||||
}
|
||||
const inWeeks = (ranges, n) => !ranges || (n != null && ranges.some(([a, b]) => n >= a && (b === null || n <= b)));
|
||||
/**
|
||||
* A lesson's rooms and teachers by week ("1-9н. 502н", "бел.н.504н/зел.н.524н",
|
||||
* "ауд.533н-б.н.,420н-з.н."): the plan entries for a week `{n, color}`, by its number, its colour
|
||||
* or both. Shared by the server's timetable and the browser.
|
||||
*/
|
||||
export const planFor = (plan, week) =>
|
||||
week && plan?.length ? plan.filter((p) => inWeeks(p.weeks, week.n) && (!p.color || p.color === week.color)) : [];
|
||||
/** Subgroup labels present for a group, in column order. */
|
||||
export function subgroupsOf(schedule, group) {
|
||||
const labels = new Set();
|
||||
|
||||
Reference in New Issue
Block a user