From: pines Date: Thu, 12 Oct 2006 14:41:52 +0000 (+0000) Subject: functions for column definitions for lists X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e07bdfd755964c8eee49e1b963c513b11b4a3111;p=evergreen%2Fpines.git functions for column definitions for lists git-svn-id: svn://svn.open-ils.org/ILS/trunk@6446 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 9406f03dec..514ab35ee1 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 @@ -53,68 +53,62 @@ admin.offline_manage_xacts.prototype = { '$' : function(id) { return document.getElementById(id); }, 'init_list' : function() { - var obj = this; JSAN.use('util.list'); + var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util'); obj.list = new util.list('session_tree'); obj.list.init( { 'columns' : [ { 'id' : 'org', 'hidden' : 'true', 'flex' : '1', 'label' : 'Organization', - 'render' : 'v = data.hash.aou[ my.org ].shortname(); v;', + 'render' : function(my) { return obj.data.hash.aou[ my.org ].shortname(); }, }, { 'id' : 'description', 'flex' : '2', 'label' : 'Description', - 'render' : "v = my.description; v;", + 'render' : function(my) { return my.description; }, }, { 'id' : 'create_time', 'flex' : '1', 'label' : 'Date Created', - 'render' : 'if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); v = util.date.formatted_date(x,"%F %H:%M"); } else { v = ""; }; v;', + 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }, }, { 'id' : 'creator', 'flex' : '1', 'hidden' : 'true', 'label' : 'Created By', - 'render' : 'JSAN.use("patron.util"); var staff_obj = patron.util.retrieve_name_via_id( ses(), my.creator ); v = staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); v;', + 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.creator ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }, }, { 'id' : 'count', 'flex' : '1', 'label' : 'Upload Count', - 'render' : "v = my.scripts.length; v;", + 'render' : function(my) { return my.scripts.length; }, }, { 'id' : 'num_complete', 'flex' : '1', 'label' : 'Transactions Processed', - 'render' : "v = my.num_complete; v;", + 'render' : function(my) { return my.num_complete; }, }, { 'id' : 'in_process', 'flex' : '1', 'label' : 'Processing?', - 'render' : "if (my.end_time) { v = 'Completed' } else { v = my.in_process == 0 ? 'No' : 'Yes'}; v;", + 'render' : function(my) { if (my.end_time) { return 'Completed' } else { return get_bool(my.in_process) ? 'Yes' : 'No'}; }, }, { 'id' : 'start_time', 'flex' : '1', 'hidden' : 'true', 'label' : 'Date Started', - 'render' : 'if (my.start_time) {var x = new Date(); x.setTime(my.start_time+"000"); v = util.date.formatted_date(x,"%F %H:%M");} else { v = ""; }; v;', + 'render' : function(my) { if (my.start_time) {var x = new Date(); x.setTime(my.start_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }, }, { 'id' : 'end_time', 'flex' : '1', 'label' : 'Date Completed', - 'render' : 'if (my.end_time) {var x = new Date(); x.setTime(my.end_time+"000"); v = util.date.formatted_date(x,"%F %H:%M");} else { v = ""; }; v;', + 'render' : function(my) { if (my.end_time) {var x = new Date(); x.setTime(my.end_time+"000"); return util.date.formatted_date(x,"%F %H:%M");} else { return ""; }; }, }, { 'id' : 'key', 'hidden' : 'true', 'flex' : '1', 'label' : 'Session', - 'render' : "v = my.key; v;", + 'render' : function(my) { return my.key; }, }, ], - 'map_row_to_column' : function(row,col) { - JSAN.use('util.date'); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var my = row; var value; - try { value = eval( col.render ); } catch(E) { obj.error.sdump('D_ERROR',E); value = '???'; } - return value; - }, + 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { try { $('deck').selectedIndex = 0; @@ -191,126 +185,114 @@ admin.offline_manage_xacts.prototype = { }, 'init_script_list' : function() { - var obj = this; JSAN.use('util.list'); + var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util'); obj.script_list = new util.list('script_tree'); obj.script_list.init( { 'columns' : [ { 'id' : 'create_time', 'flex' : '1', 'label' : 'Date Uploaded', - 'render' : 'if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); v = util.date.formatted_date(x,"%F %H:%M"); } else { v = ""; }; v;', + 'render' : function(my) { if (my.create_time) { var x = new Date(); x.setTime(my.create_time+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return ""; }; }, }, { 'id' : 'requestor', 'flex' : '1', 'hidden' : 'true', 'label' : 'Uploaded By', - 'render' : 'JSAN.use("patron.util"); var staff_obj = patron.util.retrieve_name_via_id( ses(), my.requestor ); v = staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); v;', + 'render' : function(my) { var staff_obj = patron.util.retrieve_name_via_id( ses(), my.requestor ); return staff_obj[0] + " @ " + obj.data.hash.aou[ staff_obj[3] ].shortname(); }, }, { 'id' : 'time_delta', 'hidden' : 'true', 'flex' : '1', 'label' : 'Server/Local Time Delta', - 'render' : "v = my.time_delta; v;", + 'render' : function(my) { return my.time_delta; }, }, { 'id' : 'workstation', 'flex' : '1', 'label' : 'Workstation', - 'render' : "v = my.workstation; v;", + 'render' : function(my) { return my.workstation; }, }, ], - 'map_row_to_column' : function(row,col) { - JSAN.use('util.date'); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var my = row; var value; - try { value = eval( col.render ); } catch(E) { obj.error.sdump('D_ERROR',E); value = '???'; } - return value; - }, + 'map_row_to_columns' : patron.util.std_map_row_to_columns(), } ); }, 'init_error_list' : function() { - var obj = this; JSAN.use('util.list'); + var obj = this; JSAN.use('util.list'); JSAN.use('util.date'); JSAN.use('patron.util'); JSAN.use('util.functional'); obj.error_list = new util.list('error_tree'); obj.error_list.init( { 'columns' : [ { 'id' : 'workstation', 'flex' : '1', 'label' : 'Workstation', - 'render' : 'v = my.command._workstation ? my.command._workstation : my.command._worksation; v;', + 'render' : function(my) { return my.command._workstation ? my.command._workstation : my.command._worksation; }, }, { 'id' : 'timestamp', 'flex' : '1', 'label' : 'Timestamp', - 'render' : 'if (my.command.timestamp) { var x = new Date(); x.setTime(my.command.timestamp+"000"); v = util.date.formatted_date(x,"%F %H:%M"); } else { v = my.command._realtime; }; v;', + 'render' : function(my) { if (my.command.timestamp) { var x = new Date(); x.setTime(my.command.timestamp+"000"); return util.date.formatted_date(x,"%F %H:%M"); } else { return my.command._realtime; }; }, }, { 'id' : 'type', 'flex' : '1', 'label' : 'Type', - 'render' : 'v = my.command.type; v;', + 'render' : function(my) { return my.command.type; }, }, { 'id' : 'ilsevent', 'hidden' : 'true', 'flex' : '1', 'label' : 'Event Code', - 'render' : "v = my.event.ilsevent; v;", + 'render' : function(my) { return my.event.ilsevent; }, }, { 'id' : 'textcode', 'flex' : '1', 'label' : 'Event Name', - 'render' : "JSAN.use('util.functional'); v = typeof my.event.textcode != 'undefined' ? my.event.textcode : util.functional.map_list( my.event, function(o) { return o.textcode; }).join('/'); v;", + 'render' : function(my) { return typeof my.event.textcode != 'undefined' ? my.event.textcode : util.functional.map_list( my.event, function(o) { return o.textcode; }).join('/'); }, }, { 'id' : 'desc', 'flex' : '1', 'hidden' : 'true', 'label' : 'Event Description', - 'render' : "v = my.event.desc; v;", + 'render' : function(my) { return my.event.desc; }, }, { 'id' : 'i_barcode', 'flex' : '1', 'label' : 'Item Barcode', - 'render' : 'v = my.command.barcode ? my.command.barcode : ""; v;', + 'render' : function(my) { return my.command.barcode ? my.command.barcode : ""; }, }, { 'id' : 'p_barcode', 'flex' : '1', 'label' : 'Patron Barcode', - 'render' : 'if (my.command.patron_barcode) { v = my.command.patron_barcode; } else { if (my.command.user.card.barcode) { v = my.command.user.card.barcode; } else { v = ""; } }; v;', + 'render' : function(my) { if (my.command.patron_barcode) { return my.command.patron_barcode; } else { if (my.command.user.card.barcode) { return my.command.user.card.barcode; } else { return ""; } }; }, }, { 'id' : 'duedate', 'flex' : '1', 'hidden' : 'true', 'label' : 'Due Date', - 'render' : 'v = my.command.due_date || ""; v;', + 'render' : function(my) { return my.command.due_date || ""; }, }, { 'id' : 'backdate', 'flex' : '1', 'hidden' : 'true', 'label' : 'Check In Backdate', - 'render' : 'v = my.command.backdate || ""; v;', + 'render' : function(my) { return my.command.backdate || ""; }, }, { 'id' : 'count', 'flex' : '1', 'hidden' : 'true', 'label' : 'In House Use Count', - 'render' : 'v = my.command.count || ""; v;', + 'render' : function(my) { return my.command.count || ""; }, }, { 'id' : 'noncat', 'flex' : '1', 'hidden' : 'true', 'label' : 'Non-Cataloged?', - 'render' : 'v = my.command.noncat == 1 ? "Yes" : "No"; v;', + 'render' : function(my) { return get_bool(my.command.noncat) ? "Yes" : "No"; }, }, { 'id' : 'noncat_type', 'flex' : '1', 'hidden' : 'true', 'label' : 'Non-Cataloged Type', - 'render' : 'v = data.hash.cnct[ my.command.noncat_type ] ? data.hash.cnct[ my.command.noncat_type ].name() : ""; v;', + 'render' : function(my) { return data.hash.cnct[ my.command.noncat_type ] ? obj.data.hash.cnct[ my.command.noncat_type ].name() : ""; }, }, { 'id' : 'noncat_count', 'flex' : '1', 'hidden' : 'true', 'label' : 'Non-Cataloged Count', - 'render' : 'v = my.command.noncat_count || ""; v;', + 'render' : function(my) { return my.command.noncat_count || ""; }, }, ], - 'map_row_to_column' : function(row,col) { - JSAN.use('util.date'); - JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); - var my = row; var value; - try { value = eval( col.render ); } catch(E) { obj.error.sdump('D_ERROR',E); value = '???'; } - return value; - }, + 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'on_select' : function(ev) { try { var sel = obj.error_list.retrieve_selection(); @@ -591,7 +573,7 @@ admin.offline_manage_xacts.prototype = { obj.list.append( { 'retrieve_id' : idx, 'row' : row } ); if (idx == old_idx) obj.list.node.view.selection.select(idx); }; - }(i,obj.seslist[i]) + }(i,{ 'my' : obj.seslist[i] }) ); } @@ -625,7 +607,7 @@ admin.offline_manage_xacts.prototype = { return function(){ obj.script_list.append( { 'row' : row } ); }; - }(scripts[i]) + }({ 'my' : scripts[i] }) ); } JSAN.use('util.exec'); var exec = new util.exec(); @@ -654,7 +636,7 @@ admin.offline_manage_xacts.prototype = { return function(){ obj.error_list.append( { 'retrieve_id' : idx, 'row' : row } ); }; - }(i,obj.errors[i]) + }(i,{ 'my' : obj.errors[i] }) ); } JSAN.use('util.exec'); var exec = new util.exec(); diff --git a/Open-ILS/xul/staff_client/server/cat/copy_browser.js b/Open-ILS/xul/staff_client/server/cat/copy_browser.js index 66e79df580..73c90555f5 100644 --- a/Open-ILS/xul/staff_client/server/cat/copy_browser.js +++ b/Open-ILS/xul/staff_client/server/cat/copy_browser.js @@ -1374,17 +1374,17 @@ cat.copy_browser.prototype = { { 'id' : 'tree_location', 'label' : 'Location/Barcode', 'flex' : 1, 'primary' : true, 'hidden' : false, - 'render' : 'v = my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; v;' + 'render' : function(my) { return my.acp ? my.acp.barcode() : my.acn ? my.acn.label() : my.aou ? my.aou.shortname() + " : " + my.aou.name() : "???"; }, }, { 'id' : 'volume_count', 'label' : 'Volumes', 'flex' : 0, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.volume_count; v;' + 'render' : function(my) { return my.volume_count; }, }, { 'id' : 'copy_count', 'label' : 'Copies', 'flex' : 0, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.copy_count; v;' + 'render' : function(my) { return my.copy_count; }, }, ].concat( circ.util.columns( diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index f0f7003666..8426a49456 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -5,7 +5,7 @@ circ.util = {}; circ.util.EXPORT_OK = [ 'offline_checkout_columns', 'offline_checkin_columns', 'offline_renew_columns', 'offline_inhouse_use_columns', - 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_column', + 'columns', 'hold_columns', 'checkin_via_barcode', 'std_map_row_to_columns', 'show_last_few_circs', 'abort_transits', 'transit_columns', 'renew_via_barcode', ]; circ.util.EXPORT_TAGS = { ':all' : circ.util.EXPORT_OK }; @@ -117,55 +117,55 @@ circ.util.offline_checkout_columns = function(modify,params) { 'id' : 'timestamp', 'label' : 'Timestamp', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.timestamp; v;' + 'render' : function(my) { return my.timestamp; }, }, { 'id' : 'checkout_time', 'label' : 'Check Out Time', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.checkout_time; v;' + 'render' : function(my) { return my.checkout_time; }, }, { 'id' : 'type', 'label' : 'Transaction Type', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.type; v;' + 'render' : function(my) { return my.type; }, }, { 'id' : 'noncat', 'label' : 'Non-Cataloged?', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.noncat; v;' + 'render' : function(my) { return my.noncat; }, }, { 'id' : 'noncat_type', 'label' : 'Non-Cat Type ID', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.noncat_type; v;' + 'render' : function(my) { return my.noncat_type; }, }, { 'id' : 'noncat_count', 'label' : 'Count', 'sort_type' : 'number', 'flex' : 1, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.noncat_count; v;' + 'render' : function(my) { return my.noncat_count; }, }, { 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.patron_barcode; v;' + 'render' : function(my) { return my.patron_barcode; }, }, { 'id' : 'barcode', 'label' : 'Item Barcode', 'flex' : 2, 'primary' : true, 'hidden' : false, - 'render' : 'v = my.barcode; v;' + 'render' : function(my) { return my.barcode; }, }, { 'id' : 'due_date', 'label' : 'Due Date', 'flex' : 1, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.due_date; v;' + 'render' : function(my) { return my.due_date; }, }, ]; if (modify) for (var i = 0; i < c.length; i++) { @@ -206,25 +206,25 @@ circ.util.offline_checkin_columns = function(modify,params) { 'id' : 'timestamp', 'label' : 'Timestamp', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.timestamp; v;' + 'render' : function(my) { return my.timestamp; }, }, { 'id' : 'backdate', 'label' : 'Back Date', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.backdate; v;' + 'render' : function(my) { return my.backdate; }, }, { 'id' : 'type', 'label' : 'Transaction Type', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.type; v;' + 'render' : function(my) { return my.type; }, }, { 'id' : 'barcode', 'label' : 'Item Barcode', 'flex' : 2, 'primary' : true, 'hidden' : false, - 'render' : 'v = my.barcode; v;' + 'render' : function(my) { return my.barcode; }, }, ]; if (modify) for (var i = 0; i < c.length; i++) { @@ -265,37 +265,37 @@ circ.util.offline_renew_columns = function(modify,params) { 'id' : 'timestamp', 'label' : 'Timestamp', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.timestamp; v;' + 'render' : function(my) { return my.timestamp; }, }, { 'id' : 'checkout_time', 'label' : 'Check Out Time', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.checkout_time; v;' + 'render' : function(my) { return my.checkout_time; }, }, { 'id' : 'type', 'label' : 'Transaction Type', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.type; v;' + 'render' : function(my) { return my.type; }, }, { 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.patron_barcode; v;' + 'render' : function(my) { return my.patron_barcode; }, }, { 'id' : 'barcode', 'label' : 'Item Barcode', 'flex' : 2, 'primary' : true, 'hidden' : false, - 'render' : 'v = my.barcode; v;' + 'render' : function(my) { return my.barcode; }, }, { 'id' : 'due_date', 'label' : 'Due Date', 'flex' : 1, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.due_date; v;' + 'render' : function(my) { return my.due_date; }, }, ]; if (modify) for (var i = 0; i < c.length; i++) { @@ -336,31 +336,31 @@ circ.util.offline_inhouse_use_columns = function(modify,params) { 'id' : 'timestamp', 'label' : 'Timestamp', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.timestamp; v;' + 'render' : function(my) { return my.timestamp; }, }, { 'id' : 'use_time', 'label' : 'Use Time', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.use_time; v;' + 'render' : function(my) { return my.use_time; }, }, { 'id' : 'type', 'label' : 'Transaction Type', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.type; v;' + 'render' : function(my) { return my.type; }, }, { 'id' : 'count', 'label' : 'Count', 'sort_type' : 'number', 'flex' : 1, 'primary' : false, 'hidden' : false, - 'render' : 'v = my.count; v;' + 'render' : function(my) { return my.count; }, }, { 'id' : 'barcode', 'label' : 'Item Barcode', 'flex' : 2, 'primary' : true, 'hidden' : false, - 'render' : 'v = my.barcode; v;' + 'render' : function(my) { return my.barcode; }, }, ]; if (modify) for (var i = 0; i < c.length; i++) { @@ -399,189 +399,205 @@ circ.util.offline_inhouse_use_columns = function(modify,params) { circ.util.columns = function(modify,params) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + JSAN.use('util.network'); var network = new util.network(); + JSAN.use('util.money'); function getString(s) { return data.entities[s]; } var c = [ { 'id' : 'acp_id', 'label' : getString('staff.acp_label_id'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.id(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.id(); }, 'persist' : 'hidden width ordinal', }, { 'id' : 'circ_id', 'label' : getString('staff.circ_label_id'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.id() : ( my.acp.circulations() ? my.acp.circulations()[0].id() : ""); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'mvr_doc_id', 'label' : getString('staff.mvr_label_doc_id'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.doc_id(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.doc_id(); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'barcode', 'label' : getString('staff.acp_label_barcode'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.barcode(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'call_number', 'label' : getString('staff.acp_label_call_number'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : ' if (my.acp && my.acp.call_number() == -1) { v = "Not Cataloged"; v; } else { if (!my.acn) { var x = obj.network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { v = "Not Cataloged"; v; } else { my.acn = x; v = x.label(); v; } } else { v = my.acn.label(); v; } } ' , 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { if (my.acp && my.acp.call_number() == -1) { return "Not Cataloged"; } else { if (!my.acn) { var x = network.simple_request("FM_ACN_RETRIEVE",[ my.acp.call_number() ]); if (x.ilsevent) { return "Not Cataloged"; } else { my.acn = x; return x.label(); } } else { return my.acn.label(); } } }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'owning_lib', 'label' : 'Owning Lib', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'if (Number(my.acn.owning_lib())>=0) { v = obj.data.hash.aou[ my.acn.owning_lib() ].shortname(); v; } else { v = my.acn.owning_lib().shortname(); v; }', 'persist' : 'hidden width ordinal', + 'render' : function(my) { if (Number(my.acn.owning_lib())>=0) { return data.hash.aou[ my.acn.owning_lib() ].shortname(); } else { return my.acn.owning_lib().shortname(); } }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1, 'sort_type' : 'number', - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.copy_number(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.copy_number(); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'location', 'label' : getString('staff.acp_label_location'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'if (Number(my.acp.location())>=0) v = obj.data.lookup("acpl", my.acp.location() ).name(); else v = my.acp.location().name(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.location())>=0) return data.lookup("acpl", my.acp.location() ).name(); else return my.acp.location().name(); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'loan_duration', 'label' : getString('staff.acp_label_loan_duration'), 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'switch(my.acp.loan_duration()){ case 1: v = "Short"; break; case 2: v = "Normal"; break; case 3: v = "Long"; break; }; v;', 'persist' : 'hidden width ordinal', + 'render' : function(my) { switch(my.acp.loan_duration()){ case 1: return "Short"; break; case 2: return "Normal"; break; case 3: return "Long"; break; }; }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'circ_lib', 'label' : getString('staff.acp_label_circ_lib'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'if (Number(my.acp.circ_lib())>=0) v = obj.data.hash.aou[ my.acp.circ_lib() ].shortname(); else v = my.acp.circ_lib().shortname(); v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.circ_lib())>=0) return data.hash.aou[ my.acp.circ_lib() ].shortname(); else return my.acp.circ_lib().shortname(); }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'fine_level', 'label' : getString('staff.acp_label_fine_level'), 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'switch(my.acp.fine_level()){ case 1: v = "Low"; break; case 2: v = "Normal"; break; case 3: v = "High"; break; }; v;', 'persist' : 'hidden width ordinal', + 'render' : function(my) { switch(my.acp.fine_level()){ case 1: return "Low"; break; case 2: return "Normal"; break; case 3: return "High"; break; }; }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'circulate', 'label' : 'Circulate?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.circulate() ) ? "Yes" : "No"; v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.circulate() ) ? "Yes" : "No"; }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'deleted', 'label' : 'Deleted?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.deleted() ) ? "Yes" : "No"; v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deleted() ) ? "Yes" : "No"; }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'holdable', 'label' : 'Holdable?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.holdable() ) ? "Yes" : "No"; v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.holdable() ) ? "Yes" : "No"; }, + 'persist' : 'hidden width ordinal', }, { 'id' : 'opac_visible', 'label' : 'OPAC Visible?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.opac_visible() ) ? "Yes" : "No"; v;', 'persist' : 'hidden width ordinal', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.opac_visible() ) ? "Yes" : "No"; }, + 'persist' : 'hidden width ordinal', }, { 'persist' : 'hidden width ordinal', 'id' : 'ref', 'label' : 'Reference?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.ref() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.ref() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'deposit', 'label' : 'Deposit?', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.acp.deposit() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.acp.deposit() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : getString('staff.acp_label_deposit_amount'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = util.money.sanitize(my.acp.deposit_amount()); v;', 'sort_type' : 'money', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return util.money.sanitize(my.acp.deposit_amount()); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'price', 'label' : getString('staff.acp_label_price'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = util.money.sanitize(my.acp.price()); v;', 'sort_type' : 'money', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return util.money.sanitize(my.acp.price()); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'circ_as_type', 'label' : getString('staff.acp_label_circ_as_type'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.circ_as_type(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_as_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'circ_modifier', 'label' : getString('staff.acp_label_circ_modifier'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.circ_modifier(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.circ_modifier(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_start_full', 'label' : 'Checkout Timestamp', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start() : (my.acp.circulations() ? my.acp.circulations()[0].xact_start() : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'checkin_time_full', 'label' : 'Checkin Timestamp', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time() : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time() : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Checkout Date', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.xact_start().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].xact_start().substr(0,10) : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.xact_start().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].xact_start().substr(0,10) : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'checkin_time', 'label' : 'Checkin Date', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.checkin_time().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time().substr(0,10) : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.checkin_time().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].checkin_time().substr(0,10) : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Transaction Finished', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ.xact_finish(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ.xact_finish(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'due_date', 'label' : getString('staff.circ_label_due_date'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.due_date().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].due_date().substr(0,10) : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.due_date().substr(0,10) : (my.acp.circulations() ? my.acp.circulations()[0].due_date().substr(0,10) : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Date Created', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.create_date().substr(0,10); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.create_date().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'edit_date', 'label' : 'Date Last Edited', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.edit_date().substr(0,10); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.edit_date().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 2, 'sort_type' : 'title', - 'primary' : false, 'hidden' : true, 'render' : 'try { v = my.mvr.title(); v; } catch(E) { v = my.acp.dummy_title(); v; }' + 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } } }, { 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'try { v = my.mvr.author(); v; } catch(E) { v = my.acp.dummy_author(); v; }' + 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } } }, { 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.edition(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.isbn(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.pubdate(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.publisher(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.tcn(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : getString('staff.circ_label_renewal_remaining'), 'flex' : 0, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.renewal_remaining() : (my.acp.circulations() ? my.acp.circulations()[0].renewal_remaining() : ""); v;', 'sort_type' : 'number', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.renewal_remaining() : (my.acp.circulations() ? my.acp.circulations()[0].renewal_remaining() : ""); }, 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines() : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'stop_fines_time', 'label' : 'Fines Stopped Time', 'flex' : 0, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.circ ? my.circ.stop_fines_time() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines_time() : ""); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.circ ? my.circ.stop_fines_time() : (my.acp.circulations() ? my.acp.circulations()[0].stop_fines_time() : ""); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : getString('staff.acp_label_status'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'if (Number(my.acp.status())>=0) v = obj.data.hash.ccs[ my.acp.status() ].name(); else v = my.acp.status().name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { if (Number(my.acp.status())>=0) return data.hash.ccs[ my.acp.status() ].name(); else return my.acp.status().name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'route_to', 'label' : 'Route To', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.route_to.toString(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.route_to.toString(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'message', 'label' : 'Message', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.message.toString(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.message.toString(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.uses; v;', 'sort_type' : 'number', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.uses; }, 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.alert_message(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.alert_message(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -623,43 +639,43 @@ circ.util.transit_columns = function(modify,params) { var c = [ { 'persist' : 'hidden width ordinal', 'id' : 'transit_item_barcode', 'label' : 'Barcode', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp.barcode(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp.barcode(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_item_title', 'label' : 'Title', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'try { v = my.mvr.title(); v; } catch(E) { v = my.acp.dummy_title(); v; }' + 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.title(); } catch(E) { return my.acp.dummy_title(); } }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_item_author', 'label' : 'Author', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'try { v = my.mvr.author(); v; } catch(E) { v = my.acp.dummy_author(); v; }' + 'primary' : false, 'hidden' : true, 'render' : function(my) { try { return my.mvr.author(); } catch(E) { return my.acp.dummy_author(); } }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_item_callnumber', 'label' : 'Call Number', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acn.label(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_id', 'label' : 'Transit ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.atc.id(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = typeof my.atc.source() == "object" ? my.atc.source().shortname() : obj.data.hash.aou[ my.atc.source() ].shortname(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.source() == "object" ? my.atc.source().shortname() : data.hash.aou[ my.atc.source() ].shortname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.atc.source_send_time(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.source_send_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = typeof my.atc.dest() == "object" ? my.atc.dest().shortname() : obj.data.hash.aou[ my.atc.dest() ].shortname(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return typeof my.atc.dest() == "object" ? my.atc.dest().shortname() : data.hash.aou[ my.atc.dest() ].shortname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.atc.dest_recv_time(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.atc.dest_recv_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_target_copy', 'label' : 'Transit Copy ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.atc.target_copy(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.atc.target_copy(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -704,162 +720,162 @@ circ.util.hold_columns = function(modify,params) { { 'persist' : 'hidden width ordinal', 'id' : 'request_timestamp', 'label' : 'Request Timestamp', 'flex' : 0, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.ahr.request_time().toString().substr(0,10); v;' + 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'request_time', 'label' : 'Request Date', 'flex' : 0, 'primary' : false, 'hidden' : true, - 'render' : 'v = my.ahr.request_time().toString().substr(0,10); v;' + 'render' : function(my) { return my.ahr.request_time().toString().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'available_timestamp', 'label' : 'Available On (Timestamp)', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString() : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString() : "" ); v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString() : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString() : "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'available_time', 'label' : 'Available On', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString().substr(0,10) : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : "" ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.ahr.transit() ? ( my.ahr.transit().dest_recv_time() ? my.ahr.transit().dest_recv_time().toString().substr(0,10) : "") : ( my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'capture_timestamp', 'label' : 'Capture Timestamp', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'capture_time', 'label' : 'Capture Date', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.capture_time() ? my.ahr.capture_time().toString().substr(0,10) : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'status', 'label' : getString('staff.ahr_status_label'), 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'switch(my.status) { case 1: case "1": v = "Waiting for copy"; break; case 2: case "2": v = "Waiting for capture"; break; case 3: case "3": v = "In-Transit"; break; case 4: case "4" : v = "Ready for pickup"; break; default: v = my.status; break;}; v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { switch(my.status) { case 1: case "1": return "Waiting for copy"; break; case 2: case "2": return "Waiting for capture"; break; case 3: case "3": return "In-Transit"; break; case 4: case "4" : return "Ready for pickup"; break; default: return my.status; break;}; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'hold_type', 'label' : getString('staff.ahr_hold_type_label'), 'flex' : 0, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.hold_type(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.hold_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib', 'label' : 'Pickup Lib (Full Name)', 'flex' : 1, 'primary' : false, 'hidden' : true, - 'render' : 'if (Number(my.ahr.pickup_lib())>=0) v = obj.data.hash.aou[ my.ahr.pickup_lib() ].name(); else v = my.ahr.pickup_lib().name(); v;' + 'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].name(); else return my.ahr.pickup_lib().name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'pickup_lib_shortname', 'label' : getString('staff.ahr_pickup_lib_label'), 'flex' : 0, 'primary' : false, 'hidden' : true, - 'render' : 'if (Number(my.ahr.pickup_lib())>=0) v = obj.data.hash.aou[ my.ahr.pickup_lib() ].shortname(); else v = my.ahr.pickup_lib().shortname(); v;' + 'render' : function(my) { if (Number(my.ahr.pickup_lib())>=0) return data.hash.aou[ my.ahr.pickup_lib() ].shortname(); else return my.ahr.pickup_lib().shortname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'current_copy', 'label' : getString('staff.ahr_current_copy_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acp ? my.acp.barcode() : "No Copy"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acp ? my.acp.barcode() : "No Copy"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'email_notify', 'label' : getString('staff.ahr_email_notify_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.email_notify() == 1 ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool(my.ahr.email_notify()) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'expire_time', 'label' : getString('staff.ahr_expire_time_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.expire_time(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.expire_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'fulfillment_time', 'label' : getString('staff.ahr_fulfillment_time_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.fulfillment_time(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.fulfillment_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'holdable_formats', 'label' : getString('staff.ahr_holdable_formats_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.holdable_formats(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.holdable_formats(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : getString('staff.ahr_id_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.id(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'phone_notify', 'label' : getString('staff.ahr_phone_notify_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.phone_notify(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.phone_notify(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'prev_check_time', 'label' : getString('staff.ahr_prev_check_time_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.prev_check_time(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.prev_check_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'requestor', 'label' : getString('staff.ahr_requestor_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.requestor(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.requestor(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'selection_depth', 'label' : getString('staff.ahr_selection_depth_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.selection_depth(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.selection_depth(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'target', 'label' : getString('staff.ahr_target_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.target(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.target(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : getString('staff.ahr_usr_label'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.usr(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.usr(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'title', 'label' : getString('staff.mvr_label_title'), 'flex' : 1, 'sort_type' : 'title', - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr ? my.mvr.title() : "No Title?"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.title() : "No Title?"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'author', 'label' : getString('staff.mvr_label_author'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr ? my.mvr.author() : "No Author?"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr ? my.mvr.author() : "No Author?"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'edition', 'label' : 'Edition', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.edition(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.edition(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'isbn', 'label' : 'ISBN', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.isbn(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.isbn(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'pubdate', 'label' : 'PubDate', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.pubdate(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.pubdate(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'publisher', 'label' : 'Publisher', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.publisher(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.publisher(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'tcn', 'label' : 'TCN', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mvr.tcn(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mvr.tcn(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'notify_time', 'label' : 'Last Notify Time', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.notify_time(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'notify_count', 'label' : 'Notices', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.notify_count(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.notify_count(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_source', 'label' : 'Transit Source', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.transit() ? obj.data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().source() ].shortname() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_source_send_time', 'label' : 'Transitted On', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().source_send_time() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_lib', 'label' : 'Transit Destination', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.transit() ? obj.data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? data.hash.aou[ my.ahr.transit().dest() ].shortname() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'transit_dest_recv_time', 'label' : 'Transit Completed On', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.ahr.transit() ? my.ahr.transit().dest_recv_time() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'patron_barcode', 'label' : 'Patron Barcode', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.patron_barcode ? my.patron_barcode : ""; v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_barcode ? my.patron_barcode : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'patron_family_name', 'label' : 'Patron Last Name', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.patron_family_name ? my.patron_family_name : ""; v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_family_name ? my.patron_family_name : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'patron_first_given_name', 'label' : 'Patron First Name', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.patron_first_given_name ? my.patron_first_given_name : ""; v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.patron_first_given_name ? my.patron_first_given_name : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'callnumber', 'label' : 'Call Number', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.acn.label(); v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.acn.label(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -892,7 +908,7 @@ circ.util.hold_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; } ); } - +/* circ.util.std_map_row_to_column = function(error_value) { return function(row,col) { // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } } @@ -916,7 +932,7 @@ circ.util.std_map_row_to_column = function(error_value) { return value; } } - +*/ circ.util.std_map_row_to_columns = function(error_value) { return function(row,cols) { // row contains { 'my' : { 'acp' : {}, 'circ' : {}, 'mvr' : {} } } @@ -933,9 +949,13 @@ circ.util.std_map_row_to_columns = function(error_value) { var cmd = ''; try { for (var i = 0; i < cols.length; i++) { - cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; + switch (typeof cols[i].render) { + case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } 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)+'"; '; + } } - eval( cmd ); + if (cmd) eval( cmd ); } catch(E) { obj.error.sdump('D_WARN','map_row_to_column: ' + E); if (error_value) { value = error_value; } else { value = ' ' }; diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index cfe41867b6..0c68ee9063 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', /*'std_map_row_to_column',*/ 'std_map_row_to_columns', 'retrieve_au_via_id', 'retrieve_fleshed_au_via_id', 'retrieve_fleshed_au_via_barcode', 'set_penalty_css', 'retrieve_name_via_id' ]; patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK }; @@ -12,6 +12,7 @@ patron.util.EXPORT_TAGS = { ':all' : patron.util.EXPORT_OK }; patron.util.mbts_columns = function(modify,params) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + JSAN.use('util.money'); JSAN.use('util.date'); function getString(s) { return data.entities[s]; } @@ -19,62 +20,62 @@ patron.util.mbts_columns = function(modify,params) { var c = [ { 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : 'Id', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mbts.id(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mbts.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'usr', 'label' : 'User', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mbts.usr() ? "Id = " + my.mbts.usr() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mbts.usr() ? "Id = " + my.mbts.usr() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_type', 'label' : 'Type', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mbts.xact_type(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mbts.xact_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'balance_owed', 'label' : 'Balance Owed', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.money.sanitize( my.mbts.balance_owed() ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.balance_owed() ); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'total_owed', 'label' : 'Total Billed', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.money.sanitize( my.mbts.total_owed() ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_owed() ); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'total_paid', 'label' : 'Total Paid', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.money.sanitize( my.mbts.total_paid() ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.money.sanitize( my.mbts.total_paid() ); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'last_billing_note', 'label' : 'Last Billing Note', 'flex' : 2, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mbts.last_billing_note(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mbts.last_billing_note(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'last_billing_type', 'label' : 'Last Billing Type', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mbts.last_billing_type(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mbts.last_billing_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'last_billing_ts', 'label' : 'Last Billed', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = util.date.formatted_date( my.mbts.last_billing_ts(), "" ); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_billing_ts(), "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'last_payment_note', 'label' : 'Last Payment Note', 'flex' : 2, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mbts.last_payment_note(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mbts.last_payment_note(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'last_payment_type', 'label' : 'Last Payment Type', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mbts.last_payment_type(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mbts.last_payment_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'last_payment_ts', 'label' : 'Last Payment', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = util.date.formatted_date( my.mbts.last_payment_ts(), "" ); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return util.date.formatted_date( my.mbts.last_payment_ts(), "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_start', 'label' : 'Created', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mbts.xact_start() ? my.mbts.xact_start().toString().substr(0,10) : ""; v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mbts.xact_start() ? my.mbts.xact_start().toString().substr(0,10) : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact_finish', 'label' : 'Closed', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mbts.xact_finish() ? my.mbts.xact_finish().toString().substr(0,10) : ""; v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mbts.xact_finish() ? my.mbts.xact_finish().toString().substr(0,10) : ""; }, }, ]; for (var i = 0; i < c.length; i++) { @@ -110,6 +111,7 @@ patron.util.mbts_columns = function(modify,params) { patron.util.mb_columns = function(modify,params) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + JSAN.use('util.money'); JSAN.use('util.date'); function getString(s) { return data.entities[s]; } @@ -117,40 +119,40 @@ patron.util.mb_columns = function(modify,params) { var c = [ { 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : 'Id', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mb.id(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mb.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'voided', 'label' : 'Voided', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = get_bool( my.mb.voided() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return get_bool( my.mb.voided() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'voider', 'label' : 'Voider', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mb.voider() ? "Id = " + my.mb.voider() : ""; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mb.voider() ? "Id = " + my.mb.voider() : ""; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'void_time', 'label' : 'Void Time', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mb.void_time(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mb.void_time(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : 'Amount', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.money.sanitize( my.mb.amount() ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.money.sanitize( my.mb.amount() ); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'billing_type', 'label' : 'Type', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mb.billing_type(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mb.billing_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'billing_ts', 'label' : 'When', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.date.formatted_date( my.mb.billing_ts(), "" ); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.date.formatted_date( my.mb.billing_ts(), "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'note', 'label' : 'Note', 'flex' : 2, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mb.note(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mb.note(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'xact', 'label' : 'Transaction ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mb.xact(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mb.xact(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -187,6 +189,7 @@ patron.util.mb_columns = function(modify,params) { patron.util.mp_columns = function(modify,params) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + JSAN.use('util.money'); JSAN.use('util.date'); JSAN.use('patron.util'); function getString(s) { return data.entities[s]; } @@ -194,36 +197,36 @@ patron.util.mp_columns = function(modify,params) { var c = [ { 'persist' : 'hidden width ordinal', 'id' : 'mp_id', 'label' : 'ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mp.id(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mp.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_amount', 'label' : 'Amount', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.money.sanitize( my.mp.amount() ); v;', + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.money.sanitize( my.mp.amount() ); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_type', 'label' : 'Type', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mp.payment_type(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mp.payment_type(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_payment_ts', 'label' : 'When', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = util.date.formatted_date( my.mp.payment_ts(), "" ); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return util.date.formatted_date( my.mp.payment_ts(), "" ); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_note', 'label' : 'Note', 'flex' : 2, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mp.note(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mp.note(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_ws', 'label' : 'Workstation', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'v = my.mp.cash_drawer().name(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { return my.mp.cash_drawer().name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_staff', 'label' : 'Staff', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'JSAN.use("patron.util"); var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); v = s.card().barcode() + " @ " + obj.OpenILS.data.hash.aou[ s.home_ou() ].shortname(); v;' + 'primary' : false, 'hidden' : false, 'render' : function(my) { var s = my.mp.accepting_usr(); if (s && typeof s != "object") s = patron.util.retrieve_fleshed_au_via_id(ses(),s); return s.card().barcode() + " @ " + data.hash.aou[ s.home_ou() ].shortname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'mp_xact', 'label' : 'Transaction ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.mp.xact(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.mp.xact(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -266,121 +269,121 @@ patron.util.columns = function(modify,params) { var c = [ { 'persist' : 'hidden width ordinal', 'id' : 'barcode', 'label' : 'Barcode', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.card().barcode(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.card().barcode(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'usrname', 'label' : 'Login Name', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.usrname(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { my.au.usrname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'profile', 'label' : 'Group', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = obj.OpenILS.data.hash.pgt[ my.au.profile() ].name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return data.hash.pgt[ my.au.profile() ].name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'active', 'label' : getString('staff.au_label_active'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.au.active() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.au.active() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'barred', 'label' : 'Barred', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.au.barred() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.au.barred() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'id', 'label' : getString('staff.au_label_id'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.id(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.id(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'prefix', 'label' : getString('staff.au_label_prefix'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.prefix(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.prefix(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'family_name', 'label' : getString('staff.au_label_family_name'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.family_name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.family_name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'first_given_name', 'label' : getString('staff.au_label_first_given_name'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.first_given_name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.first_given_name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'second_given_name', 'label' : getString('staff.au_label_second_given_name'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.second_given_name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.second_given_name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'suffix', 'label' : getString('staff.au_label_suffix'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.suffix(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.suffix(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.alert_message(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.alert_message(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'claims_returned_count', 'label' : 'Returns Claimed', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.claims_returned_count(); v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.claims_returned_count(); }, 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Created On', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.create_date(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.create_date(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'expire_date', 'label' : 'Expires On', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.expire_date().substr(0,10); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.expire_date().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'home_ou', 'label' : 'Home Lib', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = obj.OpenILS.data.hash.aou[ my.au.home_ou() ].shortname(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return data.hash.aou[ my.au.home_ou() ].shortname(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'credit_forward_balance', 'label' : 'Credit', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.credit_forward_balance(); v;', + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.credit_forward_balance(); }, 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'day_phone', 'label' : 'Day Phone', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.day_phone(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.day_phone(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'evening_phone', 'label' : 'Evening Phone', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.evening_phone(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.evening_phone(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'other_phone', 'label' : 'Other Phone', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.other_phone(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.other_phone(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'email', 'label' : 'Email', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.email(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.email(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'dob', 'label' : 'Birth Date', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.dob().substr(0,10); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.dob().substr(0,10); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'ident_type', 'label' : 'Ident Type', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = obj.OpenILS.data.hash.cit[ my.au.ident_type() ].name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return data.hash.cit[ my.au.ident_type() ].name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'ident_value', 'label' : 'Ident Value', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.ident_value(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.ident_value(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'ident_type2', 'label' : 'Ident Type 2', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = obj.OpenILS.data.hash.cit[ my.au.ident_type2() ].name(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return data.hash.cit[ my.au.ident_type2() ].name(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'ident_value2', 'label' : 'Ident Value 2', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.ident_value2(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.ident_value2(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'net_access_level', 'label' : 'Net Access', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.net_access_level(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.net_access_level(); }, }, { 'persist' : 'hidden width ordinal', 'id' : 'master_account', 'label' : 'Group Lead', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = get_bool( my.au.master_account() ) ? "Yes" : "No"; v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return get_bool( my.au.master_account() ) ? "Yes" : "No"; }, }, { 'persist' : 'hidden width ordinal', 'id' : 'usrgroup', 'label' : 'Group ID', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'v = my.au.usrgroup(); v;' + 'primary' : false, 'hidden' : true, 'render' : function(my) { return my.au.usrgroup(); }, }, ]; for (var i = 0; i < c.length; i++) { @@ -413,7 +416,7 @@ 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_column = function(error_value) { return function(row,col) { // row contains { 'my' : { 'au' : {} } } @@ -435,7 +438,7 @@ patron.util.std_map_row_to_column = function(error_value) { return value; } } - +*/ patron.util.std_map_row_to_columns = function(error_value) { return function(row,cols) { // row contains { 'my' : { 'au' : {} } } @@ -451,9 +454,13 @@ patron.util.std_map_row_to_columns = function(error_value) { var cmd = ''; try { for (var i = 0; i < cols.length; i++) { - cmd += 'try { ' + cols[i].render + '; values['+i+'] = v; } catch(E) { values['+i+'] = error_value; }'; + switch (typeof cols[i].render) { + case 'function': try { values[i] = cols[i].render(my); } catch(E) { values[i] = error_value; dump(E+'\n'); } 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)+'"; '; + } } - eval( cmd ); + if (cmd) eval( cmd ); } catch(E) { obj.error.sdump('D_WARN','map_row_to_column: ' + E); if (error_value) { value = error_value; } else { value = ' ' };