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) {
64 if ($scope.recordId || $scope.marcXml)
72 * A record='foo' attribute is required as a storage location of the
75 .directive('egRecordSummary', function() {
83 templateUrl : './cat/share/t_record_summary',
86 function($scope , egCore) {
88 function loadRecord() {
89 egCore.pcrud.retrieve('bre', $scope.recordId, {
92 bre : ['simple_record','creator','editor']
94 }).then(function(rec) {
95 rec.owner(egCore.org.get(rec.owner()));
100 $scope.$watch('recordId',
101 function(newVal, oldVal) {
102 if (newVal && newVal !== oldVal) {
112 $scope.toggle_expand_summary = function() {
113 if ($scope.collapseRecordSummary) {
114 $scope.collapseRecordSummary = false;
115 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
117 $scope.collapseRecordSummary = true;
118 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
122 $scope.collapse_summary = function() {
123 return $scope.collapseRecordSummary;
126 egCore.hatch.getItem('eg.cat.record.summary.collapse')
127 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});