2 * Simple directive for rending the HTML view of a bib record.
4 * <eg-record-html record-id="myRecordIdScopeVariable"></eg-record-id>
6 * The value of myRecordIdScopeVariable is watched internally and the
7 * record is updated to match.
9 angular.module('egCoreMod')
11 .directive('egRecordHtml', function() {
14 scope : {recordId : '='},
15 link : function(scope, element, attrs) {
16 scope.element = angular.element(element);
18 // kill refs to destroyed DOM elements
19 element.bind("$destroy", function() {
25 function($scope , egCore) {
27 function loadRecordHtml() {
30 'open-ils.search.biblio.record.html',
32 ).then(function(html) {
35 // Remove those pesky non-i8n labels / actions.
36 // Note: for printing, use the browser print page
37 // option. The end result is the same.
39 /<button onclick="window.print(.*?)<\/button>/,'');
40 html = html.replace(/<title>(.*?)<\/title>/,'');
42 // remove reference to nonexistant CSS file
43 html = html.replace(/<link(.*?)\/>/,'');
45 $scope.element.html(html);
49 $scope.$watch('recordId',
50 function(newVal, oldVal) {
51 if (newVal && newVal !== oldVal) {
65 * A record='foo' attribute is required as a storage location of the
68 .directive('egRecordSummary', function() {
75 templateUrl : './cat/share/t_record_summary',
78 function($scope , egCore) {
80 function loadRecord() {
81 egCore.pcrud.retrieve('bre', $scope.recordId, {
84 bre : ['simple_record','creator','editor']
86 }).then(function(rec) {
87 rec.owner(egCore.org.get(rec.owner()));
92 $scope.$watch('recordId',
93 function(newVal, oldVal) {
94 if (newVal && newVal !== oldVal) {
104 $scope.toggle_expand_summary = function() {
105 if ($scope.collapseRecordSummary) {
106 $scope.collapseRecordSummary = false;
107 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
109 $scope.collapseRecordSummary = true;
110 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
114 $scope.collapse_summary = function() {
115 return $scope.collapseRecordSummary;
118 egCore.hatch.getItem('eg.cat.record.summary.collapse')
119 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});