From c893639b9e2e3972712d0728636d093bf74bb9c7 Mon Sep 17 00:00:00 2001 From: Jean-Christophe Engel Date: Sat, 22 Feb 2025 13:09:46 +0100 Subject: [PATCH] =?UTF-8?q?d=C3=A9sactiver=20tri=20colonnes=20de=20class?= =?UTF-8?q?=20nosort=20dans=20une=20liste=20triable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- historique.html | 15 +++++++++++---- inventaire.html | 9 ++++++++- scripts.js | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 scripts.js diff --git a/historique.html b/historique.html index dd42f25..7002f2f 100644 --- a/historique.html +++ b/historique.html @@ -148,9 +148,9 @@ {{$col2}} {{$op_label}} {{$amount}} - {{$stock}} - {{$exterieur}} - {{$dispo}} + {{$stock}} + {{$exterieur}} + {{$dispo}} {{$comment}} {{if $current != "archives"}} @@ -199,7 +199,7 @@ {{$col2}} {{$op_label}} {{$amount}} - {{$stock}} + {{$stock}} {{$comment}} {{:linkbutton @@ -224,3 +224,10 @@ {{/if}} {{:admin_footer}} + + + diff --git a/inventaire.html b/inventaire.html index 249df13..3a02514 100644 --- a/inventaire.html +++ b/inventaire.html @@ -124,7 +124,7 @@ {{$cat_name}} {{$col3}} {{$col4}} - {{$dispo}} + {{$dispo}} {{if $col4 > 0}} {{:linkbutton @@ -159,3 +159,10 @@ {{else}}

Aucun matériel.

{{/list}} + + + diff --git a/scripts.js b/scripts.js new file mode 100644 index 0000000..487abe3 --- /dev/null +++ b/scripts.js @@ -0,0 +1,23 @@ +/** + * désactiver le tri des colonnes ayant la classe nosort dans une liste triable + * @param {Node} liste - liste triable + */ +function disableColumSort(liste) { + + // chercher la première ligne du corps de la table + let columns = liste.querySelectorAll("tbody > tr > td"); + + // chercher la ligne de titres + let titles = liste.querySelectorAll("thead > tr > td"); + + // désactiver le tri + for (let i = 0; i < titles.length; ++i) { + let anchor = titles[i].querySelector("a"); + const classAttr = columns[i].getAttribute("class"); + if (anchor != null && classAttr != null && classAttr.includes("nosort")) { + anchor.removeAttribute("href"); + anchor.removeAttribute("title"); + anchor.removeChild(anchor.firstElementChild); + } + } +}