admin_game_controller.js 814 B

1234567891011121314151617181920212223242526272829
  1. import { Controller } from '@hotwired/stimulus';
  2. /*
  3. * Contrôleur Stimulus pour le formulaire JEUX.
  4. */
  5. export default class extends Controller {
  6. connect() {
  7. this.initDisabling();
  8. console.log("Stimulus: gestion des champs à désactiver");
  9. }
  10. initDisabling() {
  11. const checkInLibrary = document.querySelector('#library-controller input');
  12. checkInLibrary.addEventListener('change', () => {
  13. const formToDisable = Array.from(document.querySelectorAll(".only-in-library"));
  14. formToDisable.forEach((el) => {
  15. if (checkInLibrary.checked) {
  16. el.classList.remove("is-hidden");
  17. } else {
  18. el.classList.add("is-hidden");
  19. }
  20. });
  21. });
  22. }
  23. }