Files
eminuxCRM/app/javascript/controllers/audience_preview_controller.js
T
eminuxandCursor 3e73e708e4
CI / scan_ruby (push) Failing after 12m54s
CI / scan_js (push) Successful in 12m34s
CI / lint (push) Failing after 13m10s
Rende usabili i filtri destinatari e permette di eliminare le bozze email.
Le listbox non applicavano sport e altri criteri; ora i filtri sono checkbox, c'è «mai contattati» e dal cruscotto si cancellano le bozze. La lista organizzazioni allinea le colonne al foglio campagna.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 07:57:50 +02:00

45 lines
1.1 KiB
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["intent"]
disconnect() {
clearTimeout(this.refreshTimer)
}
refresh() {
clearTimeout(this.refreshTimer)
this.refreshTimer = setTimeout(() => this.submitPreview(), 250)
}
apply() {
clearTimeout(this.refreshTimer)
this.persistOpenSections()
this.setIntent("apply")
}
submitPreview() {
this.persistOpenSections()
this.setIntent("preview")
this.element.requestSubmit()
}
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
}
}