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() {
76 templateUrl : './cat/share/t_record_summary',
79 function($scope , egCore) {
81 function loadRecord() {
82 egCore.pcrud.retrieve('bre', $scope.recordId, {
85 bre : ['simple_record','creator','editor']
87 }).then(function(rec) {
88 rec.owner(egCore.org.get(rec.owner()));
93 $scope.$watch('recordId',
94 function(newVal, oldVal) {
95 if (newVal && newVal !== oldVal) {
105 $scope.toggle_expand_summary = function() {
106 if ($scope.collapseRecordSummary) {
107 $scope.collapseRecordSummary = false;
108 egCore.hatch.removeItem('eg.cat.record.summary.collapse');
110 $scope.collapseRecordSummary = true;
111 egCore.hatch.setItem('eg.cat.record.summary.collapse', true);
115 $scope.collapse_summary = function() {
116 return $scope.collapseRecordSummary;
119 egCore.hatch.getItem('eg.cat.record.summary.collapse')
120 .then(function(val) {$scope.collapseRecordSummary = Boolean(val)});