templates/content/structure/commentaires/jquery/script.html.twig line 1

Open in your IDE?
  1. gestionBtnCommentaireAjoute();
  2. gestionBtnModifMonComm();
  3. gestionBtnSupprMonComm();
  4. gestionBtnAjouteComplement();
  5. function gestionBtnCommentaireAjoute(){
  6.   // gestion des boutons ajouter un commentaire
  7.   $("[id^='btnCommentaireAjoute']").click(function(){
  8.     // recup id du stack
  9.     console.log("polop "+$(this).attr("id").substr(20));
  10.     idStack = $(this).attr("id").substr(20);
  11.     console.log("polop "+idStack);
  12.     // vide le modal
  13.     $("#contentForm").html('<i class="fa-solid fa-rotate fa-spin"></i>');
  14.     $.ajax({
  15.       type: "POST",
  16.       url: "{{ path('membre_stacks_comm_formAjoute') }}",
  17.       data: {
  18.         idStack: idStack,
  19.       },
  20.       success: function(msg){
  21.         //console.log(msg);
  22.         // affiche le form
  23.         $("#contentForm").html(msg);
  24.         // gestion du bouton enregistrer
  25.         $("#btnValideForm").click(function(){
  26.           // affiche le chargement en cours
  27.           $("#contentForm").html('<div id="chargement" style="text-align:center; padding:20% 0 ;background-color: burlywood; position: absolute; display: block; top: 0; left: 0; width: 100%; height: 100%;"><i class="fa fa-solid fa-clipboard-list fa-2x"></i><br>Enregistrement</div>')
  28.           // recup donnĂ©es
  29.           nouveauMessage = CKEDITOR.instances['form_texte'].getData()
  30.           console.log("nouveauMessage "+nouveauMessage);
  31.           // enregistre l'Assignation
  32.           $.ajax({
  33.             type: "POST",
  34.             url: "{{ path('membre_stacks_comm_formAjouteTraitement') }}",
  35.             data: {
  36.               monid: idStack,
  37.               nouveauMessage: nouveauMessage,
  38.             },
  39.             success: function(msg){
  40.               console.log("clik ok");
  41.               // recharge ligne stack
  42.               rechargeLigneStack(idStack);
  43.             }
  44.           });
  45.         });
  46.       }
  47.     });
  48.   });
  49. }
  50. function gestionBtnModifMonComm(){
  51.   // gestion des boutons modifier un commentaire
  52.   $("[id^='btnModifMonComm_']").click(function(){
  53.     // recup id du stack
  54.     idComm = $(this).attr("id").substr(16);
  55.     console.log("btnModifMonComm_"+idComm);
  56.     // vide le modal
  57.     $("#contentForm").html('<i class="fa-solid fa-rotate fa-spin"></i>');
  58.     $.ajax({
  59.       type: "POST",
  60.       url: "{{ path('membre_stacks_comm_formModif') }}",
  61.       data: {
  62.         idComm: idComm,
  63.       },
  64.       success: function(msg){
  65.         // affiche le form
  66.         $("#contentForm").html(msg);
  67.         // gestion du bouton enregistrer
  68.         $("#btnValideForm").click(function(){
  69.           // enregistre la modification
  70.           $.ajax({
  71.             type: "POST",
  72.             url: "{{ path('membre_stacks_comm_formModifTraitement') }}",
  73.             data: {
  74.               idComm: idComm,
  75.               nouveauMessage: CKEDITOR.instances['form_texte'].getData(),
  76.             },
  77.             success: function(msg){
  78.               console.log(msg['ok']);
  79.               // recharge ligne stack
  80.               rechargeLigneStack(msg['ok']);
  81.             }
  82.           });
  83.         });
  84.       }
  85.     });
  86.   });
  87. }
  88. function gestionBtnSupprMonComm(){
  89.   // gestion des boutons supprimer un commentaire
  90.   $("[id^='btnSupprMonComm_']").click(function(){
  91.     // recup id du stack
  92.     idComm = $(this).attr("id").substr(16);
  93.     console.log("btnModifMonComm_"+idComm);
  94.     // vide le modal
  95.     $("#contentForm").html('<i class="fa-solid fa-rotate fa-spin"></i>');
  96.     $.ajax({
  97.       type: "POST",
  98.       url: "{{ path('membre_stacks_comm_formSuppr') }}",
  99.       data: {
  100.         idComm: idComm,
  101.       },
  102.       success: function(msg){
  103.         // affiche le form
  104.         $("#contentForm").html(msg);
  105.         // gestion du bouton enregistrer
  106.         $("#btnValideForm").click(function(){
  107.           // enregistre la modification
  108.           $.ajax({
  109.             type: "POST",
  110.             url: "{{ path('membre_stacks_comm_formSupprTraitement') }}",
  111.             data: {
  112.               idComm: idComm,
  113.             },
  114.             success: function(msg){
  115.               console.log(msg['ok']);
  116.               // recharge ligne stack
  117.               rechargeLigneStack(msg['ok']);
  118.             }
  119.           });
  120.         });
  121.       }
  122.     });
  123.   });
  124. }
  125. function gestionBtnAjouteComplement(){
  126.   // gestion des boutons supprimer un commentaire
  127.   $("[id^='btnAjouteComp_']").click(function(){
  128.     // recup id du stack
  129.     idComm = $(this).attr("id").substr(14);
  130.     console.log("btnAjouteComp_"+idComm);
  131.     // vide le modal
  132.     $("#contentForm").html('<i class="fa-solid fa-rotate fa-spin"></i>');
  133.     $.ajax({
  134.       type: "POST",
  135.       url: "{{ path('membre_stacks_comm_formAjouteComp') }}",
  136.       data: {
  137.         idComm: idComm,
  138.       },
  139.       success: function(msg){
  140.         //console.log(msg);
  141.         // affiche le form
  142.         $("#contentForm").html(msg);
  143.         // gestion du bouton enregistrer
  144.         $("#btnValideForm").click(function(){
  145.           // affiche le chargement en cours
  146.           $("#contentForm").html('<div id="chargement" style="text-align:center; padding:20% 0 ;background-color: burlywood; position: absolute; display: block; top: 0; left: 0; width: 100%; height: 100%;"><i class="fa fa-solid fa-clipboard-list fa-2x"></i><br>Enregistrement</div>')
  147.           // recup donnĂ©es
  148.           nouveauMessage = CKEDITOR.instances['form_message'].getData()
  149.           console.log("nouveauMessage "+nouveauMessage);
  150.           // enregistre le complement d info
  151.           $.ajax({
  152.             type: "POST",
  153.             url: "{{ path('membre_stacks_comm_formAjouteCompTraitement') }}",
  154.             data: {
  155.               idComm: idComm,
  156.               nouveauMessage: nouveauMessage,
  157.             },
  158.             success: function(msg){
  159.               console.log("clik ok");
  160.               // recharge ligne stack
  161.               rechargeLigneStack(msg['ok']);
  162.             }
  163.           });
  164.         });
  165.       },
  166.     });
  167.   });
  168. }
  169. function rechargeLigneStack(idStack){
  170.   // enregistre l'Assignation
  171.   $.ajax({
  172.     type: "POST",
  173.     url: "{{ path('membre_rechargeLigneStack') }}",
  174.     data: {
  175.       idStack: idStack,
  176.     },
  177.     success: function(msg){
  178.       $("#ligne_"+idStack).html(msg)
  179.       // masque le modal
  180.       $("#exampleModal").modal('hide');
  181.       //
  182.       gestionBtnCommentaireAjoute();
  183.       gestionBtnModifMonComm();
  184.       gestionBtnSupprMonComm();
  185.       gestionBtnAjouteComplement();
  186.     }
  187.   });
  188. }