From 4361d69de393a55ad27574d10d7c6ad62477a13e Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Sat, 24 Dec 2022 22:16:52 +0100 Subject: Fix table sort of dates. Fixes . --- assets/js/sort-table.js | 14 ++++++++++++++ mumi/web/view/html.scm | 15 ++++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/assets/js/sort-table.js b/assets/js/sort-table.js index b0f0e62..26fbc49 100644 --- a/assets/js/sort-table.js +++ b/assets/js/sort-table.js @@ -9,6 +9,8 @@ * or http://opensource.org/licenses/MIT * * latest version available at https://github.com/tyleruebele/sort-table + * + * With changes Copyright (c) 2022 Ricardo Wurmus */ /** @@ -173,6 +175,18 @@ sortTable.raw = function(Cell) { return Cell.innerHTML; }; +/** + * Helper function that acts on a sortable data attribute of a table + * cell (TD). + * + * @param Cell A TD DOM object + * @returns {Number} + */ +sortTable.position = function(Cell) { + return Number(Cell.getAttribute('data-js-sort-position')); +}; + + /** * Helper function that converts a table cell (TD) to a comparable value * Captures the last space-delimited token from innerHTML diff --git a/mumi/web/view/html.scm b/mumi/web/view/html.scm index 7154585..6b675e5 100644 --- a/mumi/web/view/html.scm +++ b/mumi/web/view/html.scm @@ -268,7 +268,7 @@ simple query language. Here is a list of supported query terms:") (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(list-of-bugs (recent-bugs 10))))) @@ -282,7 +282,7 @@ simple query language. Here is a list of supported query terms:") (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(list-of-bugs (forgotten-issues 10))))) @@ -295,7 +295,7 @@ simple query language. Here is a list of supported query terms:") (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(priority-bugs)))))))) @@ -743,7 +743,8 @@ m1 3H6v5h2V4zm0 6H6v2h2v-2z"))))) `(a (@ (href ,(string-append "/" id))) ,(bug-subject* bug)) (bug-subject* bug))) - (td ,(date->string (bug-date bug))) + (td (@ (data-js-sort-position ,(date->string (bug-date bug) "~s"))) + ,(date->string (bug-date bug))) (td ,(status-tag bug))))) bugs)) @@ -767,7 +768,7 @@ m1 3H6v5h2V4zm0 6H6v2h2v-2z"))))) (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(list-of-bugs (recent-bugs max)))))))) @@ -785,7 +786,7 @@ m1 3H6v5h2V4zm0 6H6v2h2v-2z"))))) (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(list-of-bugs (forgotten-issues max)))))))) @@ -815,7 +816,7 @@ m1 3H6v5h2V4zm0 6H6v2h2v-2z"))))) (tr (@ (class "heading")) (th (@ (class "js-sort-number")) "ID") (th "Subject") - (th "Date submitted") + (th (@ (class "js-sort-position")) "Date submitted") (th "Status"))) (tbody ,@(list-of-bugs bugs)))))))) -- cgit v1.2.3