diff --git a/main.py b/main.py index 635b5b0..dd7cdc6 100644 --- a/main.py +++ b/main.py @@ -138,7 +138,7 @@ MAX_MESSAGE_LEN = 10_000 # ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква). # Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version). -APP_VERSION = "2026-07-17r" +APP_VERSION = "2026-07-17s" # Audit: path → action name mapping _AUDIT_MAP = [ diff --git a/static/chat.html b/static/chat.html index f7f1cb7..fd2c6e4 100644 --- a/static/chat.html +++ b/static/chat.html @@ -110,7 +110,7 @@ button { font-family: inherit; } .qa-chip:hover { border-color: var(--accent); color: var(--accent); } .est-panel { align-self: stretch; max-width: 100%; margin: .5rem 0; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-card); overflow: hidden; } .est-head { padding: .6rem .9rem; font-weight: 700; font-size: .95rem; color: var(--text); background: var(--bg-sunken); border-bottom: 1px solid var(--border); } -.est-scroll { overflow-x: auto; } +.est-scroll { overflow: auto; max-height: 60vh; } /* большие сметы: внутр. скролл + липкий заголовок (срез 6.5) */ .est-table { width: 100%; border-collapse: collapse; font-size: .82rem; } .est-table th, .est-table td { padding: .35rem .55rem; border-bottom: 1px solid var(--border-light, var(--border)); text-align: left; color: var(--text); vertical-align: top; } .est-table th { position: sticky; top: 0; background: var(--bg-sunken); color: var(--text-muted); font-weight: 600; white-space: nowrap; } @@ -128,6 +128,8 @@ button { font-family: inherit; } .est-dl:hover { border-color: var(--accent); color: var(--accent); } .est-qty { width: 5.5rem; padding: .15rem .3rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg-card); color: var(--text); font-size: .8rem; text-align: right; font-variant-numeric: tabular-nums; } .est-qty:focus { border-color: var(--accent); outline: none; } +.est-panel.est-approved { border-color: var(--ok, #3fa066); } +.est-badge { float: right; font-size: .72rem; font-weight: 700; color: #fff; background: var(--ok, #3fa066); padding: .1rem .5rem; border-radius: 999px; } .msg-system { align-self: center; background: var(--system-bg); border: none; font-size: .8rem; color: var(--system-text); box-shadow: none; padding: .4rem .8rem; } .typing { align-self: flex-start; color: var(--text-light); font-style: italic; font-size: .85rem; padding: .4rem 0; } @@ -1240,7 +1242,7 @@ function fmtMoney(v) { if (typeof v !== 'number' || !isFinite(v)) return v == null ? '' : String(v); return v.toLocaleString('ru-RU', {minimumFractionDigits: 2, maximumFractionDigits: 2}); } -function addEstimatePanel(data) { +function addEstimatePanel(data, prevData) { const panel = document.createElement('div'); panel.className = 'est-panel'; panel.setAttribute('role', 'region'); @@ -1348,14 +1350,34 @@ function addEstimatePanel(data) { body: JSON.stringify({positions, meta: {title: data.title}})}); if (!r.ok) { rc.textContent = httpErrText(r.status); return; } const upd = await r.json(); - const fresh = addEstimatePanel(upd); // новая панель с пересчётом - panel.replaceWith(fresh); // заменить старую + const fresh = addEstimatePanel(upd, data); // новая панель + прежние данные для отмены + panel.replaceWith(fresh); // заменить старую } catch (e) { rc.textContent = 'Нет связи'; rc.disabled = false; } }; acts.appendChild(rc); } + // Отменить пересчёт (срез 6.3): вернуть панель к состоянию до последнего пересчёта + if (prevData) { + const un = document.createElement('button'); + un.className = 'est-dl'; un.type = 'button'; un.textContent = '↩ Отменить пересчёт'; + un.onclick = () => { const back = addEstimatePanel(prevData); panel.replaceWith(back); }; + acts.appendChild(un); + } + // Утвердить смету (срез 6.4): человек фиксирует смету — блокируем правки, метка + const appr = document.createElement('button'); + appr.className = 'est-dl'; appr.type = 'button'; appr.textContent = '✓ Утвердить'; + appr.onclick = () => { + panel.classList.add('est-approved'); + panel.querySelectorAll('.est-qty').forEach(i => { i.readOnly = true; i.tabIndex = -1; }); + acts.querySelectorAll('button').forEach(b => { if (b !== dl) b.disabled = true; }); + const badge = document.createElement('span'); + badge.className = 'est-badge'; badge.textContent = '✓ Утверждено'; + panel.querySelector('.est-head').appendChild(badge); + srAnnounce('Смета утверждена'); + }; + acts.appendChild(appr); panel.appendChild(acts); const ob = document.getElementById('onboarding'); if (ob) ob.remove();