Изменил страницу "Кафедра", добавлены изменения из задачи #54 в Vikunja

This commit is contained in:
2026-04-01 23:18:05 +03:00
parent 3cdb8614cb
commit c82e3feaed
4 changed files with 111 additions and 50 deletions

View File

@@ -17,7 +17,7 @@ export async function initGroups() {
populateEfSelects(educationForms);
await loadGroups();
} catch (e) {
groupsTbody.innerHTML = '<tr><td colspan="7" class="loading-row">Ошибка загрузки данных</td></tr>';
groupsTbody.innerHTML = '<tr><td colspan="8" class="loading-row">Ошибка загрузки данных</td></tr>';
}
}
@@ -26,7 +26,7 @@ export async function initGroups() {
allGroups = await api.get('/api/groups');
applyGroupFilter();
} catch (e) {
groupsTbody.innerHTML = '<tr><td colspan="7" class="loading-row">Ошибка загрузки</td></tr>';
groupsTbody.innerHTML = '<tr><td colspan="8" class="loading-row">Ошибка загрузки</td></tr>';
}
}
@@ -61,7 +61,7 @@ export async function initGroups() {
function renderGroups(groups) {
if (!groups || !groups.length) {
groupsTbody.innerHTML = '<tr><td colspan="7" class="loading-row">Нет групп</td></tr>';
groupsTbody.innerHTML = '<tr><td colspan="8" class="loading-row">Нет групп</td></tr>';
return;
}
groupsTbody.innerHTML = groups.map(g => `
@@ -72,6 +72,7 @@ export async function initGroups() {
<td><span class="badge badge-ef">${escapeHtml(g.educationFormName)}</span></td>
<td>${g.departmentId || '-'}</td>
<td>${g.course || '-'}</td>
<td>${escapeHtml(g.specialityCode || '-')}</td>
<td><button class="btn-delete" data-id="${g.id}">Удалить</button></td>
</tr>`).join('');
}
@@ -83,13 +84,15 @@ export async function initGroups() {
const groupSize = document.getElementById('new-group-size').value;
const educationFormId = newGroupEfSelect.value;
const departmentId = document.getElementById('new-group-department').value;
const yearStartStudy = document.getElementById('new-group-yearStartStudy').value;
const course = document.getElementById('new-group-course').value;
const specialityCode = document.getElementById('new-group-speciality-code').value.trim();
if (!name) { showAlert('create-group-alert', 'Введите название группы', 'error'); return; }
if (!groupSize) { showAlert('create-group-alert', 'Введите размер группы', 'error'); return; }
if (!educationFormId) { showAlert('create-group-alert', 'Выберите форму обучения', 'error'); return; }
if (!departmentId) { showAlert('create-group-alert', 'Введите ID кафедры', 'error'); return; }
if (!yearStartStudy) { showAlert('create-group-alert', 'Введите курс', 'error'); return; }
if (!course) { showAlert('create-group-alert', 'Введите курс', 'error'); return; }
if (!specialityCode) { showAlert('create-group-alert', 'Введите код специальности', 'error'); return; }
try {
const data = await api.post('/api/groups', {
@@ -97,7 +100,8 @@ export async function initGroups() {
groupSize: Number(groupSize),
educationFormId: Number(educationFormId),
departmentId: Number(departmentId),
yearStartStudy: Number(yearStartStudy)
course: Number(course),
specialityCode: specialityCode
});
showAlert('create-group-alert', `Группа "${escapeHtml(data.name || name)}" создана`, 'success');
createGroupForm.reset();