From 208ac82a84dae508952183e58e394cf877bf1b46 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Sep 2015 20:26:24 +0000 Subject: [PATCH] webstaff: add Validate (headings) button to MARC editor Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- .../src/templates/staff/cat/share/t_marcedit.tt2 | 3 ++ Open-ILS/src/templates/staff/css/cat.css.tt2 | 4 +++ .../js/ui/default/staff/cat/services/marcedit.js | 38 +++++++++++++++++++++- .../js/ui/default/staff/cat/services/tagtable.js | 10 ------ 4 files changed, 44 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 index f4503167af..eef0f6a336 100644 --- a/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 +++ b/Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2 @@ -18,6 +18,9 @@
+ +
+
diff --git a/Open-ILS/src/templates/staff/css/cat.css.tt2 b/Open-ILS/src/templates/staff/css/cat.css.tt2 index fcd98bdfaf..f3f27d214d 100644 --- a/Open-ILS/src/templates/staff/css/cat.css.tt2 +++ b/Open-ILS/src/templates/staff/css/cat.css.tt2 @@ -43,6 +43,10 @@ input.marcedit:focus { border-right: 0px !important; } +.unvalidatedheading { + color: red; +} + .marctag, .marcind { text-align: center; } 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 ca161f546a..9d11cd72a8 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 @@ -363,7 +363,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) ''+ ''+ ''+ - ''+ + ''+ // FIXME: template should probably be moved to file to improve // translatibility ''+ + ''+ + ''+ '
', scope: { field: "=", onKeydown: '=' }, replace: true, @@ -991,6 +993,40 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap']) return $scope.saveRecord(); }; + $scope.validateHeadings = function () { + if ($scope.record_type != 'bre') return; + angular.forEach($scope.record.fields, function(f) { + if (!$scope.controlSet.bibFieldByTag(f.tag)) return; + // if heading already has a $0, assume it's good + if (f.subfield('0', true).length) { + f.heading_checked = true; + f.heading_valid = true; + return; + } + var auth_match = $scope.controlSet.bibToAuthorities(f); + egCore.net.request( + 'open-ils.search', + 'open-ils.search.authority.simple_heading.from_xml.batch.atomic', + auth_match[0] + ).then(function (matches) { + f.heading_valid = false; + if (matches[0]) { // probably set + for (var cset in matches[0]) { + var arr = matches[0][cset]; + if (arr.length) { + // protect against errant empty string values + if (arr.length == 1 && arr[0] == '') + continue; + f.heading_valid = true; + break; + } + } + } + f.heading_checked = true; + }); + }); + } + $scope.saveRecord = function () { if ($scope.inPlaceMode) { $scope.marcXml = $scope.record.toXmlString(); 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 1580ca53b6..6c3e10c1dd 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 @@ -489,16 +489,6 @@ function($q, egCore, egAuth) { return auth_list; } - // This should not be used in an angular world. Instead, the call - // to open-ils.search.authority.simple_heading.from_xml.batch.atomic should - // be performed by the code that wants to find matching authorities. - this.findMatchingAuthorities = function (field) { - return fieldmapper.standardRequest( - [ 'open-ils.search', 'open-ils.search.authority.simple_heading.from_xml.batch.atomic' ], - this.bibToAuthorities(field) - ); - } - } service.getAuthorityControlSet = function() { -- 2.11.0