Correção do QR do holerite entre outras coisas
This commit is contained in:
@@ -6,7 +6,8 @@ import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [
|
||||
"linha", "checkbox", "selecionarTodos", "toggles", "barra", "percentual",
|
||||
"linha", "checkbox", "selecionarTodos", "modoRemover", "rotuloAcao",
|
||||
"toggles", "barra", "percentual",
|
||||
"contadorClassificadas", "contadorTotal",
|
||||
"qtdNormal", "qtdRetirada", "qtdBonus", "qtdDesconto", "valorTotal"
|
||||
]
|
||||
@@ -52,15 +53,18 @@ export default class extends Controller {
|
||||
|
||||
// ── Marcar todos como Normal ───────────────────────────────
|
||||
async marcarTodos(event) {
|
||||
const tipo = event.currentTarget.dataset.tipo
|
||||
if (!confirm(`Marcar TODAS as entregas como ${this.labelTipo(tipo)}?`)) return
|
||||
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
|
||||
|
||||
const resp = await this.post(this.massaUrlValue, {
|
||||
tipo: tipo,
|
||||
motorista: this.motoristaValue,
|
||||
tracking_ids: [] // vazio = todas
|
||||
tracking_ids: [], // vazio = todas
|
||||
acao: remover ? "remover" : "adicionar"
|
||||
})
|
||||
this.linhaTargets.forEach(l => this.setToggle(l.dataset.tracking, tipo, true))
|
||||
this.linhaTargets.forEach(l => this.setToggle(l.dataset.tracking, tipo, !remover))
|
||||
this.atualizarResumo(resp)
|
||||
}
|
||||
|
||||
@@ -70,6 +74,18 @@ export default class extends Controller {
|
||||
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
|
||||
}
|
||||
|
||||
alternarModo() {
|
||||
if (this.hasRotuloAcaoTarget) {
|
||||
this.rotuloAcaoTarget.textContent =
|
||||
this.modoRemover ? "Remover dos selecionados:" : "Selecionados como:"
|
||||
}
|
||||
}
|
||||
|
||||
// ── Marcar selecionados como X ─────────────────────────────
|
||||
async marcarSelecionados(event) {
|
||||
const tipo = event.currentTarget.dataset.tipo
|
||||
@@ -80,12 +96,14 @@ export default class extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
const remover = this.modoRemover
|
||||
const resp = await this.post(this.massaUrlValue, {
|
||||
tipo: tipo,
|
||||
motorista: this.motoristaValue,
|
||||
tracking_ids: ids
|
||||
tracking_ids: ids,
|
||||
acao: remover ? "remover" : "adicionar"
|
||||
})
|
||||
ids.forEach(id => this.setToggle(id, tipo, true))
|
||||
ids.forEach(id => this.setToggle(id, tipo, !remover))
|
||||
this.checkboxTargets.forEach(c => c.checked = false)
|
||||
if (this.hasSelecionarTodosTarget) this.selecionarTodosTarget.checked = false
|
||||
this.atualizarResumo(resp)
|
||||
|
||||
Reference in New Issue
Block a user