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)
79 * A record='foo' attribute is required as a storage location of the
82 .directive('egRecordSummary', function() {
90 templateUrl : './cat/share/t_record_summary',
93 function($scope , egCore) {
95 function loadRecord() {
96 egCore.pcrud.retrieve('bre', $scope.recordId, {
99 bre : ['simple_record','creator','editor']
101 }).then(function(rec) {
102 rec.owner(egCore.org.get(rec.owner()));
107 $scope.$watch('recordId',
108 function(newVal, oldVal) {
109 if (newVal && newVal !== oldVal) {
119 $scope.toggle_expand_summary = function() {
120 if ($scope.collapseRecordSummary) {
121 $scope.collapseRecordSummary = false;
122 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
124 $scope.collapseRecordSummary = true;
125 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
129 $scope.collapse_summary = function() {
130 return $scope.collapseRecordSummary;
133 egCore.hatch.getItem('eg.cat.record.summary.collapse')
134 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});