5 angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
7 .directive("egContextMenuItem", ['$timeout',function ($timeout) {
11 template: '<li><a ng-click="setContent(item.value,item.action)">{{item.label}}</a></li>',
12 scope: { item: '=', content: '=', contextMenuEvent: '=' },
13 controller: ['$scope','$element',
14 function ($scope , $element) {
15 if (!$scope.item.label) $scope.item.label = $scope.item.value;
16 if ($scope.item.divider) {
17 $element.css('borderTop','solid 1px');
20 $scope.setContent = function (v, a) {
28 $scope.$parent.$parent.content,
29 $scope.contextMenuEvent
33 if (typeof replace_with !== 'undefined') {
35 $scope.$parent.$parent.$apply(function(){
36 $scope.$parent.$parent.content = replace_with
40 $($element).parent().css({display: 'none'});
47 .directive("egMarcEditEditable", ['$timeout', '$compile', '$document', function ($timeout, $compile, $document) {
52 'style="font-family: \'Lucida Console\', Monaco, monospace;" '+
53 'ng-model="content" '+
54 'size="{{content.length * 1.1}}" '+
55 'maxlength="{{max}}" '+
64 contextItemContainer: '@',
65 contextItemGenerator: '=',
70 controller : ['$scope',
73 if ($scope.contextItemContainer && angular.isArray($scope.$parent[$scope.contextItemContainer]))
74 $scope.item_container = $scope.$parent[$scope.contextItemContainer];
75 else if ($scope.contextItemGenerator)
76 $scope.item_generator = $scope.contextItemGenerator;
78 $scope.showContext = function (event) {
79 $scope.item_list = [];
80 if ($scope.item_container) {
81 $scope.item_list = $scope.item_container;
82 } else if ($scope.item_generator) {
83 // always recalculate; tag and/or subfield
84 // codes may have changed
86 var generator = $scope.item_generator;
87 if (!angular.isArray(generator)) generator = [generator];
90 angular.forEach(generator, function (g) {
95 else if (Boolean(sub_list[0]))
96 sub_list[0].divider = true;
98 $scope.item_list = $scope.item_list.concat(sub_list);
105 if (angular.isArray($scope.item_list) && $scope.item_list.length > 0) { // we have a list of values or transforms
106 console.log('Showing context menu...');
107 $('body').trigger('click');
109 $scope.contextMenuEvent = event;
111 '<ul class="dropdown-menu scrollable-menu" role="menu" style="z-index: 2000;">'+
112 '<eg-context-menu-item context-menu-event="contextMenuEvent" ng-repeat="item in item_list" item="item" content="content"/>'+
115 var tnode = angular.element(tmpl);
116 $document.find('body').append(tnode);
124 $timeout(function() {
125 var e = $compile(tnode)($scope);
129 $('body').on('click.context_menu',function() {
130 $(tnode).css('display','none');
131 $('body').off('click.context_menu');
142 link: function (scope, element, attrs) {
144 if (scope.onKeydown) element.bind('keydown', {scope : scope}, scope.onKeydown);
146 if (Boolean(scope.selectOnFocus)) {
147 element.addClass('noSelection');
148 element.bind('focus', function () { element.select() });
151 element.bind('change', function (e) { element.size = scope.max || parseInt(scope.content.length * 1.1) });
153 element.bind('contextmenu', {scope : scope}, scope.showContext);
158 .directive("egMarcEditFixedField", ['$timeout', '$compile', '$document', function ($timeout, $compile, $document) {
162 template: '<div class="col-md-2">'+
163 '<div class="col-md-1"><label name="{{fixedField}}" for="{{fixedField}}_ff_input">{{fixedField}}</label></div>'+
164 '<div class="col-md-1"><input type="text" style="padding-left: 5px; margin-left: 1em" size="4" id="{{fixedField}}_ff_input"/></div>'+
166 scope: { record: "=", fixedField: "@" },
168 controller : ['$scope', '$element', 'egTagTable',
169 function ( $scope , $element , egTagTable) {
170 $($element).children().css({ display : 'none' });
172 $scope.content = null; // this is where context menus dump their values
173 $scope.item_container = [];
174 $scope.in_handler = false;
175 $scope.ready = false;
177 $scope.$watch('content', function (newVal, oldVal) {
178 var input = $($element).find('input');
180 input.trigger('keyup'); // cascade the update
183 $scope.$watch('record.ready', function (newVal, oldVal) { // wait for the record to be loaded
184 if (newVal && !$scope.ready) {
185 $scope.rtype = $scope.record.recordType();
187 egTagTable.fetchFFPosTable( $scope.rtype ).then(function (ff_list) {
188 angular.forEach(ff_list, function (ff) {
190 if (ff.fixed_field == $scope.fixedField && ff.rec_type == $scope.rtype) {
193 $($element).children().css({ display : 'inline' });
195 var input = $($element).find('input');
196 input.attr('maxlength', $scope.me.length);
197 input.val($scope.record.extractFixedField($scope.me.fixed_field));
198 input.on('keyup', function(e) {
199 $scope.in_handler = true;
200 $scope.record.setFixedField($scope.me.fixed_field, input.val());
201 try { $scope.$parent.$digest(); } catch(e) {};
207 }).then(function (me) {
211 return $scope.record.extractFixedField($scope.fixedField);
213 function (newVal, oldVal) {
214 if ($scope.in_handler) {
215 $scope.in_handler = false;
216 } else if (oldVal != newVal) {
217 $($element).find('input').val(newVal);
222 }).then(function () {
223 return egTagTable.fetchFFValueTable( $scope.rtype );
224 }).then(function (vlist) {
225 if (vlist[$scope.fixedField]) {
226 vlist[$scope.fixedField].forEach(function (v) {
227 if (v[0].length <= v[2]) {
228 $scope.item_container.push({ value : v[0], label : v[0] + ': ' + v[1] });
232 }).then(function () {
233 if ($scope.item_container && $scope.item_container.length)
234 $($element).bind('contextmenu', $scope.showContext);
240 $scope.showContext = function (event) {
241 if ($scope.context_menu_element) {
242 console.log('Reshowing context menu...');
243 $('body').trigger('click');
244 $($scope.context_menu_element).css({ display: 'block', top: event.pageY, left: event.pageX });
245 $('body').on('click.context_menu',function() {
246 $($scope.context_menu_element).css('display','none');
247 $('body').off('click.context_menu');
252 if (angular.isArray($scope.item_container)) { // we have a list of values or transforms
253 console.log('Showing context menu...');
254 $('body').trigger('click');
257 '<ul class="dropdown-menu scrollable-menu" role="menu" style="z-index: 2000;">'+
258 '<eg-context-menu-item ng-repeat="item in item_container" item="item" content="content"/>'+
261 var tnode = angular.element(tmpl);
262 $document.find('body').append(tnode);
270 $scope.context_menu_element = tnode;
272 $timeout(function() {
273 var e = $compile(tnode)($scope);
277 $('body').on('click.context_menu',function() {
278 $(tnode).css('display','none');
279 $('body').off('click.context_menu');
293 .directive("egMarcEditSubfield", function () {
298 '<span><label class="marcedit marcsfcodedelimiter"'+
299 'for="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}s{{subfield[2]}}code" '+
300 '>‡</label><eg-marc-edit-editable '+
302 'select-on-focus="true" '+
303 'class="marcedit marcsf marcsfcode" '+
305 'subfield="subfield" '+
306 'content="subfield[0]" '+
308 'on-keydown="onKeydown" '+
309 'context-item-generator="sf_code_options" '+
310 'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}s{{subfield[2]}}code" '+
312 '<span><eg-marc-edit-editable '+
314 'class="marcedit marcsf marcsfvalue" '+
316 'subfield="subfield" '+
317 'content="subfield[1]" '+
318 'on-keydown="onKeydown" '+
319 'context-item-generator="sf_val_options" '+
320 'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}s{{subfield[2]}}value" '+
323 scope: { field: "=", subfield: "=", onKeydown: '=' },
325 controller : ['$scope', 'egTagTable',
326 function ( $scope , egTagTable) {
328 $scope.sf_code_options = function () {
329 return egTagTable.getSubfieldCodes($scope.field.tag);
331 $scope.sf_val_options = function () {
332 return egTagTable.getSubfieldValues($scope.field.tag, $scope.subfield[0]);
339 .directive("egMarcEditInd", function () {
343 template: '<span><eg-marc-edit-editable '+
345 'class="marcedit marcind" '+
346 'select-on-focus="true" '+
350 'on-keydown="onKeydown" '+
351 'context-item-generator="ind_val_options" '+
352 'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}i{{indNumber}}"'+
354 scope: { ind : '=', field: '=', onKeydown: '=', indNumber: '@' },
356 controller : ['$scope', 'egTagTable',
357 function ( $scope , egTagTable) {
359 $scope.ind_val_options = function () {
360 return egTagTable.getIndicatorValues($scope.field.tag, $scope.indNumber);
367 .directive("egMarcEditTag", function () {
371 template: '<span><eg-marc-edit-editable '+
373 'class="marcedit marctag" '+
374 'select-on-focus="true" '+
378 'on-keydown="onKeydown" '+
379 'context-item-generator="tag_options" '+
380 'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}tag"'+
382 scope: { tag : '=', field: '=', onKeydown: '=', contextFunctions: '=' },
384 controller : ['$scope', 'egTagTable', 'egCore',
385 function ( $scope , egTagTable, egCore) {
387 $scope.tag_options = [
390 { label : egCore.strings.ADD_006, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.add006(e) } },
391 { label : egCore.strings.ADD_007, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.add007(e) } },
392 { label : egCore.strings.ADD_REPLACE_008, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.reify008(e) } },
395 if (!$scope.field.isControlfield()) {
396 options = options.concat([
397 { label : egCore.strings.INSERT_FIELD_AFTER, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e) } },
398 { label : egCore.strings.INSERT_FIELD_BEFORE, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e,true) } },
402 options.push({ label : egCore.strings.DELETE_FIELD, action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.deleteDatafield(e) } });
405 function () { return egTagTable.getFieldTags() }
413 .directive("egMarcEditDatafield", function () {
418 '<span><eg-marc-edit-tag context-functions="contextFunctions" field="field" tag="field.tag" on-keydown="onKeydown"/></span>'+
419 '<span><eg-marc-edit-ind field="field" ind="field.ind1" on-keydown="onKeydown" ind-number="1"/></span>'+
420 '<span><eg-marc-edit-ind field="field" ind="field.ind2" on-keydown="onKeydown" ind-number="2"/></span>'+
421 '<span><eg-marc-edit-subfield ng-class="{ \'unvalidatedheading\' : field.heading_checked && !field.heading_valid, \'marcedit_stacked_subfield\' : stackSubfields.enabled }" ng-repeat="subfield in field.subfields" subfield="subfield" field="field" on-keydown="onKeydown"/></span>'+
422 // FIXME: template should probably be moved to file to improve
424 '<span ng-class="{ \'marcedit_stacked_subfield\' : stackSubfields.enabled }">' +
425 '<button class="btn btn-info btn-xs" '+
426 'aria-label="Manage authority record links" '+
427 'ng-show="isAuthorityControlled(field)"'+
428 'ng-click="spawnAuthorityLinker()"'+
430 '<span class="glyphicon glyphicon-link"></span>'+
432 '<span ng-show="field.heading_checked && field.heading_valid" class="glyphicon glyphicon-ok-sign"></span>'+
433 '<span ng-show="field.heading_checked && !field.heading_valid" class="glyphicon glyphicon-question-sign"></span>'+
436 scope: { field: "=", onKeydown: '=', contextFunctions: '=' },
438 controller : ['$scope','$modal',
439 function ( $scope, $modal ) {
440 $scope.stackSubfields = $scope.$parent.$parent.stackSubfields;
441 $scope.isAuthorityControlled = function () {
442 return ($scope.$parent.$parent.record_type == 'bre') &&
443 $scope.$parent.$parent.controlSet.bibFieldByTag($scope.field.tag);
445 $scope.spawnAuthorityLinker = function() {
446 // intentionally making a clone in case
447 // user decides to abandon the linking
448 var fieldCopy = new MARC21.Field({
449 tag : $scope.field.tag,
450 ind1 : $scope.field.ind1,
451 ind2 : $scope.field.ind2
453 angular.forEach($scope.field.subfields, function(sf) {
454 fieldCopy.subfields.push(sf.slice(0));
456 var cs = $scope.$parent.$parent.controlSet;
457 var args = { changed : false };
459 templateUrl: './cat/share/t_authority_link_dialog',
461 controller: ['$scope', '$modalInstance', function($scope, $modalInstance) {
462 $scope.controlSet = cs;
463 $scope.bibField = fieldCopy;
464 $scope.focusMe = true;
466 $scope.ok = function(args) { $modalInstance.close(args) };
467 $scope.cancel = function () { $modalInstance.dismiss() };
469 }).result.then(function (args) {
471 $scope.field.subfields.length = 0;
472 angular.forEach(fieldCopy.subfields, function(sf) {
473 $scope.field.addSubfields(sf[0], sf[1]);
483 .directive("egMarcEditControlfield", function () {
488 '<span><eg-marc-edit-tag context-functions="contextFunctions" field="field" tag="field.tag" on-keydown="onKeydown"/></span>'+
489 '<span><eg-marc-edit-editable '+
492 'class="marcedit marcdata" '+
493 'content="field.data" '+
494 'on-keydown="onKeydown" '+
495 'id="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}data"'+
497 // TODO: move to TT2 template
498 '<button class="btn btn-info btn-xs" '+
499 'aria-label="Physical Characteristics Wizard" '+
500 'ng-show="showPhysCharLink()"'+
501 'ng-click="spawnPhysCharWizard()"'+
503 '<span class="glyphicon glyphicon-link"></span>'+
506 scope: { field: "=", onKeydown: '=', contextFunctions: '=' },
507 controller : ['$scope','$modal',
508 function ( $scope, $modal) {
509 $scope.showPhysCharLink = function () {
510 return ($scope.$parent.$parent.record_type == 'bre')
511 && $scope.field.tag == '007';
513 $scope.spawnPhysCharWizard = function() {
516 field : $scope.field,
517 orig_value : $scope.field.data
520 templateUrl: './cat/share/t_physchar_dialog',
521 controller: ['$scope','$modalInstance',
522 function( $scope , $modalInstance) {
523 $scope.focusMe = true;
525 $scope.ok = function(args) { $modalInstance.close(args) };
526 $scope.cancel = function () {
527 $modalInstance.dismiss();
528 args.field.data = args.orig_value;
531 }).result.then(function (args) {
532 // $scope.field.data is changed within the
533 // wizard. Nothing left to do on submit.
542 .directive("egMarcEditLeader", function () {
547 '<span><eg-marc-edit-editable '+
548 'class="marcedit marctag" '+
550 'on-keydown="onKeydown" '+
552 'disabled="disabled"'+
554 '<span><eg-marc-edit-editable '+
555 'class="marcedit marcdata" '+
557 'max="{{record.leader.length}}" '+
558 'content="record.leader" '+
559 'id="r{{record.subfield(\'901\',\'c\')[1]}}leaderdata" '+
560 'on-keydown="onKeydown"'+
563 controller : ['$scope',
564 function ( $scope ) {
568 scope: { record: "=", onKeydown: '=' }
572 /// TODO: fixed field editor and such
573 .directive("egMarcEditRecord", function () {
575 templateUrl : './cat/share/t_marcedit',
583 // in-place mode means that the editor is being
584 // used just to munge some MARCXML client-side, rather
585 // than to (immediately) update the database
593 link: function (scope, element, attrs) {
595 element.bind('mouseup', function(e) {;
596 scope.current_event_target = $(e.target).attr('id');
597 if (scope.current_event_target && $(e.target).hasClass('noSelection')) {
603 element.bind('click', function(e) {;
604 scope.current_event_target = $(e.target).attr('id');
605 if (scope.current_event_target) {
606 console.log('Recording click event on ' + scope.current_event_target);
607 scope.current_event_target_cursor_pos =
608 e.target.selectionDirection=='backward' ?
609 e.target.selectionStart :
610 e.target.selectionEnd;
615 controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable',
616 function ( $timeout , $scope , $q, $window , egCore , egTagTable ) {
619 $scope.onSaveCallback = $scope.onSave;
620 if (typeof $scope.onSaveCallback !== 'undefined' && !angular.isArray($scope.onSaveCallback))
621 $scope.onSaveCallback = [ $scope.onSaveCallback ];
623 MARC21.Record.delimiter = '$';
625 $scope.enable_fast_add = false;
626 $scope.fast_item_callnumber = '';
627 $scope.fast_item_barcode = '';
628 $scope.flatEditor = $scope.flatOnly ? true : false;
629 $scope.brandNewRecord = false;
630 $scope.bib_source = null;
631 $scope.record_type = $scope.recordType || 'bre';
632 $scope.max_undo = $scope.maxUndo || 100;
633 $scope.record_undo_stack = [];
634 $scope.record_redo_stack = [];
635 $scope.in_undo = false;
636 $scope.in_redo = false;
637 $scope.record = new MARC21.Record();
638 $scope.save_stack_depth = 0;
639 $scope.controlfields = [];
640 $scope.datafields = [];
641 $scope.controlSet = egTagTable.getAuthorityControlSet();
642 $scope.stackSubfields = { enabled : false };
643 egCore.hatch.getItem('cat.marcedit.stack_subfields').then(function(val) {
644 $scope.stackSubfields.enabled = val;
646 $scope.$watch('stackSubfields.enabled', function (newVal, oldVal) {
647 if (newVal != oldVal) egCore.hatch.setItem('cat.marcedit.stack_subfields', newVal);
650 egTagTable.loadTagTable({ marcRecordType : $scope.record_type });
652 $scope.saveFlatTextMARC = function () {
653 $scope.record = new MARC21.Record({ marcbreaker : $scope.flat_text_marc });
656 $scope.refreshVisual = function () {
657 if (!$scope.flatEditor) {
658 $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
659 $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
663 var addDatafield = function (e,before) {
664 var element = $(e.target);
666 var index_field = e.data.scope.field.position;
667 var new_field_index = index_field;
669 var new_field = new MARC21.Field({
671 subfields : [[' ','',0]]
674 if (Boolean(before)) {
675 e.data.scope.field.record.insertFieldsBefore(
680 e.data.scope.field.record.insertFieldsAfter(
687 $scope.current_event_target = 'r' + $scope.recordId +
688 'f' + new_field_index + 'tag';
690 $scope.current_event_target_cursor_pos = 0;
691 $scope.current_event_target_cursor_pos_end = 3;
692 $scope.force_render = true;
694 $timeout(function(){$scope.$digest()}).then(setCaret);
697 var deleteDatafield = function (e) {
698 var del_field = e.data.scope.field.position;
700 var sf901c = e.data.scope.field.record.subfield('901','c');
701 var recId = (sf901c === null) ? '' : sf901c[1];
702 var domnode = $('#r' + recId + 'f' + del_field);
704 e.data.scope.field.record.deleteFields(
708 domnode.scope().$destroy();
711 $scope.current_event_target = 'r' + $scope.recordId +
712 'f' + del_field + 'tag';
714 $scope.current_event_target_cursor_pos = 0;
715 $scope.current_event_target_cursor_pos_end = 0
716 $scope.force_render = true;
718 $timeout(function(){$scope.$digest()}).then(setCaret);
721 var add006 = function (e) {
722 e.data.scope.field.record.insertOrderedFields(
729 $scope.force_render = true;
730 $timeout(function(){$scope.$digest()}).then(setCaret);
733 var add007 = function (e) {
734 e.data.scope.field.record.insertOrderedFields(
741 $scope.force_render = true;
742 $timeout(function(){$scope.$digest()}).then(setCaret);
745 var reify008 = function (e) {
746 var new_008_data = e.data.scope.field.record.generate008();
749 var old_008s = e.data.scope.field.record.field('008',true);
750 old_008s.forEach(function(o) {
751 var domnode = $('#r'+o.record.subfield('901','c')[1] + 'f' + o.position);
752 domnode.scope().$destroy();
754 e.data.scope.field.record.deleteFields(o);
757 e.data.scope.field.record.insertOrderedFields(
764 $scope.force_render = true;
765 $timeout(function(){$scope.$digest()}).then(setCaret);
768 $scope.context_functions = {
769 addDatafield : addDatafield,
770 deleteDatafield : deleteDatafield,
776 $scope.onKeydown = function (event) {
777 var event_return = true;
780 'keydown: which='+event.which+
781 ', ctrlKey='+event.ctrlKey+
782 ', shiftKey='+event.shiftKey+
783 ', altKey='+event.altKey+
784 ', metaKey='+event.altKey
787 if (event.which == 89 && event.ctrlKey) { // ctrl+y, redo
788 event_return = $scope.processRedo();
789 } else if (event.which == 90 && event.ctrlKey) { // ctrl+z, undo
790 event_return = $scope.processUndo();
791 } else if ((event.which == 68 || event.which == 73) && event.ctrlKey) { // ctrl+d or ctrl+i, insert subfield
793 var element = $(event.target);
794 var new_sf, index_sf, move_data;
796 if (element.hasClass('marcsfvalue')) {
797 index_sf = event.data.scope.subfield[2];
798 new_sf = index_sf + 1;
800 var start = event.target.selectionStart;
801 var end = event.target.selectionEnd - event.target.selectionStart ?
802 event.target.selectionEnd :
803 event.target.value.length;
805 move_data = event.target.value.substring(start,end);
807 } else if (element.hasClass('marcsfcode')) {
808 index_sf = event.data.scope.subfield[2];
809 new_sf = index_sf + 1;
810 } else if (element.hasClass('marctag') || element.hasClass('marcind')) {
815 $scope.current_event_target = 'r' + $scope.recordId +
816 'f' + event.data.scope.field.position +
817 's' + new_sf + 'code';
819 event.data.scope.field.subfields.forEach(function(sf) {
820 if (sf[2] >= new_sf) sf[2]++;
821 if (sf[2] == index_sf) sf[1] = event.target.value.substring(0,start) + event.target.value.substring(end);
823 event.data.scope.field.subfields.splice(
826 [' ', move_data, new_sf ]
829 $scope.current_event_target_cursor_pos = 0;
830 $scope.current_event_target_cursor_pos_end = 1;
832 $timeout(function(){$scope.$digest()}).then(setCaret);
834 event_return = false;
836 } else if (event.which == 117 && event.shiftKey) { // shift + F6, insert 006
838 event_return = false;
840 } else if (event.which == 118 && event.shiftKey) { // shift + F7, insert 007
842 event_return = false;
844 } else if (event.which == 119 && event.shiftKey) { // shift + F8, insert/replace 008
846 event_return = false;
848 } else if (event.which == 13 && event.ctrlKey) { // ctrl+enter, insert datafield
849 addDatafield(event, event.shiftKey); // shift key inserts before
850 event_return = false;
852 } else if (event.which == 46 && event.ctrlKey) { // ctrl+del, remove field
853 deleteDatafield(event);
854 event_return = false;
856 } else if (event.which == 46 && event.shiftKey && $(event.target).hasClass('marcsf')) { // shift+del, remove subfield
858 var sf = event.data.scope.subfield[2] - 1;
859 if (sf == -1) sf = 0;
861 event.data.scope.field.deleteExactSubfields(
862 event.data.scope.subfield
865 if (!event.data.scope.field.subfields[sf]) {
866 $scope.current_event_target = 'r' + $scope.recordId +
867 'f' + event.data.scope.field.position +
870 $scope.current_event_target = 'r' + $scope.recordId +
871 'f' + event.data.scope.field.position +
875 $scope.current_event_target_cursor_pos = 0;
876 $scope.current_event_target_cursor_pos_end = 0;
877 $scope.force_render = true;
879 $timeout(function(){$scope.$digest()}).then(setCaret);
881 event_return = false;
883 } else if (event.keyCode == 38) {
884 if (event.ctrlKey) { // copy the field up
885 var index_field = event.data.scope.field.position;
888 if (event.data.scope.field.isControlfield()) {
889 field_obj = new MARC21.Field({
890 tag : event.data.scope.field.tag,
891 data : event.data.scope.field.data
895 for (var i in event.data.scope.field.subfields) {
896 sf_clone.push(event.data.scope.field.subfields[i].slice());
898 field_obj = new MARC21.Field({
899 tag : event.data.scope.field.tag,
900 ind1 : event.data.scope.field.ind1,
901 ind2 : event.data.scope.field.ind2,
907 event.data.scope.field.record.insertFieldsBefore(
908 event.data.scope.field,
912 $scope.current_event_target = 'r' + $scope.recordId +
913 'f' + index_field + 'tag';
915 $scope.current_event_target_cursor_pos = 0;
916 $scope.current_event_target_cursor_pos_end = 3;
917 $scope.force_render = true;
919 $timeout(function(){$scope.$digest()}).then(setCaret);
921 } else { // jump to prev field
922 if (event.data.scope.field.position > 0) {
924 $scope.current_event_target_cursor_pos = 0;
925 $scope.current_event_target_cursor_pos_end = 0;
926 $scope.current_event_target = 'r' + $scope.recordId +
927 'f' + (event.data.scope.field.position - 1) +
933 event_return = false;
935 } else if (event.keyCode == 40) { // down arrow...
936 if (event.ctrlKey) { // copy the field down
938 var index_field = event.data.scope.field.position;
939 var new_field = index_field + 1;
942 if (event.data.scope.field.isControlfield()) {
943 field_obj = new MARC21.Field({
944 tag : event.data.scope.field.tag,
945 data : event.data.scope.field.data
949 for (var i in event.data.scope.field.subfields) {
950 sf_clone.push(event.data.scope.field.subfields[i].slice());
952 field_obj = new MARC21.Field({
953 tag : event.data.scope.field.tag,
954 ind1 : event.data.scope.field.ind1,
955 ind2 : event.data.scope.field.ind2,
960 event.data.scope.field.record.insertFieldsAfter(
961 event.data.scope.field,
965 $scope.current_event_target = 'r' + $scope.recordId +
966 'f' + new_field + 'tag';
968 $scope.current_event_target_cursor_pos = 0;
969 $scope.current_event_target_cursor_pos_end = 3;
970 $scope.force_render = true;
972 $timeout(function(){$scope.$digest()}).then(setCaret);
974 } else { // jump to next field
975 if (event.data.scope.field.record.fields[event.data.scope.field.position + 1]) {
977 $scope.current_event_target_cursor_pos = 0;
978 $scope.current_event_target_cursor_pos_end = 0;
979 $scope.current_event_target = 'r' + $scope.recordId +
980 'f' + (event.data.scope.field.position + 1) +
986 event_return = false;
988 } else { // Assumes only marc editor elements have IDs that can trigger this event handler.
989 $scope.current_event_target = $(event.target).attr('id');
990 if ($scope.current_event_target) {
991 $scope.current_event_target_cursor_pos =
992 event.target.selectionDirection=='backward' ?
993 event.target.selectionStart :
994 event.target.selectionEnd;
1001 function setCaret() {
1002 if ($scope.current_event_target) {
1003 console.log("Putting caret in " + $scope.current_event_target);
1004 if (!$scope.current_event_target_cursor_pos_end)
1005 $scope.current_event_target_cursor_pos_end = $scope.current_event_target_cursor_pos
1007 var element = $('#'+$scope.current_event_target).get(0);
1010 if (element.setSelectionRange) {
1011 element.setSelectionRange(
1012 $scope.current_event_target_cursor_pos,
1013 $scope.current_event_target_cursor_pos_end
1016 $scope.current_event_cursor_pos_end = null;
1017 $scope.current_event_target = null;
1022 function loadRecord() {
1023 return (function() {
1024 var deferred = $q.defer();
1025 if ($scope.recordId) {
1026 egCore.pcrud.retrieve(
1027 $scope.record_type, $scope.recordId
1028 ).then(function(rec) {
1029 deferred.resolve(rec);
1032 if ($scope.recordType == 'bre') {
1033 var bre = new egCore.idl.bre();
1034 bre.marc($scope.marcXml);
1035 deferred.resolve(bre);
1036 } else if ($scope.recordType == 'are') {
1037 var are = new egCore.idl.are();
1038 are.marc($scope.marcXml);
1039 deferred.resolve(are);
1041 $scope.brandNewRecord = true;
1043 return deferred.promise;
1044 })().then(function(rec) {
1045 $scope.in_redo = true;
1046 $scope[$scope.record_type] = rec;
1047 $scope.record = new MARC21.Record({ marcxml : $scope.Record().marc() });
1048 $scope.calculated_record_type = $scope.record.recordType();
1049 $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
1050 $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
1051 $scope.save_stack_depth = $scope.record_undo_stack.length;
1052 $scope.flat_text_marc = $scope.record.toBreaker();
1054 if ($scope.record_type == 'bre') {
1055 $scope.bib_source = $scope.Record().source();
1059 return egTagTable.fetchFFPosTable($scope.calculated_record_type)
1061 return egTagTable.fetchFFValueTable($scope.calculated_record_type)
1065 $scope.$watch('record.toBreaker()', function (newVal, oldVal) {
1066 if (!$scope.in_undo && !$scope.in_redo && oldVal != newVal) {
1067 $scope.record_undo_stack.push({
1069 target: $scope.current_event_target,
1070 pos: $scope.current_event_target_cursor_pos
1073 if ($scope.force_render) {
1074 $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
1075 $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
1076 $scope.force_render = false;
1079 $scope.flat_text_marc = newVal;
1082 if ($scope.record_undo_stack.length != $scope.save_stack_depth) {
1083 $scope.dirtyFlag = true;
1085 $scope.dirtyFlag = false;
1088 if ($scope.record_undo_stack.length > $scope.max_undo)
1089 $scope.record_undo_stack.shift();
1091 console.log('undo stack is ' + $scope.record_undo_stack.length + ' deep');
1092 $scope.in_redo = false;
1093 $scope.in_undo = false;
1096 $scope.processUndo = function () {
1097 if ($scope.record_undo_stack.length) {
1098 $scope.in_undo = true;
1100 var undo_item = $scope.record_undo_stack.pop();
1101 $scope.record_redo_stack.push(undo_item);
1103 $scope.record = new MARC21.Record({ marcbreaker : undo_item.breaker });
1104 $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
1105 $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
1107 $scope.current_event_target = undo_item.target;
1108 $scope.current_event_target_cursor_pos = undo_item.pos;
1109 console.log('Undo targeting ' + $scope.current_event_target + ' position ' + $scope.current_event_target_cursor_pos);
1111 $timeout(function(){$scope.$digest()}).then(setCaret);
1118 $scope.processRedo = function () {
1119 if ($scope.record_redo_stack.length) {
1120 $scope.in_redo = true;
1122 var redo_item = $scope.record_redo_stack.pop();
1123 $scope.record_undo_stack.push(redo_item);
1125 $scope.record = new MARC21.Record({ marcbreaker : redo_item.breaker });
1126 $scope.controlfields = $scope.record.fields.filter(function(f){ return f.isControlfield() });
1127 $scope.datafields = $scope.record.fields.filter(function(f){ return !f.isControlfield() });
1129 $scope.current_event_target = redo_item.target;
1130 $scope.current_event_target_cursor_pos = redo_item.pos;
1131 console.log('Redo targeting ' + $scope.current_event_target + ' position ' + $scope.current_event_target_cursor_pos);
1133 $timeout(function(){$scope.$digest()}).then(setCaret);
1140 $scope.Record = function () {
1141 return $scope[$scope.record_type];
1144 $scope.deleteRecord = function () {
1145 $scope.Record().deleted(true);
1146 return $scope.saveRecord();
1149 $scope.undeleteRecord = function () {
1150 $scope.Record().deleted(false);
1151 return $scope.saveRecord();
1154 $scope.validateHeadings = function () {
1155 if ($scope.record_type != 'bre') return;
1156 var chain = $q.when();
1157 angular.forEach($scope.record.fields, function(f) {
1158 if (!$scope.controlSet.bibFieldByTag(f.tag)) return;
1159 // if heading already has a $0, assume it's good
1160 if (f.subfield('0', true).length) {
1161 f.heading_checked = true;
1162 f.heading_valid = true;
1165 var auth_match = $scope.controlSet.bibToAuthorities(f);
1166 chain = chain.then(function() {
1167 var promise = egCore.net.request(
1169 'open-ils.search.authority.simple_heading.from_xml.batch.atomic',
1171 ).then(function (matches) {
1172 f.heading_valid = false;
1173 if (matches[0]) { // probably set
1174 for (var cset in matches[0]) {
1175 var arr = matches[0][cset];
1177 // protect against errant empty string values
1178 if (arr.length == 1 && arr[0] == '')
1180 f.heading_valid = true;
1185 f.heading_checked = true;
1192 processOnSaveCallbacks = function() {
1193 var deferred = $q.defer();
1194 if (typeof $scope.onSaveCallback !== 'undefined') {
1195 var promise = deferred.promise;
1197 angular.forEach($scope.onSaveCallback, function (f) {
1198 if (angular.isFunction(f)) promise = promise.then(f);
1202 return deferred.resolve($scope.recordId)
1205 $scope.saveRecord = function () {
1206 if ($scope.inPlaceMode) {
1207 $scope.marcXml = $scope.record.toXmlString();
1208 return processOnSaveCallbacks();
1210 $scope.mangle_005();
1211 $scope.Record().editor(egCore.auth.user().id());
1212 $scope.Record().edit_date('now');
1213 $scope.record.pruneEmptyFieldsAndSubfields();
1214 $scope.Record().marc($scope.record.toXmlString());
1215 if ($scope.recordId) {
1216 return egCore.pcrud.update(
1219 if ($scope.enable_fast_add) {
1222 'open-ils.actor.anon_cache.set_value',
1223 null, 'edit-these-copies', {
1224 record_id: $scope.recordId,
1226 label : $scope.fast_item_callnumber,
1227 barcode : $scope.fast_item_barcode,
1233 ).then(function(key) {
1235 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1236 $timeout(function() { $window.open(url, '_blank') });
1238 alert('Could not create anonymous cache key!');
1242 }).then(loadRecord).then(processOnSaveCallbacks);
1244 $scope.Record().creator(egCore.auth.user().id());
1245 $scope.Record().create_date('now');
1246 return egCore.pcrud.create(
1248 ).then(function(bre) {
1249 $scope.recordId = bre.id();
1250 if ($scope.enable_fast_add) {
1253 'open-ils.actor.anon_cache.set_value',
1254 null, 'edit-these-copies', {
1255 record_id: $scope.recordId,
1257 label : $scope.fast_item_callnumber,
1258 barcode : $scope.fast_item_barcode,
1263 ).then(function(key) {
1265 var url = egCore.env.basePath + 'cat/volcopy/' + key;
1266 $timeout(function() { $window.open(url, '_blank') });
1268 alert('Could not create anonymous cache key!');
1272 }).then(loadRecord).then(processOnSaveCallbacks);
1278 $scope.seeBreaker = function () {
1279 alert($scope.record.toBreaker());
1282 $scope.$watch('recordId',
1283 function(newVal, oldVal) {
1284 if (newVal && newVal !== oldVal) {
1289 $scope.$watch('marcXml',
1290 function(newVal, oldVal) {
1291 if (newVal && newVal !== oldVal) {
1297 var unregister = $scope.$watch(function() {
1298 return egTagTable.initialized();
1302 if ($scope.recordId || $scope.marcXml) {
1308 $scope.mangle_005 = function () {
1309 var now = new Date();
1310 var y = now.getUTCFullYear();
1312 var m = now.getUTCMonth() + 1;
1313 if (m < 10) m = '0' + m;
1315 var d = now.getUTCDate();
1316 if (d < 10) d = '0' + d;
1318 var H = now.getUTCHours();
1319 if (H < 10) H = '0' + H;
1321 var M = now.getUTCMinutes();
1322 if (M < 10) M = '0' + M;
1324 var S = now.getUTCSeconds();
1325 if (S < 10) S = '0' + S;
1327 var stamp = '' + y + m + d + H + M + S + '.0';
1328 var f = $scope.record.field('005',true)[0];
1332 $scope.record.insertOrderedFields(
1347 .directive("egMarcEditBibsource", ['$timeout',function ($timeout) {
1351 template: '<span class="nullable">'+
1352 '<select class="form-control" ng-model="bib_source" ng-options="s.id() as s.source() for s in bib_sources">'+
1353 '<option value="">Select a Source</option>'+
1356 controller: ['$scope','egCore',
1357 function ($scope , egCore) {
1359 egCore.pcrud.retrieveAll('cbs', {}, {atomic : true})
1360 .then(function(list) { $scope.bib_sources = list; });
1362 $scope.$watch('bib_source',
1363 function(newVal, oldVal) {
1364 if (newVal !== oldVal) {
1365 $scope.bre.source(newVal);
1375 .directive("egMarcEditAuthorityLinker", function () {
1379 templateUrl: './cat/share/t_authority_linker',
1385 controller: ['$scope','$modal','egCore','egAuth',
1386 function ($scope , $modal, egCore, egAuth) {
1388 $scope.searchStr = '';
1389 var cni = egCore.env.aous['cat.marc_control_number_identifier'] ||
1390 'Set cat.marc_control_number_identifier in Library Settings';
1392 var axis_list = $scope.controlSet.bibFieldBrowseAxes($scope.bibField.tag);
1393 $scope.axis = axis_list[0];
1395 $scope._controlled_sf_list = {};
1396 $scope._controlled_auth_sf_list = {};
1398 angular.forEach($scope.controlSet.controlSetList(), function(acs_id) {
1399 if ($scope.controlSet.controlSet(acs_id).control_map[$scope.bibField.tag])
1400 found_acs.push(acs_id);
1402 if (found_acs.length) {
1403 angular.forEach($scope.controlSet.controlSet(found_acs[0]).control_map[$scope.bibField.tag],
1404 function(value, sf_label) {
1405 $scope._controlled_sf_list[ sf_label ] = 1;
1406 angular.forEach($scope.controlSet.controlSet(found_acs[0]).control_map[$scope.bibField.tag][sf_label],
1407 function(auth_sf, auth_tag) {
1408 if (!$scope._controlled_auth_sf_list[auth_tag]) {
1409 $scope._controlled_auth_sf_list[auth_tag] = { };
1411 $scope._controlled_auth_sf_list[auth_tag][auth_sf] = 1;
1418 $scope.bibField.subfields.forEach(function (sf) {
1419 if (sf[0] in $scope._controlled_sf_list) {
1421 sf.selectable = true;
1423 sf.selectable = false;
1426 $scope.summarizeField = function() {
1428 'tag': $scope.bibField.tag,
1429 'ind1': $scope.bibField.ind1,
1430 'ind2': $scope.bibField.ind2,
1433 $scope.bibField.subfields.forEach(function(sf) {
1435 source_f.subfields.push([ sf[0], sf[1] ]);
1440 $scope.getSearchString = function() {
1441 var source_f = $scope.summarizeField();
1443 angular.forEach(source_f.subfields, function(val) {
1444 values.push(val[1]);
1446 return values.join(' ');
1448 $scope.searchStr = $scope.getSearchString();
1449 $scope.$watch(function() {
1451 angular.forEach($scope.bibField.subfields, function(sf) {
1452 if (sf.selected) ct++
1456 function(newVal, oldVal) {
1457 $scope.searchStr = $scope.getSearchString();
1460 $scope.updateSubfieldZero = function(value) {
1461 $scope.changed = true;
1462 $scope.bibField.deleteSubfield({ code : ['0'] });
1463 $scope.bibField.subfields.push([
1464 '0', '(' + cni + ')' + value
1468 $scope.applyHeading = function(headingField) {
1469 // TODO: move the MARC21 rules for copying indicators
1471 if (headingField.tag == '130' && $scope.bibField.tag == '130') {
1472 $scope.bibField.ind1 = headingField.ind2;
1474 $scope.bibField.ind1 = headingField.ind1;
1476 // deal with 4xx and 5xx
1477 var authFallbackTag = '1' + headingField.tag.substr(1, 2);
1478 var _valid_auth_sfs = (headingField.tag in $scope._controlled_auth_sf_list) ?
1479 $scope._controlled_auth_sf_list[headingField.tag] :
1480 (authFallbackTag in $scope._controlled_auth_sf_list) ?
1481 $scope._controlled_auth_sf_list[authFallbackTag] :
1483 // save the $0 for later use
1485 if (headingField.subfield('0')) {
1486 sfZero = headingField.subfield('0')[1];
1488 // grab any bib subfields not under authority control
1489 // TODO do something about uncontrolled subdivisions
1490 var uncontrolledBibSf = [];
1491 angular.forEach($scope.bibField.subfields, function(sf) {
1492 if (!(sf[0] in $scope._controlled_sf_list) && (sf[0] != '0')) {
1493 uncontrolledBibSf.push([ sf[0], sf[1] ]);
1496 // grab the authority subfields
1497 var authoritySf = [];
1498 angular.forEach(headingField.subfields, function(sf) {
1499 if (sf[0] in _valid_auth_sfs) {
1500 authoritySf.push([ sf[0], sf[1] ]);
1503 $scope.bibField.subfields.length = 0;
1504 angular.forEach(authoritySf, function(sf) {
1505 $scope.bibField.addSubfields(sf[0], sf[1]);
1507 angular.forEach(uncontrolledBibSf, function(sf) {
1508 $scope.bibField.addSubfields(sf[0], sf[1]);
1511 $scope.bibField.addSubfields('0', sfZero);
1513 $scope.bibField.subfields.forEach(function (sf) {
1514 if (sf[0] in $scope._controlled_sf_list) {
1515 // intentionally not selecting any subfields
1516 // after we've applied an authority heading
1517 sf.selected = false;
1518 sf.selectable = true;
1520 sf.selectable = false;
1523 $scope.changed = true;
1526 $scope.createAuthorityFromBib = function(spawn_editor) {
1527 var source_f = $scope.summarizeField();
1529 var args = { authority_id : 0 };
1530 var method = (spawn_editor) ?
1531 'open-ils.cat.authority.record.create_from_bib.readonly' :
1532 'open-ils.cat.authority.record.create_from_bib';
1539 ).then(function(newAuthority) {
1542 templateUrl: './cat/share/t_edit_new_authority',
1545 ['$scope', '$modalInstance', function($scope, $modalInstance) {
1546 $scope.focusMe = true;
1548 $scope.dirty_flag = false;
1549 $scope.marc_xml = newAuthority,
1550 $scope.ok = function(args) { $modalInstance.close(args) }
1551 $scope.cancel = function () { $modalInstance.dismiss() }
1553 }).result.then(function (args) {
1554 if (!args || !args.authority_id) return;
1555 $scope.updateSubfieldZero(args.authority_id);
1558 $scope.updateSubfieldZero(newAuthority.id());
1568 .directive("egPhyscharWizard", function () {
1572 templateUrl: './cat/share/t_physchar_wizard',
1576 controller: ['$scope','$q','egTagTable',
1577 function ($scope , $q , egTagTable) {
1579 // $scope.step is the 1-based position in the list of
1580 // subfields for the currently selected type.
1581 // step==0 means we are currently selecting the type
1584 if (!$scope.field.data)
1585 $scope.field.data = '';
1587 // currently selected subfield value selector option
1588 $scope.selected_option = null;
1590 function current_ptype() {
1591 return $scope.field.data.substr(0, 1);
1594 function current_subfield() {
1595 return egTagTable.getPhysCharSubfieldMap(current_ptype())
1596 .then(function(sf_list) {return sf_list[$scope.step-1]});
1599 $scope.values_for_step = [];
1600 function set_values_for_step() {
1603 if ($scope.step == 0) {
1604 promise = egTagTable.getPhysCharTypeMap();
1606 promise = current_subfield().then(
1607 function(subfield) {
1609 .getPhysCharValueMap(subfield.id());
1614 return promise.then(function(list) {
1615 $scope.values_for_step = list;
1616 set_selected_option_from_field();
1617 set_label_for_step();
1621 $scope.change_ptype = function(option) {
1622 $scope.selected_option = option;
1623 var new_val = option.ptype_key();
1624 if (current_ptype() != new_val) {
1625 $scope.field.data = new_val; // total reset
1629 $scope.change_option = function(option) {
1630 $scope.selected_option = option;
1631 var new_val = option.value();
1632 get_step_slot().then(function(slot) {
1633 var value = $scope.field.data;
1634 while (value.length < (slot[0] + slot[1]))
1636 var before = value.substr(0, slot[0]);
1637 var after = value.substr(slot[0] + slot[1]);
1639 before + new_val.substr(0, slot[1]) + after;
1643 function get_step_slot() {
1644 if ($scope.step == 0) return $q.when([0, 1]);
1645 return current_subfield().then(function(sf) {
1646 return [sf.start_pos(), sf.length()]
1650 $scope.is_last_step = function() {
1651 // This one is called w/ every digest, so avoid async
1652 // calls. Wait until we have loaded the current ptype
1653 // subfields to determine if this is the last step.
1656 egTagTable.phys_char_sf_map[current_ptype()] &&
1657 egTagTable.phys_char_sf_map[current_ptype()].length
1662 $scope.label_for_step = '';
1663 function set_label_for_step() {
1664 if ($scope.step > 0) {
1665 current_subfield().then(function(sf) {
1666 $scope.label_for_step = sf.label();
1671 $scope.next_step = function() {
1673 set_values_for_step();
1676 $scope.prev_step = function() {
1678 set_values_for_step();
1681 function set_selected_option_from_field() {
1682 if ($scope.step == 0) {
1683 $scope.selected_option = $scope.values_for_step
1684 .filter(function(opt) {
1685 return (opt.ptype_key() == current_ptype())})[0];
1687 get_step_slot().then(function(slot) {
1688 var val = String.prototype.substr.apply(
1689 $scope.field.data, slot);
1691 $scope.selected_option = $scope.values_for_step
1692 .filter(function(opt) {
1693 return (opt.value() == val)})[0];
1695 $scope.selected_option = null;
1700 set_values_for_step();
1707 .directive("egMarcEditAuthorityBrowser", function () {
1711 templateUrl: './cat/share/t_authority_browser',
1718 controller: ['$scope','$http',
1719 function ($scope , $http) {
1723 $scope.main_headings = [];
1725 function getHeadingString(headingField) {
1727 angular.forEach(headingField.subfields, function (sf) {
1728 if (['x', 'y', 'z'].indexOf(sf[0]) > -1) {
1739 $scope.doBrowse = function() {
1740 $scope.main_headings.length = 0;
1741 if ($scope.searchString.length == 0) return;
1742 var type = 'authority.'
1743 var url = '/opac/extras/browse/marcxml/'
1744 + 'authority.' + $scope.axis + '.refs'
1745 + '/1' // OU - currently unscoped
1746 + '/' + $scope.searchString
1748 + '/' + $scope.limit;
1752 transformResponse : function(data) {
1753 // use a bit of jQuery to deal with the XML
1754 var $xml = $( $.parseXML(data) );
1756 $xml.find('record').each(function() {
1757 var rec = new MARC21.Record();
1758 rec.fromXmlDocument($(this)[0].outerHTML);
1763 }).then(function(response) {
1764 angular.forEach(response.data, function(rec) {
1765 var authId = rec.subfield('901', 'c')[1];
1767 if (rec.field('003')) {
1768 auth_org = rec.field('003').data;
1770 var headingField = rec.field('1..');
1771 var seeFroms = rec.field('4..', true);
1772 var seeAlsos = rec.field('5..', true);
1774 var main_heading = {
1775 authority_id : authId,
1776 heading : getHeadingString(headingField),
1777 seealso_headings : [ ],
1778 seefrom_headings : [ ],
1783 sfZero = '(' + auth_org + ')';
1786 headingField.addSubfields('0', sfZero);
1788 main_heading['headingField'] = headingField;
1789 angular.forEach(seeAlsos, function(headingField) {
1790 main_heading.seealso_headings.push({
1791 heading : getHeadingString(headingField),
1792 headingField : headingField
1795 angular.forEach(seeFroms, function(headingField) {
1796 main_heading.seefrom_headings.push({
1797 heading : getHeadingString(headingField),
1798 headingField : headingField
1801 $scope.main_headings.push(main_heading);
1806 $scope.$watch('searchString',
1807 function(newVal, oldVal) {
1808 if (newVal !== oldVal) {
1813 $scope.$watch('page',
1814 function(newVal, oldVal) {
1815 if (newVal !== oldVal) {