[open-ils-commits] [GIT] Evergreen ILS branch rel_2_2 updated. aedf2bde4e4610ef0e2de01f2fbef1b827822b2a

Evergreen Git git at git.evergreen-ils.org
Wed May 2 18:32:00 EDT 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, rel_2_2 has been updated
       via  aedf2bde4e4610ef0e2de01f2fbef1b827822b2a (commit)
       via  c4bfb05af96266a580974c375a4b78045bf1064f (commit)
      from  3501dd8f265bce21c1952d0ea46b439f4c9386c6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aedf2bde4e4610ef0e2de01f2fbef1b827822b2a
Author: Jason Etheridge <jason at esilibrary.com>
Date:   Wed May 2 15:23:06 2012 -0400

    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 <jason at esilibrary.com>
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>

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 61d4853..d6057e3 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 184dc2b..a2c4b1a 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 6bc54d2..0158080 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 2507345..e741494 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 56627e0..91e21f4 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 eecf162..1f7ca40 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 3984074..e9e5f4a 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 b2e6b2c..4f7a629 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 30dfa58..8c6f26a 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();

commit c4bfb05af96266a580974c375a4b78045bf1064f
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Wed May 2 14:01:00 2012 -0400

    Fix date sorting in patron-related XUL interfaces
    
    Null time stamps are now converted to dates in the Middle Paleolithic
    era so they always sort as the lowest date.
    
    Seriously, this is the minimum possible date you can express with a JavaScript
    date object.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/util/date.js b/Open-ILS/xul/staff_client/chrome/content/util/date.js
index cf17627..fb95bee 100644
--- a/Open-ILS/xul/staff_client/chrome/content/util/date.js
+++ b/Open-ILS/xul/staff_client/chrome/content/util/date.js
@@ -46,8 +46,10 @@ util.date.timer_elapsed = function (id) {
 }
 
 util.date.db_date2Date = function (db_date) {
-    if (!db_date) { return db_date; }
-    if (typeof window.dojo != 'undefined') {
+    if (!db_date) {  /* we get stringified null at times */
+        return new Date(-8640000000000000); /* minimum possible date.
+                                           max is this * -1. */
+    } else if (typeof window.dojo != 'undefined') {
         dojo.require('dojo.date.stamp');
         return dojo.date.stamp.fromISOString( db_date.replace( /^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[\+-]\d{2})(\d{2})$/, '$1:$2') );
     } else {
diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js
index 19aab0f..30dfa58 100644
--- a/Open-ILS/xul/staff_client/server/patron/util.js
+++ b/Open-ILS/xul/staff_client/server/patron/util.js
@@ -570,6 +570,7 @@ patron.util.std_map_row_to_columns = function(error_value) {
 
         var my = row.my;
         var values = [];
+        var sort_values = [];
         var cmd = '';
         try { 
             for (var i = 0; i < cols.length; i++) {
@@ -578,13 +579,28 @@ patron.util.std_map_row_to_columns = function(error_value) {
                     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;
+        return {values: values, sort_values: sort_values};
     }
 }
 

-----------------------------------------------------------------------

Summary of changes:
 .../xul/staff_client/chrome/content/util/date.js   |    6 +-
 .../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    |  118 +++++++----
 10 files changed, 262 insertions(+), 96 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list