[open-ils-commits] r16740 - in trunk/Open-ILS/xul/staff_client: chrome/content/util server/circ server/patron (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jun 16 23:39:25 EDT 2010


Author: phasefx
Date: 2010-06-16 23:39:22 -0400 (Wed, 16 Jun 2010)
New Revision: 16740

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
   trunk/Open-ILS/xul/staff_client/server/circ/util.js
   trunk/Open-ILS/xul/staff_client/server/patron/util.js
Log:
correctly sort date/timestamp columns in xul lists now that they're localized

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-06-17 03:39:21 UTC (rev 16739)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/list.js	2010-06-17 03:39:22 UTC (rev 16740)
@@ -1444,6 +1444,11 @@
                             a = a.value; b = b.value; 
                             if (col.getAttribute('sort_type')) {
                                 switch(col.getAttribute('sort_type')) {
+                                    case 'date' :
+                                        JSAN.use('util.date'); // to pull in dojo.date.locale
+                                        a = dojo.date.locale.parse(a,{});
+                                        b = dojo.date.locale.parse(b,{});
+                                    break;
                                     case 'number' :
                                         a = Number(a); b = Number(b);
                                     break;
@@ -1466,6 +1471,7 @@
                                     b = String( b ).toUpperCase();
                                 }
                             }
+                            //dump('sorting: type = ' + col.getAttribute('sort_type') + ' a = ' + a + ' b = ' + b + ' a<b= ' + (a<b) + ' a>b= ' + (a>b) + '\n');
                             if (a < b) return -1; 
                             if (a > b) return 1; 
                             return 0; 
@@ -1684,7 +1690,9 @@
                 var def = {
                     'id' : col_id,
                     'label' : my_field.label || my_field.name,
-                    'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' : ( my_field.datatype == 'money' ? 'money' : 'default'),
+                    'sort_type' : [ 'int', 'float', 'id', 'number' ].indexOf(my_field.datatype) > -1 ? 'number' : 
+                        ( my_field.datatype == 'money' ? 'money' : 
+                        ( my_field.datatype == 'timestamp' ? 'date' : 'default')),
                     'hidden' : my_field.virtual || my_field.datatype == 'link',
                     'flex' : 1
                 };                    

Modified: trunk/Open-ILS/xul/staff_client/server/circ/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/circ/util.js	2010-06-17 03:39:21 UTC (rev 16739)
+++ trunk/Open-ILS/xul/staff_client/server/circ/util.js	2010-06-17 03:39:22 UTC (rev 16740)
@@ -882,6 +882,7 @@
             'fm_class' : 'acp',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.status_changed_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.status_changed_time(), '%{localized}' ); },
@@ -909,6 +910,7 @@
             'id' : 'xact_start',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_start'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) {
@@ -925,6 +927,7 @@
             'id' : 'checkin_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) {
@@ -941,6 +944,7 @@
             'id' : 'xact_finish',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.xact_finish'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.xact_finish(), '%{localized}' ) : ""; },
@@ -951,6 +955,7 @@
             'id' : 'due_date',
             'label' : document.getElementById('commonStrings').getString('staff.circ_label_due_date'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) {
@@ -967,6 +972,7 @@
             'id' : 'acp_create_date',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.create_date'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.create_date(), '%{localized}' ); }
@@ -977,6 +983,7 @@
             'id' : 'acp_edit_date',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.edit_date'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.acp.edit_date(), '%{localized}' ); }
@@ -1121,6 +1128,7 @@
             'id' : 'stop_fines_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.stop_fines_time'),
             'flex' : 0,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) {
@@ -1221,6 +1229,7 @@
             'id' : 'checkin_scan_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.checkin_scan_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.circ ? util.date.formatted_date( my.circ.checkin_scan_time(), '%{localized}' ) : ""; },
@@ -1251,6 +1260,7 @@
             'id' : 'create_date',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.create_date'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.create_date(), '%{localized}' ) : ''; }
@@ -1261,6 +1271,7 @@
             'id' : 'edit_date',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.bre.edit_date'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.bre ? util.date.formatted_date( my.bre.edit_date(), '%{localized}' ) : ''; }
@@ -1449,6 +1460,7 @@
             'id' : 'transit_source_send_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : false,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.source_send_time(), '%{localized}' ); }
@@ -1473,6 +1485,7 @@
             'id' : 'transit_dest_recv_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : false,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.atc.dest_recv_time(), '%{localized}' ); }
@@ -1536,6 +1549,7 @@
             'id' : 'cancel_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.hold_cancel_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.cancel_time(), '%{localized}' ); }
@@ -1593,6 +1607,7 @@
             'id' : 'request_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.request_time'),
             'flex' : 0,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.request_time(), '%{localized}' ); }
@@ -1602,6 +1617,7 @@
             'id' : 'shelf_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_time'),
             'flex' : 0,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_time(), '%{localized}' ); }
