Stage isolated engine price catalog for inline zone choices

This commit is contained in:
anor
2026-12-04 02:31:11 +10:00
parent f93c0e50b2
commit beda783439
5 changed files with 131 additions and 3 deletions
+12 -2
View File
@@ -376,6 +376,7 @@ button { font-family: inherit; }
.inline-basis-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.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-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; }
@@ -2338,6 +2339,13 @@ async function openFreeformBasis(button, host, label) {
const currentZone = zones.find(z => z.name === 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 = 'Квартал из ответа не загружен. Выберите доступный квартал для нового расчёта.';
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
? String(roman[quarterMention[1].toUpperCase()] || Number(quarterMention[1])) + ' квартал ' + quarterMention[2]
: '';
const fillPeriods = () => {
periodSelect.replaceChildren();
const placeholder = document.createElement('option'); placeholder.value = '';
@@ -2345,8 +2353,10 @@ async function openFreeformBasis(button, host, label) {
const zone = zones.find(z => String(z.zone_id) === zoneSelect.value);
(zone ? zone.periods : []).forEach(p => { const o = document.createElement('option');
o.value = String(p.period_id); o.textContent = p.name; periodSelect.appendChild(o); });
const named = (zone ? zone.periods : []).find(p => (host._rawText || '').includes(p.name));
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;
};
fillPeriods(); zoneSelect.onchange = fillPeriods;
const normRows = options.norms || [];
@@ -2397,7 +2407,7 @@ async function openFreeformBasis(button, host, label) {
}
};
if (normRows.length) picker.append(normSelect, quantity);
picker.append(zoneSelect, periodSelect, apply, cancel);
picker.append(zoneSelect, periodSelect, apply, cancel, periodNote);
button.replaceWith(picker); zoneSelect.focus();
} catch (e) {
button.disabled = false;