Explain required price quarter and preserve chat wheel scrolling
This commit is contained in:
+46
-4
@@ -377,6 +377,8 @@ button { font-family: inherit; }
|
||||
.inline-basis-picker { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .2rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-card); max-width: 100%; }
|
||||
.inline-basis-picker select, .inline-basis-picker button, .inline-basis-picker input { max-width: 100%; min-width: 0; padding: .2rem .35rem; font: inherit; color: var(--text); background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px; }
|
||||
.inline-basis-note { flex-basis: 100%; font-size: .78rem; color: var(--text-muted); }
|
||||
.inline-basis-note[role="alert"] { color: var(--danger); }
|
||||
.inline-basis-picker select[aria-invalid="true"] { border-color: var(--danger); }
|
||||
.inline-basis-picker .inline-norm-select { max-width: min(28rem, 100%); }
|
||||
.inline-basis-picker .inline-quantity { width: 6rem; }
|
||||
.inline-basis-picker .inline-basis-apply { color: var(--accent); cursor: pointer; }
|
||||
@@ -420,7 +422,7 @@ button { font-family: inherit; }
|
||||
/* Таблица живёт в своём окне с ограничением высоты: иначе её горизонтальная полоса
|
||||
оказывалась внизу длинной таблицы, и до неё надо было прокрутить всю ленту
|
||||
(сказал Хозяин 18.11). С max-height обе полосы всегда у края видимой рамки. */
|
||||
.msg-ai .table-wrap { overflow-y: auto; overflow-x: hidden; max-height: min(60vh, 560px); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
|
||||
.msg-ai .table-wrap { overflow-y: auto; overflow-x: hidden; max-height: min(60vh, 560px); -webkit-overflow-scrolling: touch; margin: .5rem 0; border: 1px solid var(--border); border-radius: 8px; scrollbar-width: thin; scrollbar-color: var(--text-muted) transparent; }
|
||||
/* Полоса прокрутки у таблицы должна быть видна в обеих темах: общий «тихий»
|
||||
скроллбар в тёмной теме сливался с фоном, и казалось, что таблица обрезана
|
||||
(жалоба Хозяина 18.11). */
|
||||
@@ -1110,6 +1112,7 @@ function enhanceTables(container) {
|
||||
}
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'table-wrap';
|
||||
wrap.addEventListener('wheel', passTableWheelAtEdge, {passive: false});
|
||||
table.parentNode.insertBefore(wrap, table);
|
||||
wrap.appendChild(table);
|
||||
// панель с кнопкой выгрузки
|
||||
@@ -1127,6 +1130,26 @@ function enhanceTables(container) {
|
||||
});
|
||||
}
|
||||
|
||||
// Когда таблица дошла до края, прокручиваем саму ленту. Chromium иногда
|
||||
// оставляет колесо во вложенном скролле даже без overscroll-behavior: contain.
|
||||
function passTableWheelAtEdge(event) {
|
||||
if (event.shiftKey || Math.abs(event.deltaY) <= Math.abs(event.deltaX)) return;
|
||||
const table = event.currentTarget;
|
||||
const chat = document.getElementById('messages');
|
||||
if (!chat) return;
|
||||
const down = event.deltaY > 0;
|
||||
const tableAtEdge = down
|
||||
? table.scrollTop + table.clientHeight >= table.scrollHeight - 2
|
||||
: table.scrollTop <= 2;
|
||||
const chatCanScroll = down
|
||||
? chat.scrollTop + chat.clientHeight < chat.scrollHeight - 1
|
||||
: chat.scrollTop > 1;
|
||||
if (!tableAtEdge || !chatCanScroll) return;
|
||||
event.preventDefault();
|
||||
const factor = event.deltaMode === 1 ? 16 : event.deltaMode === 2 ? chat.clientHeight : 1;
|
||||
chat.scrollTop += event.deltaY * factor;
|
||||
}
|
||||
|
||||
// Обновляет подсказки у всех таблиц: нужна и после вставки, и после смены ширины окна —
|
||||
// иначе на узком окне таблица молча обрезается без объяснения (жалоба Хозяина 18.11).
|
||||
function updateTableHeights() {
|
||||
@@ -2321,6 +2344,7 @@ function bindFreeformBasis(host) {
|
||||
'Изменить объём для этого расчёта');
|
||||
}
|
||||
|
||||
let inlineBasisNoteSequence = 0;
|
||||
async function openFreeformBasis(button, host, label) {
|
||||
if (!host._messageId || viewOwner) return;
|
||||
const requestTab = tabId;
|
||||
@@ -2340,7 +2364,8 @@ async function openFreeformBasis(button, host, label) {
|
||||
if (currentZone) zoneSelect.value = String(currentZone.zone_id);
|
||||
const periodSelect = document.createElement('select'); periodSelect.setAttribute('aria-label', 'Квартал цен');
|
||||
const periodNote = document.createElement('span'); periodNote.className = 'inline-basis-note';
|
||||
periodNote.textContent = 'Квартал из ответа не загружен. Выберите доступный квартал для нового расчёта.';
|
||||
periodNote.id = 'inline-basis-period-note-' + ++inlineBasisNoteSequence;
|
||||
periodSelect.setAttribute('aria-describedby', periodNote.id);
|
||||
const quarterMention = (host._rawText || '').match(/\b(IV|III|II|I|[1-4])\s*квартал[а-яё]*\s+(20\d{2})/i);
|
||||
const roman = {I:1, II:2, III:3, IV:4};
|
||||
const mentionedPeriod = quarterMention
|
||||
@@ -2356,9 +2381,19 @@ async function openFreeformBasis(button, host, label) {
|
||||
const named = (zone ? zone.periods : []).find(p => p.name === mentionedPeriod)
|
||||
|| (zone ? zone.periods : []).find(p => (host._rawText || '').includes(p.name));
|
||||
if (named) periodSelect.value = String(named.period_id);
|
||||
periodNote.hidden = !quarterMention || !!named;
|
||||
periodSelect.removeAttribute('aria-invalid');
|
||||
periodNote.removeAttribute('role');
|
||||
periodNote.textContent = quarterMention && !named
|
||||
? 'Квартал из ответа не загружен. Выберите доступный квартал для нового расчёта.'
|
||||
: 'Выберите квартал цен для пересчёта.';
|
||||
periodNote.hidden = !!periodSelect.value;
|
||||
};
|
||||
fillPeriods(); zoneSelect.onchange = fillPeriods;
|
||||
periodSelect.onchange = () => {
|
||||
periodSelect.removeAttribute('aria-invalid');
|
||||
periodNote.removeAttribute('role');
|
||||
periodNote.hidden = !!periodSelect.value;
|
||||
};
|
||||
const normRows = options.norms || [];
|
||||
const position = options.position;
|
||||
const normSelect = document.createElement('select');
|
||||
@@ -2377,7 +2412,14 @@ async function openFreeformBasis(button, host, label) {
|
||||
const cancel = document.createElement('button'); cancel.type = 'button'; cancel.textContent = 'Отмена';
|
||||
cancel.onclick = () => picker.replaceWith(button);
|
||||
apply.onclick = async () => {
|
||||
if (!periodSelect.value) { periodSelect.focus(); return; }
|
||||
if (!periodSelect.value) {
|
||||
periodSelect.setAttribute('aria-invalid', 'true');
|
||||
periodNote.textContent = 'Выберите квартал цен перед пересчётом.';
|
||||
periodNote.hidden = false;
|
||||
periodNote.setAttribute('role', 'alert');
|
||||
periodSelect.focus();
|
||||
return;
|
||||
}
|
||||
if (normRows.length && (!quantity.value || !quantity.checkValidity()
|
||||
|| !Number.isFinite(Number(quantity.value)) || Number(quantity.value) <= 0)) {
|
||||
quantity.focus(); return;
|
||||
|
||||
Reference in New Issue
Block a user