feat(modules): флаг «Вложения» у модуля и подсказка ученику на главной
- переключатель «Вложения» слева от «Количество занятий» в модалке модуля, бейдж «Вложения» в списке модулей - колонка modules.has_attachments: db/init.sql, db/migration.sql, ensureModulesTable(), POST/PUT/GET /api/modules, GET /api/v1/modules, backup - на главной странице у выбранного модуля с вложениями показывается подсказка «К этой теме нужно приложить файлы» Также вошла ранее незакоммиченная работа: - битые изображения: скан и карантин, раздел «Битые изображения» в корзине (таблица broken_images, /api/broken-images/*, trash.html + trash.js) - отзывы: фото ученика и цветовая полоса оценки работ в модалке (#fbResidentPhoto, #fbMarkStripe, GET /api/feedbacks/work-marks) - фото и галереи: photo_key/photo_id в /api/photos и inline-карантин битых фото - поля пароля на journal.html и links.html обёрнуты в no-op form
This commit is contained in:
+11
-1
@@ -8,6 +8,7 @@ const moduleInput = document.getElementById('moduleInput');
|
||||
const moduleInputList = document.getElementById('moduleInputList');
|
||||
const moduleField = document.getElementById('moduleField');
|
||||
const moduleNames = new Map();
|
||||
const moduleAttachments = new Map();
|
||||
let moduleSearchTimer = null;
|
||||
const toast = document.getElementById('toast');
|
||||
const camVideo = document.getElementById('camVideo');
|
||||
@@ -20,6 +21,7 @@ const descInput = document.getElementById('descInput');
|
||||
const filesInput = document.getElementById('filesInput');
|
||||
const filesList = document.getElementById('filesList');
|
||||
const filesClearBtn = document.getElementById('filesClearBtn');
|
||||
const filesAttachHint = document.getElementById('filesAttachHint');
|
||||
let selectedFiles = [];
|
||||
const sentPanel = document.getElementById('sentPanel');
|
||||
const sentTitle = document.getElementById('sentTitle');
|
||||
@@ -247,7 +249,7 @@ if (params.get('nameInput')) {
|
||||
}
|
||||
|
||||
function renderModuleOptions(list) {
|
||||
list.forEach(m => moduleNames.set(m.name, m.id));
|
||||
list.forEach(m => { moduleNames.set(m.name, m.id); moduleAttachments.set(m.name.toLowerCase(), m.has_attachments === true); });
|
||||
moduleInputList.innerHTML = '';
|
||||
list.forEach(m => {
|
||||
const opt = document.createElement('option');
|
||||
@@ -256,6 +258,11 @@ function renderModuleOptions(list) {
|
||||
});
|
||||
}
|
||||
|
||||
function updateAttachHint() {
|
||||
const name = (moduleInput.value || '').trim().toLowerCase();
|
||||
filesAttachHint.style.display = name && moduleAttachments.get(name) === true ? '' : 'none';
|
||||
}
|
||||
|
||||
async function fetchModules(q, limit) {
|
||||
const p = new URLSearchParams();
|
||||
if (q) p.set('search', q);
|
||||
@@ -442,6 +449,7 @@ form.addEventListener('submit', async (e) => {
|
||||
form.reset();
|
||||
removePhoto();
|
||||
clearFiles();
|
||||
updateAttachHint();
|
||||
localStorage.setItem(SENT_KEY, String(Date.now()));
|
||||
showSent('Запись отправлена!', 'Спасибо! Твоя запись уже передана преподавателю.', Date.now() + cooldownMs());
|
||||
} catch (err) {
|
||||
@@ -463,10 +471,12 @@ document.getElementById('filesBtn').addEventListener('click', () => document.get
|
||||
document.getElementById('cancelCamBtn').addEventListener('click', closeCam);
|
||||
document.getElementById('captureBtn').addEventListener('click', capture);
|
||||
moduleInput.addEventListener('input', () => {
|
||||
updateAttachHint();
|
||||
clearTimeout(moduleSearchTimer);
|
||||
const q = moduleInput.value.trim();
|
||||
moduleSearchTimer = setTimeout(async () => {
|
||||
renderModuleOptions(await fetchModules(q, 20));
|
||||
updateAttachHint();
|
||||
}, 250);
|
||||
});
|
||||
moduleInput.addEventListener('focus', async () => {
|
||||
|
||||
Reference in New Issue
Block a user