2 * Simple directive for rending the HTML view of a MARC record.
4 * <eg-record-html record-id="myRecordIdScopeVariable"></eg-record-id>
6 * <eg-record-html marc-xml="myMarcXmlVariable"></eg-record-html>
8 * The value of myRecordIdScopeVariable is watched internally and the
9 * record is updated to match.
11 angular.module('egCoreMod')
13 .directive('egRecordHtml', function() {
20 link : function(scope, element, attrs) {
21 scope.element = angular.element(element);
23 // kill refs to destroyed DOM elements
24 element.bind("$destroy", function() {
30 function($scope , egCore) {
32 function loadRecordHtml() {
35 'open-ils.search.biblio.record.html',
39 ).then(function(html) {
42 // Remove those pesky non-i8n labels / actions.
43 // Note: for printing, use the browser print page
44 // option. The end result is the same.
46 /<button onclick="window.print(.*?)<\/button>/,'');
47 html = html.replace(/<title>(.*?)<\/title>/,'');
49 // remove reference to nonexistant CSS file
50 html = html.replace(/<link(.*?)\/>/,'');
52 $scope.element.html(html);
56 $scope.$watch('recordId',
57 function(newVal, oldVal) {
58 if (newVal && newVal !== oldVal) {
63 $scope.$watch('marcXml',
64 function(newVal, oldVal) {
65 if (newVal && newVal !== oldVal) {
71 if ($scope.recordId || $scope.marcXml)
78 .directive('egRecordBreaker', function() {
81 template : '<pre>{{breaker}}</pre>',
86 link : function(scope, element, attrs) {
87 scope.element = angular.element(element);
89 // kill refs to destroyed DOM elements
90 element.bind("$destroy", function() {
96 function($scope , egCore) {
98 function loadRecordBreaker() {
100 if ($scope.marcXml) {
101 $scope.breaker = new MARC21.Record({ marcxml : $scope.marcXml }).toBreaker();
103 egCore.pcrud.retrieve('bre', $scope.recordId)
104 .then(function(rec) {
105 $scope.breaker = new MARC21.Record({ marcxml : rec.marc() }).toBreaker();
110 $scope.$watch('recordId',
111 function(newVal, oldVal) {
112 if (newVal && newVal !== oldVal) {
117 $scope.$watch('marcXml',
118 function(newVal, oldVal) {
119 if (newVal && newVal !== oldVal) {
125 if ($scope.recordId || $scope.marcXml)
133 * A record='foo' attribute is required as a storage location of the
136 .directive('egRecordSummary', function() {
144 templateUrl : './cat/share/t_record_summary',
146 ['$scope','egCore','$sce',
147 function($scope , egCore , $sce) {
149 function loadRecord() {
150 egCore.pcrud.retrieve('bre', $scope.recordId, {
153 bre : ['simple_record','creator','editor']
155 }).then(function(rec) {
156 rec.owner(egCore.org.get(rec.owner()));
159 $scope.bib_cn = null;
160 $scope.bib_cn_tooltip = '';
161 var label_class = egCore.env.aous['cat.default_classification_scheme'] || 1;
164 'open-ils.cat.biblio.record.marc_cn.retrieve',
167 ).then(function(cn_array) {
169 if (cn_array.length > 0) {
170 for (var field in cn_array[0]) {
171 $scope.bib_cn = cn_array[0][field];
173 for (var i in cn_array) {
174 for (var field in cn_array[i]) {
176 field + ' : ' + cn_array[i][field] + '<br>';
179 $scope.bib_cn_tooltip = $sce.trustAsHtml(tooltip);
184 $scope.$watch('recordId',
185 function(newVal, oldVal) {
186 if (newVal && newVal !== oldVal) {
196 $scope.toggle_expand_summary = function() {
197 if ($scope.collapseRecordSummary) {
198 $scope.collapseRecordSummary = false;
199 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
201 $scope.collapseRecordSummary = true;
202 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
206 $scope.collapse_summary = function() {
207 return $scope.collapseRecordSummary;
210 egCore.hatch.getItem('eg.cat.record.summary.collapse')
211 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});