Files
sure/app/javascript/controllers/currency_preferences_controller.js
Ang Wei Feng (Ted) 60929cdee0 feat: add currency management for families with enabled currencies (#1419)
* feat: add currency management for families with enabled currencies

* feat: update currency selection logic and improve accessibility

* feat: update currency preferences to use group moniker in titles

---------

Signed-off-by: Ang Wei Feng (Ted) <hello@tedawf.com>
Signed-off-by: Juan José Mata <juanjo.mata@gmail.com>
Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
2026-04-13 19:53:04 +02:00

32 lines
643 B
JavaScript

import { Controller } from "@hotwired/stimulus";
export default class extends Controller {
static targets = ["dialog", "checkbox"];
static values = {
baseCurrency: String,
};
open() {
this.dialogTarget.showModal();
}
selectAll() {
this.checkboxTargets.forEach((checkbox) => {
checkbox.checked = true;
});
}
selectBaseOnly() {
this.checkboxTargets.forEach((checkbox) => {
checkbox.checked = checkbox.value === this.baseCurrencyValue;
});
}
handleSubmitEnd(event) {
if (!event.detail.success) return;
if (!this.dialogTarget.open) return;
this.dialogTarget.close();
}
}