code cleanup
authorJason Etheridge <jason@esilibrary.com>
Wed, 2 May 2012 19:23:06 +0000 (15:23 -0400)
committerJason Etheridge <jason@esilibrary.com>
Wed, 2 May 2012 19:29:12 +0000 (15:29 -0400)
removing patron.util.std_map_row_to_columns

Signed-off-by: Jason Etheridge <jason@esilibrary.com>
Open-ILS/xul/staff_client/chrome/content/util/list.js
Open-ILS/xul/staff_client/server/admin/offline_manage_xacts.js
Open-ILS/xul/staff_client/server/patron/bill2.js
Open-ILS/xul/staff_client/server/patron/bill_details.js
Open-ILS/xul/staff_client/server/patron/bill_history.js
Open-ILS/xul/staff_client/server/patron/search_result.js
Open-ILS/xul/staff_client/server/patron/standing_penalties.js
Open-ILS/xul/staff_client/server/patron/util.js

index 61d4853..d6057e3 100644 (file)
@@ -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 + '];';
index 184dc2b..a2c4b1a 100644 (file)
@@ -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();
index 2507345..e741494 100644 (file)
@@ -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(
index 56627e0..91e21f4 100644 (file)
@@ -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(
index eecf162..1f7ca40 100644 (file)
@@ -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(
index 3984074..e9e5f4a 100644 (file)
@@ -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(
index b2e6b2c..4f7a629 100644 (file)
@@ -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)
             } 
index f97437d..9956064 100644 (file)
@@ -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'
 ];
@@ -557,53 +557,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();