Files
eminuxCRM/app/javascript/controllers/audience_preview_controller.js
T
eminuxandCursor 1f946f63ba
CI / scan_ruby (push) Failing after 18m40s
CI / scan_js (push) Successful in 11m46s
CI / lint (push) Failing after 13m8s
Aggiunge filtri avanzati per i destinatari delle campagne email.
La scelta della lista passa da un wizard a tre passi, con anteprima del conteggio e lista congelata solo dopo la conferma.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 21:00:11 +02:00

35 lines
899 B
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["intent"]
refresh() {
this.persistOpenSections()
this.setIntent("preview")
this.element.requestSubmit()
}
apply() {
this.persistOpenSections()
this.setIntent("apply")
}
persistOpenSections() {
this.element.querySelectorAll("input[data-open-section]").forEach((input) => input.remove())
this.element.querySelectorAll("details[data-section]").forEach((details) => {
if (!details.open) return
const input = document.createElement("input")
input.type = "hidden"
input.name = "open_sections[]"
input.value = details.dataset.section
input.setAttribute("data-open-section", "")
this.element.appendChild(input)
})
}
setIntent(value) {
if (this.hasIntentTarget) this.intentTarget.value = value
}
}