From adc75e0236fb5dc9ad46797c64d49dd49b7d8056 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Wed, 2 May 2012 15:23:06 -0400 Subject: [PATCH] Address date sorting in Item Status and Copy Buckets interfaces, too > The sort_value function for the date columns being used in those > interfaces had no error protection, and were returning empty strings > upon failure. Signed-off-by: Jason Etheridge Signed-off-by: Lebbeous Fogle-Weekley --- .../xul/staff_client/chrome/content/util/list.js | 12 +- .../server/admin/offline_manage_xacts.js | 5 +- Open-ILS/xul/staff_client/server/circ/util.js | 210 +++++++++++++++++---- Open-ILS/xul/staff_client/server/patron/bill2.js | 1 - .../xul/staff_client/server/patron/bill_details.js | 2 - .../xul/staff_client/server/patron/bill_history.js | 1 - .../staff_client/server/patron/search_result.js | 1 - .../server/patron/standing_penalties.js | 2 - Open-ILS/xul/staff_client/server/patron/util.js | 134 +++++++------ 9 files changed, 258 insertions(+), 110 deletions(-) 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 61d48534bb..d6057e399f 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -2161,6 +2161,10 @@ util.list.prototype = { JSAN.use('util.network'); obj.network = new util.network(); JSAN.use('util.money'); + // FIXME: backwards compatability with server/patron code and the old patron.util.std_map_row_to_columns. + // Will remove in a separate commit and change all instances of obj.OpenILS.data to obj.data at the same time. + obj.OpenILS = { 'data' : obj.data }; + var my = row.my; var values = []; var sort_values = []; @@ -2182,13 +2186,7 @@ util.list.prototype = { } break; case 'string' : - cmd += 'try { ' - + cols[i].sort_value - + '; values[' - + i - +'] = v; } catch(E) { sort_values[' - + i - + '] = error_value; }'; + sort_values[i] = JSON2js(cols[i].sort_value); break; default: cmd += 'sort_values['+i+'] = values[' + i + '];'; diff --git a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js index 184dc2bf39..a2c4b1abe0 100644 --- a/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js +++ b/Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js @@ -117,7 +117,6 @@ admin.offline_manage_xacts.prototype = { 'render' : function(my) { return my.key; } }, ], - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { try { $('deck').selectedIndex = 0; @@ -218,8 +217,7 @@ admin.offline_manage_xacts.prototype = { 'label' : $('adminStrings').getString('staff.admin.offline_manage_xacts.init_script_list.workstation'), 'render' : function(my) { return my.workstation; } }, - ], - 'map_row_to_columns' : patron.util.std_map_row_to_columns() + ] } ); @@ -301,7 +299,6 @@ admin.offline_manage_xacts.prototype = { 'render' : function(my) { return my.command.noncat_count || ""; } }, ], - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { try { var sel = obj.error_list.retrieve_selection(); diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 6bc54d2b31..01580807e2 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,14 +2003,11 @@ circ.util.hold_columns = function(modify,params) { return ""; } ,'sort_value' : function(my) { - 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(); - } - if (!my.ahr.transit() && my.ahr.capture_time()) { - return util.date.db_date2Date( my.ahr.capture_time() ).getTime(); + if (my.ahr.current_shelf_lib() == my.ahr.pickup_lib()) { + return util.date.db_date2Date( my.ahr.shelf_time() ).getTime(); + } else { + return util.date.db_date2Date( null ).getTime(); } - return 0; } }, { @@ -1921,7 +2019,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 +2120,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 +2208,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 +2225,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 +2305,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 +2443,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 +2484,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 +2510,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/bill2.js b/Open-ILS/xul/staff_client/server/patron/bill2.js index 2507345d25..e7414949bb 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill2.js +++ b/Open-ILS/xul/staff_client/server/patron/bill2.js @@ -493,7 +493,6 @@ function init_lists() { } ] ))), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(' '), 'on_select' : function(ev) { JSAN.use('util.functional'); g.bill_list_selection = util.functional.map_list( diff --git a/Open-ILS/xul/staff_client/server/patron/bill_details.js b/Open-ILS/xul/staff_client/server/patron/bill_details.js index 56627e0f76..91e21f4c5d 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_details.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_details.js @@ -129,7 +129,6 @@ function init_lists() { g.bill_list.init( { 'columns' : patron.util.mb_columns({}), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { JSAN.use('util.functional'); g.bill_list_selection = util.functional.map_list( @@ -146,7 +145,6 @@ function init_lists() { g.payment_list.init( { 'columns' : patron.util.mp_columns({}), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { JSAN.use('util.functional'); g.payment_list_selection = util.functional.map_list( diff --git a/Open-ILS/xul/staff_client/server/patron/bill_history.js b/Open-ILS/xul/staff_client/server/patron/bill_history.js index eecf162b9f..1f7ca401a8 100644 --- a/Open-ILS/xul/staff_client/server/patron/bill_history.js +++ b/Open-ILS/xul/staff_client/server/patron/bill_history.js @@ -128,7 +128,6 @@ function init_main_list() { 'title' : { 'hidden' : false, 'flex' : '3' } }) ), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(' '), 'on_select' : function(ev) { JSAN.use('util.functional'); g.bill_list_selection = util.functional.map_list( diff --git a/Open-ILS/xul/staff_client/server/patron/search_result.js b/Open-ILS/xul/staff_client/server/patron/search_result.js index 3984074021..e9e5f4a6c6 100644 --- a/Open-ILS/xul/staff_client/server/patron/search_result.js +++ b/Open-ILS/xul/staff_client/server/patron/search_result.js @@ -76,7 +76,6 @@ patron.search_result.prototype = { obj.list.init( { 'columns' : columns, - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'retrieve_row' : function(params) { var id = params.retrieve_id; var au_obj = patron.util.retrieve_fleshed_au_via_id( diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js index b2e6b2c346..4f7a629b36 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -52,7 +52,6 @@ function init_list() { list.init( { 'columns' : patron.util.ausp_columns({}), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'retrieve_row' : retrieve_row, 'on_select' : generate_handle_selection(list) } @@ -71,7 +70,6 @@ function init_archived_list() { archived_list.init( { 'columns' : patron.util.ausp_columns({}), - 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'retrieve_row' : retrieve_row, // We're getting fleshed objects for now, but if we move to just ausp.id's, then we'll need to put a per-id fetcher in here 'on_select' : generate_handle_selection(archived_list) } diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index f97437d99a..427460cee3 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -4,7 +4,7 @@ if (typeof patron == 'undefined') var patron = {}; patron.util = {}; patron.util.EXPORT_OK = [ - 'columns', 'mbts_columns', 'mb_columns', 'mp_columns', /*'std_map_row_to_column',*/ 'std_map_row_to_columns', + 'columns', 'mbts_columns', 'mb_columns', 'mp_columns', 'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id', 'merge', 'ausp_columns', 'format_name', 'work_log_patron_edit' ]; @@ -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, @@ -557,53 +618,6 @@ patron.util.columns = function(modify,params) { return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } ); } -patron.util.std_map_row_to_columns = function(error_value) { - return function(row,cols,scratch) { - // row contains { 'my' : { 'au' : {} } } - // cols contains all of the objects listed above in columns - // scratch is a temporary space shared by all cells/rows (or just per row if not explicitly passed in) - - var obj = {}; obj.OpenILS = {}; - JSAN.use('util.error'); obj.error = new util.error(); - JSAN.use('OpenILS.data'); obj.OpenILS.data = new OpenILS.data(); obj.OpenILS.data.init({'via':'stash'}); - JSAN.use('util.date'); JSAN.use('util.money'); - - var my = row.my; - var values = []; - var sort_values = []; - var cmd = ''; - try { - for (var i = 0; i < cols.length; i++) { - switch (typeof cols[i].render) { - case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; obj.error.sdump('D_COLUMN_RENDER_ERROR',E); } break; - case 'string' : cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; break; - default: cmd += 'values['+i+'] = "??? '+(typeof cols[i].render)+'"; '; - } - switch (typeof cols[i].sort_value) { - case 'function': - try { - sort_values[i] = cols[i].sort_value(my,scratch); - } catch(E) { - sort_values[i] = error_value; - obj.error.sdump('D_COLUMN_RENDER_ERROR',E); - } - break; - case 'string' : - sort_values[i] = JSON2js(cols[i].sort_value); - break; - default: - cmd += 'sort_values['+i+'] = values[' + i + '];'; - } - } - if (cmd) eval( cmd ); - } catch(E) { - obj.error.sdump('D_WARN','map_row_to_column: ' + E); - if (error_value) { value = error_value; } else { value = ' ' }; - } - return {values: values, sort_values: sort_values}; - } -} - patron.util.retrieve_au_via_id = function(session, id, f) { JSAN.use('util.network'); var network = new util.network(); -- 2.11.0