templates/article/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}LouvreBible, gestion des contenus{% endblock %}
  3. {% block content %}
  4. <a title="Nouvel article" class="btn btn-primary" href="{{ path('insert_article_global') }}">Nouvel Article</a>
  5.     <div id="toolbar-ujuo">
  6.       <div class="form-inline" role="form">
  7.         <h4 style="color:purple;">Articles un jour une oeuvre</h4>
  8.       </div>
  9.     </div>
  10.     <table     id="articles-ujuo-table" name="articles-ujuo-table" class="w-100 table-striped clickable-row" 
  11.             data-url="{{ path('articles_un_jour_une_oeuvre_list_json') }}"
  12.             data-show-export="true"
  13.             data-export-types="['excel','csv']"
  14.             data-smart-display="true" 
  15.             data-pagination="true"
  16.             data-page-list="[10, 25, 50, 100, 500, 1000, 5000]"
  17.             data-page-size="20"
  18.             data-show-pagination-switch="true" 
  19.             data-show-toggle="false" 
  20.             data-id-field="id"
  21.             data-cache="false"
  22.             data-show-refresh="true" 
  23.             data-show-columns="false"  
  24.             data-search="true"
  25.             data-filter-control="false"
  26.             data-toolbar="#toolbar-ujuo"
  27.             >
  28.         <thead>
  29.             <tr>
  30.                 <th data-field="id"  data-sortable="true" data-visible="true">#</th>
  31.                 <th data-field="status"  data-sortable="true" data-visible="true">Statut</th>
  32.                 <th data-field="title"  data-sortable="true" data-visible="true">Titre de l'article</th>
  33.                 <th data-field="last_update" data-formatter="dateFormatHour" data-sortable="false" data-visible="true" >MAJ</th>
  34.                 <th data-field="to_show" data-sortable="true" data-visible="true" >En avant (MM-JJ)</th>
  35.                 <th data-field="bible_book_name_verse" data-sortable="true" data-visible="true" >Livre</th>
  36.                 <th data-field="operate" data-formatter="operateFormatter" data-sortable="true">Actions</th>
  37.             </tr>
  38.         </thead>
  39.     </table>
  40.     <div id="toolbar-lbi">
  41.       <div class="form-inline" role="form">
  42.         <h4 style="color:purple;">Articles la Bible illustrée</h4>
  43.       </div>
  44.     </div>
  45.     <table     id="articles-lbi-table" name="articles-lbi-table" class="w-100 table-striped clickable-row" 
  46.             data-url="{{ path('articles_lbi_list_json') }}"
  47.             data-show-export="true"
  48.             data-export-types="['excel','csv']"
  49.             data-smart-display="true" 
  50.             data-pagination="true"
  51.             data-page-list="[10, 25, 50, 100, 500, 1000, 5000]"
  52.             data-page-size="20"
  53.             data-show-pagination-switch="true" 
  54.             data-show-toggle="false" 
  55.             data-id-field="id"
  56.             data-cache="false"
  57.             data-show-refresh="true" 
  58.             data-show-columns="false"  
  59.             data-search="true"
  60.             data-filter-control="false"
  61.             data-toolbar="#toolbar-lbi"
  62.             >
  63.         <thead>
  64.             <tr>
  65.                 <th data-field="id"  data-sortable="true" data-visible="true">#</th>
  66.                 <th data-field="status"  data-sortable="true" data-visible="true">Statut</th>
  67.                 <th data-field="title"  data-sortable="true" data-visible="true">Titre de l'article</th>
  68.                 <th data-field="last_update" data-formatter="dateFormatHour" data-sortable="false" data-visible="true" >MAJ</th>
  69.                 <th data-field="to_show" data-sortable="true" data-visible="true" >En avant (MM-JJ)</th>
  70.                 <th data-field="bible_book_name_verse" data-sortable="true" data-visible="true" >Livre</th>
  71.                 <th data-field="operate" data-formatter="operateFormatter" data-sortable="true">Actions</th>
  72.             </tr>
  73.         </thead>
  74.     </table>
  75.     <div id="toolbar-only">
  76.       <div class="form-inline" role="form">
  77.         <h4 style="color:purple;">Autres articles du site</h4>
  78.       </div>
  79.     </div>
  80.     <table     id="articles-only-table" name="articles-only-table" class="w-100 table-striped clickable-row" 
  81.             data-url="{{ path('articles_list_json') }}"
  82.             data-show-export="true"
  83.             data-export-types="['excel','csv']"
  84.             data-smart-display="true" 
  85.             data-pagination="true"
  86.             data-page-list="[10, 25, 50, 100, 500, 1000, 5000]"
  87.             data-page-size="20"
  88.             data-show-pagination-switch="true" 
  89.             data-show-toggle="false" 
  90.             data-id-field="id"
  91.             data-cache="false"
  92.             data-show-refresh="true" 
  93.             data-show-columns="false"  
  94.             data-search="true"
  95.             data-filter-control="false"
  96.             data-toolbar="#toolbar-only"
  97.             >
  98.         <thead>
  99.             <tr>
  100.                 <th data-field="id"  data-sortable="true" data-visible="true">#</th>
  101.                 <th data-field="status"  data-sortable="true" data-visible="true">Statut</th>
  102.                 <th data-field="title"  data-sortable="true" data-visible="true">Titre de l'article</th>
  103.                 <th data-field="last_update" data-formatter="dateFormatHour" data-sortable="false" data-visible="true" >MAJ</th>
  104.                 <th data-field="to_show" data-sortable="true" data-visible="true" >En avant (MM-JJ)</th>
  105.                 <th data-field="operate" data-formatter="operateFormatter" data-sortable="true">Actions</th>
  106.             </tr>
  107.         </thead>
  108.     </table>
  109. <div class="modal" id="deleteArticleModal" tabindex="-1" aria-labelledby="deleteArticleModalLabel" aria-hidden="true">
  110.     <div class="modal-dialog">
  111.     <div class="modal-content">
  112.         <div class="modal-header">
  113.             <h5 class="modal-title" id="deleteArticleModalLabel">Suppression de l'article</h5>
  114.             <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  115.         </div>
  116.         <div class="modal-body">
  117.             <label for="articleDelId">Êtes-vous certain de supprimer l'article no:</label>
  118.             <p id="articleDelId">#</p>
  119.         </div>
  120.         <div class="modal-footer">
  121.             <button type="button" class="btn btn-light" data-dismiss="modal">Fermer</button>
  122.             <button id="submitButton" type="button" class="btn btn-danger" value="" >Valider</button> 
  123.         </div>
  124.     </div>
  125.     </div>
  126. </div>
  127. <script>
  128.     $('#titlenav').html('Gestion des articles');
  129.     //<i class="fas fa-exclamation"></i>&nbsp;&nbsp;
  130.     function operateFormatter(value, row, index) {
  131.         var actions = '';
  132.         console.log('value : '+ value); console.log('index : '+ index); console.log('row.id : '+row.id);
  133.         var articleEditUrl = "{{ path('edit_article_global') }}/"+row.id;
  134.         console.log('articleEditUrl: '+articleEditUrl);
  135.         var articleCopyUrl = "{{ path('insert_article_global') }}/"+row.id;
  136.         console.log('articleCopyUrl: '+articleCopyUrl);
  137.         actions +="<a title='Modifier' class='btn btn-warning edit_item mx-2'  href="+articleEditUrl+"><i class='far fa-file-alt fa-2x'></i></a>";
  138.         actions +="<a title='Dupliquer' class='btn btn-outline-info mx-2'  href="+articleCopyUrl+"><i class='far fa-copy fa-2x'></i></a>";
  139.         actions +="<button type='button' title='Supprimer' class='btn btn-danger mx-2'  data-toggle='modal' data-target='#deleteArticleModal' data-whatever="+row.id+"><i class='fas fa-trash fa-2x'></i></button>";
  140.         return [ actions ].join('');
  141.     }
  142.     
  143.     // CALLBACKS
  144.     
  145.     $('#deleteArticleModal').on('show.bs.modal', function (event) {
  146.         var button = $(event.relatedTarget); // Button that triggered the modal
  147.         var recipient = button.data('whatever'); // Extract info from data-* attributes
  148.         console.log('data-whatever : '+ recipient); 
  149.           // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
  150.           // Update the modal's content.
  151.         var modal = $(this);
  152.         modal.find('.modal-body p').text(recipient);
  153.         modal.find('.modal-footer #submitButton').val(recipient);
  154.     });
  155.     
  156.     $( "#submitButton" ).on( "click", function() {
  157.         console.log("submitButton val is :" + $( this ).val() );
  158.         // RETRIEVE
  159.         var id_article = $( this ).val();
  160.         // CREATE JSON
  161.         var donnees = JSON.stringify({
  162.             "id_article":id_article
  163.         });
  164.         console.log(donnees);
  165.         // SEND REQUEST
  166.         $.ajax({
  167.                 type:'POST',
  168.                 url:'{{ path("delete_article_global") }}',
  169.                 data:{'parametres':donnees},
  170.                 dataType:'json',
  171.                 success: function(data){
  172.                     if ( (data['retour']=="O") || (data['retour']=="N") ){
  173.                         /*if(confirm(data['message']+". Voulez vous recharger la page ?") ){
  174.                             location.reload();
  175.                         }
  176.                         else{ }*/
  177.                         $('#articles-ujuo-table').bootstrapTable('refresh');
  178.                         $('#articles-lbi-table').bootstrapTable('refresh');
  179.                         $('#articles-only-table').bootstrapTable('refresh');
  180.                         $('#deleteArticleModal').modal('hide');
  181.                     }
  182.                 },
  183.                 error: function(request, status, error){
  184.                     alert("Erreur interne");
  185.                     console.log("Appel AJAX : "+error);
  186.                 }
  187.         });
  188.     });
  189.     
  190.     
  191. </script>
  192. {% endblock %}
  193. {% block document_ready %}
  194.     $('#articles-only-table').bootstrapTable();    
  195.     $('#articles-only-table').on('dbl-click-row.bs.table', function (row, element, field) {
  196.         $('#articles-only-table tbody tr').removeClass("selected");
  197.         field.addClass("selected");
  198.         var params = "{{ path('edit_article_global') }}/"+element.id;
  199.         $(location).attr('href', params);    
  200.     });
  201.     
  202.     $('#articles-ujuo-table').bootstrapTable();    
  203.     $('#articles-ujuo-table').on('dbl-click-row.bs.table', function (row, element, field) {
  204.         $('#articles-ujuo-table tbody tr').removeClass("selected");
  205.         field.addClass("selected");
  206.         var params = "{{ path('edit_article_global') }}/"+element.id;
  207.         $(location).attr('href', params);    
  208.     });
  209.     $('#articles-lbi-table').bootstrapTable();    
  210.     $('#articles-lbi-table').on('dbl-click-row.bs.table', function (row, element, field) {
  211.         $('#articles-lbi-table tbody tr').removeClass("selected");
  212.         field.addClass("selected");
  213.         var params = "{{ path('edit_article_global') }}/"+element.id;
  214.         $(location).attr('href', params);    
  215.     });
  216. {% endblock %}