// app/javascript/controllers/adicionar_motorista_controller.js // Stimulus — modal "Adicionar motorista" no Passo 1. Só abre/fecha o modal; o // formulário em si submete normalmente (Turbo), redirecionando de volta ao wizard. import { Controller } from "@hotwired/stimulus" export default class extends Controller { static targets = ["modal", "input"] abrir() { this.modalTarget.classList.remove("hidden") if (this.hasInputTarget) this.inputTarget.focus() } fechar() { this.modalTarget.classList.add("hidden") } // Fecha ao clicar no fundo (fora do card) fundo(event) { if (event.target === this.modalTarget) this.fechar() } // Preenche o input com o motorista escolhido na lista de previstos. selecionar(event) { if (this.hasInputTarget) { this.inputTarget.value = event.currentTarget.dataset.nome this.inputTarget.focus() } } }