Replace toggle_button_disable ctrller with generic toggle_control ctrller

- add enableIfPresent method in toggle_control_controller.js to handle enabling on toggle
- add testing in the corresponding spec
- replace in view previous ctrler with intended generic toggle-control
This commit is contained in:
cyrillefr
2024-01-16 18:46:55 +01:00
parent dd502f0883
commit 8eb5ac990e
3 changed files with 38 additions and 3 deletions

View File

@@ -17,6 +17,14 @@ export default class extends Controller {
}
}
enableIfPresent(event) {
const input = event.currentTarget;
const enable = !!this.#inputValue(input);
this.controlTargets.forEach((target) => {
target.disabled = !enable;
});
}
//todo: can a new method disableIfBlank replace ButtonDisabledController?
//todo: can a new method toggleDisplay replace ToggleController?
//todo: can toggleDisplay with optional chevron-target replace RemoteToggleController?