mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
feat(retirement): PR4d what-if slider rail
Each lever (retire age / target spend / save per mo / real return) now pairs a numeric input with a range slider; retirement_what_if_controller mirrors the value across the pair (data-lever) and debounces the live forecast preview. Birth year stays a plain numeric input. (Skinned delete confirmations already render via Sure's global Turbo.config.forms.confirm → DS::Dialog override, so the PR2 turbo_confirm buttons are already styled — no change needed.)
This commit is contained in:
@@ -7,6 +7,18 @@ export default class extends Controller {
|
||||
static targets = ["form"]
|
||||
static values = { url: String, debounce: { type: Number, default: 300 } }
|
||||
|
||||
// Mirror a lever's value across its paired number + range inputs (matched
|
||||
// by data-lever), then debounce a preview.
|
||||
sync(event) {
|
||||
const lever = event.target.dataset.lever
|
||||
if (lever) {
|
||||
this.element.querySelectorAll(`[data-lever="${lever}"]`).forEach((el) => {
|
||||
if (el !== event.target) el.value = event.target.value
|
||||
})
|
||||
}
|
||||
this.preview()
|
||||
}
|
||||
|
||||
preview() {
|
||||
clearTimeout(this.timer)
|
||||
this.timer = setTimeout(() => this.fetchPreview(), this.debounceValue)
|
||||
|
||||
Reference in New Issue
Block a user