webstaff: teach eg-record-html how to initialize itself from MARCXML
authorGalen Charlton <gmc@esilibrary.com>
Mon, 27 Jul 2015 17:14:06 +0000 (17:14 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:19 +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/record.js

index 6f79a70..a67cb87 100644 (file)
@@ -1,7 +1,9 @@
 /**
- * Simple directive for rending the HTML view of a bib record.
+ * Simple directive for rending the HTML view of a MARC record.
  *
  * <eg-record-html record-id="myRecordIdScopeVariable"></eg-record-id>
+ * OR
+ * <eg-record-html marc-xml="myMarcXmlVariable"></eg-record-html>
  *
  * The value of myRecordIdScopeVariable is watched internally and the 
  * record is updated to match.
@@ -11,7 +13,10 @@ angular.module('egCoreMod')
 .directive('egRecordHtml', function() {
     return {
         restrict : 'AE',
-        scope : {recordId : '='},
+        scope : {
+            recordId : '=',
+            marcXml  : '@',
+        },
         link : function(scope, element, attrs) {
             scope.element = angular.element(element);
 
@@ -28,7 +33,9 @@ angular.module('egCoreMod')
                     egCore.net.request(
                         'open-ils.search',
                         'open-ils.search.biblio.record.html',
-                        $scope.recordId
+                        $scope.recordId,
+                        false,
+                        $scope.marcXml
                     ).then(function(html) {
                         if (!html) return;
 
@@ -54,7 +61,7 @@ angular.module('egCoreMod')
                     }
                 );
 
-                if ($scope.recordId) 
+                if ($scope.recordId || $scope.marcXml
                     loadRecordHtml();
             }
         ]