From a032c4acb7d146c22c6c893e3319ed18bfd175ba Mon Sep 17 00:00:00 2001 From: phasefx Date: Thu, 17 Jun 2010 03:39:22 +0000 Subject: [PATCH] correctly sort date/timestamp columns in xul lists now that they're localized git-svn-id: svn://svn.open-ils.org/ILS/trunk@16740 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/util/list.js | 10 ++++++- Open-ILS/xul/staff_client/server/circ/util.js | 26 +++++++++++++++++++ .../xul/staff_client/server/patron/util.js | 11 ++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index 47481fef4b..8f3c9b0d7f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -1444,6 +1444,11 @@ util.list.prototype = { a = a.value; b = b.value; if (col.getAttribute('sort_type')) { switch(col.getAttribute('sort_type')) { + case 'date' : + JSAN.use('util.date'); // to pull in dojo.date.locale + a = dojo.date.locale.parse(a,{}); + b = dojo.date.locale.parse(b,{}); + break; case 'number' : a = Number(a); b = Number(b); break; @@ -1466,6 +1471,7 @@ util.list.prototype = { b = String( b ).toUpperCase(); } } + //dump('sorting: type = ' + col.getAttribute('sort_type') + ' a = ' + a + ' b = ' + b + ' ab= ' + (a>b) + '\n'); if (a < b) return -1; if (a > b) return 1; return 0; @@ -1684,7 +1690,9 @@ util.list.prototype = { var def = { 'id' : col_id, 'label' : my_field.label || my_field.name, - 'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' : ( my_field.datatype == 'money' ? 'money' : 'default'), + 'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' : + ( my_field.datatype == 'money' ? 'money' : + ( my_field.datatype == 'timestamp' ? 'date' : 'default')), 'hidden' : my_field.virtual || my_field.datatype == 'link', 'flex' : 1 }; diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index f715c44009..5c963f182e 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -882,6 +882,7 @@ circ.util.columns = function(modify,params) { 'fm_class' : 'acp', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.status_changed_time(), '%{localized}' ); }, @@ -909,6 +910,7 @@ circ.util.columns = function(modify,params) { 'id' : 'xact_start', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { @@ -925,6 +927,7 @@ circ.util.columns = function(modify,params) { 'id' : 'checkin_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { @@ -941,6 +944,7 @@ circ.util.columns = function(modify,params) { 'id' : 'xact_finish', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.xact_finish(), '%{localized}' ) : ""; }, @@ -951,6 +955,7 @@ circ.util.columns = function(modify,params) { 'id' : 'due_date', 'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { @@ -967,6 +972,7 @@ circ.util.columns = function(modify,params) { 'id' : 'acp_create_date', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.create_date(), '%{localized}' ); } @@ -977,6 +983,7 @@ circ.util.columns = function(modify,params) { 'id' : 'acp_edit_date', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.edit_date(), '%{localized}' ); } @@ -1121,6 +1128,7 @@ circ.util.columns = function(modify,params) { 'id' : 'stop_fines_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'), 'flex' : 0, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { @@ -1221,6 +1229,7 @@ circ.util.columns = function(modify,params) { 'id' : 'checkin_scan_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.checkin_scan_time(), '%{localized}' ) : ""; }, @@ -1251,6 +1260,7 @@ circ.util.columns = function(modify,params) { 'id' : 'create_date', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.create_date'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.create_date(), '%{localized}' ) : ''; } @@ -1261,6 +1271,7 @@ circ.util.columns = function(modify,params) { 'id' : 'edit_date', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.edit_date'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.edit_date(), '%{localized}' ) : ''; } @@ -1449,6 +1460,7 @@ circ.util.transit_columns = function(modify,params) { 'id' : 'transit_source_send_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.source_send_time(), '%{localized}' ); } @@ -1473,6 +1485,7 @@ circ.util.transit_columns = function(modify,params) { 'id' : 'transit_dest_recv_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.dest_recv_time(), '%{localized}' ); } @@ -1536,6 +1549,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'cancel_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.cancel_time(), '%{localized}' ); } @@ -1593,6 +1607,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'request_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'), 'flex' : 0, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.request_time(), '%{localized}' ); } @@ -1602,6 +1617,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'shelf_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_time'), 'flex' : 0, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' ); } @@ -1611,6 +1627,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'shelf_expire_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_expire_time'), 'flex' : 0, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_expire_time(), '%{localized}' ); } @@ -1620,6 +1637,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'available_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { @@ -1637,6 +1655,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'capture_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? util.date.formatted_date( my.ahr.capture_time(), '%{localized}' ) : ""; } @@ -1715,6 +1734,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'thaw_date', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'), 'flex' : 0, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { @@ -1801,6 +1821,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'expire_date', 'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; } @@ -1810,6 +1831,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'fulfillment_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); } @@ -1846,6 +1868,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'prev_check_time', 'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); } @@ -1976,6 +1999,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'notify_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); } @@ -2009,6 +2033,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'transit_source_send_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; } @@ -2027,6 +2052,7 @@ circ.util.hold_columns = function(modify,params) { 'id' : 'transit_dest_recv_time', 'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; } diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index 8bb16b35b6..c757ba0bfd 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -55,6 +55,7 @@ patron.util.mbts_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'last_billing_ts', 'label' : commonStrings.getString('staff.mbts_last_billing_timestamp_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_billing_ts(), "%{localized}" ); } }, { @@ -67,14 +68,17 @@ patron.util.mbts_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'last_payment_ts', 'label' : commonStrings.getString('staff.mbts_last_payment_timestamp_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_payment_ts(), "%{localized}" ); } }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : commonStrings.getString('staff.mbts_xact_start_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_start() ? util.date.formatted_date( my.mbts.xact_start(), "%{localized}" ) : ""; } }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : commonStrings.getString('staff.mbts_xact_finish_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_finish() ? util.date.formatted_date( my.mbts.xact_finish(), "%{localized}" ) : ""; } }, ]; @@ -130,6 +134,7 @@ patron.util.mb_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'void_time', 'label' : commonStrings.getString('staff.mb_void_time_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.void_time(), "%{localized}" ); } }, { @@ -143,6 +148,7 @@ patron.util.mb_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'billing_ts', 'label' : commonStrings.getString('staff.mb_billing_ts_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.billing_ts(), "%{localized}" ); } }, { @@ -208,6 +214,7 @@ patron.util.mp_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_ts', 'label' : commonStrings.getString('staff.mp_payment_timestamp_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mp.payment_ts(), "%{localized}" ); } }, { @@ -316,6 +323,7 @@ patron.util.ausp_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'ausp_set_date', 'label' : commonStrings.getString('staff.ausp_set_date_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.ausp ? util.date.formatted_date( my.ausp.set_date(), "%{localized}" ) : ''; } @@ -425,10 +433,12 @@ patron.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : commonStrings.getString('staff.au_create_date_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.create_date(), "%{localized}" ); } }, { 'persist' : 'hidden width ordinal', 'id' : 'expire_date', 'label' : commonStrings.getString('staff.au_expire_date_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.expire_date(), "%{localized_date}" ); } }, { @@ -466,6 +476,7 @@ patron.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'dob', 'label' : commonStrings.getString('staff.au_birth_date_label'), 'flex' : 1, + 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.dob(), "%{localized_date}" ); } }, { -- 2.43.2