Match norm finder table to video with row toggles

This commit is contained in:
anor
2026-12-04 17:26:04 +10:00
parent 927ac978ef
commit 5f50dab4ab
5 changed files with 327 additions and 143 deletions
+1 -1
View File
@@ -555,7 +555,7 @@ MAX_MESSAGE_LEN = 10_000
# ⚠️ Версия UI — единый источник. БАМПАТЬ ПРИ КАЖДОМ ДЕПЛОЕ (формат: YYYY-MM-DD + буква).
# Фронт берёт её через GET /api/version (chat.html + admin.html, элемент .app-version).
APP_VERSION = "2026-12-04f"
APP_VERSION = "2026-12-04g"
# Audit: path → action name mapping
_AUDIT_MAP = [
+7 -8
View File
@@ -1,4 +1,11 @@
[
{
"version": "2026-12-04g",
"date": "2026-12-04",
"changes": [
"Каталог норм получил таблицу с пятью колонками и два треугольника у каждой нормы: состав работ и ресурсы раскрываются отдельными строками"
]
},
{
"version": "2026-12-04f",
"date": "2026-12-04",
@@ -26,13 +33,5 @@
"changes": [
"Таблица ресурсов в подборе норм теперь прокручивается внутри карточки и не растягивает страницу телефона"
]
},
{
"version": "2026-12-04b",
"date": "2026-12-04",
"changes": [
"Подбор норм открыт без входа: поиск по работе и шифру, варианты таблиц и сравнение состава",
"Несколько норм можно сохранить в подборку и пересчитать по зоне и кварталу; неполные цены отмечаются отдельно"
]
}
]
+31 -33
View File
@@ -77,23 +77,37 @@
.tree-list { list-style:none; margin:0; padding:0 0 0 12px; border-left:1px solid var(--line); }
.tree-list button { width:100%; text-align:left; border:0; border-radius:5px; background:transparent;
padding:6px; color:var(--text); font-size:.84rem; line-height:1.3; }
.tree-arrow { display:inline-block; width:17px; color:#526569; }
.tree-root-toggle { width:100%; border:0; background:#e8f0f3; text-align:left;
padding:7px; font-size:.85rem; font-weight:650; }
.tree-list button:hover,.tree-list button[aria-current="true"] { background:#e9f4f1; color:var(--accent); }
.table-panel { min-width:0; }
.table-panel h2 { margin:0; }
.table-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:12px; }
.norm-scroll { max-width:100%; overflow-x:auto; }
.norm-table { min-width:680px; }
.norm-table th { background:#f6f7f4; position:sticky; top:0; z-index:1; }
.norm-table .norm-row:hover { background:#f8faf8; }
.norm-table .norm-row button { min-height:32px; }
.norm-table .norm-name { min-width:240px; }
.norm-table .inline-cell { padding:0; background:#f8faf8; }
.inline-content { padding:16px; border-left:3px solid var(--accent); }
.inline-content .detail-grid { grid-template-columns:minmax(0,1fr); }
.inline-content .panel { border:0; padding:12px 0; background:transparent; }
.inline-content #quote-panel { border-top:1px solid var(--line); }
.inline-actions { display:flex; align-items:center; flex-wrap:wrap; gap:6px; }
.inline-actions .secondary { min-height:32px; }
.norm-table { min-width:720px; table-layout:fixed; font-size:.78rem; line-height:1.28; }
.norm-table th,.norm-table td { border:1px solid #d9e0e2; padding:4px 6px; vertical-align:middle; }
.norm-table th { background:#eef2f4; position:sticky; top:0; z-index:1; }
.norm-table .norm-row:hover { background:#f2f7f7; }
.norm-table .norm-row td,.norm-table .norm-resource-row td,
.norm-table .norm-work-row td { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.norm-table .norm-family-row { background:#e8f0f3; font-weight:650; }
.norm-table .norm-family-row td { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.norm-table .norm-section-heading { background:#f7fafb; }
.norm-table .norm-section-heading td:nth-child(2) { text-decoration:underline; }
.norm-table .norm-work-row,.norm-table .norm-resource-row { background:#fbfcfc; }
.norm-table .norm-name { min-width:0; }
.norm-code-cell { white-space:nowrap; }
.norm-toggle { display:inline-grid; place-items:center; width:19px; height:19px;
padding:0; margin-right:2px; border:1px solid #89999b; border-radius:2px;
background:#fff; color:#526569; font-size:.84rem; line-height:1; vertical-align:middle; }
.norm-toggle:hover,.norm-toggle[aria-expanded="true"] { background:#dcebed; color:#164e57; }
.norm-code { margin-left:5px; font-variant-numeric:tabular-nums; }
.norm-tools-row td { background:#f7fafb; }
.norm-tools { display:flex; gap:6px; align-items:center; flex-wrap:wrap; }
.norm-tools .secondary { min-height:26px; padding:2px 8px; font-size:.75rem; }
.norm-tools .variant-list { width:100%; }
.table-mobile-hint { display:none; }
.breadcrumb { color:var(--muted); font-size:.84rem; overflow-wrap:anywhere; }
.catalog-mobile { display:none; }
[hidden] { display:none !important; }
@@ -104,25 +118,8 @@
.catalog-mobile { display:block; margin-bottom:10px; }
.catalog-tree { position:static; max-height:45vh; margin-bottom:12px; }
.catalog-tree[hidden] { display:none !important; }
.norm-scroll { overflow:visible; }
.norm-table,.norm-table > tbody,.norm-table > tbody > .norm-detail-row,
.norm-table > tbody > .norm-detail-row > td { display:block; min-width:0; width:100%; }
.norm-table thead { display:none; }
.norm-table .norm-row { display:grid; grid-template-columns:minmax(0,1fr) auto;
gap:5px 12px; padding:13px 0; border-top:1px solid var(--line); }
.norm-table .norm-row td { border:0; padding:0; min-width:0; }
.norm-table .norm-row td:nth-child(1) { grid-column:1 / -1; }
.norm-table .norm-row td:nth-child(2) { grid-column:1 / -1; overflow-wrap:anywhere; }
.norm-table .norm-row td:nth-child(3) { grid-column:1; }
.norm-table .norm-row td:nth-child(4) { grid-column:2; }
.norm-table .norm-row td:nth-child(5) { grid-column:1 / -1; }
.norm-table .norm-row .inline-actions { gap:6px; }
.norm-table .norm-row .inline-actions button { flex:1 1 auto; }
.inline-content { padding:12px 10px; }
.inline-content #detail-title { font-size:1.05rem; overflow-wrap:anywhere; }
.inline-content .scroll { overflow-x:auto; }
.inline-content .scroll table { min-width:560px; }
.inline-content .detail-grid { display:block; }
.table-mobile-hint { display:block; }
.norm-table { min-width:760px; }
}
</style>
</head>
@@ -150,7 +147,8 @@
<section id="results-section" class="panel table-panel" aria-label="Нормы сборника">
<div class="table-heading"><h2 id="results-title">Нормы сборника</h2><span id="result-count" class="hint"></span></div>
<p id="breadcrumb" class="breadcrumb"></p>
<div class="norm-scroll"><table class="norm-table"><thead><tr><th>Шифр</th><th>Наименование</th><th>Ед. изм.</th><th class="num">Базисная стоимость</th><th>Действия</th></tr></thead><tbody id="results"></tbody></table></div>
<p class="hint table-mobile-hint">Таблица прокручивается по горизонтали.</p>
<div class="norm-scroll"><table class="norm-table"><colgroup><col style="width:18%"><col style="width:47%"><col style="width:12%"><col style="width:10%"><col style="width:13%"></colgroup><thead><tr><th>Шифр</th><th>Наименование</th><th>Ед. изм.</th><th class="num">Расход</th><th class="num">ПЗ, руб.</th></tr></thead><tbody id="results"></tbody></table></div>
<div class="actions" style="margin-top:16px"><button id="more-results" type="button" class="secondary" hidden>Показать ещё нормы</button></div>
</section>
</div>
@@ -181,6 +179,6 @@
<section id="compare-section" class="section" hidden><h2>Сравнение норм</h2><p id="compare-warning" class="notice" hidden></p>
<div id="comparison" class="comparison"></div></section>
</main>
<script src="/static/norm-finder.js?v=2026-12-04f" defer></script>
<script src="/static/norm-finder.js?v=2026-12-04g" defer></script>
</body>
</html>
+208 -86
View File
@@ -23,8 +23,7 @@
let catalogRows = [];
let requestSeq = 0;
let detailSeq = 0;
let openedRow = null;
let rowSeq = 0;
let lastFamily = '';
let subjects = [];
let priceZones = [];
const compared = new Map();
@@ -107,77 +106,192 @@
function detachDetail() {
$('detail-section').hidden = true;
document.querySelector('.workspace').after($('detail-section'));
if (openedRow) openedRow.hidden = true;
openedRow = null;
}
function renderSearchItem(item) {
const fragment = document.createDocumentFragment();
const row = node('tr', null, 'norm-row');
const detailRow = node('tr', null, 'norm-detail-row');
detailRow.hidden = true;
const detailCell = node('td', null, 'inline-cell');
detailCell.colSpan = 5;
const inline = node('div', null, 'inline-content');
const variantList = node('div', null, 'variant-list'); variantList.hidden = true;
inline.append(variantList); detailCell.append(inline); detailRow.append(detailCell);
const controlId = 'norm-detail-' + (++rowSeq);
detailRow.id = controlId;
row.append(node('td', item.code, 'code'), node('td', item.name || 'Без наименования', 'norm-name'),
node('td', item.unit || '—'),
node('td', item.cost != null ? money(item.cost) : '—', 'num'));
const actionsCell = node('td');
const actions = node('div', null, 'inline-actions');
const open = node('button', 'Открыть состав', 'primary small');
open.type = 'button'; open.setAttribute('aria-controls', controlId);
open.setAttribute('aria-expanded', 'false');
open.addEventListener('click', () => openDetail(item, detailRow));
const compare = node('button', compared.has(key(item)) ? 'Убрать из сравнения' : 'Сравнить', 'secondary small');
compare.type = 'button';
compare.dataset.compareKey = key(item);
compare.addEventListener('click', () => toggleCompare(item));
const familyCode = String(item.code || '').replace(/-\d{2}$/, '');
const variants = node('button', 'Варианты таблицы', 'secondary small');
variants.type = 'button';
variants.setAttribute('aria-expanded', 'false');
variants.addEventListener('click', async () => {
if (variants.getAttribute('aria-expanded') === 'true') {
variantList.hidden = true; variants.setAttribute('aria-expanded', 'false');
if ($('detail-section').parentElement !== inline) detailRow.hidden = true;
return;
function familyKey(item) {
return [item.base,item.base_type,String(item.code || '').replace(/-\d+$/, '')].join('|');
}
function familyTitle(items) {
const names = items.map(item => String(item.name || '')).filter(Boolean);
if (names.length > 1) {
let common = names[0];
for (const name of names.slice(1)) {
while (common && !name.startsWith(common)) common = common.slice(0, -1);
}
variants.disabled = true;
try {
const found = await api(readPath('search') + '?' + new URLSearchParams({
q:familyCode, base:baseAlias(item), limit:publicMode ? '8' : '30'}));
const family = (found.items || []).filter(row => row.base_type === item.base_type
&& row.code.startsWith(familyCode + '-'));
variantList.replaceChildren();
if (!family.length) variantList.append(node('p', 'Варианты в каталоге не найдены.', 'hint'));
for (const row of family) {
const line = node('div', null, 'variant-row');
const button = node('button', row.code + ' — ' + row.name + ' · ' + (row.unit || 'измеритель не указан'),
'variant-option');
button.type = 'button'; button.addEventListener('click', () => openDetail(row, detailRow));
const compareVariant = node('button', compared.has(key(row)) ? 'Убрать из сравнения' : 'Сравнить',
'secondary small');
compareVariant.type = 'button';
compareVariant.dataset.compareKey = key(row);
compareVariant.addEventListener('click', () => toggleCompare(row));
line.append(button, compareVariant); variantList.append(line);
const colon = common.lastIndexOf(':');
const comma = common.lastIndexOf(',');
const end = colon > 25 ? colon : comma > 25 ? comma : -1;
if (end > 0) return common.slice(0, end).trim();
}
return String(items[0]?.section_path || '').split(' > ').at(-1) || names[0] || 'Нормы';
}
function tableRow(className, cells) {
const row = node('tr', null, className);
for (const [value, className] of cells) {
const cell = node('td', value, className);
if (value != null) cell.title = String(value);
row.append(cell);
}
return row;
}
function sectionHeading(label) {
return tableRow('norm-section-heading', [['',''],[label,''],['',''],['',''],['','']]);
}
function selectVariant(row) {
showRows([row]); browsePage = null; searchPage = null; $('more-results').hidden = true;
$('results-title').textContent = 'Вариант таблицы';
$('breadcrumb').textContent = row.base_type + ' › ' + row.code;
document.querySelector('#results .norm-toggle')?.click();
}
function renderSearchItem(item, familyName) {
const row = tableRow('norm-row', [['','norm-code-cell'],['','norm-name'],[item.unit || '—',''],['','num'],
[item.cost != null ? money(item.cost).replace(' ₽', '') : '—','num']]);
row.dataset.key = key(item);
row.cells[4].title = item.cost != null
? 'Базисная стоимость, уровень ' + (item.price_level || 'не указан')
: 'Прямые затраты для этой нормы в индексе не указаны';
const codeCell = row.cells[0];
const workToggle = node('button', '▸', 'norm-toggle');
const resourceToggle = node('button', '▸', 'norm-toggle');
for (const [button, label] of [[workToggle,'состав работ'],[resourceToggle,'состав норматива']]) {
button.type = 'button';
button.setAttribute('aria-label', 'Показать ' + label + ' для ' + item.code);
button.title = 'Показать ' + label;
button.setAttribute('aria-expanded', 'false');
}
codeCell.append(workToggle, resourceToggle, node('span', item.code, 'norm-code'));
const fullName = String(item.name || 'Без наименования');
const shortName = fullName.startsWith(familyName)
? fullName.slice(familyName.length).replace(/^[\s,:;—-]+/, '') || fullName
: fullName;
row.cells[1].textContent = shortName; row.cells[1].title = fullName;
let detailPromise = null, detail = null;
let workOpen = false, resourceOpen = false;
let workRows = [], resourceRows = [];
async function getDetail() {
if (detail) return detail;
if (!detailPromise) detailPromise = detailFor(item).catch(error => { detailPromise = null; throw error; });
detail = await detailPromise;
return detail;
}
function toolsRow() {
const toolRow = tableRow('norm-tools-row', [['',''],['',''],['',''],['',''],['','']]);
const cell = toolRow.cells[1]; cell.colSpan = 4;
while (toolRow.cells.length > 2) toolRow.deleteCell(2);
const tools = node('div', null, 'norm-tools');
const compare = node('button', compared.has(key(item)) ? 'Убрать из сравнения' : 'Сравнить', 'secondary');
compare.type = 'button'; compare.dataset.compareKey = key(item);
compare.addEventListener('click', () => toggleCompare(item));
const variants = node('button', 'Варианты таблицы', 'secondary'); variants.type = 'button';
variants.setAttribute('aria-expanded', 'false');
const variantList = node('div', null, 'variant-list'); variantList.hidden = true;
variants.addEventListener('click', async () => {
if (!variantList.hidden) {
variantList.hidden = true; variants.setAttribute('aria-expanded', 'false'); return;
}
variantList.hidden = false; detailRow.hidden = false;
variants.setAttribute('aria-expanded', 'true');
} catch (e) { status(e.message, true); }
finally { variants.disabled = false; }
});
actions.append(open, compare, variants); actionsCell.append(actions); row.append(actionsCell);
fragment.append(row, detailRow);
return fragment;
variants.disabled = true;
try {
const familyCode = String(item.code || '').replace(/-\d+$/, '');
const found = await api(readPath('search') + '?' + new URLSearchParams({
q:familyCode, base:baseAlias(item), limit:publicMode ? '8' : '30'}));
const family = (found.items || []).filter(candidate => candidate.base_type === item.base_type
&& candidate.code.startsWith(familyCode + '-'));
variantList.replaceChildren();
for (const candidate of family) {
const line = node('div', null, 'variant-row');
const choice = node('button', candidate.code + ' — ' + candidate.name, 'variant-option');
choice.type = 'button'; choice.addEventListener('click', () => selectVariant(candidate));
const compareVariant = node('button', compared.has(key(candidate)) ? 'Убрать из сравнения' : 'Сравнить',
'secondary small');
compareVariant.type = 'button'; compareVariant.dataset.compareKey = key(candidate);
compareVariant.addEventListener('click', () => toggleCompare(candidate));
line.append(choice, compareVariant); variantList.append(line);
}
if (!family.length) variantList.append(node('p', 'Варианты в каталоге не найдены.', 'hint'));
variantList.hidden = false; variants.setAttribute('aria-expanded', 'true');
} catch (error) { status(error.message, true); }
finally { variants.disabled = false; }
});
tools.append(compare, variants);
if (!publicMode) {
const quoteButton = node('button', 'Расчёт и подборка', 'secondary');
quoteButton.type = 'button'; quoteButton.addEventListener('click', () => openDetail(item));
tools.append(quoteButton);
}
const source = detail?.provenance || {};
if (source.file || source.decree) {
const disclosure = node('details');
disclosure.append(node('summary', 'Источник нормы'));
disclosure.append(node('span', [source.decree,source.file].filter(Boolean).join(' · '), 'hint'));
tools.append(disclosure);
}
tools.append(variantList); cell.append(tools);
return toolRow;
}
function mount() {
for (const child of [...workRows,...resourceRows]) child.remove();
row.after(...(workOpen ? workRows : []), ...(resourceOpen ? resourceRows : []));
}
async function toggle(which) {
const button = which === 'work' ? workToggle : resourceToggle;
const current = which === 'work' ? workOpen : resourceOpen;
if (!current) {
button.disabled = true;
try {
const data = await getDetail();
if (!row.isConnected) return;
if (which === 'work' && !workRows.length) {
workRows = [sectionHeading('Состав работ')];
for (const [index, line] of (data.content || []).entries())
workRows.push(tableRow('norm-work-row', [[index + 1,'num'],[line,''],['',''],['',''],['','']]));
if (workRows.length === 1) workRows.push(tableRow('norm-work-row', [['',''],['Состав работ в индексе не указан',''],['',''],['',''],['','']]));
}
if (which === 'resource' && !resourceRows.length) {
resourceRows = [sectionHeading('Состав норматива')];
for (const resource of data.resources || []) {
const quantity = resource.quantity_note || (resource.quantity ?? '—');
const price = !resource.quantity_note && Number.isFinite(resource.quantity)
&& Number.isFinite(resource.base_price?.cost)
? money(resource.quantity * resource.base_price.cost).replace(' ₽','') : '—';
resourceRows.push(tableRow('norm-resource-row', [[resource.code || '—',''],
[resource.name || '—',''],[resource.unit || '—',''],[quantity,'num'],[price,'num']]));
}
if (resourceRows.length === 1) resourceRows.push(tableRow('norm-resource-row', [['',''],['Ресурсы в индексе не указаны',''],['',''],['',''],['','']]));
resourceRows.push(toolsRow());
}
} catch (error) { status(error.message, true); return; }
finally { button.disabled = false; }
}
if (which === 'work') workOpen = !workOpen;
else resourceOpen = !resourceOpen;
const expanded = which === 'work' ? workOpen : resourceOpen;
button.textContent = expanded ? '▾' : '▸';
button.setAttribute('aria-expanded', String(expanded));
button.setAttribute('aria-label', (expanded ? 'Скрыть ' : 'Показать ')
+ (which === 'work' ? 'состав работ' : 'состав норматива') + ' для ' + item.code);
mount();
}
workToggle.addEventListener('click', () => toggle('work'));
resourceToggle.addEventListener('click', () => toggle('resource'));
return row;
}
function showRows(items, append=false) {
if (!append) { detachDetail(); $('results').replaceChildren(); }
$('results').append(...items.map(renderSearchItem));
if (!append) { detachDetail(); $('results').replaceChildren(); lastFamily = ''; }
const groups = new Map();
for (const item of items) {
const family = familyKey(item);
if (!groups.has(family)) groups.set(family, []);
groups.get(family).push(item);
}
for (const item of items) {
const family = familyKey(item);
const title = familyTitle(groups.get(family));
if (family !== lastFamily) {
$('results').append(tableRow('norm-family-row', [[String(item.code || '').replace(/-\d+$/, ''),''],
[title,''],['',''],['',''],['','']]));
lastFamily = family;
}
$('results').append(renderSearchItem(item, title));
}
}
function fillBaseTypes() {
const base = $('base').value === '2020' ? 'ФЕР-2020' : 'ГЭСН-2022';
@@ -189,9 +303,17 @@
}
function treeNode(child) {
const li = node('li');
const button = node('button', child.name); button.type = 'button';
const button = node('button'); button.type = 'button';
button.append(node('span', '▸', 'tree-arrow'), node('span', child.name));
button.setAttribute('aria-expanded', 'false');
button.addEventListener('click', () => loadBrowse(child.path, li));
button.addEventListener('click', () => {
if (button.getAttribute('aria-expanded') === 'true') {
const list = li.querySelector(':scope > ul');
if (list) list.hidden = true;
button.setAttribute('aria-expanded', 'false');
button.querySelector('.tree-arrow').textContent = '▸';
} else loadBrowse(child.path, li);
});
li.append(button);
return li;
}
@@ -218,15 +340,26 @@
if (treeItem) {
const button = treeItem.querySelector('button');
button.setAttribute('aria-expanded', 'true');
button.querySelector('.tree-arrow').textContent = '▾';
document.querySelectorAll('#tree-root button[aria-current]').forEach(x => x.removeAttribute('aria-current'));
button.setAttribute('aria-current', 'true');
let list = treeItem.querySelector(':scope > ul');
if (!list) { list = node('ul', null, 'tree-list'); treeItem.append(list); }
list.hidden = false;
list.replaceChildren(...(data.children || []).map(treeNode));
} else if (!path) {
const list = node('ul', null, 'tree-list');
list.replaceChildren(...(data.children || []).map(treeNode));
$('tree-root').replaceChildren(list);
const top = node('div');
const root = node('button', '▾ ' + baseType + ' · разделы', 'tree-root-toggle');
root.type = 'button'; root.setAttribute('aria-expanded', 'true');
root.addEventListener('click', () => {
list.hidden = !list.hidden;
root.setAttribute('aria-expanded', String(!list.hidden));
root.textContent = (list.hidden ? '▸ ' : '▾ ') + baseType + ' · разделы';
});
top.append(root, list);
$('tree-root').replaceChildren(top);
}
status('Откройте строку для состава работ и ресурсов.');
} catch (e) { if (seq === requestSeq) status(e.message, true); }
@@ -309,27 +442,20 @@
if (item.prices?.cost != null) root.append(node('p', 'Базисная стоимость: ' + money(item.prices.cost) +
' (уровень ' + (item.price_level || 'не указан') + '). Это не цена выбранного квартала.', 'notice'));
}
async function openDetail(item, targetRow=null) {
async function openDetail(item) {
const seq = ++detailSeq;
const listing = requestSeq;
status('Загружаю состав нормы…');
try {
const loaded = await detailFor(item);
if (seq !== detailSeq || listing !== requestSeq || (targetRow && !targetRow.isConnected)) return;
if (seq !== detailSeq || listing !== requestSeq) return;
active = loaded; savedQuote = null;
$('quote').replaceChildren(); renderDetail(active);
setUnits(active.unit);
$('calc').disabled = !active.current_price_supported;
if (active.calculation_limitation) $('quote').append(node('p', active.calculation_limitation, 'notice'));
if (targetRow) {
if (openedRow && openedRow !== targetRow) openedRow.hidden = true;
targetRow.querySelector('.inline-content').append($('detail-section'));
targetRow.hidden = false; openedRow = targetRow;
document.querySelectorAll('.norm-row button[aria-controls]').forEach(button =>
button.setAttribute('aria-expanded', String(button.getAttribute('aria-controls') === targetRow.id)));
}
$('detail-section').hidden = false;
if (targetRow) targetRow.scrollIntoView({behavior:'smooth', block:'nearest'});
$('detail-section').scrollIntoView({behavior:'smooth', block:'start'});
status('Состав нормы загружен. Сверьте измеритель и ресурсы.');
} catch (e) { status(e.message, true); }
}
@@ -513,7 +639,7 @@
const row = {base:first.base === '2020' ? 'ФЕР-2020' : 'ГЭСН-2022',
base_type:first.base_type,code:first.code,name:first.name,unit:first.unit};
showRows([row]);
await openDetail(row, $('results').querySelector('.norm-detail-row'));
await openDetail(row);
}
if (first) { $('qty').value = String(first.quantity); $('unit').value = first.unit; }
const selection = draft.price_selection || {};
@@ -539,10 +665,6 @@
active = await detailFor({base:selection.base === '2020' ? 'ФЕР-2020' : 'ГЭСН-2022',
base_type:selection.base_type, code:selection.code});
showRows([active]);
const target = $('results').querySelector('.norm-detail-row');
target.querySelector('.inline-content').append($('detail-section'));
target.hidden = false; openedRow = target;
$('results').querySelector('button[aria-controls]').setAttribute('aria-expanded', 'true');
renderDetail(active); $('detail-section').hidden = false;
$('calc').disabled = !active.current_price_supported;
$('qty').value = String(selection.quantity); setUnits(active.unit); $('unit').value = selection.unit;
+80 -15
View File
@@ -64,6 +64,7 @@ def test_family_variants_can_be_opened_and_compared_on_phone(browser, site):
page.goto(site)
page.locator('#query').fill('стяжка пола')
page.locator('#search-form button[type="submit"]').click()
page.locator('#results .norm-row').first.locator('.norm-toggle').nth(1).click()
page.locator('button', has_text='Варианты таблицы').click()
options = page.locator('.variant-option')
options.first.wait_for()
@@ -73,8 +74,9 @@ def test_family_variants_can_be_opened_and_compared_on_phone(browser, site):
page.locator('#comparison .card').nth(1).wait_for()
assert 'Отличающиеся ресурсы' in page.locator('#comparison').inner_text()
options.filter(has_text='11-01-011-01').click()
page.locator('#detail-title', has_text='11-01-011-01').wait_for()
assert page.locator('#detail').inner_text().find('100 м2') >= 0
page.locator('#results .norm-row', has_text='11-01-011-01').wait_for()
page.locator('#results .norm-work-row').first.wait_for()
assert 'Устройство стяжки' in page.locator('#results .norm-work-row').first.inner_text()
assert page.evaluate('document.documentElement.scrollWidth <= window.innerWidth')
page.close()
@@ -101,21 +103,82 @@ def test_catalog_tree_opens_norm_composition_in_the_same_table(browser, site):
};
})()""")
page.goto(site)
page.locator('#tree-root button', has_text='Земляные работы').click()
tree = page.locator('#tree-root button', has_text='Земляные работы').first
assert tree.locator('.tree-arrow').inner_text() == '▸'
tree.click()
page.locator('#tree-root button', has_text='Раздел 1').wait_for()
assert tree.locator('.tree-arrow').inner_text() == '▾'
tree.click()
assert page.locator('#tree-root button', has_text='Раздел 1').is_hidden()
tree.click()
page.locator('#tree-root button', has_text='Раздел 1').wait_for(state='visible')
row = page.locator('#results .norm-row').first
row.locator('button', has_text='Открыть состав').click()
detail = page.locator('#results .norm-detail-row').first
detail.wait_for(state='visible')
assert 'Разработка грунта экскаватором' in detail.inner_text()
assert 'Экскаватор' in detail.inner_text()
detail.locator('summary', has_text='Источник нормы').click()
assert 'ГЭСН.xml' in detail.inner_text()
assert row.locator('button', has_text='Открыть состав').get_attribute('aria-expanded') == 'true'
row.locator('.norm-toggle').first.click()
page.locator('#results .norm-work-row', has_text='Разработка грунта экскаватором').wait_for()
row.locator('.norm-toggle').nth(1).click()
page.locator('#results .norm-resource-row', has_text='Экскаватор').wait_for()
page.locator('#results .norm-tools-row summary', has_text='Источник нормы').click()
assert 'ГЭСН.xml' in page.locator('#results .norm-tools-row').inner_text()
assert row.locator('.norm-toggle').first.get_attribute('aria-expanded') == 'true'
assert page.locator('#results .norm-row').count() == 1
page.close()
def test_video_table_has_two_triangle_toggles_and_inline_grid_rows(browser, site):
page = browser.new_page(viewport={"width": 1360, "height": 800})
page.add_init_script("""(() => {
const base = {base:'ГЭСН-2022',base_type:'ГЭСН',unit:'1000 м3',
section_path:'Земляные работы > Разработка грунта в отвал'};
const first = {...base,code:'01-01-001-01',name:'Разработка грунта в отвал, группа грунтов 1'};
const second = {...base,code:'01-01-001-02',name:'Разработка грунта в отвал, группа грунтов 2'};
window.fetch = async url => {
const u = new URL(url, location.href);
let value = {};
if (u.pathname.endsWith('/catalog')) value={bases:[{base:'ГЭСН-2022',base_type:'ГЭСН',count:2}]};
if (u.pathname.endsWith('/browse')) value={items:[first,second],children:[],has_more:false};
if (u.pathname.endsWith('/detail')) value={...first,
content:['Разработка грунта навымет','Устройство водоотводных канав'],
resources:[{code:'1-100-38',name:'Рабочие',unit:'чел.-ч',quantity:1.54}],
current_price_supported:false};
return new Response(JSON.stringify(value),{status:200,headers:{'Content-Type':'application/json'}});
};
})()""")
page.goto(site)
assert page.locator('.norm-table thead th').all_text_contents() == [
'Шифр', 'Наименование', 'Ед. изм.', 'Расход', 'ПЗ, руб.']
family = page.locator('#results .norm-family-row').first
family.wait_for()
assert '01-01-001' in family.inner_text()
first = page.locator('#results .norm-row').first
toggles = first.locator('.norm-toggle')
assert toggles.count() == 2
assert toggles.first.inner_text() == '▸'
assert toggles.nth(1).inner_text() == '▸'
assert first.locator('td').nth(4).inner_text() == '—'
toggles.first.click()
work = page.locator('#results .norm-work-row').first
work.wait_for(state='visible')
assert 'Разработка грунта навымет' in work.inner_text()
assert toggles.first.inner_text() == '▾'
assert page.locator('#results .norm-resource-row').count() == 0
toggles.nth(1).click()
resource = page.locator('#results .norm-resource-row').first
resource.wait_for(state='visible')
assert resource.locator('td').all_text_contents()[:4] == [
'1-100-38', 'Рабочие', 'чел.-ч', '1.54']
assert toggles.nth(1).inner_text() == '▾'
toggles.first.click()
assert page.locator('#results .norm-work-row').count() == 0
assert resource.is_visible()
toggles.nth(1).click()
assert page.locator('#results .norm-resource-row').count() == 0
page.locator('#results .norm-row').nth(1).locator('.norm-toggle').first.click()
page.locator('#results .norm-work-row').first.wait_for(state='visible')
assert toggles.first.inner_text() == '▸'
assert page.evaluate('document.documentElement.scrollWidth <= window.innerWidth')
page.close()
def test_saved_multi_position_draft_survives_reload_and_marks_incomplete_price(browser, site):
state = {"draft": None}
first = {"base": "ГЭСН-2022", "base_type": "ГЭСН", "code": "11-01-011-01",
@@ -170,7 +233,8 @@ def test_saved_multi_position_draft_survives_reload_and_marks_incomplete_price(b
page.goto(site)
page.locator('#query').fill('стяжка')
page.locator('#search-form button[type="submit"]').click()
page.locator('button', has_text='Открыть состав').first.click()
page.locator('#results .norm-row').first.locator('.norm-toggle').nth(1).click()
page.locator('button', has_text='Расчёт и подборка').click()
page.locator('#qty').fill('50')
page.locator('#add-draft').click()
page.locator('#draft-positions .draft-row').first.wait_for()
@@ -180,7 +244,8 @@ def test_saved_multi_position_draft_survives_reload_and_marks_incomplete_price(b
assert page.locator('#draft-positions input').input_value() == '50'
page.locator('#query').fill('бетон')
page.locator('#search-form button[type="submit"]').click()
page.locator('button', has_text='Открыть состав').first.click()
page.locator('#results .norm-row').first.locator('.norm-toggle').nth(1).click()
page.locator('button', has_text='Расчёт и подборка').click()
page.locator('#qty').fill('2')
page.locator('#add-draft').click()
page.locator('#draft-positions .draft-row').nth(1).wait_for()
@@ -226,8 +291,8 @@ def test_guest_can_search_and_read_norm_but_not_see_price_controls(browser, site
page.locator('#auth-notice').wait_for(state="visible")
page.locator('#query').fill('стяжка')
page.locator('#search-form button[type="submit"]').click()
page.locator('button', has_text='Открыть состав').first.click()
page.locator('#detail-title', has_text='11-01-011-01').wait_for()
page.locator('#results .norm-row').first.locator('.norm-toggle').first.click()
page.locator('#results .norm-work-row', has_text='Работа').wait_for()
assert page.locator('#quote-panel').is_hidden()
assert all(path.startswith('/api/public/norm-finder/') for path in seen)
assert page.evaluate('document.documentElement.scrollWidth <= window.innerWidth')