webstaff: Phys Char Wiz : initial service funcs
authorBill Erickson <berickxx@gmail.com>
Mon, 7 Sep 2015 15:23:48 +0000 (11:23 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:21 +0000 (15:44 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js

index 6c3e10c..932794e 100644 (file)
@@ -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;
 }]);