поправил вид сетки и прочие баги
This commit is contained in:
@@ -580,39 +580,56 @@ export async function initAcademicCalendar() {
|
||||
function renderCourseSemesters(course, courseRows) {
|
||||
const calendar = selectedEditorCalendar();
|
||||
const semestersForCourse = semesterBlocksForCourse(calendar, course, courseRows);
|
||||
const maxWeekColumns = Math.max(
|
||||
...semestersForCourse.map(block => uniqueWeekNumbers(block.rows).length),
|
||||
1
|
||||
);
|
||||
return semestersForCourse.map(block => `
|
||||
<section class="calendar-semester-block">
|
||||
<div class="calendar-semester-header">
|
||||
<h4>${block.semesterNumber} семестр</h4>
|
||||
<span>${escapeHtml(block.caption)}</span>
|
||||
</div>
|
||||
${renderSemesterTable(block.rows)}
|
||||
${renderSemesterTable(block.rows, maxWeekColumns)}
|
||||
</section>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
function renderSemesterTable(rows) {
|
||||
function renderSemesterTable(rows, targetWeekColumns = 0) {
|
||||
if (!rows.length) {
|
||||
return '<div class="calendar-empty-semester">Нет дат в этом семестре</div>';
|
||||
}
|
||||
|
||||
const rowsByWeek = groupBy(rows, row => row.weekNumber);
|
||||
const weeks = Array.from(rowsByWeek.keys()).sort((a, b) => Number(a) - Number(b));
|
||||
const weekSlots = [...weeks];
|
||||
while (weekSlots.length < targetWeekColumns) {
|
||||
weekSlots.push(null);
|
||||
}
|
||||
const cellByWeekAndDay = new Map(rows.map(row => [`${row.weekNumber}:${row.dayOfWeek}`, row]));
|
||||
return `
|
||||
<div class="calendar-semester-table-wrap">
|
||||
<table class="calendar-semester-table">
|
||||
<table class="calendar-semester-table" style="--calendar-week-columns:${weekSlots.length}; --calendar-min-table-width:${32 + weekSlots.length * 22}px">
|
||||
<colgroup>
|
||||
<col class="calendar-day-head-col">
|
||||
${weekSlots.map(() => '<col class="calendar-week-col">').join('')}
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="calendar-day-head">День</th>
|
||||
${weeks.map(week => `<th title="Неделя ${week} учебного года">${week}</th>`).join('')}
|
||||
${weekSlots.map(week => week === null
|
||||
? '<th class="calendar-week-placeholder" aria-hidden="true"></th>'
|
||||
: `<th title="Неделя ${week} учебного года">${week}</th>`).join('')}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
${DAY_OPTIONS.map(day => `
|
||||
<tr>
|
||||
<th class="calendar-day-head">${escapeHtml(day.shortLabel)}</th>
|
||||
${weeks.map(week => {
|
||||
${weekSlots.map(week => {
|
||||
if (week === null) {
|
||||
return '<td class="calendar-empty-day calendar-week-placeholder" aria-hidden="true"></td>';
|
||||
}
|
||||
const row = cellByWeekAndDay.get(`${week}:${day.value}`);
|
||||
return row ? renderCalendarDay(row) : '<td class="calendar-empty-day"></td>';
|
||||
}).join('')}
|
||||
@@ -624,6 +641,10 @@ export async function initAcademicCalendar() {
|
||||
`;
|
||||
}
|
||||
|
||||
function uniqueWeekNumbers(rows) {
|
||||
return Array.from(new Set(rows.map(row => row.weekNumber)));
|
||||
}
|
||||
|
||||
function renderCalendarDay(row) {
|
||||
const selected = row.activityTypeId || activityIdByCode(row.activityCode) || theoryActivityId();
|
||||
const dayName = shortDayLabel(row.dayOfWeek);
|
||||
|
||||
Reference in New Issue
Block a user