From b475e65303e25545ad77e053e7bb55bed05edf8a Mon Sep 17 00:00:00 2001 From: Jakub Trzaskoma Date: Fri, 7 Dec 2012 14:52:20 +0100 Subject: [PATCH] [FIX] Sorting room list --- indico/htdocs/js/indico/Core/Presentation.js | 20 ++++++++++++++++++-- indico/htdocs/js/indico/Management/RoomBooking.js | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/indico/htdocs/js/indico/Core/Presentation.js b/indico/htdocs/js/indico/Core/Presentation.js index bf9c29211..adcf45068 100644 --- a/indico/htdocs/js/indico/Core/Presentation.js +++ b/indico/htdocs/js/indico/Core/Presentation.js @@ -205,14 +205,30 @@ var SortCriteria = { return e1 == e2?0:(e1 < e2?-1:1); }, Integer: function(e1, e2) { - if (isNaN(parseInt(e1,10)) || isNaN(parseInt(e2,10))) { return SortCriteria.Default(e1, e2); } else { return parseInt(e1,10) == parseInt(e2,10)?0:(parseInt(e1,10) < parseInt(e2,10)?-1:1); } - } + }, + DashSeparated: function(e1, e2) { + // sorting format: int-string-string-... + // for example 41-R2-020 + var e1Array = e1.split('-'); + var e2Array = e2.split('-'); + for (var i = 0; i < e1Array.length; i++) { + if (i == 0) { + var result = SortCriteria.Integer(e1Array[i], e2Array[i]); + } + else { + var result = SortCriteria.Default(e1Array[i], e2Array[i]); + } + if (result != 0) + return result; + }; + return 0; + }, }; function partition(list, start, end, index, cmp) { diff --git a/indico/htdocs/js/indico/Management/RoomBooking.js b/indico/htdocs/js/indico/Management/RoomBooking.js index 65fe4f183..a751688e7 100644 --- a/indico/htdocs/js/indico/Management/RoomBooking.js +++ b/indico/htdocs/js/indico/Management/RoomBooking.js @@ -44,7 +44,7 @@ type("RoomBookingWidget", ["IWidget"], this.eventFavorites.indexOf(e2) !== null) { return 1; } else { - return SortCriteria.Integer(e1, e2); + return SortCriteria.DashSeparated(e1, e2); } }, -- 2.11.4.GIT