Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1367,19 +1367,52 @@ function expandRangeLabel(label) {

function shouldShowContagemSide() {
const scope = normalizeText(el.contagemScope?.value);
return ['B', 'TISSUE', 'TTD', 'CAFE', 'LONIL', 'CHAO'].includes(scope);
return ['PRINCIPAL', 'B', 'TISSUE', 'TTD', 'CAFE', 'LONIL', 'CHAO'].includes(scope);
}

function getContagemSideOptions(scope) {
const s = normalizeText(scope);
if (s === 'PRINCIPAL') {
return [
{ value: 'A', label: 'A' },
{ value: 'AB_D', label: 'A + B direito' },
{ value: 'B_ALL', label: 'B (direito + esquerdo)' },
{ value: 'B_D', label: 'B (direito)' },
{ value: 'B_E', label: 'B (esquerdo)' },
{ value: 'C', label: 'C' },
{ value: 'C_E', label: 'C + esquerdo' }
];
}
return [
{ value: 'ALL', label: 'Direito + Esquerdo' },
{ value: 'D', label: 'Somente direito' },
{ value: 'E', label: 'Somente esquerdo' }
];
}

function updateContagemSideVisibility() {
if (!el.contagemSide) return;
const options = getContagemSideOptions(el.contagemScope?.value);
const current = el.contagemSide.value;
el.contagemSide.innerHTML = options.map((opt) => `<option value="${opt.value}">${opt.label}</option>`).join('');
el.contagemSide.value = options.some((opt) => opt.value === current) ? current : options[0].value;
const visible = shouldShowContagemSide();
const sideLabel = document.getElementById('contagemSideLabel');
sideLabel?.classList.toggle('hidden', !visible);
if (!visible) el.contagemSide.value = 'ALL';
if (!visible) el.contagemSide.value = options[0]?.value || 'ALL';
}

function getContagemPositions(scope, side = 'ALL') {
const s = normalizeText(scope);
if (s === 'PRINCIPAL') {
if (side === 'A') return getContagemPositions('A', 'ALL');
if (side === 'AB_D') return [...getContagemPositions('A', 'ALL'), ...getContagemPositions('B', 'D')];
if (side === 'B_D') return getContagemPositions('B', 'D');
if (side === 'B_E') return getContagemPositions('B', 'E');
if (side === 'C') return getContagemPositions('C', 'ALL');
if (side === 'C_E') return [...getContagemPositions('C', 'ALL'), ...getContagemPositions('B', 'E')];
return getContagemPositions('B', 'ALL');
}
if (s === 'A') return Array.from({ length: 26 }, (_, i) => `A${String(i + 1).padStart(2, '0')}`);
if (s === 'C') return Array.from({ length: 26 }, (_, i) => `C${String(i + 1).padStart(2, '0')}`);
if (s === 'B') {
Expand Down
16 changes: 9 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ <h2>Contagem por rua/estrutura</h2>
<form id="contagemForm" class="grid two-col">
<label>Área de contagem
<select id="contagemScope">
<option value="A">Rua A</option>
<option value="B">Rua B</option>
<option value="C">Rua C</option>
<option value="PRINCIPAL">Principal (A + B + C)</option>
<option value="ESTRUTURA">Estrutura</option>
<option value="CHAO">Chão</option>
<option value="TISSUE">Tissue</option>
Expand All @@ -336,11 +334,15 @@ <h2>Contagem por rua/estrutura</h2>
<option value="LONIL">Lonil</option>
</select>
</label>
<label id="contagemSideLabel">Lado (Rua B / Tissue / Livro / Café / Lonil)
<label id="contagemSideLabel">Lado
<select id="contagemSide">
<option value="ALL">Direito + Esquerdo</option>
<option value="D">Somente direito</option>
<option value="E">Somente esquerdo</option>
<option value="A">A</option>
<option value="AB_D">A + B direito</option>
<option value="B_ALL">B (direito + esquerdo)</option>
<option value="B_D">B (direito)</option>
<option value="B_E">B (esquerdo)</option>
<option value="C">C</option>
<option value="C_E">C + esquerdo</option>
</select>
</label>
<label>Importar planilha para pré-preenchimento
Expand Down