From 89154f8c6d7714ab937b2c5312e7995db7f22c43 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Mon, 13 Apr 2015 17:16:57 +0000 Subject: [PATCH] webstaff: teach MARC editor how to build context menus for subfield values Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../js/ui/default/staff/cat/services/marcedit.js | 4 ++++ .../js/ui/default/staff/cat/services/tagtable.js | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js index 9a364eab08..aad3d007b5 100644 --- a/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js +++ b/Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js @@ -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" '+ '/>'+ '', @@ -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]); + } } ] } 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 74b11c44ce..f4d5e973f2 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 @@ -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; -- 2.11.0