From 4e9009e912b9d8eb62ce1093546287240489f54a Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 2 May 2012 17:25:09 -0400 Subject: [PATCH] errors in the sort_value function wreak havoc (and return "") Signed-off-by: Jason Etheridge --- Open-ILS/xul/staff_client/server/circ/util.js | 200 +++++++++++++++++++++--- Open-ILS/xul/staff_client/server/patron/util.js | 85 ++++++++-- 2 files changed, 248 insertions(+), 37 deletions(-) diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 6bc54d2b31..d5d653d7da 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -1115,7 +1115,13 @@ circ.util.columns = function(modify,params) { 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.status_changed_time(), '%{localized}' ); }, 'persist' : 'hidden width ordinal' - ,'sort_value' : function(my) { return util.date.db_date2Date( my.acp.status_changed_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.acp + ? my.acp.status_changed_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1149,7 +1155,13 @@ circ.util.columns = function(modify,params) { return ""; } } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.circ.xact_start() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.xact_start() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1167,7 +1179,13 @@ circ.util.columns = function(modify,params) { return ""; } } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.circ.checkin_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.checkin_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1179,7 +1197,12 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.xact_finish(), '%{localized}' ) : ""; }, - 'sort_value' : function(my) { return util.date.db_date2Date( my.circ.xact_finish() ).getTime(); } + 'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.xact_finish() + : null + ).getTime(); } }, { 'persist' : 'hidden width ordinal', @@ -1197,7 +1220,13 @@ circ.util.columns = function(modify,params) { return ""; } } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.circ.due_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.due_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1209,7 +1238,13 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.create_date(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.acp.create_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.acp + ? my.acp.create_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1221,7 +1256,13 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.edit_date(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.acp.edit_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.acp + ? my.acp.edit_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1373,7 +1414,13 @@ circ.util.columns = function(modify,params) { return ""; } } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.circ.stop_fines_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.stop_fines_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1469,7 +1516,13 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.checkin_scan_time(), '%{localized}' ) : ""; }, - 'sort_value' : function(my) { return util.date.db_date2Date( my.circ.checkin_scan_time() ).getTime(); } + 'sort_value' : function(my) { + return util.date.db_date2Date( + my.circ + ? my.circ.checkin_scan_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1511,7 +1564,13 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.create_date(), '%{localized}' ) : ''; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.bre.create_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.bre + ? my.bre.create_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1523,7 +1582,13 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.edit_date(), '%{localized}' ) : ''; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.bre.edit_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.bre + ? my.bre.edit_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1713,7 +1778,13 @@ circ.util.transit_columns = function(modify,params) { 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.source_send_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.atc.source_send_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.atc + ? my.atc.source_send_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1739,7 +1810,13 @@ circ.util.transit_columns = function(modify,params) { 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.dest_recv_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.atc.dest_recv_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.atc + ? my.atc.dest_recv_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1804,7 +1881,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.cancel_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.cancel_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.cancel_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1863,7 +1946,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.request_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.request_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.request_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1874,7 +1963,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.shelf_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.shelf_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1885,7 +1980,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_expire_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.shelf_expire_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.shelf_expire_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -1902,6 +2003,7 @@ circ.util.hold_columns = function(modify,params) { return ""; } ,'sort_value' : function(my) { + // FIXME - ugh return util.date.db_date2Date( my.acp.create_date() ).getTime(); if (my.ahr.transit() && my.ahr.transit().dest_recv_time()) { return util.date.db_date2Date( my.ahr.transit().dest_recv_time() ).getTime(); @@ -1921,7 +2023,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? util.date.formatted_date( my.ahr.capture_time(), '%{localized}' ) : ""; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.capture_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.capture_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2016,7 +2124,13 @@ circ.util.hold_columns = function(modify,params) { return util.date.formatted_date( my.ahr.thaw_date(), '%{localized}' ); } } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.thaw_date() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.thaw_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2098,7 +2212,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.expire_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.expire_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2109,7 +2229,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.fulfillment_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.fulfillment_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2183,7 +2309,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.prev_check_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.prev_check_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2315,7 +2447,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.notify_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.notify_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2350,7 +2488,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.transit().source_send_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.transit().source_send_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', @@ -2370,7 +2514,13 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return my.ahr.transit() ? util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ahr.transit().dest_recv_time() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.ahr + ? my.ahr.transit().dest_recv_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index 9956064341..427460cee3 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -57,7 +57,13 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mbts.last_billing_ts() ).getTime(); } + ,'sort_value' : function(my) { + return util.date.db_date2Date( + my.mbts + ? my.mbts.last_billing_ts() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'last_payment_note', 'label' : commonStrings.getString('staff.mbts_last_payment_note_label'), 'flex' : 2, @@ -71,19 +77,34 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mbts.last_payment_ts() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mbts + ? my.mbts.last_payment_ts() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'mbts_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}" ) : ""; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mbts.xact_start() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mbts + ? my.mbts.xact_start() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'mbts_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}" ) : ""; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mbts.xact_finish() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mbts + ? my.mbts.xact_finish() + : null + ).getTime(); + } }, ]; for (var i = 0; i < c.length; i++) { @@ -140,7 +161,12 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mb.void_time() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mbts + ? my.mb.void_time() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : commonStrings.getString('staff.mb_amount_label'), 'flex' : 1, @@ -155,7 +181,12 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mb.billing_ts() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mb + ? my.mb.billing_ts() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'note', 'label' : commonStrings.getString('staff.mb_note_label'), 'flex' : 2, @@ -222,7 +253,12 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.mp.payment_ts() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.mp + ? my.mp.payment_ts() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_note', 'label' : commonStrings.getString('staff.mp_note_label'), 'flex' : 2, @@ -334,7 +370,12 @@ patron.util.ausp_columns = function(modify,params) { 'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.ausp ? util.date.formatted_date( my.ausp.set_date(), "%{localized}" ) : ''; } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.ausp.set_date() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.ausp + ? my.ausp.set_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'ausp_note', 'label' : commonStrings.getString('staff.ausp_note_label'), 'flex' : 1, @@ -443,20 +484,35 @@ patron.util.columns = function(modify,params) { 'persist' : 'hidden width ordinal', 'id' : 'au_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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.au.create_date() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.au + ? my.au.create_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'au_last_update_time', 'label' : commonStrings.getString('staff.au_last_update_time_label'), 'flex' : 1, 'sort_type' : 'date', 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.last_update_time(), "%{localized}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.au.last_update_time() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.au + ? my.au.last_update_time() + : null + ).getTime(); + } }, { '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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.au.expire_date() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.au + ? my.au.expire_date() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'home_ou', 'label' : commonStrings.getString('staff.au_home_library_label'), 'flex' : 1, @@ -495,7 +551,12 @@ 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}" ); } - ,'sort_value' : function(my) { return util.date.db_date2Date( my.au.dob() ).getTime(); } + ,'sort_value' : function(my) { return util.date.db_date2Date( + my.au + ? my.au.dob() + : null + ).getTime(); + } }, { 'persist' : 'hidden width ordinal', 'id' : 'ident_type', 'label' : commonStrings.getString('staff.au_ident_type_label'), 'flex' : 1, -- 2.11.0