Redesign B3 bordeaux + finish lab-page rework
- Lab page is now read-only with a settings screen for levels/variants; variant issuance moved to a large modal on the group page (assign-fragment). - Header: bordeaux logo and 2px accent underline, bordeaux login/logout/theme buttons; smaller radii across the UI; filled secondary/danger buttons. - Includes prior agent work (login backoff, no-cache pages, API timeouts, content tweaks) and fixes (variant usage Map.values, import order). - Bump static asset version to v=9.
This commit is contained in:
@@ -57,7 +57,7 @@ function csRow(text, tone) {
|
||||
|
||||
var rm = document.createElement('button');
|
||||
rm.type = 'button';
|
||||
rm.className = 'btn btn-secondary btn-sm';
|
||||
rm.className = 'btn btn-secondary';
|
||||
rm.textContent = 'удалить';
|
||||
rm.onclick = function () { row.remove(); };
|
||||
|
||||
@@ -361,13 +361,13 @@ function applyDefenseToCell(s) {
|
||||
}
|
||||
if (label) {
|
||||
label.textContent = started ? ''
|
||||
: (s.status == null ? 'нет'
|
||||
: (s.status === 'ready' ? 'готов'
|
||||
: (s.code ? 'код' : 'ожид.')));
|
||||
: (s.status == null ? '—'
|
||||
: (s.status === 'ready' ? 'готова'
|
||||
: (s.code ? 'код' : 'ожидает')));
|
||||
}
|
||||
if (s.status === 'ready') {
|
||||
btn.title = 'Защита завершена: ' + (s.readyReason === 'timeout' ? 'время вышло' : 'студент нажал «Готов»');
|
||||
if (label) label.textContent = 'готов';
|
||||
if (label) label.textContent = 'готова';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,7 +521,11 @@ function openVariant(btn) {
|
||||
levelSel.innerHTML = '';
|
||||
VARIANT_CACHE = {};
|
||||
fetch('/admin/labs/' + encodeURIComponent(lab) + '/schema')
|
||||
.then(function (r) { return r.ok ? r.json() : { levels: [] }; })
|
||||
.then(function (r) { return r.ok && !r.redirected ? r.json() : { levels: [] }; })
|
||||
.catch(function () {
|
||||
alert('Не удалось загрузить уровни и варианты (возможно, сессия истекла). Обновите страницу и откройте модалку заново.');
|
||||
return { levels: [] };
|
||||
})
|
||||
.then(function (data) {
|
||||
(data.levels || []).forEach(function (lvl, i) {
|
||||
var opt = document.createElement('option');
|
||||
@@ -607,3 +611,55 @@ window.addEventListener('DOMContentLoaded', function () {
|
||||
startDefenseWatch();
|
||||
attachPublishToggles();
|
||||
});
|
||||
|
||||
/* ---------- Большая модалка «Выдача вариантов» ---------- */
|
||||
|
||||
function refreshAssignModal(url) {
|
||||
var body = document.getElementById('assign-modal-body');
|
||||
if (!body) return Promise.resolve();
|
||||
return fetch(url, { headers: { 'X-Requested-With': 'fetch' } })
|
||||
.then(function (r) {
|
||||
if (r.redirected) throw new Error('сессия истекла — обновите страницу');
|
||||
return r.text();
|
||||
})
|
||||
.then(function (html) { body.innerHTML = html; });
|
||||
}
|
||||
|
||||
window.openLabAssign = function (btn) {
|
||||
var body = document.getElementById('assign-modal-body');
|
||||
if (!body) return;
|
||||
var title = document.getElementById('assign-modal-title');
|
||||
if (title) title.textContent = 'Выдача вариантов — ' + (btn.getAttribute('data-lab-name') || '');
|
||||
body.innerHTML = '<p class="text-muted">Загрузка…</p>';
|
||||
openModal('modal-lab-assign');
|
||||
refreshAssignModal(btn.getAttribute('data-url')).catch(function (e) {
|
||||
body.innerHTML = '<p class="text-danger">Не удалось загрузить: ' + e.message + '</p>';
|
||||
});
|
||||
};
|
||||
|
||||
window.confirmAssignVariant = function (sel) {
|
||||
var opt = sel.selectedOptions[0];
|
||||
var taken = opt ? parseInt(opt.getAttribute('data-taken') || '0', 10) : 0;
|
||||
if (opt && opt.value && taken > 0 && sel.value !== sel.dataset.prev) {
|
||||
if (!confirm('Вариант уже занят (' + taken + '). Назначить всё равно?')) {
|
||||
sel.value = sel.dataset.prev;
|
||||
return;
|
||||
}
|
||||
}
|
||||
sel.dataset.prev = sel.value;
|
||||
sel.closest('form').requestSubmit();
|
||||
};
|
||||
|
||||
/* Формы внутри модалки сохраняются через fetch — модалка не закрывается и обновляется */
|
||||
document.addEventListener('submit', function (ev) {
|
||||
var form = ev.target;
|
||||
if (!form.classList || !form.classList.contains('js-assign-form')) return;
|
||||
ev.preventDefault();
|
||||
var btn = form.querySelector('button[type="submit"]');
|
||||
if (btn) btn.disabled = true;
|
||||
fetch(form.action, { method: 'POST', body: new FormData(form), headers: { 'X-Requested-With': 'fetch' } })
|
||||
.then(function (r) { if (r.redirected) throw new Error('сессия истекла — обновите страницу'); return r.text(); })
|
||||
.then(function () { return refreshAssignModal(form.getAttribute('data-refresh')); })
|
||||
.catch(function (e) { showToast('Не удалось сохранить: ' + e.message, 'error'); })
|
||||
.finally(function () { if (btn) btn.disabled = false; });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user