Commit 23e28278 authored by Mat's avatar Mat
Browse files

améliorations diverses

parent 0b22d46f
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
function reloadTableMembre(paginate) function reloadTableMembre(paginate)
{ {
console.log(paginate);
tbody.innerHTML = null; tbody.innerHTML = null;
let membreURL = Routing.generate('api_membre_read_paginate', paginate); let membreURL = Routing.generate('api_membre_read_paginate', paginate);
...@@ -200,6 +201,7 @@ ...@@ -200,6 +201,7 @@
let membreId = this.dataset.membreId; let membreId = this.dataset.membreId;
let r = confirm('Effacer le membre n°' + membreId let r = confirm('Effacer le membre n°' + membreId
+ '\nCette action n\'est pas réversible. Souhaitez-vous continuer ?\n'); + '\nCette action n\'est pas réversible. Souhaitez-vous continuer ?\n');
if (r === true) { if (r === true) {
submitURL = Routing.generate('api_membre_delete', {'id': membreId }); submitURL = Routing.generate('api_membre_delete', {'id': membreId });
AJAX('DELETE', submitURL, function() AJAX('DELETE', submitURL, function()
...@@ -227,17 +229,17 @@ ...@@ -227,17 +229,17 @@
let total = json.length; let total = json.length;
let perPage = paginate.step; let perPage = paginate.step;
//console.log('parPage:' + perPage + ' total:' + total); //console.log('total:' + total + ' parPage:' + perPage);
if (total > perPage) if (total > perPage)
{ {
let nbPages = total % perPage; let nbPages = Math.ceil(total / perPage);
//console.log(nbPages + ' pages'); //console.log(nbPages + ' pages');
currentPage = paginate.page; currentPage = paginate.page;
//console.log('page courante: '+ currentPage); //console.log('page courante: '+ currentPage);
for (var i = 1; i <= nbPages; i++) for (let i = 1; i <= nbPages; i++)
{ {
//console.log(i);
let pageItem = document.createElement('li'); let pageItem = document.createElement('li');
pageItem.classList.add('page-item', (i === currentPage) ? 'active' : null); pageItem.classList.add('page-item', (i === currentPage) ? 'active' : null);
...@@ -245,15 +247,16 @@ ...@@ -245,15 +247,16 @@
let pageItemChild = document.createElement((i === currentPage) ? 'span' : 'a'); let pageItemChild = document.createElement((i === currentPage) ? 'span' : 'a');
pageItemChild.classList.add('page-link'); pageItemChild.classList.add('page-link');
pageItemChild.textContent = i; pageItemChild.textContent = i;
if (i !== currentPage) {
paginate.page = i; if (i !== currentPage)
{
pageItemChild.addEventListener('click', function(e) pageItemChild.addEventListener('click', function(e)
{ {
console.log(paginate); console.log('click:' + i);
paginate.page = i;
reloadTableMembre(paginate); reloadTableMembre(paginate);
}); });
} }
pageItem.appendChild(pageItemChild); pageItem.appendChild(pageItemChild);
pageNav.appendChild(pageItem); pageNav.appendChild(pageItem);
} }
...@@ -326,7 +329,8 @@ ...@@ -326,7 +329,8 @@
stepform.addEventListener('change', function(e) stepform.addEventListener('change', function(e)
{ {
step = (this.value === '-1') ? 10 : this.value; step = (this.value === '-1') ? 10 : this.value;
paginate.step = step; paginate.step = parseInt(step);
paginate.page = 1;
reloadTableMembre(paginate); reloadTableMembre(paginate);
}); });
...@@ -350,7 +354,6 @@ ...@@ -350,7 +354,6 @@
paginate.column = col; paginate.column = col;
paginate.order = (paginate.order === 'ASC') ? 'DESC' : 'ASC'; paginate.order = (paginate.order === 'ASC') ? 'DESC' : 'ASC';
console.log(paginate);
reloadTableMembre(paginate); reloadTableMembre(paginate);
let th = this.parentNode; let th = this.parentNode;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment