webstaff: teach MARC editor how to build context menus for subfield values
authorGalen Charlton <gmc@esilibrary.com>
Mon, 13 Apr 2015 17:16:57 +0000 (17:16 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:16 +0000 (13:39 -0400)
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/marcedit.js
Open-ILS/web/js/ui/default/staff/cat/services/tagtable.js

index 9a364ea..aad3d00 100644 (file)
@@ -284,6 +284,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         'subfield="subfield" '+
                         'content="subfield[1]" '+
                         'on-keydown="onKeydown" '+
+                        'context-item-generator="sf_val_options" '+
                         'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}s{{subfield[2]}}value" '+
                     '/></span>'+
                   '</span>',
@@ -295,6 +296,9 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                 $scope.sf_code_options = function () {
                     return egTagTable.getSubfieldCodes($scope.field.tag);
                 }
+                $scope.sf_val_options = function () {
+                    return egTagTable.getSubfieldValues($scope.field.tag, $scope.subfield[0]);
+                }
             }
         ]
     }
index 74b11c4..f4d5e97 100644 (file)
@@ -145,6 +145,27 @@ function($q,   egCore,   egAuth) {
         return list;
     }
 
+    service.getSubfieldValues = function(tag, sf_code) {
+        var list = [];
+        if (!tag) return list;
+        if (!service.fields[tag]) return;
+        if (!service.fields[tag]) return;
+        angular.forEach(service.fields[tag].subfields, function(sf) {
+            if (sf.code == sf_code && sf.hasOwnProperty('value_list')) {
+                angular.forEach(sf.value_list, function(value) {
+                    var label = (value.code == value.description) ?
+                                value.code :
+                                value.code + ': ' + value.description;
+                    this.push({
+                        value: value.code,
+                        label: label
+                    });
+                }, this);
+            }
+        }, list);
+        return list;
+    }
+
     service.getIndicatorValues = function(tag, pos) {
         var list = [];
         if (!tag) return list;