11import { Controller } from "@hotwired/stimulus" ;
22
3+ /**
4+ * Update 20250917
5+ * assets/controllers/table_check_controller.js
6+ */
37export default class extends Controller {
4- static targets = [ "rowInputs" , "itemDelete" , "itemDirDelete" ] ;
8+ static targets = [ "rowInputs" , "itemDownload" , "itemDirDownload" , " itemDelete", "itemDirDelete" ] ;
59 static values = {
610 check : Array ,
711 checkDir : Array
@@ -10,9 +14,11 @@ export default class extends Controller {
1014 connect ( )
1115 {
1216 console . log ( "Contrôleur table-check connecté !" ) ;
17+ // this.checkValue = []; // Initialise le tableau
1318 }
1419
1520 changes ( event ) {
21+ // console.log(event.target.closest('table'));
1622 this . checks ( event . target . checked ) ;
1723 }
1824
@@ -30,6 +36,7 @@ export default class extends Controller {
3036 this . checkValue = check ; // Met à jour la valeur réactive
3137
3238 this . updateHiddenInput ( ) ;
39+ // console.log(this.checkValue);
3340 }
3441
3542 check ( event ) {
@@ -42,12 +49,16 @@ export default class extends Controller {
4249 }
4350
4451 this . updateHiddenInput ( ) ;
52+ // console.log(this.checkValue);
4553 }
4654
4755 updateHiddenInput ( ) {
4856 if ( this . hasItemDeleteTarget ) {
4957 this . itemDeleteTarget . value = JSON . stringify ( this . checkValue ) ;
5058 }
59+ if ( this . hasItemDownloadTarget ) {
60+ this . itemDownloadTarget . value = JSON . stringify ( this . checkValue ) ;
61+ }
5162 }
5263
5364 checkDir ( event ) {
@@ -60,11 +71,15 @@ export default class extends Controller {
6071 }
6172
6273 this . updateHiddenDirInput ( ) ;
74+ // console.log(this.checkDirValue);
6375 }
6476
6577 updateHiddenDirInput ( ) {
6678 if ( this . hasItemDirDeleteTarget ) {
6779 this . itemDirDeleteTarget . value = JSON . stringify ( this . checkDirValue ) ;
6880 }
81+ if ( this . hasItemDirDownloadTarget ) {
82+ this . itemDirDownloadTarget . value = JSON . stringify ( this . checkDirValue ) ;
83+ }
6984 }
7085}
0 commit comments