Atualização do layout da tela de consolidação do motorista

This commit is contained in:
2026-06-26 13:55:32 -03:00
parent 1bda666d5a
commit 418cf43353
3 changed files with 26 additions and 61 deletions

View File

@@ -6,7 +6,7 @@ import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [
"linha", "checkbox", "selecionarTodos", "modoRemover", "rotuloAcao",
"linha", "checkbox", "selecionarTodos",
"toggles", "barra", "barraManuais", "percentual", "chipVeiculo",
"contadorClassificadas", "contadorTotal", "contadorManuais", "manuaisInfo",
"qtdNormal", "qtdRetirada", "qtdBonus", "qtdDesconto", "qtdExtraordinaria",
@@ -64,50 +64,21 @@ export default class extends Controller {
}
}
// ── Marcar todos como Normal ───────────────────────────────
async marcarTodos(event) {
const tipo = event.currentTarget.dataset.tipo
const remover = this.modoRemover
const verbo = remover ? "REMOVER de TODAS as entregas" : "Marcar TODAS as entregas como"
if (!confirm(`${verbo} ${this.labelTipo(tipo)}?`)) return
let valor = null
if (tipo === "extraordinaria" && !remover) {
valor = this.pedirValor()
if (valor === null) return
}
const resp = await this.post(this.massaUrlValue, {
tipo: tipo,
motorista: this.motoristaValue,
vehicle: this.veiculoValue,
tracking_ids: [], // vazio = todas (do veículo selecionado, se houver)
acao: remover ? "remover" : "adicionar",
valor: valor
})
this.linhaTargets.forEach(l => this.setToggle(l.dataset.tracking, tipo, !remover))
this.atualizarResumo(resp)
}
// ── Selecionar / desmarcar todos os checkboxes ─────────────
selecionarTodos(event) {
const marcar = event.currentTarget.checked
this.checkboxTargets.forEach(c => { c.checked = marcar })
}
// ── Modo das ações em massa: adicionar (padrão) ou remover ──
get modoRemover() {
return this.hasModoRemoverTarget && this.modoRemoverTarget.checked
// O pilar está ativo (ring-2) na entrega indicada?
pilarAtivo(tracking, tipo) {
const grupo = this.togglesTargets.find(t => t.dataset.tracking === tracking)
if (!grupo) return false
const btn = grupo.querySelector(`.toggle-btn[data-tipo="${tipo}"]`)
return !!btn && btn.classList.contains("ring-2")
}
alternarModo() {
if (this.hasRotuloAcaoTarget) {
this.rotuloAcaoTarget.textContent =
this.modoRemover ? "Remover dos selecionados:" : "Selecionados como:"
}
}
// ── Marcar selecionados como X ─────────────────────────────
// ── Aplicar/remover o pilar nos selecionados (toggle em massa) ──
async marcarSelecionados(event) {
const tipo = event.currentTarget.dataset.tipo
const ids = this.checkboxTargets.filter(c => c.checked).map(c => c.value)
@@ -117,7 +88,9 @@ export default class extends Controller {
return
}
const remover = this.modoRemover
// Toggle em massa: se TODAS as selecionadas já têm o pilar, remove de todas;
// caso contrário, aplica em todas.
const remover = ids.every(id => this.pilarAtivo(id, tipo))
let valor = null
if (tipo === "extraordinaria" && !remover) {