From: Victoria Lewis Date: Wed, 30 Apr 2014 22:09:07 +0000 (-0700) Subject: lp1182605 Abstracting out common functionality from code that sorts call numbers... X-Git-Tag: sprint4-merge-nov22~1944 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=59b0333ba7b4ea0cda0f35d5af4b1bc70d0a6e3a;p=working%2FEvergreen.git lp1182605 Abstracting out common functionality from code that sorts call numbers by label_sortkey Code had been added to insure that LC call numbers are sorting as they should by asset.call_number.label_sortkey. Code was duplicated in the 'call_number column' in the 'columns' group and in the 'hold_columns'group. I abstracted the logic out of 'sort_value' and 'render' in the 'call_number' column in the 'columns' group and from 'render' in the 'call_number' column in the 'hold_columns' group to a utility function called 'sort_call_numbers_by_label_sortkey'. Signed-off-by: Victoria Lewis modified: xul/staff_client/server/circ/util.js Signed-off-by: Kathy Lussier Signed-off-by: Remington Steed Signed-off-by: Dan Wells --- diff --git a/Open-ILS/xul/staff_client/server/circ/util.js b/Open-ILS/xul/staff_client/server/circ/util.js index 991b62c2bb..93a065dc48 100644 --- a/Open-ILS/xul/staff_client/server/circ/util.js +++ b/Open-ILS/xul/staff_client/server/circ/util.js @@ -566,93 +566,16 @@ circ.util.columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'sort_value' : function(my,scratch_data) { - var acn_id; - if (my.acn) { - if (typeof my.acn == 'object') { - acn_id = my.acn.id(); - } else { - acn_id = my.acn; - } - } else if (my.acp) { - if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) { - acn_id = my.acp.call_number().id(); - } else { - acn_id = my.acp.call_number(); - } - } - if (!acn_id && acn_id != 0) { - return ''; - } else if (acn_id == -1) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else if (acn_id == -2) { - return document.getElementById('circStrings').getString('staff.circ.utils.retrieving'); - } else { - if (!my.acn) { - if (typeof scratch_data == 'undefined' || scratch_data == null) { - scratch_data = {}; - } - if (typeof scratch_data['acn_map'] == 'undefined') { - scratch_data['acn_map'] = {}; - } - if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') { - var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]); - if (x.ilsevent) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else { - my.acn = x; - scratch_data['acn_map'][ acn_id ] = my.acn; - } - } else { - my.acn = scratch_data['acn_map'][ acn_id ]; - } - } - return my.acn.label_sortkey(); - } - }, + var result_label = "label_sortkey"; + return sort_call_numbers_by_label_sortkey(my, scratch_data, result_label); + }, + 'editable' : false, 'render' : function(my,scratch_data) { - var acn_id; - if (my.acn) { - if (typeof my.acn == 'object') { - acn_id = my.acn.id(); - } else { - acn_id = my.acn; - } - } else if (my.acp) { - if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) { - acn_id = my.acp.call_number().id(); - } else { - acn_id = my.acp.call_number(); - } - } - if (!acn_id && acn_id != 0) { - return ''; - } else if (acn_id == -1) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else if (acn_id == -2) { - return document.getElementById('circStrings').getString('staff.circ.utils.retrieving'); - } else { - if (!my.acn) { - if (typeof scratch_data == 'undefined' || scratch_data == null) { - scratch_data = {}; - } - if (typeof scratch_data['acn_map'] == 'undefined') { - scratch_data['acn_map'] = {}; - } - if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') { - var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]); - if (x.ilsevent) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else { - my.acn = x; - scratch_data['acn_map'][ acn_id ] = my.acn; - } - } else { - my.acn = scratch_data['acn_map'][ acn_id ]; - } - } - return my.acn.label(); - } - } + + var result_label = "render_label"; + return sort_call_numbers_by_label_sortkey(my, scratch_data, result_label); + } + }, { 'id' : 'owning_lib', @@ -2530,49 +2453,9 @@ circ.util.hold_columns = function(modify,params) { 'primary' : false, 'hidden' : true, 'editable' : false, 'render' : function(my,scratch_data) { - var acn_id; - if (my.acn) { - if (typeof my.acn == 'object') { - acn_id = my.acn.id(); - } else { - acn_id = my.acn; - } - } else if (my.acp) { - if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) { - acn_id = my.acp.call_number().id(); - } else { - acn_id = my.acp.call_number(); - } - } - if (!acn_id && acn_id != 0) { - return ''; - } else if (acn_id == -1) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else if (acn_id == -2) { - return document.getElementById('circStrings').getString('staff.circ.utils.retrieving'); - } else { - if (!my.acn) { - if (typeof scratch_data == 'undefined' || scratch_data == null) { - scratch_data = {}; - } - if (typeof scratch_data['acn_map'] == 'undefined') { - scratch_data['acn_map'] = {}; - } - if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') { - var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]); - if (x.ilsevent) { - return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); - } else { - my.acn = x; - scratch_data['acn_map'][ acn_id ] = my.acn; - } - } else { - my.acn = scratch_data['acn_map'][ acn_id ]; - } - } - return my.acn.label(); - } - } + var result_label = "render_label"; + return sort_call_numbers_by_label_sortkey(my, scratch_data, result_label); + } }, { 'id' : 'prefix', @@ -3968,4 +3851,57 @@ circ.util.find_acq_po = function(session, copy_id) { ); }; + +function sort_call_numbers_by_label_sortkey(my, scratch_data, result_label){ + var acn_id; + if (my.acn) { + if (typeof my.acn == 'object') { + acn_id = my.acn.id(); + } else { + acn_id = my.acn; + } + } else if (my.acp) { + if (typeof my.acp.call_number() == 'object' && my.acp.call_number() != null) { + acn_id = my.acp.call_number().id(); + } else { + acn_id = my.acp.call_number(); + } + } + if (!acn_id && acn_id != 0) { + return ''; + } else if (acn_id == -1) { + return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); + } else if (acn_id == -2) { + return document.getElementById('circStrings').getString('staff.circ.utils.retrieving'); + } else { + if (!my.acn) { + if (typeof scratch_data == 'undefined' || scratch_data == null) { + scratch_data = {}; + } + if (typeof scratch_data['acn_map'] == 'undefined') { + scratch_data['acn_map'] = {}; + } + if (typeof scratch_data['acn_map'][ acn_id ] == 'undefined') { + var x = network.simple_request("FM_ACN_RETRIEVE.authoritative",[ acn_id ]); + if (x.ilsevent) { + return document.getElementById('circStrings').getString('staff.circ.utils.not_cataloged'); + } else { + my.acn = x; + scratch_data['acn_map'][ acn_id ] = my.acn; + } + } else { + my.acn = scratch_data['acn_map'][ acn_id ]; + } + } + + if(result_label == "label_sortkey"){ + return my.acn.label_sortkey(); + } + else if(result_label == "render_label"){ + return my.acn.label(); + } + } + }; + + dump('exiting circ/util.js\n');