5 angular.module('egVolCopy',
6 ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'egGridMod'])
8 .filter('boolText', function(){
14 .config(function($routeProvider, $locationProvider, $compileProvider) {
15 $locationProvider.html5Mode(true);
16 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
19 delay : ['egStartup', function(egStartup) { return egStartup.go(); }]
22 $routeProvider.when('/cat/volcopy/:dataKey', {
23 templateUrl: './cat/volcopy/t_view',
24 controller: 'EditCtrl',
28 $routeProvider.when('/cat/volcopy/:dataKey/:mode', {
29 templateUrl: './cat/volcopy/t_view',
30 controller: 'EditCtrl',
37 function(egCore , $q) {
40 currently_generating : false,
41 auto_gen_barcode : false,
42 barcode_checkdigit : false,
45 tree : {}, // holds lib->cn->copy hash stack
46 copies : [] // raw copy list
49 service.nextBarcode = function(bc) {
50 service.currently_generating = true;
51 return egCore.net.request(
53 'open-ils.cat.item.barcode.autogen',
55 bc, 1, { checkdigit: service.barcode_checkdigit }
56 ).then(function(resp) { // get_barcodes
57 var evt = egCore.evt.parse(resp);
58 if (!evt) return resp[0];
63 service.checkBarcode = function(bc) {
64 if (!service.barcode_checkdigit) return true;
65 if (bc != Number(bc)) return false;
67 // "16.00" == Number("16.00"), but the . is bad.
68 // Throw out any barcode that isn't just digits
69 if (bc.search(/\D/) != -1) return false;
70 var last_digit = bc.substr(bc.length-1);
71 var stripped_barcode = bc.substr(0,bc.length-1);
72 return service.barcodeCheckdigit(stripped_barcode).toString() == last_digit;
75 service.barcodeCheckdigit = function(bc) {
76 var reverse_barcode = bc.toString().split('').reverse();
77 var check_sum = 0; var multiplier = 2;
78 for (var i = 0; i < reverse_barcode.length; i++) {
79 var digit = reverse_barcode[i];
80 var product = digit * multiplier; product = product.toString();
82 for (var j = 0; j < product.length; j++) {
83 temp_sum += Number( product[j] );
85 check_sum += Number( temp_sum );
86 multiplier = ( multiplier == 2 ? 1 : 2 );
88 check_sum = check_sum.toString();
89 var next_multiple_of_10 = (check_sum.match(/(\d*)\d$/)[1] * 10) + 10;
90 var check_digit = next_multiple_of_10 - Number(check_sum); if (check_digit == 10) check_digit = 0;
94 // returns a promise resolved with the list of circ mods
95 service.get_classifications = function() {
97 return $q.when(egCore.env.acnc.list);
99 return egCore.pcrud.retrieveAll('acnc', null, {atomic : true})
100 .then(function(list) {
101 egCore.env.absorbList(list, 'acnc');
106 service.get_prefixes = function(org) {
107 return egCore.pcrud.search('acnp',
108 {owning_lib : egCore.org.fullPath(org, true)},
109 {order_by : { acnp : 'label_sortkey' }}, {atomic : true}
114 service.get_statcats = function(orgs) {
115 return egCore.pcrud.search('asc',
119 asc : ['owner','entries']
126 service.get_locations = function(orgs) {
127 return egCore.pcrud.search('acpl',
129 {order_by : { acpl : 'name' }}, {atomic : true}
133 service.get_suffixes = function(org) {
134 return egCore.pcrud.search('acns',
135 {owning_lib : egCore.org.fullPath(org, true)},
136 {order_by : { acns : 'label_sortkey' }}, {atomic : true}
141 service.get_statuses = function() {
143 return $q.when(egCore.env.ccs.list);
145 return egCore.pcrud.retrieveAll('ccs', {order_by : { ccs : 'name' }}, {atomic : true}).then(
147 egCore.env.absorbList(list, 'ccs');
154 service.get_circ_mods = function() {
156 return $q.when(egCore.env.ccm.list);
158 return egCore.pcrud.retrieveAll('ccm', {}, {atomic : true}).then(
160 egCore.env.absorbList(list, 'ccm');
167 service.get_circ_types = function() {
169 return $q.when(egCore.env.citm.list);
171 return egCore.pcrud.retrieveAll('citm', {}, {atomic : true}).then(
173 egCore.env.absorbList(list, 'citm');
180 service.get_age_protects = function() {
181 if (egCore.env.crahp)
182 return $q.when(egCore.env.crahp.list);
184 return egCore.pcrud.retrieveAll('crahp', {}, {atomic : true}).then(
186 egCore.env.absorbList(list, 'crahp');
193 service.get_floating_groups = function() {
195 return $q.when(egCore.env.cfg.list);
197 return egCore.pcrud.retrieveAll('cfg', {}, {atomic : true}).then(
199 egCore.env.absorbList(list, 'cfg');
206 service.bmp_parts = {};
207 service.get_parts = function(rec) {
208 if (service.bmp_parts[rec])
209 return $q.when(service.bmp_parts[rec]);
211 return egCore.pcrud.search('bmp',
212 {record : rec, deleted : 'f'},
213 null, {atomic : true}
214 ).then(function(list) {
215 service.bmp_parts[rec] = list;
224 acp : ['call_number','parts','stat_cat_entries', 'notes'],
225 acn : ['label_class','prefix','suffix']
229 service.addCopy = function (cp) {
231 if (!cp.parts()) cp.parts([]); // just in case...
233 var lib = cp.call_number().owning_lib();
234 var cn = cp.call_number().id();
236 if (!service.tree[lib]) service.tree[lib] = {};
237 if (!service.tree[lib][cn]) service.tree[lib][cn] = [];
239 service.tree[lib][cn].push(cp);
240 service.copies.push(cp);
243 service.fetchIds = function(idList) {
244 service.tree = {}; // clear the tree on fetch
245 service.copies = []; // clear the copy list on fetch
246 return egCore.pcrud.search('acp', { 'id' : idList }, service.flesh).then(null,null,
248 service.addCopy(copy);
253 // create a new acp object with default values
254 // (both hard-coded and coming from OU settings)
255 service.generateNewCopy = function(callNumber, owningLib, isFastAdd, isNew) {
256 var cp = new egCore.idl.acp();
257 cp.id( --service.new_cp_id );
261 cp.circ_lib( owningLib );
262 cp.call_number( callNumber );
265 cp.deposit_amount(0);
266 cp.fine_level(2); // Normal
267 cp.loan_duration(2); // Normal
268 cp.location(1); // Stacks
271 cp.opac_visible('t');
273 cp.mint_condition('t');
275 var status_setting = isFastAdd ?
276 'cat.default_copy_status_fast' :
277 'cat.default_copy_status_normal';
281 ).then(function(set) {
282 var default_ccs = set[status_setting] ||
283 (isFastAdd ? 0 : 5); // 0 is Available, 5 is In Process
284 cp.status(default_ccs);
293 .directive("egVolCopyEdit", function () {
299 '<div class="col-xs-5" ng-class="{'+"'has-error'"+':barcode_has_error}">'+
300 '<input id="{{callNumber.id()}}_{{copy.id()}}"'+
301 ' eg-enter="nextBarcode(copy.id())" class="form-control"'+
302 ' type="text" ng-model="barcode" ng-change="updateBarcode()"/>'+
304 '<div class="col-xs-3"><input class="form-control" type="number" ng-model="copy_number" ng-change="updateCopyNo()"/></div>'+
305 '<div class="col-xs-4"><eg-basic-combo-box eg-disabled="record == 0" list="parts" selected="part"></eg-basic-combo-box></div>'+
308 scope: { focusNext: "=", copy: "=", callNumber: "=", index: "@", record: "@" },
309 controller : ['$scope','itemSvc','egCore',
310 function ( $scope , itemSvc , egCore ) {
311 $scope.new_part_id = 0;
312 $scope.barcode_has_error = false;
314 $scope.nextBarcode = function (i) {
315 $scope.focusNext(i, $scope.barcode);
318 $scope.updateBarcode = function () {
319 if ($scope.barcode != '')
320 $scope.barcode_has_error = !Boolean(itemSvc.checkBarcode($scope.barcode));
321 $scope.copy.barcode($scope.barcode);
322 $scope.copy.ischanged(1);
323 if (itemSvc.currently_generating)
324 $scope.focusNext($scope.copy.id(), $scope.barcode);
327 $scope.updateCopyNo = function () { $scope.copy.copy_number($scope.copy_number); $scope.copy.ischanged(1); };
328 $scope.updatePart = function () {
330 var p = $scope.part_list.filter(function (x) {
331 return x.label() == $scope.part
333 if (p.length > 0) { // preexisting part
335 } else { // create one...
336 var part = new egCore.idl.bmp();
337 part.id( --$scope.new_part_id );
339 part.label( $scope.part );
340 part.record( $scope.callNumber.record() );
341 $scope.copy.parts([part]);
342 $scope.copy.ischanged(1);
345 $scope.copy.parts([]);
347 $scope.copy.ischanged(1);
349 $scope.$watch('part', $scope.updatePart);
351 $scope.barcode = $scope.copy.barcode();
352 $scope.copy_number = $scope.copy.copy_number();
354 if ($scope.copy.parts()) {
355 $scope.part = $scope.copy.parts()[0];
356 if ($scope.part) $scope.part = $scope.part.label();
360 $scope.part_list = [];
362 itemSvc.get_parts($scope.callNumber.record()).then(function(list){
363 $scope.part_list = list;
364 angular.forEach(list, function(p){ $scope.parts.push(p.label()) });
365 $scope.parts = angular.copy($scope.parts);
374 .directive("egVolRow", function () {
381 '<div class="col-xs-2">'+
382 '<select ng-disabled="record == 0" class="form-control" ng-model="classification" ng-change="updateClassification()" ng-options="cl.name() for cl in classification_list"/>'+
384 '<div class="col-xs-1">'+
385 '<select ng-disabled="record == 0" class="form-control" ng-model="prefix" ng-change="updatePrefix()" ng-options="p.label() for p in prefix_list"/>'+
387 '<div class="col-xs-2"><input ng-disabled="record == 0" class="form-control" type="text" ng-change="updateLabel()" ng-model="label"/></div>'+
388 '<div class="col-xs-1">'+
389 '<select ng-disabled="record == 0" class="form-control" ng-model="suffix" ng-change="updateSuffix()" ng-options="s.label() for s in suffix_list"/>'+
391 '<div ng-hide="onlyVols" class="col-xs-1"><input ng-disabled="record == 0" class="form-control" type="number" ng-model="copy_count" min="{{orig_copy_count}}" ng-change="changeCPCount()"></div>'+
392 '<div ng-hide="onlyVols" class="col-xs-5">'+
393 '<eg-vol-copy-edit record="{{record}}" ng-repeat="cp in copies track by idTracker(cp)" focus-next="focusNextBarcode" copy="cp" call-number="callNumber"></eg-vol-copy-edit>'+
397 scope: {focusNext: "=", allcopies: "=", copies: "=", onlyVols: "=", record: "@" },
398 controller : ['$scope','itemSvc','egCore',
399 function ( $scope , itemSvc , egCore ) {
400 $scope.callNumber = $scope.copies[0].call_number();
402 $scope.idTracker = function (x) { if (x && x.id) return x.id() };
404 // XXX $() is not working! arg
405 $scope.focusNextBarcode = function (i, prev_bc) {
408 angular.forEach($scope.copies, function (cp) {
416 if (yep) n = cp.id();
420 var next = '#' + $scope.callNumber.id() + '_' + n;
423 if (!itemSvc.currently_generating) el.focus();
424 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
425 itemSvc.nextBarcode(prev_bc).then(function(bc){
428 el.trigger('change');
431 itemSvc.currently_generating = false;
435 $scope.focusNext($scope.callNumber.id(),prev_bc)
439 $scope.suffix_list = [];
440 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
441 $scope.suffix_list = list;
442 $scope.$watch('callNumber.suffix()', function (v) {
443 if (angular.isObject(v)) v = v.id();
444 $scope.suffix = $scope.suffix_list.filter( function (s) {
450 $scope.updateSuffix = function () {
451 angular.forEach($scope.copies, function(cp) {
452 cp.call_number().suffix($scope.suffix);
453 cp.call_number().ischanged(1);
457 $scope.prefix_list = [];
458 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
459 $scope.prefix_list = list;
460 $scope.$watch('callNumber.prefix()', function (v) {
461 if (angular.isObject(v)) v = v.id();
462 $scope.prefix = $scope.prefix_list.filter(function (p) {
468 $scope.updatePrefix = function () {
469 angular.forEach($scope.copies, function(cp) {
470 cp.call_number().prefix($scope.prefix);
471 cp.call_number().ischanged(1);
474 $scope.$watch('callNumber.owning_lib()', function(oldLib, newLib) {
475 if (oldLib == newLib) return;
476 var currentPrefix = $scope.callNumber.prefix();
477 if (angular.isObject(currentPrefix)) currentPrefix = currentPrefix.id();
478 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
479 $scope.prefix_list = list;
480 var newPrefixId = $scope.prefix_list.filter(function (p) {
481 return p.id() == currentPrefix;
483 if (newPrefixId.id) newPrefixId = newPrefixId.id();
484 $scope.prefix = $scope.prefix_list.filter(function (p) {
485 return p.id() == newPrefixId;
487 if ($scope.newPrefixId != currentPrefix) {
488 $scope.callNumber.prefix($scope.prefix);
491 var currentSuffix = $scope.callNumber.suffix();
492 if (angular.isObject(currentSuffix)) currentSuffix = currentSuffix.id();
493 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
494 $scope.suffix_list = list;
495 var newSuffixId = $scope.suffix_list.filter(function (s) {
496 return s.id() == currentSuffix;
498 if (newSuffixId.id) newSuffixId = newSuffixId.id();
499 $scope.suffix = $scope.suffix_list.filter(function (s) {
500 return s.id() == newSuffixId;
502 if ($scope.newSuffixId != currentSuffix) {
503 $scope.callNumber.suffix($scope.suffix);
508 $scope.classification_list = [];
509 itemSvc.get_classifications().then(function(list){
510 $scope.classification_list = list;
511 $scope.$watch('callNumber.label_class()', function (v) {
512 if (angular.isObject(v)) v = v.id();
513 $scope.classification = $scope.classification_list.filter(function (c) {
519 $scope.updateClassification = function () {
520 angular.forEach($scope.copies, function(cp) {
521 cp.call_number().label_class($scope.classification);
522 cp.call_number().ischanged(1);
526 $scope.updateLabel = function () {
527 angular.forEach($scope.copies, function(cp) {
528 cp.call_number().label($scope.label);
529 cp.call_number().ischanged(1);
533 $scope.$watch('callNumber.label()', function (v) {
537 $scope.prefix = $scope.callNumber.prefix();
538 $scope.suffix = $scope.callNumber.suffix();
539 $scope.classification = $scope.callNumber.label_class();
540 $scope.label = $scope.callNumber.label();
542 $scope.copy_count = $scope.copies.length;
543 $scope.orig_copy_count = $scope.copy_count;
545 $scope.changeCPCount = function () {
546 while ($scope.copy_count > $scope.copies.length) {
547 var cp = itemSvc.generateNewCopy(
549 $scope.callNumber.owning_lib()
551 $scope.copies.push( cp );
552 $scope.allcopies.push( cp );
556 if ($scope.copy_count >= $scope.orig_copy_count) {
557 var how_many = $scope.copies.length - $scope.copy_count;
559 var dead = $scope.copies.splice($scope.copy_count,how_many);
560 $scope.callNumber.copies($scope.copies);
562 // Trimming the global list is a bit more tricky
563 angular.forEach( dead, function (d) {
564 angular.forEach( $scope.allcopies, function (l, i) {
565 if (l === d) $scope.allcopies.splice(i,1);
578 .directive("egVolEdit", function () {
584 '<div class="col-xs-1"><eg-org-selector alldisabled="{{record == 0}}" selected="owning_lib" disable-test="cant_have_vols"></eg-org-selector></div>'+
585 '<div class="col-xs-1"><input ng-disabled="record == 0" class="form-control" type="number" min="{{orig_cn_count}}" ng-model="cn_count" ng-change="changeCNCount()"/></div>'+
586 '<div class="col-xs-10">'+
587 '<eg-vol-row only-vols="onlyVols" record="{{record}}"'+
588 'ng-repeat="(cn,copies) in struct | orderBy:cn track by cn" '+
589 'focus-next="focusNextFirst" copies="copies" allcopies="allcopies">'+
594 scope: { focusNext: "=", allcopies: "=", struct: "=", lib: "@", record: "@", onlyVols: "=" },
595 controller : ['$scope','itemSvc','egCore',
596 function ( $scope , itemSvc , egCore ) {
597 $scope.first_cn = Object.keys($scope.struct)[0];
598 $scope.full_cn = $scope.struct[$scope.first_cn][0].call_number();
600 $scope.defaults = {};
601 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
607 $scope.focusNextFirst = function(prev_cn,prev_bc) {
610 angular.forEach(Object.keys($scope.struct).sort(), function (cn) {
622 var next = '#' + n + '_' + $scope.struct[n][0].id();
625 if (!itemSvc.currently_generating) el.focus();
626 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
627 itemSvc.nextBarcode(prev_bc).then(function(bc){
630 el.trigger('change');
633 itemSvc.currently_generating = false;
637 $scope.focusNext($scope.lib, prev_bc);
641 $scope.cn_count = Object.keys($scope.struct).length;
642 $scope.orig_cn_count = $scope.cn_count;
644 $scope.owning_lib = egCore.org.get($scope.lib);
645 $scope.$watch('owning_lib', function (oldLib, newLib) {
646 if (oldLib == newLib) return;
647 angular.forEach( Object.keys($scope.struct), function (cn) {
648 $scope.struct[cn][0].call_number().owning_lib( $scope.owning_lib.id() );
649 $scope.struct[cn][0].call_number().ischanged(1);
653 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
655 $scope.$watch('cn_count', function (n) {
656 var o = Object.keys($scope.struct).length;
657 if (n > o) { // adding
658 for (var i = o; o < n; o++) {
659 var cn = new egCore.idl.acn();
660 cn.id( --itemSvc.new_cn_id );
662 cn.prefix( $scope.defaults.prefix || -1 );
663 cn.suffix( $scope.defaults.suffix || -1 );
664 cn.label_class( $scope.defaults.classification || 1 );
665 cn.owning_lib( $scope.owning_lib.id() );
666 cn.record( $scope.full_cn.record() );
668 var cp = itemSvc.generateNewCopy(cn, $scope.owning_lib.id());
670 $scope.struct[cn.id()] = [cp];
671 $scope.allcopies.push(cp);
672 if (!scope.defaults.classification) {
674 ['cat.default_classification_scheme'],
676 ).then(function (val) {
677 cn.label_class(val['cat.default_classification_scheme']);
681 } else if (n < o && n >= $scope.orig_cn_count) { // removing
682 var how_many = o - n;
685 .sort(function(a, b){return parseInt(a)-parseInt(b)})
686 .filter(function(x){ return parseInt(x) <= 0 });
687 for (var i = 0; i < how_many; i++) {
688 // Trimming the global list is a bit more tricky
689 angular.forEach($scope.struct[list[i]], function (d) {
690 angular.forEach( $scope.allcopies, function (l, j) {
691 if (l === d) $scope.allcopies.splice(j,1);
694 delete $scope.struct[list[i]];
707 .controller('EditCtrl',
708 ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$modal',
709 function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $modal) {
711 $scope.defaults = { // If defaults are not set at all, allow everything
712 barcode_checkdigit : false,
713 auto_gen_barcode : false,
718 loan_duration : true,
723 deposit_amount : true,
727 mint_condition : true,
730 circ_modifier : true,
739 $scope.embedded = ($routeParams.mode && $routeParams.mode == 'embedded') ? true : false;
741 $scope.saveDefaults = function () {
742 egCore.hatch.setItem('cat.copy.defaults', $scope.defaults);
745 $scope.fetchDefaults = function () {
746 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
749 if (!$scope.batch) $scope.batch = {};
750 $scope.batch.classification = $scope.defaults.classification;
751 $scope.batch.prefix = $scope.defaults.prefix;
752 $scope.batch.suffix = $scope.defaults.suffix;
753 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
754 if (typeof $scope.defaults.statcat_filter == 'object') {
755 // want fieldmapper object here...
756 $scope.defaults.statcat_filter =
757 egCore.idl.Clone($scope.defaults.statcat_filter);
759 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
761 if ($scope.defaults.always_volumes) $scope.show_vols = true;
762 if ($scope.defaults.barcode_checkdigit) itemSvc.barcode_checkdigit = true;
763 if ($scope.defaults.auto_gen_barcode) itemSvc.auto_gen_barcode = true;
767 $scope.fetchDefaults();
769 $scope.$watch('defaults.statcat_filter', function() {
770 $scope.saveDefaults();
772 $scope.$watch('defaults.auto_gen_barcode', function (n,o) {
773 itemSvc.auto_gen_barcode = n
776 $scope.$watch('defaults.barcode_checkdigit', function (n,o) {
777 itemSvc.barcode_checkdigit = n
780 $scope.dirty = false;
781 $scope.$watch('dirty',
782 function(newVal, oldVal) {
783 if (newVal && newVal != oldVal) {
784 $($window).on('beforeunload.edit', function(){
785 return 'There is unsaved data!'
788 $($window).off('beforeunload.edit');
793 $scope.only_vols = false;
794 $scope.show_vols = true;
795 $scope.show_copies = true;
797 $scope.tracker = function (x,f) { if (x) return x[f]() };
798 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
799 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
801 $scope.orgById = function (id) { return egCore.org.get(id) }
802 $scope.statusById = function (id) {
803 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
805 $scope.locationById = function (id) {
806 return $scope.location_cache[''+id];
809 $scope.workingToComplete = function () {
810 angular.forEach( $scope.workingGridControls.selectedItems(), function (c) {
811 angular.forEach( itemSvc.copies, function (w, i) {
813 $scope.completed_copies = $scope.completed_copies.concat(itemSvc.copies.splice(i,1));
820 $scope.completeToWorking = function () {
821 angular.forEach( $scope.completedGridControls.selectedItems(), function (c) {
822 angular.forEach( $scope.completed_copies, function (w, i) {
824 itemSvc.copies = itemSvc.copies.concat($scope.completed_copies.splice(i,1));
831 createSimpleUpdateWatcher = function (field) {
832 return $scope.$watch('working.' + field, function () {
833 var newval = $scope.working[field];
835 if (typeof newval != 'undefined') {
836 if (angular.isObject(newval)) { // we'll use the pkey
837 if (newval.id) newval = newval.id();
838 else if (newval.code) newval = newval.code();
841 if (""+newval == "" || newval == null) {
842 $scope.working[field] = undefined;
846 if ($scope.workingGridControls && $scope.workingGridControls.selectedItems) {
848 $scope.workingGridControls.selectedItems(),
850 if (cp[field]() !== newval) {
864 statcat_filter: undefined
867 $scope.statcatUpdate = function (id) {
868 var newval = $scope.working.statcats[id];
870 if (typeof newval != 'undefined') {
871 if (angular.isObject(newval)) { // we'll use the pkey
872 newval = newval.id();
875 if (""+newval == "" || newval == null) {
876 $scope.working.statcats[id] = undefined;
880 if (!$scope.in_item_select && $scope.workingGridControls && $scope.workingGridControls.selectedItems) {
882 $scope.workingGridControls.selectedItems(),
887 angular.forEach( cp.stat_cat_entries(), function (e) {
888 if (e.stat_cat() == id) { // mark deleted
895 var e = new egCore.idl.asce();
901 cp.stat_cat_entries() ?
902 cp.stat_cat_entries().concat([ e ]) :
908 // trim out all deleted ones; the API used to
909 // do the update doesn't actually consult
910 // isdeleted for stat cat entries
912 cp.stat_cat_entries().filter(function (e) {
913 return !Boolean(e.isdeleted());
924 var dataKey = $routeParams.dataKey;
925 console.debug('dataKey: ' + dataKey);
927 if (dataKey && dataKey.length > 0) {
929 $scope.templates = {};
930 $scope.template_name = '';
931 $scope.template_name_list = [];
933 $scope.fetchTemplates = function () {
934 egCore.hatch.getItem('cat.copy.templates').then(function(t) {
936 $scope.templates = t;
937 $scope.template_name_list = Object.keys(t);
940 egCore.hatch.getItem('cat.copy.last_template').then(function(t) {
941 if (t) $scope.template_name = t;
944 $scope.fetchTemplates();
946 $scope.applyTemplate = function (n) {
947 angular.forEach($scope.templates[n], function (v,k) {
948 if (k == 'circ_lib') {
949 $scope.working[k] = egCore.org.get(v);
950 } else if (!angular.isObject(v)) {
951 $scope.working[k] = angular.copy(v);
953 angular.forEach(v, function (sv,sk) {
954 if (k == 'callnumber') {
955 angular.forEach(v, function (cnv,cnk) {
956 $scope.batch[cnk] = cnv;
958 $scope.applyBatchCNValues();
960 $scope.working[k][sk] = angular.copy(sv);
961 if (k == 'statcats') $scope.statcatUpdate(sk);
966 egCore.hatch.setItem('cat.copy.last_template', n);
969 $scope.copytab = 'working';
971 $scope.summaryRecord = null;
972 $scope.record_id = null;
974 $scope.completed_copies = [];
975 $scope.location_orgs = [];
976 $scope.location_cache = {};
977 $scope.statcats = [];
978 if (!$scope.batch) $scope.batch = {};
980 $scope.applyBatchCNValues = function () {
981 if ($scope.data.tree) {
982 angular.forEach($scope.data.tree, function(cn_hash) {
983 angular.forEach(cn_hash, function(copies) {
984 angular.forEach(copies, function(cp) {
985 if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') {
986 var label_class = $scope.classification_list.filter(function(p){ return p.id() == $scope.batch.classification })[0];
987 cp.call_number().label_class(label_class);
988 cp.call_number().ischanged(1);
991 if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') {
992 var prefix = $scope.prefix_list.filter(function(p){ return p.id() == $scope.batch.prefix })[0];
993 cp.call_number().prefix(prefix);
994 cp.call_number().ischanged(1);
997 if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') {
998 cp.call_number().label($scope.batch.label);
999 cp.call_number().ischanged(1);
1000 $scope.dirty = true;
1002 if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') {
1003 var suffix = $scope.suffix_list.filter(function(p){ return p.id() == $scope.batch.suffix })[0];
1004 cp.call_number().suffix(suffix);
1005 cp.call_number().ischanged(1);
1006 $scope.dirty = true;
1014 $scope.clearWorking = function () {
1015 angular.forEach($scope.working, function (v,k,o) {
1016 if (!angular.isObject(v)) {
1017 if (typeof v != 'undefined')
1018 $scope.working[k] = undefined;
1019 } else if (k != 'circ_lib') {
1020 angular.forEach(v, function (sv,sk) {
1021 if (typeof v != 'undefined')
1022 $scope.working[k][sk] = undefined;
1026 $scope.working.circ_lib = undefined; // special
1029 $scope.completedGridDataProvider = egGridDataProvider.instance({
1030 get : function(offset, count) {
1031 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1032 return this.arrayNotifier($scope.completed_copies, offset, count);
1036 $scope.completedGridControls = {};
1038 $scope.workingGridDataProvider = egGridDataProvider.instance({
1039 get : function(offset, count) {
1040 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1041 return this.arrayNotifier(itemSvc.copies, offset, count);
1045 $scope.workingGridControls = {};
1046 $scope.add_vols_copies = false;
1047 $scope.is_fast_add = false;
1051 'open-ils.actor.anon_cache.get_value',
1052 dataKey, 'edit-these-copies'
1053 ).then(function (data) {
1056 if (data.hide_vols && !$scope.defaults.always_volumes) $scope.show_vols = false;
1057 if (data.hide_copies) {
1058 $scope.show_copies = false;
1059 $scope.only_vols = true;
1062 $scope.record_id = data.record_id;
1064 function fetchRaw () {
1065 if (!$scope.only_vols) $scope.dirty = true;
1066 $scope.add_vols_copies = true;
1068 /* data.raw data structure looks like this:
1070 * callnumber : $cn_id, // optional, to add a copy to a cn
1071 * owner : $org, // optional, defaults to ws_ou
1072 * label : $cn_label, // optional, to supply a label on a new cn
1073 * barcode : $cp_barcode // optional, to supply a barcode on a new cp
1074 * fast_add : boolean // optional, to specify whether this came
1078 * All can be left out and a completely empty vol/copy combo will be vivicated.
1084 if (proto.fast_add) $scope.is_fast_add = true;
1085 if (proto.callnumber) {
1086 return egCore.pcrud.retrieve('acn', proto.callnumber)
1087 .then(function(cn) {
1088 var cp = new itemSvc.generateNewCopy(
1090 proto.owner || egCore.auth.user().ws_ou(),
1092 ((!$scope.only_vols) ? true : false)
1095 if (proto.barcode) cp.barcode( proto.barcode );
1100 var cn = new egCore.idl.acn();
1101 cn.id( --itemSvc.new_cn_id );
1103 cn.prefix( $scope.defaults.prefix || -1 );
1104 cn.suffix( $scope.defaults.suffix || -1 );
1105 cn.owning_lib( proto.owner || egCore.auth.user().ws_ou() );
1106 cn.record( $scope.record_id );
1107 egCore.org.settings(
1108 ['cat.default_classification_scheme'],
1110 ).then(function (val) {
1112 $scope.defaults.classification ||
1113 val['cat.default_classification_scheme'] ||
1117 cn.label( proto.label );
1121 'open-ils.cat.biblio.record.marc_cn.retrieve',
1124 ).then(function(cn_array) {
1125 if (cn_array.length > 0) {
1126 for (var field in cn_array[0]) {
1127 cn.label( cn_array[0][field] );
1135 var cp = new itemSvc.generateNewCopy(
1137 proto.owner || egCore.auth.user().ws_ou(),
1142 if (proto.barcode) cp.barcode( proto.barcode );
1150 return itemSvc.copies;
1153 if (data.copies && data.copies.length)
1154 return itemSvc.fetchIds(data.copies).then(fetchRaw);
1160 }).then( function() {
1161 $scope.data = itemSvc;
1162 $scope.workingGridDataProvider.refresh();
1165 $scope.focusNextFirst = function(prev_lib,prev_bc) {
1168 angular.forEach(Object.keys($scope.data.tree).sort(), function (lib) {
1171 if (lib == prev_lib) {
1180 var first_cn = Object.keys($scope.data.tree[n])[0];
1181 var next = '#' + first_cn + '_' + $scope.data.tree[n][first_cn][0].id();
1184 if (!itemSvc.currently_generating) el.focus();
1185 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
1186 itemSvc.nextBarcode(prev_bc).then(function(bc){
1189 el.trigger('change');
1192 itemSvc.currently_generating = false;
1198 $scope.in_item_select = false;
1199 $scope.afterItemSelect = function() { $scope.in_item_select = false };
1200 $scope.handleItemSelect = function (item_list) {
1201 if (item_list && item_list.length > 0) {
1202 $scope.in_item_select = true;
1204 angular.forEach(Object.keys($scope.defaults.attributes), function (attr) {
1206 var value_hash = {};
1207 angular.forEach(item_list, function (item) {
1209 var v = item[attr]()
1210 if (angular.isObject(v)) {
1211 if (v.id) v = v.id();
1212 else if (v.code) v = v.code();
1218 if (Object.keys(value_hash).length == 1) {
1219 if (attr == 'circ_lib') {
1220 $scope.working[attr] = egCore.org.get(item_list[0][attr]());
1222 $scope.working[attr] = item_list[0][attr]();
1225 $scope.working[attr] = undefined;
1229 angular.forEach($scope.statcats, function (sc) {
1232 var value_hash = {};
1234 angular.forEach(item_list, function (item) {
1235 if (item.stat_cat_entries()) {
1236 if (item.stat_cat_entries().length > 0) {
1237 var right_sc = item.stat_cat_entries().filter(function (e) {
1238 return e.stat_cat() == sc.id() && !Boolean(e.isdeleted());
1241 if (right_sc.length > 0) {
1242 value_hash[right_sc[0].id()] = right_sc[0].id();
1252 if (!none && Object.keys(value_hash).length == 1) {
1253 $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]];
1255 $scope.working.statcats[sc.id()] = undefined;
1260 $scope.clearWorking();
1265 $scope.$watch('data.copies.length', function () {
1266 if ($scope.data.copies) {
1267 var base_orgs = $scope.data.copies.map(function(cp){
1268 return cp.circ_lib()
1270 $scope.data.copies.map(function(cp){
1271 return cp.call_number().owning_lib()
1274 [egCore.auth.user().ws_ou()]
1275 ).filter(function(e,i,a){
1276 return a.lastIndexOf(e) === i;
1280 angular.forEach(base_orgs, function(o) {
1281 all_orgs = all_orgs.concat( egCore.org.fullPath(o, true) );
1284 var final_orgs = all_orgs.filter(function(e,i,a){
1285 return a.lastIndexOf(e) === i;
1286 }).sort(function(a, b){return parseInt(a)-parseInt(b)});
1288 if ($scope.location_orgs.toString() != final_orgs.toString()) {
1289 $scope.location_orgs = final_orgs;
1290 if ($scope.location_orgs.length) {
1291 itemSvc.get_locations($scope.location_orgs).then(function(list){
1292 angular.forEach(list, function(l) {
1293 $scope.location_cache[ ''+l.id() ] = l;
1295 $scope.location_list = list;
1298 $scope.statcat_filter_list = [];
1299 angular.forEach($scope.location_orgs, function (o) {
1300 $scope.statcat_filter_list.push(egCore.org.get(o));
1303 itemSvc.get_statcats($scope.location_orgs).then(function(list){
1304 $scope.statcats = list;
1305 angular.forEach($scope.statcats, function (s) {
1307 if (!$scope.working)
1308 $scope.working = { statcats: {}, statcat_filter: undefined};
1309 if (!$scope.working.statcats)
1310 $scope.working.statcats = {};
1312 if (!$scope.in_item_select) {
1313 $scope.working.statcats[s.id()] = undefined;
1315 createStatcatUpdateWatcher(s.id());
1317 $scope.in_item_select = false;
1323 $scope.workingGridDataProvider.refresh();
1326 $scope.statcat_visible = function (sc_owner) {
1327 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
1328 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
1329 if ($scope.working.statcat_filter == ancestor_org.id())
1335 $scope.suffix_list = [];
1336 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1337 $scope.suffix_list = list;
1340 $scope.prefix_list = [];
1341 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1342 $scope.prefix_list = list;
1345 $scope.classification_list = [];
1346 itemSvc.get_classifications().then(function(list){
1347 $scope.classification_list = list;
1350 $scope.$watch('completed_copies.length', function () {
1351 $scope.completedGridDataProvider.refresh();
1354 $scope.location_list = [];
1355 itemSvc.get_locations().then(function(list){
1356 $scope.location_list = list;
1358 createSimpleUpdateWatcher('location');
1360 $scope.status_list = [];
1361 itemSvc.get_statuses().then(function(list){
1362 $scope.status_list = list;
1364 createSimpleUpdateWatcher('status');
1366 $scope.circ_modifier_list = [];
1367 itemSvc.get_circ_mods().then(function(list){
1368 $scope.circ_modifier_list = list;
1370 createSimpleUpdateWatcher('circ_modifier');
1372 $scope.circ_type_list = [];
1373 itemSvc.get_circ_types().then(function(list){
1374 $scope.circ_type_list = list;
1376 createSimpleUpdateWatcher('circ_as_type');
1378 $scope.age_protect_list = [];
1379 itemSvc.get_age_protects().then(function(list){
1380 $scope.age_protect_list = list;
1382 createSimpleUpdateWatcher('age_protect');
1384 $scope.floating_list = [];
1385 itemSvc.get_floating_groups().then(function(list){
1386 $scope.floating_list = list;
1388 createSimpleUpdateWatcher('floating');
1390 createSimpleUpdateWatcher('circ_lib');
1391 createSimpleUpdateWatcher('circulate');
1392 createSimpleUpdateWatcher('holdable');
1393 createSimpleUpdateWatcher('fine_level');
1394 createSimpleUpdateWatcher('loan_duration');
1395 createSimpleUpdateWatcher('price');
1396 createSimpleUpdateWatcher('cost');
1397 createSimpleUpdateWatcher('deposit');
1398 createSimpleUpdateWatcher('deposit_amount');
1399 createSimpleUpdateWatcher('mint_condition');
1400 createSimpleUpdateWatcher('opac_visible');
1401 createSimpleUpdateWatcher('ref');
1403 $scope.saveCompletedCopies = function (and_exit) {
1405 var perCnCopies = {};
1406 angular.forEach( $scope.completed_copies, function (cp) {
1407 var cn = cp.call_number();
1408 var cn_cps = cp.call_number().copies();
1409 cp.call_number().copies([]);
1410 var cn_id = cp.call_number().id();
1411 cp.call_number(cn_id); // prevent loops in JSON-ification
1412 if (!cnHash[cn_id]) {
1413 cnHash[cn_id] = egCore.idl.Clone(cn);
1414 perCnCopies[cn_id] = [egCore.idl.Clone(cp)];
1416 perCnCopies[cn_id].push(egCore.idl.Clone(cp));
1418 cp.call_number(cn); // put the data back
1419 cp.call_number().copies(cn_cps);
1420 if (typeof cnHash[cn_id].prefix() == 'object')
1421 cnHash[cn_id].prefix(cnHash[cn_id].prefix().id()); // un-object-ize some fields
1422 if (typeof cnHash[cn_id].suffix() == 'object')
1423 cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields
1426 angular.forEach(perCnCopies, function (v, k) {
1427 cnHash[k].copies(v);
1431 angular.forEach(cnHash, function (v, k) {
1437 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1438 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1 }
1439 ).then(function(update_count) {
1441 $scope.dirty = false;
1442 $timeout(function(){$window.close()});
1447 $scope.saveAndContinue = function () {
1448 $scope.saveCompletedCopies(false);
1451 $scope.workingSaveAndExit = function () {
1452 $scope.workingToComplete();
1453 $scope.saveAndExit();
1456 $scope.saveAndExit = function () {
1457 $scope.saveCompletedCopies(true);
1462 $scope.copy_notes_dialog = function(copy_list) {
1463 var default_pub = Boolean($scope.defaults.copy_notes_pub);
1464 if (!angular.isArray(copy_list)) copy_list = [copy_list];
1466 return $modal.open({
1467 templateUrl: './cat/volcopy/t_copy_notes',
1470 ['$scope','$modalInstance',
1471 function($scope , $modalInstance) {
1472 $scope.focusNote = true;
1474 creator : egCore.auth.user().id(),
1480 $scope.require_initials = false;
1481 egCore.org.settings([
1482 'ui.staff.require_initials.copy_notes'
1483 ]).then(function(set) {
1484 $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
1487 $scope.note_list = [];
1488 if (copy_list.length == 1) {
1489 $scope.note_list = copy_list[0].notes();
1492 $scope.ok = function(note) {
1494 if (note.initials) note.value += ' [' + note.initials + ']';
1495 angular.forEach(copy_list, function (cp) {
1496 if (!angular.isArray(cp.notes())) cp.notes([]);
1497 var n = new egCore.idl.acpn();
1499 n.creator(note.creator);
1501 n.title(note.title);
1502 n.value(note.value);
1503 n.owning_copy(cp.id());
1504 cp.notes().push( n );
1507 $modalInstance.close();
1510 $scope.cancel = function($event) {
1511 $modalInstance.dismiss();
1512 $event.preventDefault();
1520 .directive("egVolTemplate", function () {
1524 template: '<div ng-include="'+"'/eg/staff/cat/volcopy/t_attr_edit'"+'"></div>',
1526 controller : ['$scope','$window','itemSvc','egCore',
1527 function ( $scope , $window , itemSvc , egCore ) {
1529 $scope.defaults = { // If defaults are not set at all, allow everything
1530 barcode_checkdigit : false,
1531 auto_gen_barcode : false,
1536 loan_duration : true,
1541 deposit_amount : true,
1542 opac_visible : true,
1545 mint_condition : true,
1548 circ_modifier : true,
1549 circ_as_type : true,
1557 $scope.fetchDefaults = function () {
1558 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
1560 $scope.defaults = t;
1561 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
1562 if (typeof $scope.defaults.statcat_filter == 'object') {
1563 // want fieldmapper object here...
1564 $scope.defaults.statcat_filter =
1565 egCore.idl.Clone($scope.defaults.statcat_filter);
1567 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
1572 $scope.fetchDefaults();
1574 $scope.dirty = false;
1575 $scope.$watch('dirty',
1576 function(newVal, oldVal) {
1577 if (newVal && newVal != oldVal) {
1578 $($window).on('beforeunload.template', function(){
1579 return 'There is unsaved template data!'
1582 $($window).off('beforeunload.template');
1587 $scope.template_controls = true;
1589 $scope.fetchTemplates = function () {
1590 egCore.hatch.getItem('cat.copy.templates').then(function(t) {
1592 $scope.templates = t;
1593 $scope.template_name_list = Object.keys(t);
1597 $scope.fetchTemplates();
1599 $scope.applyTemplate = function (n) {
1600 angular.forEach($scope.templates[n], function (v,k) {
1601 if (k == 'circ_lib') {
1602 $scope.working[k] = egCore.org.get(v);
1603 } else if (!angular.isObject(v)) {
1604 $scope.working[k] = angular.copy(v);
1606 angular.forEach(v, function (sv,sk) {
1607 if (!(k in $scope.working))
1608 $scope.working[k] = {};
1609 $scope.working[k][sk] = angular.copy(sv);
1613 $scope.template_name = '';
1616 $scope.deleteTemplate = function (n) {
1618 delete $scope.templates[n]
1619 $scope.template_name_list = Object.keys($scope.templates);
1620 $scope.template_name = '';
1621 egCore.hatch.setItem('cat.copy.templates', $scope.templates);
1622 $scope.$parent.fetchTemplates();
1626 $scope.saveTemplate = function (n) {
1630 angular.forEach($scope.working, function (v,k) {
1631 if (angular.isObject(v)) { // we'll use the pkey
1632 if (v.id) v = v.id();
1633 else if (v.code) v = v.code();
1639 $scope.templates[n] = tmpl;
1640 $scope.template_name_list = Object.keys($scope.templates);
1642 egCore.hatch.setItem('cat.copy.templates', $scope.templates);
1643 $scope.$parent.fetchTemplates();
1645 $scope.dirty = false;
1647 // save all templates, as we might do after an import
1648 egCore.hatch.setItem('cat.copy.templates', $scope.templates);
1649 $scope.$parent.fetchTemplates();
1653 $scope.templates = {};
1654 $scope.imported_templates = { data : '' };
1655 $scope.template_name = '';
1656 $scope.template_name_list = [];
1658 $scope.$watch('imported_templates.data', function(newVal, oldVal) {
1659 if (newVal && newVal != oldVal) {
1661 var newTemplates = JSON.parse(newVal);
1662 if (!Object.keys(newTemplates).length) return;
1663 $scope.templates = newTemplates;
1664 $scope.template_name_list = Object.keys(newTemplates);
1665 $scope.template_name = '';
1667 console.log('tried to import an invalid copy template file');
1672 $scope.tracker = function (x,f) { if (x) return x[f]() };
1673 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
1674 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1676 $scope.orgById = function (id) { return egCore.org.get(id) }
1677 $scope.statusById = function (id) {
1678 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
1680 $scope.locationById = function (id) {
1681 return $scope.location_cache[''+id];
1684 createSimpleUpdateWatcher = function (field) {
1685 $scope.$watch('working.' + field, function () {
1686 var newval = $scope.working[field];
1688 if (typeof newval != 'undefined') {
1689 $scope.dirty = true;
1690 if (angular.isObject(newval)) { // we'll use the pkey
1691 if (newval.id) $scope.working[field] = newval.id();
1692 else if (newval.code) $scope.working[field] = newval.code();
1695 if (""+newval == "" || newval == null) {
1696 $scope.working[field] = undefined;
1705 statcat_filter: undefined
1708 $scope.statcat_visible = function (sc_owner) {
1709 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
1710 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
1711 if ($scope.working.statcat_filter == ancestor_org.id())
1717 createStatcatUpdateWatcher = function (id) {
1718 return $scope.$watch('working.statcats[' + id + ']', function () {
1719 if ($scope.working.statcats) {
1720 var newval = $scope.working.statcats[id];
1722 if (typeof newval != 'undefined') {
1723 $scope.dirty = true;
1724 if (angular.isObject(newval)) { // we'll use the pkey
1725 newval = newval.id();
1728 if (""+newval == "" || newval == null) {
1729 $scope.working.statcats[id] = undefined;
1738 $scope.clearWorking = function () {
1739 angular.forEach($scope.working, function (v,k,o) {
1740 if (!angular.isObject(v)) {
1741 if (typeof v != 'undefined')
1742 $scope.working[k] = undefined;
1743 } else if (k != 'circ_lib') {
1744 angular.forEach(v, function (sv,sk) {
1745 $scope.working[k][sk] = undefined;
1749 $scope.working.circ_lib = undefined; // special
1750 $scope.dirty = false;
1753 $scope.working = {};
1754 $scope.location_orgs = [];
1755 $scope.location_cache = {};
1757 $scope.location_list = [];
1758 itemSvc.get_locations(
1759 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
1760 ).then(function(list){
1761 $scope.location_list = list;
1763 createSimpleUpdateWatcher('location');
1765 $scope.statcat_filter_list = egCore.org.fullPath( egCore.auth.user().ws_ou() );
1767 $scope.statcats = [];
1768 itemSvc.get_statcats(
1769 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
1770 ).then(function(list){
1771 $scope.statcats = list;
1772 angular.forEach($scope.statcats, function (s) {
1774 if (!$scope.working)
1775 $scope.working = { statcats: {}, statcat_filter: undefined};
1776 if (!$scope.working.statcats)
1777 $scope.working.statcats = {};
1779 $scope.working.statcats[s.id()] = undefined;
1780 createStatcatUpdateWatcher(s.id());
1784 $scope.status_list = [];
1785 itemSvc.get_statuses().then(function(list){
1786 $scope.status_list = list;
1788 createSimpleUpdateWatcher('status');
1790 $scope.circ_modifier_list = [];
1791 itemSvc.get_circ_mods().then(function(list){
1792 $scope.circ_modifier_list = list;
1794 createSimpleUpdateWatcher('circ_modifier');
1796 $scope.circ_type_list = [];
1797 itemSvc.get_circ_types().then(function(list){
1798 $scope.circ_type_list = list;
1800 createSimpleUpdateWatcher('circ_as_type');
1802 $scope.age_protect_list = [];
1803 itemSvc.get_age_protects().then(function(list){
1804 $scope.age_protect_list = list;
1806 createSimpleUpdateWatcher('age_protect');
1808 createSimpleUpdateWatcher('circulate');
1809 createSimpleUpdateWatcher('holdable');
1810 createSimpleUpdateWatcher('fine_level');
1811 createSimpleUpdateWatcher('loan_duration');
1812 createSimpleUpdateWatcher('cost');
1813 createSimpleUpdateWatcher('deposit');
1814 createSimpleUpdateWatcher('deposit_amount');
1815 createSimpleUpdateWatcher('mint_condition');
1816 createSimpleUpdateWatcher('opac_visible');
1817 createSimpleUpdateWatcher('ref');
1819 $scope.suffix_list = [];
1820 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1821 $scope.suffix_list = list;
1824 $scope.prefix_list = [];
1825 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1826 $scope.prefix_list = list;
1829 $scope.classification_list = [];
1830 itemSvc.get_classifications().then(function(list){
1831 $scope.classification_list = list;
1834 createSimpleUpdateWatcher('working.callnumber.classification');
1835 createSimpleUpdateWatcher('working.callnumber.prefix');
1836 createSimpleUpdateWatcher('working.callnumber.suffix');