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 : ['creator','editor']
155 }).then(function(rec) {
156 rec.owner(egCore.org.get(rec.owner()));
161 'open-ils.search.biblio.record.mods_slim.retrieve.authoritative',
163 ).then(function(mvr) {
166 $scope.bib_cn = null;
167 $scope.bib_cn_tooltip = '';
168 var label_class = egCore.env.aous['cat.default_classification_scheme'] || 1;
171 'open-ils.cat.biblio.record.marc_cn.retrieve',
174 ).then(function(cn_array) {
176 if (cn_array.length > 0) {
177 for (var field in cn_array[0]) {
178 $scope.bib_cn = cn_array[0][field];
180 for (var i in cn_array) {
181 for (var field in cn_array[i]) {
183 field + ' : ' + cn_array[i][field] + '<br>';
186 $scope.bib_cn_tooltip = $sce.trustAsHtml(tooltip);
191 $scope.$watch('recordId',
192 function(newVal, oldVal) {
193 if (newVal && newVal !== oldVal) {
203 $scope.toggle_expand_summary = function() {
204 if ($scope.collapseRecordSummary) {
205 $scope.collapseRecordSummary = false;
206 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
208 $scope.collapseRecordSummary = true;
209 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
213 $scope.collapse_summary = function() {
214 return $scope.collapseRecordSummary;
217 egCore.hatch.getItem('eg.cat.record.summary.collapse')
218 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});