From b3e0f1a3f6aa24f83b41e1722af567c2188f0c56 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 14 Aug 2006 13:57:59 +0000 Subject: [PATCH] sort_type (number, money) hints for list columns git-svn-id: svn://svn.open-ils.org/ILS/trunk@5485 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../xul/staff_client/chrome/content/util/list.js | 19 ++++++++++++++++++- Open-ILS/xul/staff_client/server/circ/util.js | 15 ++++++++------- Open-ILS/xul/staff_client/server/patron/util.js | 21 ++++++++++++++------- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/util/list.js b/Open-ILS/xul/staff_client/chrome/content/util/list.js index 5aeab1bb60..7214c270fd 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/list.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/list.js @@ -832,6 +832,7 @@ util.list.prototype = { obj.on_all_fleshed = function() { try { + JSAN.use('util.money'); var rows = []; var treeitems = obj.treechildren.childNodes; for (var i = 0; i < treeitems.length; i++) { @@ -843,7 +844,23 @@ util.list.prototype = { //alert('value = ' + value.value + ' node = ' + value.node); rows.push( value ); } - rows = rows.sort( function(a,b) { a = a.value; b = b.value; if (a < b) return -1; if (a > b) return 1; return 0; } ); + rows = rows.sort( function(a,b) { + a = a.value; b = b.value; + if (col.getAttribute('sort_type')) { + switch(col.getAttribute('sort_type')) { + case 'number' : + a = Number(a); b = Number(b); + break; + case 'money' : + a = util.money.dollars_float_to_cents_integer(a); + b = util.money.dollars_float_to_cents_integer(b); + break; + } + } + if (a < b) return -1; + if (a > b) return 1; + return 0; + } ); if (sortDir == 'asc') rows = rows.reverse(); while(obj.treechildren.lastChild) obj.treechildren.removeChild( obj.treechildren.lastChild ); for (var i = 0; i < rows.length; i++) { diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 878a7aa165..fd142f9796 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -134,7 +134,7 @@ circ.util.offline_checkout_columns = function(modify,params) { }, { 'id' : 'noncat_count', - 'label' : 'Count', + 'label' : 'Count', 'sort_type' : 'number', 'flex' : 1, 'primary' : false, 'hidden' : false, 'render' : 'my.noncat_count' }, @@ -311,7 +311,7 @@ circ.util.offline_inhouse_use_columns = function(modify,params) { }, { 'id' : 'count', - 'label' : 'Count', + 'label' : 'Count', 'sort_type' : 'number', 'flex' : 1, 'primary' : false, 'hidden' : false, 'render' : 'my.count' }, @@ -378,7 +378,7 @@ circ.util.columns = function(modify,params) { 'render' : 'if (Number(my.acn.owning_lib())>=0) obj.data.hash.aou[ my.acn.owning_lib() ].shortname(); else my.acn.owning_lib().shortname();', 'persist' : 'hidden width ordinal', }, { - 'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1, + 'id' : 'copy_number', 'label' : getString('staff.acp_label_copy_number'), 'flex' : 1, 'sort_type' : 'number', 'primary' : false, 'hidden' : true, 'render' : 'my.acp.copy_number()', 'persist' : 'hidden width ordinal', }, { @@ -421,11 +421,11 @@ circ.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'deposit_amount', 'label' : getString('staff.acp_label_deposit_amount'), 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'my.acp.deposit_amount()' + 'primary' : false, 'hidden' : true, 'render' : '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' : 'my.acp.price()' + 'primary' : false, 'hidden' : true, 'render' : '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, @@ -481,7 +481,7 @@ circ.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'renewal_remaining', 'label' : getString('staff.circ_label_renewal_remaining'), 'flex' : 0, - 'primary' : false, 'hidden' : true, 'render' : 'my.circ.renewal_remaining()' + 'primary' : false, 'hidden' : true, 'render' : 'my.circ.renewal_remaining()', 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'stop_fines', 'label' : 'Fines Stopped', 'flex' : 0, @@ -501,7 +501,7 @@ circ.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'uses', 'label' : '# of Uses', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'my.uses' + 'primary' : false, 'hidden' : true, 'render' : 'my.uses', 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'alert_message', 'label' : 'Alert Message', 'flex' : 1, @@ -741,6 +741,7 @@ circ.util.std_map_row_to_column = function(error_value) { JSAN.use('util.error'); obj.error = new util.error(); JSAN.use('OpenILS.data'); obj.data = new OpenILS.data(); obj.data.init({'via':'stash'}); JSAN.use('util.network'); obj.network = new util.network(); + JSAN.use('util.money'); var my = row.my; var value; diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index 0c2f957f2f..a988059e0e 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -30,15 +30,18 @@ patron.util.mbts_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'balance_owed', 'label' : 'Balance Owed', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mbts.balance_owed() )' + 'primary' : false, 'hidden' : false, 'render' : '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' : 'util.money.sanitize( my.mbts.total_owed() )' + 'primary' : false, 'hidden' : false, 'render' : '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' : 'util.money.sanitize( my.mbts.total_paid() )' + 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mbts.total_paid() )', + 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'last_billing_note', 'label' : 'Last Billing Note', 'flex' : 2, @@ -120,7 +123,8 @@ patron.util.mb_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : 'Amount', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mb.amount() )' + 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mb.amount() )', + 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'billing_type', 'label' : 'Type', 'flex' : 1, @@ -174,7 +178,8 @@ patron.util.mp_columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'amount', 'label' : 'Amount', 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mp.amount() )' + 'primary' : false, 'hidden' : false, 'render' : 'util.money.sanitize( my.mp.amount() )', + 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'payment_type', 'label' : 'Type', 'flex' : 1, @@ -271,7 +276,8 @@ patron.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'claims_returned_count', 'label' : 'Returns Claimed', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'my.au.claims_returned_count()' + 'primary' : false, 'hidden' : true, 'render' : 'my.au.claims_returned_count()', + 'sort_type' : 'number', }, { 'persist' : 'hidden width ordinal', 'id' : 'create_date', 'label' : 'Created On', 'flex' : 1, @@ -287,7 +293,8 @@ patron.util.columns = function(modify,params) { }, { 'persist' : 'hidden width ordinal', 'id' : 'credit_forward_balance', 'label' : 'Credit', 'flex' : 1, - 'primary' : false, 'hidden' : true, 'render' : 'my.au.credit_forward_balance()' + 'primary' : false, 'hidden' : true, 'render' : 'my.au.credit_forward_balance()', + 'sort_type' : 'money', }, { 'persist' : 'hidden width ordinal', 'id' : 'day_phone', 'label' : 'Day Phone', 'flex' : 1, -- 2.11.0