From: Bill Erickson Date: Mon, 7 Sep 2015 15:23:48 +0000 (-0400) Subject: webstaff: Phys Char Wiz : initial service funcs X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=da57d6c3ddd4c1992de290a7812771dec2be351b;p=evergreen%2Fmasslnc.git webstaff: Phys Char Wiz : initial service funcs Signed-off-by: Bill Erickson Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js index 6c3e10c1dd..932794e1ea 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js @@ -14,6 +14,9 @@ function($q, egCore, egAuth) { fields : { }, ff_pos_map : { }, ff_value_map : { }, + phys_char_type_map : null, + phys_char_sf_map : { }, + phys_char_value_map : { }, authority_control_set : { _remote_loaded : false, _controlsets : [ ] @@ -499,5 +502,50 @@ function($q, egCore, egAuth) { return service._active_control_set; } + // fetches and caches the full set of values from + // config.marc21_physical_characteristic_type_map + service.getPhysCharTypeMap = function() { + + if (service.phys_char_type_map) { + return $q.when(service.phys_char_type_map); + } + + return egCore.pcrud.retrieveAll('cmpctm') + .then(function(map) {service.phys_char_type_map = map}); + } + + // Fetch+caches the config.marc21_physical_characteristic_subfield_map + // values for the requested ptype_key (i.e. type_map.ptype_key). + // Values are sorted by start_pos + service.getPhysCharSubfieldMap = function(ptype_key) { + + if (service.phys_char_sf_map[ptype_key]) { + return $q.when(service.phys_char_sf_map[ptype_key]); + } + + return egCore.pcrud.search('cmpcsm', + {ptype_key : ptype_key}, + {order_by : {cmpcsm : ['start_pos']}}) + .then(function(maps) { + service.phys_char_sf_map[ptype_key] = maps; + }); + } + + // Fetches + caches the config.marc21_physical_characteristic_value_map + // for the requested ptype_subfield (subfield_map.id). + // Maps are ordered by value. + serivice.getPhysCharValueMap = function(ptype_subfield) { + if (service.phys_char_value_map[ptype_subfield]) { + return $q.when(service.phys_char_value_map[ptype_subfield]); + } + + return egCore.pcrud.search('cmpcvm', + {ptype_subfield : ptype_subfield}, + {order_by : {cmpcsm : ['value']}}) + .then(function(maps) { + service.phys_char_sf_map[ptype_subfield] = maps; + }); + } + return service; }]);