@@ -1611,6 +1627,7 @@
             'id' : 'shelf_expire_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.holds.shelf_expire_time'),
             'flex' : 0,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.shelf_expire_time(), '%{localized}' ); }
@@ -1620,6 +1637,7 @@
             'id' : 'available_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.available_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : false,
             'editable' : false, 'render' : function(my) {
@@ -1637,6 +1655,7 @@
             'id' : 'capture_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.capture_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.ahr.capture_time() ? util.date.formatted_date( my.ahr.capture_time(), '%{localized}' ) : ""; }
@@ -1715,6 +1734,7 @@
             'id' : 'thaw_date',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.thaw_date'),
             'flex' : 0,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) {
@@ -1801,6 +1821,7 @@
             'id' : 'expire_date',
             'label' : document.getElementById('commonStrings').getString('staff.ahr_expire_date_label'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.ahr.expire_time() ? util.date.formatted_date( my.ahr.expire_time(), '%{localized}' ) : ''; }
@@ -1810,6 +1831,7 @@
             'id' : 'fulfillment_time',
             'label' : document.getElementById('commonStrings').getString('staff.ahr_fulfillment_time_label'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.fulfillment_time(), '%{localized}' ); }
@@ -1846,6 +1868,7 @@
             'id' : 'prev_check_time',
             'label' : document.getElementById('commonStrings').getString('staff.ahr_prev_check_time_label'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.prev_check_time(), '%{localized}' ); }
@@ -1976,6 +1999,7 @@
             'id' : 'notify_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.notify_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.ahr.notify_time(), '%{localized}' ); }
@@ -2009,6 +2033,7 @@
             'id' : 'transit_source_send_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_source_send_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().source_send_time(), '%{localized}' ) : ""; }
@@ -2027,6 +2052,7 @@
             'id' : 'transit_dest_recv_time',
             'label' : document.getElementById('circStrings').getString('staff.circ.utils.transit_dest_recv_time'),
             'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false,
             'hidden' : true,
             'editable' : false, 'render' : function(my) { return my.ahr.transit() ?  util.date.formatted_date( my.ahr.transit().dest_recv_time(), '%{localized}' ) : ""; }

Modified: trunk/Open-ILS/xul/staff_client/server/patron/util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/server/patron/util.js	2010-06-17 03:39:21 UTC (rev 16739)
+++ trunk/Open-ILS/xul/staff_client/server/patron/util.js	2010-06-17 03:39:22 UTC (rev 16740)
@@ -55,6 +55,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'last_billing_ts', 'label' : commonStrings.getString('staff.mbts_last_billing_timestamp_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_billing_ts(), "%{localized}" ); }
         },
         {
@@ -67,14 +68,17 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'last_payment_ts', 'label' : commonStrings.getString('staff.mbts_last_payment_timestamp_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_payment_ts(), "%{localized}" ); }
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : commonStrings.getString('staff.mbts_xact_start_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_start() ? util.date.formatted_date( my.mbts.xact_start(), "%{localized}" ) : ""; }
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : commonStrings.getString('staff.mbts_xact_finish_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return my.mbts.xact_finish() ? util.date.formatted_date( my.mbts.xact_finish(), "%{localized}" ) : ""; }
         },
     ];
@@ -130,6 +134,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'void_time', 'label' : commonStrings.getString('staff.mb_void_time_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.void_time(), "%{localized}" ); }
         },
         {
@@ -143,6 +148,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'billing_ts', 'label' : commonStrings.getString('staff.mb_billing_ts_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.billing_ts(), "%{localized}" ); }
         },
         {
@@ -208,6 +214,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'mp_payment_ts', 'label' : commonStrings.getString('staff.mp_payment_timestamp_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.mp.payment_ts(), "%{localized}" ); }
         },
         {
@@ -316,6 +323,7 @@
         },
         {
             'persist' : 'hidden width ordinal', 'id' : 'ausp_set_date', 'label' : commonStrings.getString('staff.ausp_set_date_label'), 'flex' : 1,
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : false, 'editable' : false, 'render' : function(my) { 
                 return my.ausp ? util.date.formatted_date( my.ausp.set_date(), "%{localized}" ) : '';
             }
@@ -425,10 +433,12 @@
         },
         { 
             'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : commonStrings.getString('staff.au_create_date_label'), 'flex' : 1, 
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.create_date(), "%{localized}" ); }
         },
         { 
             'persist' : 'hidden width ordinal', 'id' : 'expire_date', 'label' : commonStrings.getString('staff.au_expire_date_label'), 'flex' : 1, 
+            'sort_type' : 'date',
             'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my) { return util.date.formatted_date( my.au.expire_date(), "%{localized_date}" ); }
         },
         { 
@@ -466,6 +476,7 @@
         },
         { 
             '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}" ); }
         },
         { 



More information about the open-ils-commits mailing list