5 angular.module('egVolCopy',
6 ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'egGridMod'])
8 .filter('boolText', function(){
14 .config(['ngToastProvider', function(ngToastProvider) {
15 ngToastProvider.configure({
16 verticalPosition: 'bottom',
21 .config(function($routeProvider, $locationProvider, $compileProvider) {
22 $locationProvider.html5Mode(true);
23 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|mailto|blob):/); // grid export
26 delay : ['egStartup', function(egStartup) { return egStartup.go(); }]
29 $routeProvider.when('/cat/volcopy/edit_templates', {
30 templateUrl: './cat/volcopy/t_view',
31 controller: 'EditCtrl',
35 $routeProvider.when('/cat/volcopy/:dataKey', {
36 templateUrl: './cat/volcopy/t_view',
37 controller: 'EditCtrl',
41 $routeProvider.when('/cat/volcopy/:dataKey/:mode', {
42 templateUrl: './cat/volcopy/t_view',
43 controller: 'EditCtrl',
50 function(egCore , $q) {
53 currently_generating : false,
54 auto_gen_barcode : false,
55 barcode_checkdigit : false,
58 tree : {}, // holds lib->cn->copy hash stack
59 copies : [] // raw copy list
62 service.nextBarcode = function(bc) {
63 service.currently_generating = true;
64 return egCore.net.request(
66 'open-ils.cat.item.barcode.autogen',
68 bc, 1, { checkdigit: service.barcode_checkdigit }
69 ).then(function(resp) { // get_barcodes
70 var evt = egCore.evt.parse(resp);
71 if (!evt) return resp[0];
76 service.checkBarcode = function(bc) {
77 if (!service.barcode_checkdigit) return true;
78 if (bc != Number(bc)) return false;
80 // "16.00" == Number("16.00"), but the . is bad.
81 // Throw out any barcode that isn't just digits
82 if (bc.search(/\D/) != -1) return false;
83 var last_digit = bc.substr(bc.length-1);
84 var stripped_barcode = bc.substr(0,bc.length-1);
85 return service.barcodeCheckdigit(stripped_barcode).toString() == last_digit;
88 service.barcodeCheckdigit = function(bc) {
89 var reverse_barcode = bc.toString().split('').reverse();
90 var check_sum = 0; var multiplier = 2;
91 for (var i = 0; i < reverse_barcode.length; i++) {
92 var digit = reverse_barcode[i];
93 var product = digit * multiplier; product = product.toString();
95 for (var j = 0; j < product.length; j++) {
96 temp_sum += Number( product[j] );
98 check_sum += Number( temp_sum );
99 multiplier = ( multiplier == 2 ? 1 : 2 );
101 check_sum = check_sum.toString();
102 var next_multiple_of_10 = (check_sum.match(/(\d*)\d$/)[1] * 10) + 10;
103 var check_digit = next_multiple_of_10 - Number(check_sum); if (check_digit == 10) check_digit = 0;
107 // returns a promise resolved with the list of circ mods
108 service.get_classifications = function() {
110 return $q.when(egCore.env.acnc.list);
112 return egCore.pcrud.retrieveAll('acnc', null, {atomic : true})
113 .then(function(list) {
114 egCore.env.absorbList(list, 'acnc');
119 service.get_prefixes = function(org) {
120 return egCore.pcrud.search('acnp',
121 {owning_lib : egCore.org.fullPath(org, true)},
122 {order_by : { acnp : 'label_sortkey' }}, {atomic : true}
127 service.get_statcats = function(orgs) {
128 return egCore.pcrud.search('asc',
132 asc : ['owner','entries']
139 service.get_copy_alert_types = function(orgs) {
140 return egCore.pcrud.search('ccat',
147 service.get_copy_alerts = function(copy_id) {
148 return egCore.pcrud.search('aca', { copy : copy_id, ack_time : null },
149 { flesh : 1, flesh_fields : { aca : ['alert_type'] } },
154 service.get_locations = function(orgs) {
155 return egCore.pcrud.search('acpl',
156 {owning_lib : orgs, deleted : 'f'},
160 acpl : ['owning_lib']
162 order_by : { acpl : 'name' }
168 service.get_suffixes = function(org) {
169 return egCore.pcrud.search('acns',
170 {owning_lib : egCore.org.fullPath(org, true)},
171 {order_by : { acns : 'label_sortkey' }}, {atomic : true}
176 service.get_magic_statuses = function() {
177 /* TODO: make these more configurable per lp1616170 */
182 ,8 /* On holds shelf */
183 ,16 /* Long overdue */
184 ,18 /* Canceled Transit */
188 service.get_statuses = function() {
190 return $q.when(egCore.env.ccs.list);
192 return egCore.pcrud.retrieveAll('ccs', {order_by : { ccs : 'name' }}, {atomic : true}).then(
194 egCore.env.absorbList(list, 'ccs');
201 service.get_circ_mods = function() {
203 return $q.when(egCore.env.ccm.list);
205 return egCore.pcrud.retrieveAll('ccm', {}, {atomic : true}).then(
207 egCore.env.absorbList(list, 'ccm');
214 service.get_circ_types = function() {
216 return $q.when(egCore.env.citm.list);
218 return egCore.pcrud.retrieveAll('citm', {}, {atomic : true}).then(
220 egCore.env.absorbList(list, 'citm');
227 service.get_age_protects = function() {
228 if (egCore.env.crahp)
229 return $q.when(egCore.env.crahp.list);
231 return egCore.pcrud.retrieveAll('crahp', {}, {atomic : true}).then(
233 egCore.env.absorbList(list, 'crahp');
240 service.get_floating_groups = function() {
242 return $q.when(egCore.env.cfg.list);
244 return egCore.pcrud.retrieveAll('cfg', {}, {atomic : true}).then(
246 egCore.env.absorbList(list, 'cfg');
253 service.bmp_parts = {};
254 service.get_parts = function(rec) {
255 if (service.bmp_parts[rec])
256 return $q.when(service.bmp_parts[rec]);
258 return egCore.pcrud.search('bmp',
259 {record : rec, deleted : 'f'},
260 null, {atomic : true}
261 ).then(function(list) {
262 service.bmp_parts[rec] = list;
268 service.get_acp_templates = function() {
269 // Already downloaded for this user? Return local copy. Changing users or logging out causes another download
270 // so users always have their own templates, and any changes made on other machines appear as expected.
271 if (egCore.hatch.getSessionItem('cat.copy.templates.usr') == egCore.auth.user().id()) {
272 return egCore.hatch.getItem('cat.copy.templates').then(function(templ) {
276 // this can be disabled for debugging to force a re-download and translation of test templates
277 egCore.hatch.setSessionItem('cat.copy.templates.usr', egCore.auth.user().id());
278 return service.load_remote_acp_templates();
283 service.save_acp_templates = function(t) {
284 egCore.hatch.setItem('cat.copy.templates', t);
285 egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
286 egCore.auth.token(), egCore.auth.user().id(), { "webstaff.cat.copy.templates": t });
287 // console.warn('Saved ' + JSON.stringify({"webstaff.cat.copy.templates": t}));
290 service.load_remote_acp_templates = function() {
291 // After the XUL Client is completely removed everything related
292 // to staff_client.copy_editor.templates and convert_xul_templates
293 // can be thrown away.
294 return egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.retrieve.authoritative',
295 egCore.auth.token(), egCore.auth.user().id(),
296 ['webstaff.cat.copy.templates','staff_client.copy_editor.templates']).then(function(settings) {
297 if (settings['webstaff.cat.copy.templates']) {
298 egCore.hatch.setItem('cat.copy.templates', settings['webstaff.cat.copy.templates']);
299 return settings['webstaff.cat.copy.templates'];
301 if (settings['staff_client.copy_editor.templates']) {
302 var new_templ = service.convert_xul_templates(settings['staff_client.copy_editor.templates']);
303 egCore.hatch.setItem('cat.copy.templates', new_templ);
304 // console.warn('Saving: ' + JSON.stringify({'webstaff.cat.copy.templates' : new_templ}));
305 egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
306 egCore.auth.token(), egCore.auth.user().id(), {'webstaff.cat.copy.templates' : new_templ});
314 service.convert_xul_templates = function(xultempl) {
316 var templ_names = Object.keys(xultempl);
327 for (i=0; i < templ_names.length; i++) {
328 name = templ_names[i];
331 xul_t = xultempl[name];
332 fields = Object.keys(xul_t);
334 if (fields.length > 0) {
335 for (j=0; j < fields.length; j++) {
336 curr_field = xul_t[fields[j]];
337 var field_name = curr_field["field"];
339 if ( field_name == null ) { continue; }
340 if ( curr_field["value"] == "<HACK:KLUDGE:NULL>" ) { continue; }
342 // floating changed from a boolean to an integer at one point;
343 // take this opportunity to remove the boolean from any old templates
344 if ( curr_field["type"] === "attribute" && field_name === "floating" ) {
345 if ( curr_field["value"].match(/[tf]/) ) { continue; }
348 if ( curr_field["type"] === "stat_cat" ) {
349 stat_cats[field_name] = parseInt(curr_field["value"]);
351 tmp_val = curr_field['value'];
352 if ( tmp_val.toString().match(/^[-0-9.]+$/)) {
353 tmp_val = parseFloat(tmp_val);
356 if (field_name.match(/^batch_.*_menulist$/)) {
357 // special handling for volume fields
358 if (!("callnumber" in curr_templ)) curr_templ["callnumber"] = {};
359 if (field_name === "batch_class_menulist") curr_templ["callnumber"]["classification"] = tmp_val;
360 if (field_name === "batch_prefix_menulist") curr_templ["callnumber"]["prefix"] = tmp_val;
361 if (field_name === "batch_suffix_menulist") curr_templ["callnumber"]["suffix"] = tmp_val;
363 curr_templ[field_name] = tmp_val;
368 if ( (Object.keys(stat_cats)).length > 0 ) {
369 curr_templ["statcats"] = stat_cats;
372 conv_templ[name] = curr_templ;
382 acp : ['call_number','parts','stat_cat_entries', 'notes', 'tags'],
383 acn : ['label_class','prefix','suffix'],
388 service.addCopy = function (cp) {
390 if (!cp.parts()) cp.parts([]); // just in case...
392 service.get_copy_alerts(cp.id()).then(function(aca) {
396 var lib = cp.call_number().owning_lib();
397 var cn = cp.call_number().id();
399 if (!service.tree[lib]) service.tree[lib] = {};
400 if (!service.tree[lib][cn]) service.tree[lib][cn] = [];
402 service.tree[lib][cn].push(cp);
403 service.copies.push(cp);
406 service.checkDuplicateBarcode = function(bc, id) {
408 return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc, id : { '!=' : id } })
410 function () { return final },
411 function () { return final },
412 function () { final = true; }
416 service.fetchIds = function(idList) {
417 service.tree = {}; // clear the tree on fetch
418 service.copies = []; // clear the copy list on fetch
419 return egCore.pcrud.search('acp', { 'id' : idList }, service.flesh).then(null,null,
421 service.addCopy(copy);
426 // create a new acp object with default values
427 // (both hard-coded and coming from OU settings)
428 service.generateNewCopy = function(callNumber, owningLib, isFastAdd, isNew) {
429 var cp = new egCore.idl.acp();
430 cp.id( --service.new_cp_id );
434 cp.circ_lib( owningLib );
435 cp.call_number( callNumber );
438 cp.deposit_amount(0);
439 cp.fine_level(2); // Normal
440 cp.loan_duration(2); // Normal
441 cp.location(1); // Stacks
444 cp.opac_visible('t');
446 cp.mint_condition('t');
447 cp.empty_barcode = true;
449 var status_setting = isFastAdd ?
450 'cat.default_copy_status_fast' :
451 'cat.default_copy_status_normal';
455 ).then(function(set) {
456 var default_ccs = parseInt(set[status_setting]);
457 if (isNaN(default_ccs))
458 default_ccs = (isFastAdd ? 0 : 5); // 0 is Available, 5 is In Process
459 cp.status(default_ccs);
468 .directive("egVolCopyEdit", function () {
474 '<div class="col-xs-5" ng-class="{'+"'has-error'"+':barcode_has_error}">'+
475 '<input id="{{callNumber.id()}}_{{copy.id()}}"'+
476 ' eg-enter="nextBarcode(copy.id())" class="form-control"'+
477 ' type="text" ng-model="barcode" ng-change="updateBarcode()"/>'+
478 '<div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>'+
479 '<div class="label label-danger" ng-if="empty_barcode">{{empty_barcode_string}}</div>'+
481 '<div class="col-xs-3"><input class="form-control" type="number" min="1" ng-model="copy_number" ng-change="updateCopyNo()"/></div>'+
482 '<div class="col-xs-4"><eg-basic-combo-box eg-disabled="record == 0" list="parts" selected="part"></eg-basic-combo-box></div>'+
485 scope: { focusNext: "=", copy: "=", callNumber: "=", index: "@", record: "@" },
486 controller : ['$scope','itemSvc','egCore',
487 function ( $scope , itemSvc , egCore ) {
488 $scope.new_part_id = 0;
489 $scope.barcode_has_error = false;
490 $scope.duplicate_barcode = false;
491 $scope.empty_barcode = false;
492 $scope.duplicate_barcode_string = window.duplicate_barcode_string;
493 $scope.empty_barcode_string = window.empty_barcode_string;
495 if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true;
497 $scope.nextBarcode = function (i) {
498 $scope.focusNext(i, $scope.barcode);
501 $scope.updateBarcode = function () {
502 if ($scope.barcode != '') {
503 $scope.copy.empty_barcode = $scope.empty_barcode = false;
504 $scope.barcode_has_error = !Boolean(itemSvc.checkBarcode($scope.barcode));
505 itemSvc.checkDuplicateBarcode($scope.barcode, $scope.copy.id())
506 .then(function (state) { $scope.copy.duplicate_barcode = $scope.duplicate_barcode = state });
508 $scope.copy.empty_barcode = $scope.empty_barcode = true;
511 $scope.copy.barcode($scope.barcode);
512 $scope.copy.ischanged(1);
513 if (itemSvc.currently_generating)
514 $scope.focusNext($scope.copy.id(), $scope.barcode);
517 $scope.updateCopyNo = function () { $scope.copy.copy_number($scope.copy_number); $scope.copy.ischanged(1); };
518 $scope.updatePart = function () {
520 var p = $scope.part_list.filter(function (x) {
521 return x.label() == $scope.part
523 if (p.length > 0) { // preexisting part
525 } else { // create one...
526 var part = new egCore.idl.bmp();
527 part.id( --$scope.new_part_id );
529 part.label( $scope.part );
530 part.record( $scope.callNumber.record() );
531 $scope.copy.parts([part]);
532 $scope.copy.ischanged(1);
535 $scope.copy.parts([]);
537 $scope.copy.ischanged(1);
541 $scope.part_list = [];
543 itemSvc.get_parts($scope.callNumber.record())
544 .then(function(list){
545 $scope.part_list = list;
546 angular.forEach(list, function(p){ $scope.parts.push(p.label()) });
547 $scope.parts = angular.copy($scope.parts);
549 $scope.$watch('part', $scope.updatePart);
550 if ($scope.copy.parts()) {
551 var the_part = $scope.copy.parts()[0];
552 if (the_part) $scope.part = the_part.label();
556 $scope.barcode = $scope.copy.barcode();
557 $scope.copy_number = $scope.copy.copy_number();
565 .directive("egVolRow", function () {
572 '<div class="col-xs-2">'+
573 '<select ng-disabled="record == 0" class="form-control" ng-model="classification" ng-change="updateClassification()" ng-options="cl.name() for cl in classification_list"/>'+
575 '<div class="col-xs-1">'+
576 '<select ng-disabled="record == 0" class="form-control" ng-model="prefix" ng-change="updatePrefix()" ng-options="p.label() for p in prefix_list"/>'+
578 '<div class="col-xs-2">'+
579 '<input ng-disabled="record == 0" class="form-control" type="text" ng-change="updateLabel()" ng-model="label"/>'+
580 '<div class="label label-danger" ng-if="empty_label">{{empty_label_string}}</div>'+
582 '<div class="col-xs-1">'+
583 '<select ng-disabled="record == 0" class="form-control" ng-model="suffix" ng-change="updateSuffix()" ng-options="s.label() for s in suffix_list"/>'+
585 '<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>'+
586 '<div ng-hide="onlyVols" class="col-xs-5">'+
587 '<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>'+
591 scope: {focusNext: "=", allcopies: "=", copies: "=", onlyVols: "=", record: "@" },
592 controller : ['$scope','itemSvc','egCore',
593 function ( $scope , itemSvc , egCore ) {
594 $scope.callNumber = $scope.copies[0].call_number();
595 if (!$scope.callNumber.label()) $scope.callNumber.empty_label = true;
597 $scope.empty_label = false;
598 $scope.empty_label_string = window.empty_label_string;
600 $scope.idTracker = function (x) { if (x && x.id) return x.id() };
602 // XXX $() is not working! arg
603 $scope.focusNextBarcode = function (i, prev_bc) {
606 angular.forEach($scope.copies, function (cp) {
614 if (yep) n = cp.id();
618 var next = '#' + $scope.callNumber.id() + '_' + n;
621 if (!itemSvc.currently_generating) el.focus();
622 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
623 itemSvc.nextBarcode(prev_bc).then(function(bc){
626 el.trigger('change');
629 itemSvc.currently_generating = false;
633 $scope.focusNext($scope.callNumber.id(),prev_bc)
637 $scope.suffix_list = [];
638 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
639 $scope.suffix_list = list;
640 $scope.$watch('callNumber.suffix()', function (v) {
641 if (angular.isObject(v)) v = v.id();
642 $scope.suffix = $scope.suffix_list.filter( function (s) {
648 $scope.updateSuffix = function () {
649 angular.forEach($scope.copies, function(cp) {
650 cp.call_number().suffix($scope.suffix);
651 cp.call_number().ischanged(1);
655 $scope.prefix_list = [];
656 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
657 $scope.prefix_list = list;
658 $scope.$watch('callNumber.prefix()', function (v) {
659 if (angular.isObject(v)) v = v.id();
660 $scope.prefix = $scope.prefix_list.filter(function (p) {
666 $scope.updatePrefix = function () {
667 angular.forEach($scope.copies, function(cp) {
668 cp.call_number().prefix($scope.prefix);
669 cp.call_number().ischanged(1);
672 $scope.$watch('callNumber.owning_lib()', function(oldLib, newLib) {
673 if (oldLib == newLib) return;
674 var currentPrefix = $scope.callNumber.prefix();
675 if (angular.isObject(currentPrefix)) currentPrefix = currentPrefix.id();
676 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
677 $scope.prefix_list = list;
678 var newPrefixId = $scope.prefix_list.filter(function (p) {
679 return p.id() == currentPrefix;
681 if (newPrefixId.id) newPrefixId = newPrefixId.id();
682 $scope.prefix = $scope.prefix_list.filter(function (p) {
683 return p.id() == newPrefixId;
685 if ($scope.newPrefixId != currentPrefix) {
686 $scope.callNumber.prefix($scope.prefix);
689 var currentSuffix = $scope.callNumber.suffix();
690 if (angular.isObject(currentSuffix)) currentSuffix = currentSuffix.id();
691 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
692 $scope.suffix_list = list;
693 var newSuffixId = $scope.suffix_list.filter(function (s) {
694 return s.id() == currentSuffix;
696 if (newSuffixId.id) newSuffixId = newSuffixId.id();
697 $scope.suffix = $scope.suffix_list.filter(function (s) {
698 return s.id() == newSuffixId;
700 if ($scope.newSuffixId != currentSuffix) {
701 $scope.callNumber.suffix($scope.suffix);
706 $scope.classification_list = [];
707 itemSvc.get_classifications().then(function(list){
708 $scope.classification_list = list;
709 $scope.$watch('callNumber.label_class()', function (v) {
710 if (angular.isObject(v)) v = v.id();
711 $scope.classification = $scope.classification_list.filter(function (c) {
717 $scope.updateClassification = function () {
718 angular.forEach($scope.copies, function(cp) {
719 cp.call_number().label_class($scope.classification);
720 cp.call_number().ischanged(1);
724 $scope.updateLabel = function () {
725 angular.forEach($scope.copies, function(cp) {
726 cp.call_number().label($scope.label);
727 cp.call_number().ischanged(1);
731 $scope.$watch('callNumber.label()', function (v) {
733 if ($scope.label == '') {
734 $scope.callNumber.empty_label = $scope.empty_label = true;
736 $scope.callNumber.empty_label = $scope.empty_label = false;
740 $scope.prefix = $scope.callNumber.prefix();
741 $scope.suffix = $scope.callNumber.suffix();
742 $scope.classification = $scope.callNumber.label_class();
743 $scope.label = $scope.callNumber.label();
745 $scope.copy_count = $scope.copies.length;
746 $scope.orig_copy_count = $scope.copy_count;
748 $scope.changeCPCount = function () {
749 while ($scope.copy_count > $scope.copies.length) {
750 var cp = itemSvc.generateNewCopy(
752 $scope.callNumber.owning_lib(),
756 $scope.copies.push( cp );
757 $scope.allcopies.push( cp );
761 if ($scope.copy_count >= $scope.orig_copy_count) {
762 var how_many = $scope.copies.length - $scope.copy_count;
764 var dead = $scope.copies.splice($scope.copy_count,how_many);
765 $scope.callNumber.copies($scope.copies);
767 // Trimming the global list is a bit more tricky
768 angular.forEach( dead, function (d) {
769 angular.forEach( $scope.allcopies, function (l, i) {
770 if (l === d) $scope.allcopies.splice(i,1);
783 .directive("egVolEdit", function () {
789 '<div class="col-xs-1"><eg-org-selector alldisabled="{{record == 0}}" selected="owning_lib" disable-test="cant_have_vols"></eg-org-selector></div>'+
790 '<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>'+
791 '<div class="col-xs-10">'+
792 '<eg-vol-row only-vols="onlyVols" record="{{record}}"'+
793 'ng-repeat="(cn,copies) in struct" '+
794 'focus-next="focusNextFirst" copies="copies" allcopies="allcopies">'+
799 scope: { focusNext: "=", allcopies: "=", struct: "=", lib: "@", record: "@", onlyVols: "=" },
800 controller : ['$scope','itemSvc','egCore',
801 function ( $scope , itemSvc , egCore ) {
802 $scope.first_cn = Object.keys($scope.struct)[0];
803 $scope.full_cn = $scope.struct[$scope.first_cn][0].call_number();
805 $scope.defaults = {};
806 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
812 $scope.focusNextFirst = function(prev_cn,prev_bc) {
815 angular.forEach(Object.keys($scope.struct).sort(), function (cn) {
827 var next = '#' + n + '_' + $scope.struct[n][0].id();
830 if (!itemSvc.currently_generating) el.focus();
831 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
832 itemSvc.nextBarcode(prev_bc).then(function(bc){
835 el.trigger('change');
838 itemSvc.currently_generating = false;
842 $scope.focusNext($scope.lib, prev_bc);
846 $scope.cn_count = Object.keys($scope.struct).length;
847 $scope.orig_cn_count = $scope.cn_count;
849 $scope.owning_lib = egCore.org.get($scope.lib);
850 $scope.$watch('owning_lib', function (oldLib, newLib) {
851 if (oldLib == newLib) return;
852 angular.forEach( Object.keys($scope.struct), function (cn) {
853 $scope.struct[cn][0].call_number().owning_lib( $scope.owning_lib.id() );
854 $scope.struct[cn][0].call_number().ischanged(1);
858 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
860 $scope.$watch('cn_count', function (n) {
861 var o = Object.keys($scope.struct).length;
862 if (n > o) { // adding
863 for (var i = o; o < n; o++) {
864 var cn = new egCore.idl.acn();
865 cn.id( --itemSvc.new_cn_id );
867 cn.prefix( $scope.defaults.prefix || -1 );
868 cn.suffix( $scope.defaults.suffix || -1 );
869 cn.label_class( $scope.defaults.classification || 1 );
870 cn.owning_lib( $scope.owning_lib.id() );
871 cn.record( $scope.full_cn.record() );
873 var cp = itemSvc.generateNewCopy(
875 $scope.owning_lib.id(),
880 $scope.struct[cn.id()] = [cp];
881 $scope.allcopies.push(cp);
882 if (!$scope.defaults.classification) {
884 ['cat.default_classification_scheme'],
886 ).then(function (val) {
887 cn.label_class(val['cat.default_classification_scheme']);
891 } else if (n < o && n >= $scope.orig_cn_count) { // removing
892 var how_many = o - n;
895 .sort(function(a, b){return parseInt(a)-parseInt(b)})
896 .filter(function(x){ return parseInt(x) <= 0 });
897 for (var i = 0; i < how_many; i++) {
898 // Trimming the global list is a bit more tricky
899 angular.forEach($scope.struct[list[i]], function (d) {
900 angular.forEach( $scope.allcopies, function (l, j) {
901 if (l === d) $scope.allcopies.splice(j,1);
904 delete $scope.struct[list[i]];
917 .controller('EditCtrl',
918 ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$uibModal',
919 function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $uibModal) {
921 $scope.forms = {}; // Accessed by t_attr_edit.tt2
922 $scope.i18n = egCore.i18n;
924 $scope.defaults = { // If defaults are not set at all, allow everything
925 barcode_checkdigit : false,
926 auto_gen_barcode : false,
932 loan_duration : true,
937 deposit_amount : true,
941 mint_condition : true,
944 circ_modifier : true,
954 $scope.new_lib_to_add = egCore.org.get(egCore.auth.user().ws_ou());
955 $scope.changeNewLib = function (org) {
956 $scope.new_lib_to_add = org;
958 $scope.addLibToStruct = function () {
959 var newLib = $scope.new_lib_to_add;
960 var cn = new egCore.idl.acn();
961 cn.id( --itemSvc.new_cn_id );
963 cn.prefix( $scope.defaults.prefix || -1 );
964 cn.suffix( $scope.defaults.suffix || -1 );
965 cn.label_class( $scope.defaults.classification || 1 );
966 cn.owning_lib( newLib.id() );
967 cn.record( $scope.record_id );
969 var cp = itemSvc.generateNewCopy(
976 $scope.data.addCopy(cp);
978 if (!$scope.defaults.classification) {
980 ['cat.default_classification_scheme'],
982 ).then(function (val) {
983 cn.label_class(val['cat.default_classification_scheme']);
988 $scope.embedded = ($routeParams.mode && $routeParams.mode == 'embedded') ? true : false;
989 $scope.edit_templates = ($location.path().match(/edit_template/)) ? true : false;
991 $scope.saveDefaults = function () {
992 egCore.hatch.setItem('cat.copy.defaults', $scope.defaults);
995 $scope.fetchDefaults = function () {
996 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
999 if (!$scope.batch) $scope.batch = {};
1000 $scope.batch.classification = $scope.defaults.classification;
1001 $scope.batch.prefix = $scope.defaults.prefix;
1002 $scope.batch.suffix = $scope.defaults.suffix;
1003 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
1005 typeof $scope.defaults.statcat_filter == 'object' &&
1006 Object.keys($scope.defaults.statcat_filter).length > 0
1008 // want fieldmapper object here...
1009 $scope.defaults.statcat_filter =
1010 egCore.idl.Clone($scope.defaults.statcat_filter);
1012 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
1014 if ($scope.defaults.always_volumes) $scope.show_vols = true;
1015 if ($scope.defaults.barcode_checkdigit) itemSvc.barcode_checkdigit = true;
1016 if ($scope.defaults.auto_gen_barcode) itemSvc.auto_gen_barcode = true;
1020 $scope.fetchDefaults();
1022 $scope.$watch('defaults.statcat_filter', function() {
1023 $scope.saveDefaults();
1025 $scope.$watch('defaults.auto_gen_barcode', function (n,o) {
1026 itemSvc.auto_gen_barcode = n
1029 $scope.$watch('defaults.barcode_checkdigit', function (n,o) {
1030 itemSvc.barcode_checkdigit = n
1033 $scope.dirty = false;
1034 $scope.$watch('dirty',
1035 function(newVal, oldVal) {
1036 if (newVal && newVal != oldVal) {
1037 $($window).on('beforeunload.edit', function(){
1038 return 'There is unsaved data!'
1041 $($window).off('beforeunload.edit');
1046 $scope.only_vols = false;
1047 $scope.show_vols = true;
1048 $scope.show_copies = true;
1050 $scope.tracker = function (x,f) { if (x) return x[f]() };
1051 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
1052 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1054 $scope.orgById = function (id) { return egCore.org.get(id) }
1055 $scope.statusById = function (id) {
1056 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
1058 $scope.locationById = function (id) {
1059 return $scope.location_cache[''+id];
1062 $scope.workingToComplete = function () {
1063 angular.forEach( $scope.workingGridControls.selectedItems(), function (c) {
1064 angular.forEach( itemSvc.copies, function (w, i) {
1066 $scope.completed_copies = $scope.completed_copies.concat(itemSvc.copies.splice(i,1));
1073 $scope.completeToWorking = function () {
1074 angular.forEach( $scope.completedGridControls.selectedItems(), function (c) {
1075 angular.forEach( $scope.completed_copies, function (w, i) {
1077 itemSvc.copies = itemSvc.copies.concat($scope.completed_copies.splice(i,1));
1084 createSimpleUpdateWatcher = function (field,exclude_copies_with_one_of_these_values) {
1085 return $scope.$watch('working.' + field, function () {
1086 var newval = $scope.working[field];
1088 if (typeof newval != 'undefined') {
1089 delete $scope.working.MultiMap[field];
1090 if (angular.isObject(newval)) { // we'll use the pkey
1091 if (newval.id) newval = newval.id();
1092 else if (newval.code) newval = newval.code();
1095 if (""+newval == "" || newval == null) {
1096 $scope.working[field] = undefined;
1100 if ($scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1102 $scope.workingGridControls.selectedItems(),
1104 if (exclude_copies_with_one_of_these_values
1105 && exclude_copies_with_one_of_these_values.indexOf(cp[field](),0) > -1) {
1108 if (cp[field]() !== newval) {
1111 $scope.dirty = true;
1124 statcat_filter: undefined
1127 $scope.copyAlertUpdate = function (alerts) {
1128 if (!$scope.in_item_select &&
1129 $scope.workingGridControls &&
1130 $scope.workingGridControls.selectedItems) {
1131 itemSvc.get_copy_alert_types().then(function(ccat) {
1133 $scope.alert_types = ccat;
1134 angular.forEach(ccat, function(t) {
1135 ccat_map[t.id()] = t;
1138 $scope.workingGridControls.selectedItems(),
1140 $scope.dirty = true;
1141 angular.forEach(alerts, function(alrt) {
1142 var a = egCore.idl.fromHash('aca', alrt);
1144 a.create_staff(egCore.auth.user().id());
1145 a.alert_type(ccat_map[a.alert_type()]);
1148 cp.copy_alerts().push( a );
1157 $scope.copyNoteUpdate = function (notes) {
1158 if (!$scope.in_item_select &&
1159 $scope.workingGridControls &&
1160 $scope.workingGridControls.selectedItems) {
1162 $scope.workingGridControls.selectedItems(),
1164 $scope.dirty = true;
1165 angular.forEach(notes, function(note) {
1166 var n = egCore.idl.fromHash('acpn', note);
1168 n.creator(egCore.auth.user().id());
1169 n.owning_copy(cp.id());
1170 cp.notes().push( n );
1179 $scope.statcatUpdate = function (id) {
1180 var newval = $scope.working.statcats[id];
1182 if (typeof newval != 'undefined') {
1183 if (angular.isObject(newval)) { // we'll use the pkey
1184 newval = newval.id();
1187 if (""+newval == "" || newval == null) {
1188 $scope.working.statcats[id] = undefined;
1192 if (!$scope.in_item_select && $scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1194 $scope.workingGridControls.selectedItems(),
1196 $scope.dirty = true;
1198 cp.stat_cat_entries(
1199 angular.forEach( cp.stat_cat_entries(), function (e) {
1200 if (e.stat_cat() == id) { // mark deleted
1207 var e = new egCore.idl.asce();
1212 cp.stat_cat_entries(
1213 cp.stat_cat_entries() ?
1214 cp.stat_cat_entries().concat([ e ]) :
1220 // trim out all deleted ones; the API used to
1221 // do the update doesn't actually consult
1222 // isdeleted for stat cat entries
1223 cp.stat_cat_entries(
1224 cp.stat_cat_entries().filter(function (e) {
1225 return !Boolean(e.isdeleted());
1236 var dataKey = $routeParams.dataKey;
1237 console.debug('dataKey: ' + dataKey);
1239 if ((dataKey && dataKey.length > 0) || $scope.edit_templates) {
1241 $scope.templates = {};
1242 $scope.template_name = '';
1243 $scope.template_name_list = [];
1245 $scope.fetchTemplates = function () {
1246 itemSvc.get_acp_templates().then(function(t) {
1248 $scope.templates = t;
1249 $scope.template_name_list = Object.keys(t).sort();
1252 egCore.hatch.getItem('cat.copy.last_template').then(function(t) {
1253 if (t) $scope.template_name = t;
1256 $scope.fetchTemplates();
1258 $scope.applyTemplate = function (n) {
1259 angular.forEach($scope.templates[n], function (v,k) {
1260 if (k == 'circ_lib') {
1261 $scope.working[k] = egCore.org.get(v);
1262 } else if (k == 'copy_notes' && v.length) {
1263 $scope.copyNoteUpdate(v);
1264 } else if (k == 'copy_alerts' && v.length) {
1265 $scope.copyAlertUpdate(v);
1266 } else if (!angular.isObject(v)) {
1267 $scope.working[k] = angular.copy(v);
1269 angular.forEach(v, function (sv,sk) {
1270 if (k == 'callnumber') {
1271 angular.forEach(v, function (cnv,cnk) {
1272 $scope.batch[cnk] = cnv;
1274 $scope.applyBatchCNValues();
1276 $scope.working[k][sk] = angular.copy(sv);
1277 if (k == 'statcats') $scope.statcatUpdate(sk);
1282 delete $scope.working.MultiMap[k];
1283 egCore.hatch.setItem('cat.copy.last_template', n);
1286 $scope.copytab = 'working';
1287 $scope.tab = 'edit';
1288 $scope.summaryRecord = null;
1289 $scope.record_id = null;
1291 $scope.completed_copies = [];
1292 $scope.location_orgs = [];
1293 $scope.location_cache = {};
1294 $scope.statcats = [];
1295 if (!$scope.batch) $scope.batch = {};
1297 $scope.applyBatchCNValues = function () {
1298 if ($scope.data.tree) {
1299 angular.forEach($scope.data.tree, function(cn_hash) {
1300 angular.forEach(cn_hash, function(copies) {
1301 angular.forEach(copies, function(cp) {
1302 if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') {
1303 var label_class = $scope.classification_list.filter(function(p){ return p.id() == $scope.batch.classification })[0];
1304 cp.call_number().label_class(label_class);
1305 cp.call_number().ischanged(1);
1306 $scope.dirty = true;
1308 if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') {
1309 var prefix = $scope.prefix_list.filter(function(p){ return p.id() == $scope.batch.prefix })[0];
1310 cp.call_number().prefix(prefix);
1311 cp.call_number().ischanged(1);
1312 $scope.dirty = true;
1314 if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') {
1315 cp.call_number().label($scope.batch.label);
1316 cp.call_number().ischanged(1);
1317 $scope.dirty = true;
1319 if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') {
1320 var suffix = $scope.suffix_list.filter(function(p){ return p.id() == $scope.batch.suffix })[0];
1321 cp.call_number().suffix(suffix);
1322 cp.call_number().ischanged(1);
1323 $scope.dirty = true;
1331 $scope.clearWorking = function () {
1332 angular.forEach($scope.working, function (v,k,o) {
1333 if (!angular.isObject(v)) {
1334 if (typeof v != 'undefined')
1335 $scope.working[k] = undefined;
1336 } else if (k != 'circ_lib') {
1337 angular.forEach(v, function (sv,sk) {
1338 if (typeof v != 'undefined')
1339 $scope.working[k][sk] = undefined;
1343 $scope.working.circ_lib = undefined; // special
1346 $scope.completedGridDataProvider = egGridDataProvider.instance({
1347 get : function(offset, count) {
1348 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1349 return this.arrayNotifier($scope.completed_copies, offset, count);
1353 $scope.completedGridControls = {};
1355 $scope.workingGridDataProvider = egGridDataProvider.instance({
1356 get : function(offset, count) {
1357 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1358 return this.arrayNotifier(itemSvc.copies, offset, count);
1362 $scope.workingGridControls = {};
1363 $scope.add_vols_copies = false;
1364 $scope.is_fast_add = false;
1366 // Generate some functions for selecting items by column value in the working grid
1368 ['circulate','status','circ_lib','ref','location','opac_visible','circ_modifier','price',
1369 'loan_duration','cost','circ_as_type','deposit','holdable','deposit_amount','age_protect',
1370 'mint_condition','fine_level','floating'],
1372 $scope['select_by_' + field] = function (x) {
1373 $scope.workingGridControls.selectItemsByValue(field,x);
1378 var truthy = /^t|1/;
1379 $scope.labelYesNo = function (x) {
1380 return truthy.test(x) ? egCore.strings.YES : egCore.strings.NO;
1383 $scope.orgShortname = function (x) {
1384 return egCore.org.get(x).shortname();
1387 $scope.statusName = function (x) {
1388 var s = $scope.status_list.filter(function(y) {
1395 $scope.locationName = function (x) {
1396 var s = $scope.location_list.filter(function(y) {
1400 return $scope.i18n.ou_qualified_location_name(s[0]);
1403 $scope.durationLabel = function (x) {
1404 return [egCore.strings.SHORT, egCore.strings.NORMAL, egCore.strings.EXTENDED][-1 + x]
1407 $scope.fineLabel = function (x) {
1408 return [egCore.strings.LOW, egCore.strings.NORMAL, egCore.strings.HIGH][-1 + x]
1411 $scope.circTypeValue = function (x) {
1412 if (x === null) return egCore.strings.UNSET;
1413 var s = $scope.circ_type_list.filter(function(y) {
1414 return y.code() == x;
1417 return s[0].value();
1420 $scope.ageprotectName = function (x) {
1421 if (x === null) return egCore.strings.UNSET;
1422 var s = $scope.age_protect_list.filter(function(y) {
1429 $scope.floatingName = function (x) {
1430 if (x === null) return egCore.strings.UNSET;
1431 var s = $scope.floating_list.filter(function(y) {
1438 $scope.circmodName = function (x) {
1439 if (x === null) return egCore.strings.UNSET;
1440 var s = $scope.circ_modifier_list.filter(function(y) {
1441 return y.code() == x;
1449 'open-ils.actor.anon_cache.get_value',
1450 dataKey, 'edit-these-copies'
1451 ).then(function (data) {
1454 if (data.hide_vols && !$scope.defaults.always_volumes) $scope.show_vols = false;
1455 if (data.hide_copies) {
1456 $scope.show_copies = false;
1457 $scope.only_vols = true;
1460 $scope.record_id = data.record_id;
1462 function fetchRaw () {
1463 if (!$scope.only_vols) $scope.dirty = true;
1464 $scope.add_vols_copies = true;
1466 /* data.raw data structure looks like this:
1468 * callnumber : $cn_id, // optional, to add a copy to a cn
1469 * owner : $org, // optional, defaults to cn.owning_lib or ws_ou
1470 * label : $cn_label, // optional, to supply a label on a new cn
1471 * barcode : $cp_barcode // optional, to supply a barcode on a new cp
1472 * fast_add : boolean // optional, to specify whether this came
1476 * All can be left out and a completely empty vol/copy combo will be vivicated.
1482 if (proto.fast_add) $scope.is_fast_add = true;
1483 if (proto.callnumber) {
1484 return egCore.pcrud.retrieve('acn', proto.callnumber)
1485 .then(function(cn) {
1486 var cp = new itemSvc.generateNewCopy(
1488 proto.owner || cn.owning_lib(),
1490 ((!$scope.only_vols) ? true : false)
1493 if (proto.barcode) {
1494 cp.barcode( proto.barcode );
1495 cp.empty_barcode = false;
1501 var cn = new egCore.idl.acn();
1502 cn.id( --itemSvc.new_cn_id );
1504 cn.prefix( $scope.defaults.prefix || -1 );
1505 cn.suffix( $scope.defaults.suffix || -1 );
1506 cn.owning_lib( proto.owner || egCore.auth.user().ws_ou() );
1507 cn.record( $scope.record_id );
1508 egCore.org.settings(
1509 ['cat.default_classification_scheme'],
1511 ).then(function (val) {
1513 $scope.defaults.classification ||
1514 val['cat.default_classification_scheme'] ||
1518 cn.label( proto.label );
1522 'open-ils.cat.biblio.record.marc_cn.retrieve',
1525 ).then(function(cn_array) {
1526 if (cn_array.length > 0) {
1527 for (var field in cn_array[0]) {
1528 cn.label( cn_array[0][field] );
1536 // If we are adding an empty vol,
1537 // this is ultimately just a placeholder copy
1538 // which gets removed before saving.
1539 // TODO: consider ways to remove this
1541 var cp = new itemSvc.generateNewCopy(
1543 proto.owner || cn.owning_lib(),
1548 if (proto.barcode) {
1549 cp.barcode( proto.barcode );
1550 cp.empty_barcode = false;
1558 return itemSvc.copies;
1561 if (data.copies && data.copies.length)
1562 return itemSvc.fetchIds(data.copies).then(fetchRaw);
1568 }).then( function() {
1569 $scope.data = itemSvc;
1570 $scope.workingGridDataProvider.refresh();
1573 $scope.can_save = false;
1574 function check_saveable () {
1575 var can_save = true;
1580 if (!$scope.only_vols) {
1581 if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) {
1584 } else if (i.call_number().empty_label) {
1590 if (!$scope.only_vols && $scope.forms.myForm && $scope.forms.myForm.$invalid) {
1594 $scope.can_save = can_save;
1597 $scope.disableSave = function () {
1599 return !$scope.can_save;
1602 $scope.focusNextFirst = function(prev_lib,prev_bc) {
1605 angular.forEach(Object.keys($scope.data.tree).sort(), function (lib) {
1608 if (lib == prev_lib) {
1617 var first_cn = Object.keys($scope.data.tree[n])[0];
1618 var next = '#' + first_cn + '_' + $scope.data.tree[n][first_cn][0].id();
1621 if (!itemSvc.currently_generating) el.focus();
1622 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
1623 itemSvc.nextBarcode(prev_bc).then(function(bc){
1626 el.trigger('change');
1629 itemSvc.currently_generating = false;
1635 $scope.in_item_select = false;
1636 $scope.afterItemSelect = function() { $scope.in_item_select = false };
1637 $scope.handleItemSelect = function (item_list) {
1638 if (item_list && item_list.length > 0) {
1639 $scope.in_item_select = true;
1641 angular.forEach(Object.keys($scope.defaults.attributes), function (attr) {
1643 var value_hash = {};
1644 var value_list = [];
1645 angular.forEach(item_list, function (item) {
1647 var v = item[attr]()
1648 if (angular.isObject(v)) {
1649 if (v.id) v = v.id();
1650 else if (v.code) v = v.code();
1657 $scope.working.MultiMap[attr] = value_list;
1659 if (Object.keys(value_hash).length == 1) {
1660 if (attr == 'circ_lib') {
1661 $scope.working[attr] = egCore.org.get(item_list[0][attr]());
1663 $scope.working[attr] = item_list[0][attr]();
1666 $scope.working[attr] = undefined;
1670 angular.forEach($scope.statcats, function (sc) {
1673 var value_hash = {};
1675 angular.forEach(item_list, function (item) {
1676 if (item.stat_cat_entries()) {
1677 if (item.stat_cat_entries().length > 0) {
1678 var right_sc = item.stat_cat_entries().filter(function (e) {
1679 return e.stat_cat() == sc.id() && !Boolean(e.isdeleted());
1682 if (right_sc.length > 0) {
1683 value_hash[right_sc[0].id()] = right_sc[0].id();
1695 if (!none && Object.keys(value_hash).length == 1) {
1696 $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]];
1697 $scope.working.statcats_multi[sc.id()] = false;
1698 } else if (item_list.length > 1 && Object.keys(value_hash).length > 0) {
1699 $scope.working.statcats[sc.id()] = undefined;
1700 $scope.working.statcats_multi[sc.id()] = true;
1702 $scope.working.statcats[sc.id()] = undefined;
1703 $scope.working.statcats_multi[sc.id()] = false;
1709 $scope.clearWorking();
1714 $scope.$watch('data.copies.length', function () {
1715 if ($scope.data.copies) {
1716 var base_orgs = $scope.data.copies.map(function(cp){
1717 if (isNaN(cp.circ_lib())) return Number(cp.circ_lib().id());
1718 return Number(cp.circ_lib());
1720 $scope.data.copies.map(function(cp){
1721 if (isNaN(cp.call_number().owning_lib())) return Number(cp.call_number().owning_lib().id());
1722 return Number(cp.call_number().owning_lib());
1725 [egCore.auth.user().ws_ou()]
1726 ).filter(function(e,i,a){
1727 return a.lastIndexOf(e) === i;
1731 angular.forEach(base_orgs, function(o) {
1732 all_orgs = all_orgs.concat( egCore.org.fullPath(o, true) );
1735 var final_orgs = all_orgs.filter(function(e,i,a){
1736 return a.lastIndexOf(e) === i;
1737 }).sort(function(a, b){return a-b});
1739 if ($scope.location_orgs.toString() != final_orgs.toString()) {
1740 $scope.location_orgs = final_orgs;
1741 if ($scope.location_orgs.length) {
1742 itemSvc.get_locations($scope.location_orgs).then(function(list){
1743 angular.forEach(list, function(l) {
1744 $scope.location_cache[ ''+l.id() ] = l;
1746 $scope.location_list = list;
1749 $scope.statcat_filter_list = [];
1750 angular.forEach($scope.location_orgs, function (o) {
1751 $scope.statcat_filter_list.push(egCore.org.get(o));
1754 itemSvc.get_statcats($scope.location_orgs).then(function(list){
1755 $scope.statcats = list;
1756 angular.forEach($scope.statcats, function (s) {
1758 if (!$scope.working)
1759 $scope.working = { statcats_multi: {}, statcats: {}, statcat_filter: undefined};
1760 if (!$scope.working.statcats_multi)
1761 $scope.working.statcats_multi = {};
1762 if (!$scope.working.statcats)
1763 $scope.working.statcats = {};
1765 if (!$scope.in_item_select) {
1766 $scope.working.statcats[s.id()] = undefined;
1768 createStatcatUpdateWatcher(s.id());
1770 $scope.in_item_select = false;
1771 // do a refresh here to work around a race
1772 // condition that can result in stat cats
1773 // not being selected.
1774 $scope.workingGridDataProvider.refresh();
1780 $scope.workingGridDataProvider.refresh();
1783 $scope.statcat_visible = function (sc_owner) {
1784 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
1785 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
1786 if ($scope.working.statcat_filter == ancestor_org.id())
1792 $scope.suffix_list = [];
1793 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1794 $scope.suffix_list = list;
1797 $scope.prefix_list = [];
1798 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1799 $scope.prefix_list = list;
1802 $scope.classification_list = [];
1803 itemSvc.get_classifications().then(function(list){
1804 $scope.classification_list = list;
1807 $scope.$watch('completed_copies.length', function () {
1808 $scope.completedGridDataProvider.refresh();
1811 $scope.location_list = [];
1812 itemSvc.get_locations().then(function(list){
1813 $scope.location_list = list;
1815 createSimpleUpdateWatcher('location');
1817 $scope.status_list = [];
1818 itemSvc.get_magic_statuses().then(function(list){
1819 $scope.magic_status_list = list;
1820 createSimpleUpdateWatcher('status',$scope.magic_status_list);
1822 itemSvc.get_statuses().then(function(list){
1823 $scope.status_list = list;
1826 $scope.circ_modifier_list = [];
1827 itemSvc.get_circ_mods().then(function(list){
1828 $scope.circ_modifier_list = list;
1830 createSimpleUpdateWatcher('circ_modifier');
1832 $scope.circ_type_list = [];
1833 itemSvc.get_circ_types().then(function(list){
1834 $scope.circ_type_list = list;
1836 createSimpleUpdateWatcher('circ_as_type');
1838 $scope.age_protect_list = [];
1839 itemSvc.get_age_protects().then(function(list){
1840 $scope.age_protect_list = list;
1842 createSimpleUpdateWatcher('age_protect');
1844 $scope.floating_list = [];
1845 itemSvc.get_floating_groups().then(function(list){
1846 $scope.floating_list = list;
1848 createSimpleUpdateWatcher('floating');
1850 createSimpleUpdateWatcher('circ_lib');
1851 createSimpleUpdateWatcher('circulate');
1852 createSimpleUpdateWatcher('holdable');
1853 createSimpleUpdateWatcher('fine_level');
1854 createSimpleUpdateWatcher('loan_duration');
1855 createSimpleUpdateWatcher('price');
1856 createSimpleUpdateWatcher('cost');
1857 createSimpleUpdateWatcher('deposit');
1858 createSimpleUpdateWatcher('deposit_amount');
1859 createSimpleUpdateWatcher('mint_condition');
1860 createSimpleUpdateWatcher('opac_visible');
1861 createSimpleUpdateWatcher('ref');
1863 $scope.saveCompletedCopies = function (and_exit) {
1865 var perCnCopies = {};
1866 angular.forEach( $scope.completed_copies, function (cp) {
1867 var cn = cp.call_number();
1868 var cn_cps = cp.call_number().copies();
1869 cp.call_number().copies([]);
1870 var cn_id = cp.call_number().id();
1871 cp.call_number(cn_id); // prevent loops in JSON-ification
1872 if (!cnHash[cn_id]) {
1873 cnHash[cn_id] = egCore.idl.Clone(cn);
1874 perCnCopies[cn_id] = [egCore.idl.Clone(cp)];
1876 perCnCopies[cn_id].push(egCore.idl.Clone(cp));
1878 cp.call_number(cn); // put the data back
1879 cp.call_number().copies(cn_cps);
1880 if (typeof cnHash[cn_id].prefix() == 'object')
1881 cnHash[cn_id].prefix(cnHash[cn_id].prefix().id()); // un-object-ize some fields
1882 if (typeof cnHash[cn_id].suffix() == 'object')
1883 cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields
1886 if ($scope.only_vols) { // strip off copies when we're in vol-only mode
1887 angular.forEach(cnHash, function (v, k) {
1888 cnHash[k].copies([]);
1891 angular.forEach(perCnCopies, function (v, k) {
1892 cnHash[k].copies(v);
1897 angular.forEach(cnHash, function (v, k) {
1903 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1904 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1, return_copy_ids : 1 }
1905 ).then(function(copy_ids) {
1907 $scope.dirty = false;
1908 if ($scope.defaults.print_item_labels) {
1911 'open-ils.actor.anon_cache.set_value',
1912 null, 'print-labels-these-copies', {
1915 ).then(function(key) {
1917 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1918 $timeout(function() { $window.open(url, '_blank') }).then(
1919 function() { $timeout(function(){$window.close()}); }
1922 alert('Could not create anonymous cache key!');
1926 $timeout(function(){$window.close()});
1932 $scope.saveAndContinue = function () {
1933 $scope.saveCompletedCopies(false);
1936 $scope.workingSaveAndExit = function () {
1937 $scope.workingToComplete();
1938 $scope.saveAndExit();
1941 $scope.saveAndExit = function () {
1942 $scope.saveCompletedCopies(true);
1947 $scope.copy_notes_dialog = function(copy_list) {
1948 var default_pub = Boolean($scope.defaults.copy_notes_pub);
1949 if (!angular.isArray(copy_list)) copy_list = [copy_list];
1951 return $uibModal.open({
1952 templateUrl: './cat/volcopy/t_copy_notes',
1956 ['$scope','$uibModalInstance',
1957 function($scope , $uibModalInstance) {
1958 $scope.focusNote = true;
1960 creator : egCore.auth.user().id(),
1966 $scope.require_initials = false;
1967 egCore.org.settings([
1968 'ui.staff.require_initials.copy_notes'
1969 ]).then(function(set) {
1970 $scope.require_initials_ous = Boolean(set['ui.staff.require_initials.copy_notes']);
1973 $scope.are_initials_required = function() {
1974 $scope.require_initials = $scope.require_initials_ous && ($scope.note.value.length > 0 || $scope.note.title.length > 0);
1977 $scope.$watch('note.value.length', $scope.are_initials_required);
1978 $scope.$watch('note.title.length', $scope.are_initials_required);
1980 $scope.note_list = [];
1981 if (copy_list.length == 1) {
1982 $scope.note_list = copy_list[0].notes();
1985 $scope.ok = function(note) {
1987 if (note.value.length > 0 || note.title.length > 0) {
1988 if ($scope.initials) {
1989 note.value = egCore.strings.$replace(
1990 egCore.strings.COPY_NOTE_INITIALS, {
1992 initials : $scope.initials,
1993 ws_ou : egCore.org.get(
1994 egCore.auth.user().ws_ou()).shortname()
1998 angular.forEach(copy_list, function (cp) {
1999 if (!angular.isArray(cp.notes())) cp.notes([]);
2000 var n = new egCore.idl.acpn();
2002 n.creator(note.creator);
2004 n.title(note.title);
2005 n.value(note.value);
2006 n.owning_copy(cp.id());
2007 cp.notes().push( n );
2011 $uibModalInstance.close();
2014 $scope.cancel = function($event) {
2015 $uibModalInstance.dismiss();
2016 $event.preventDefault();
2022 $scope.copy_tags_dialog = function(copy_list) {
2023 if (!angular.isArray(copy_list)) copy_list = [copy_list];
2025 return $uibModal.open({
2026 templateUrl: './cat/volcopy/t_copy_tags',
2030 ['$scope','$uibModalInstance',
2031 function($scope , $uibModalInstance) {
2033 $scope.tag_map = [];
2035 var shared_tags = {};
2036 angular.forEach(copy_list, function (cp) {
2037 angular.forEach(cp.tags(), function(tag) {
2038 if (!(tag.tag().id() in shared_tags)) {
2039 shared_tags[tag.tag().id()] = 1;
2041 shared_tags[tag.tag().id()]++;
2043 if (!(tag.tag().id() in tag_hash)) {
2044 tag_hash[tag.tag().id()] = tag;
2048 angular.forEach(tag_hash, function(value, key) {
2049 if (shared_tags[key] == copy_list.length) {
2050 $scope.tag_map.push(value);
2054 $scope.tag_types = [];
2055 egCore.pcrud.retrieveAll('cctt', {order_by : { cctt : 'label' }}, {atomic : true}).then(function(list) {
2056 $scope.tag_types = list;
2057 $scope.tag_type = $scope.tag_types[0].code(); // just pick a default
2060 $scope.getTags = function(val) {
2061 return egCore.pcrud.search('acpt',
2063 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2064 label : { 'startwith' : {
2065 transform: 'evergreen.lowercase',
2066 value : [ 'evergreen.lowercase', val ]
2068 tag_type : $scope.tag_type
2070 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2071 ).then(function(list) {
2072 return list.map(function(item) {
2073 return item.label();
2078 $scope.addTag = function() {
2079 var tagLabel = $scope.selectedLabel;
2080 // clear the typeahead
2081 $scope.selectedLabel = "";
2083 // first, check tags already associated with the copy
2084 var foundMatch = false;
2085 angular.forEach($scope.tag_map, function(tag) {
2086 if (tag.tag().label() == tagLabel && tag.tag().tag_type() == $scope.tag_type) {
2088 if (tag.isdeleted()) tag.isdeleted(0); // just deleting the mapping
2092 egCore.pcrud.search('acpt',
2094 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2096 tag_type : $scope.tag_type
2098 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2099 ).then(function(list) {
2100 if (list.length > 0) {
2101 var newMap = new egCore.idl.acptcm();
2103 newMap.copy(copy_list[0].id());
2104 newMap.tag(egCore.idl.Clone(list[0]));
2105 $scope.tag_map.push(newMap);
2107 var newTag = new egCore.idl.acpt();
2109 newTag.owner(egCore.auth.user().ws_ou());
2110 newTag.label(tagLabel);
2112 newTag.tag_type($scope.tag_type);
2114 var newMap = new egCore.idl.acptcm();
2116 newMap.copy(copy_list[0].id());
2118 $scope.tag_map.push(newMap);
2124 $scope.ok = function(note) {
2125 // in the multi-item case, this works OK for
2126 // adding new maps to existing tags, but doesn't handle
2127 // all possibilities
2128 angular.forEach(copy_list, function (cp) {
2129 cp.tags($scope.tag_map);
2131 $uibModalInstance.close();
2134 $scope.cancel = function($event) {
2135 $uibModalInstance.dismiss();
2136 $event.preventDefault();
2142 $scope.copy_alerts_dialog = function(copy_list) {
2143 if (!angular.isArray(copy_list)) copy_list = [copy_list];
2145 return $uibModal.open({
2146 templateUrl: './cat/volcopy/t_copy_alerts',
2149 ['$scope','$uibModalInstance',
2150 function($scope , $uibModalInstance) {
2152 itemSvc.get_copy_alert_types().then(function(ccat) {
2153 $scope.alert_types = ccat;
2156 $scope.focusNote = true;
2157 $scope.copy_alert = {
2158 create_staff : egCore.auth.user().id(),
2163 egCore.hatch.getItem('cat.copy.alerts.last_type').then(function(t) {
2164 if (t) $scope.copy_alert.alert_type = t;
2167 if (copy_list.length == 1) {
2168 $scope.copy_alert_list = copy_list[0].copy_alerts();
2171 $scope.ok = function(copy_alert) {
2173 if (typeof(copy_alert.note) != 'undefined' &&
2174 copy_alert.note != '') {
2175 angular.forEach(copy_list, function (cp) {
2176 var a = new egCore.idl.aca();
2178 a.create_staff(copy_alert.create_staff);
2179 a.note(copy_alert.note);
2180 a.temp(copy_alert.temp ? 't' : 'f');
2184 $scope.alert_types.filter(function(at) {
2185 return at.id() == copy_alert.alert_type;
2188 cp.copy_alerts().push( a );
2191 if (copy_alert.alert_type) {
2192 egCore.hatch.setItem(
2193 'cat.copy.alerts.last_type',
2194 copy_alert.alert_type
2200 $uibModalInstance.close();
2203 $scope.cancel = function($event) {
2204 $uibModalInstance.dismiss();
2205 $event.preventDefault();
2213 .directive("egVolTemplate", function () {
2217 template: '<div ng-include="'+"'/eg/staff/cat/volcopy/t_attr_edit'"+'"></div>',
2221 controller : ['$scope','$window','itemSvc','egCore','ngToast','$uibModal',
2222 function ( $scope , $window , itemSvc , egCore , ngToast , $uibModal) {
2224 $scope.i18n = egCore.i18n;
2226 $scope.defaults = { // If defaults are not set at all, allow everything
2227 barcode_checkdigit : false,
2228 auto_gen_barcode : false,
2235 loan_duration : true,
2240 deposit_amount : true,
2241 opac_visible : true,
2244 mint_condition : true,
2247 circ_modifier : true,
2248 circ_as_type : true,
2256 $scope.fetchDefaults = function () {
2257 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
2259 $scope.defaults = t;
2260 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
2262 typeof $scope.defaults.statcat_filter == 'object' &&
2263 Object.keys($scope.defaults.statcat_filter).length > 0
2265 // want fieldmapper object here...
2266 $scope.defaults.statcat_filter =
2267 egCore.idl.Clone($scope.defaults.statcat_filter);
2269 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
2274 $scope.fetchDefaults();
2276 $scope.dirty = false;
2277 $scope.$watch('dirty',
2278 function(newVal, oldVal) {
2279 if (newVal && newVal != oldVal) {
2280 $($window).on('beforeunload.template', function(){
2281 return 'There is unsaved template data!'
2284 $($window).off('beforeunload.template');
2289 $scope.template_controls = true;
2291 $scope.fetchTemplates = function () {
2292 itemSvc.get_acp_templates().then(function(t) {
2294 $scope.templates = t;
2295 $scope.template_name_list = Object.keys(t).sort();
2299 $scope.fetchTemplates();
2301 $scope.applyTemplate = function (n) {
2302 angular.forEach($scope.templates[n], function (v,k) {
2303 if (k == 'circ_lib') {
2304 $scope.working[k] = egCore.org.get(v);
2305 } else if (angular.isArray(v) || !angular.isObject(v)) {
2306 $scope.working[k] = angular.copy(v);
2308 angular.forEach(v, function (sv,sk) {
2309 if (!(k in $scope.working))
2310 $scope.working[k] = {};
2311 $scope.working[k][sk] = angular.copy(sv);
2315 $scope.template_name = '';
2318 $scope.deleteTemplate = function (n) {
2320 delete $scope.templates[n]
2321 $scope.template_name_list = Object.keys($scope.templates).sort();
2322 $scope.template_name = '';
2323 itemSvc.save_acp_templates($scope.templates);
2324 $scope.$parent.fetchTemplates();
2325 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_DELETE);
2329 $scope.saveTemplate = function (n) {
2333 angular.forEach($scope.working, function (v,k) {
2334 if (angular.isObject(v)) { // we'll use the pkey
2335 if (v.id) v = v.id();
2336 else if (v.code) v = v.code();
2337 else v = angular.copy(v); // Should only be statcats and callnumbers currently
2343 $scope.templates[n] = tmpl;
2344 $scope.template_name_list = Object.keys($scope.templates).sort();
2346 itemSvc.save_acp_templates($scope.templates);
2347 $scope.$parent.fetchTemplates();
2349 $scope.dirty = false;
2351 // save all templates, as we might do after an import
2352 itemSvc.save_acp_templates($scope.templates);
2353 $scope.$parent.fetchTemplates();
2355 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_SAVE);
2358 $scope.templates = {};
2359 $scope.imported_templates = { data : '' };
2360 $scope.template_name = '';
2361 $scope.template_name_list = [];
2363 $scope.$watch('imported_templates.data', function(newVal, oldVal) {
2364 if (newVal && newVal != oldVal) {
2366 var newTemplates = JSON.parse(newVal);
2367 if (!Object.keys(newTemplates).length) return;
2368 angular.forEach(Object.keys(newTemplates), function (k) {
2369 $scope.templates[k] = newTemplates[k];
2371 itemSvc.save_acp_templates($scope.templates);
2372 $scope.fetchTemplates();
2374 console.log('tried to import an invalid copy template file');
2379 $scope.tracker = function (x,f) { if (x) return x[f]() };
2380 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
2381 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
2383 $scope.orgById = function (id) { return egCore.org.get(id) }
2384 $scope.statusById = function (id) {
2385 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
2387 $scope.locationById = function (id) {
2388 return $scope.location_cache[''+id];
2391 createSimpleUpdateWatcher = function (field) {
2392 $scope.$watch('working.' + field, function () {
2393 var newval = $scope.working[field];
2395 if (typeof newval != 'undefined') {
2396 $scope.dirty = true;
2397 if (angular.isObject(newval)) { // we'll use the pkey
2398 if (newval.id) $scope.working[field] = newval.id();
2399 else if (newval.code) $scope.working[field] = newval.code();
2402 if (""+newval == "" || newval == null) {
2403 $scope.working[field] = undefined;
2414 statcat_filter: undefined
2417 $scope.statcat_visible = function (sc_owner) {
2418 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
2419 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
2420 if ($scope.working.statcat_filter == ancestor_org.id())
2426 createStatcatUpdateWatcher = function (id) {
2427 return $scope.$watch('working.statcats[' + id + ']', function () {
2428 if ($scope.working.statcats) {
2429 var newval = $scope.working.statcats[id];
2431 if (typeof newval != 'undefined') {
2432 $scope.dirty = true;
2433 if (angular.isObject(newval)) { // we'll use the pkey
2434 newval = newval.id();
2437 if (""+newval == "" || newval == null) {
2438 $scope.working.statcats[id] = undefined;
2447 $scope.clearWorking = function () {
2448 angular.forEach($scope.working, function (v,k,o) {
2449 $scope.working.MultiMap[k] = [];
2450 if (!angular.isObject(v)) {
2451 if (typeof v != 'undefined')
2452 $scope.working[k] = undefined;
2453 } else if (k != 'circ_lib') {
2454 angular.forEach(v, function (sv,sk) {
2455 $scope.working[k][sk] = undefined;
2459 $scope.working.circ_lib = undefined; // special
2460 $scope.dirty = false;
2463 $scope.working = {};
2464 $scope.location_orgs = [];
2465 $scope.location_cache = {};
2467 $scope.location_list = [];
2468 itemSvc.get_locations(
2469 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2470 ).then(function(list){
2471 $scope.location_list = list;
2473 createSimpleUpdateWatcher('location');
2475 $scope.statcat_filter_list = egCore.org.fullPath( egCore.auth.user().ws_ou() );
2477 $scope.statcats = [];
2478 itemSvc.get_statcats(
2479 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2480 ).then(function(list){
2481 $scope.statcats = list;
2482 angular.forEach($scope.statcats, function (s) {
2484 if (!$scope.working)
2485 $scope.working = { statcats: {}, statcat_filter: undefined};
2486 if (!$scope.working.statcats)
2487 $scope.working.statcats = {};
2489 $scope.working.statcats[s.id()] = undefined;
2490 createStatcatUpdateWatcher(s.id());
2494 $scope.copy_notes_dialog = function() {
2495 var default_pub = Boolean($scope.defaults.copy_notes_pub);
2496 var working = $scope.working;
2498 return $uibModal.open({
2499 templateUrl: './cat/volcopy/t_copy_notes',
2502 ['$scope','$uibModalInstance',
2503 function($scope , $uibModalInstance) {
2504 $scope.focusNote = true;
2511 $scope.require_initials = false;
2512 egCore.org.settings([
2513 'ui.staff.require_initials.copy_notes'
2514 ]).then(function(set) {
2515 $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
2518 $scope.note_list = [];
2519 angular.forEach(working.copy_notes, function(note) {
2520 var acpn = egCore.idl.fromHash('acpn', note);
2521 $scope.note_list.push(acpn);
2524 $scope.ok = function(note) {
2526 if (!working.copy_notes) {
2527 working.copy_notes = [];
2531 working.copy_notes.length = 0;
2532 angular.forEach($scope.note_list, function(existing_note) {
2533 if (!existing_note.isdeleted()) {
2534 working.copy_notes.push({
2535 pub : existing_note.pub() ? 't' : 'f',
2536 title : existing_note.title(),
2537 value : existing_note.value()
2542 // add new note, if any
2543 if (note.initials) note.value += ' [' + note.initials + ']';
2544 note.pub = note.pub ? 't' : 'f';
2545 if (note.title.length && note.value.length) {
2546 working.copy_notes.push(note);
2549 $uibModalInstance.close();
2552 $scope.cancel = function($event) {
2553 $uibModalInstance.dismiss();
2554 $event.preventDefault();
2560 $scope.copy_alerts_dialog = function() {
2561 var working = $scope.working;
2563 return $uibModal.open({
2564 templateUrl: './cat/volcopy/t_copy_alerts',
2567 ['$scope','$uibModalInstance',
2568 function($scope , $uibModalInstance) {
2570 itemSvc.get_copy_alert_types().then(function(ccat) {
2572 $scope.alert_types = ccat;
2573 angular.forEach(ccat, function(t) {
2574 ccat_map[t.id()] = t;
2576 $scope.copy_alert_list = [];
2577 angular.forEach(working.copy_alerts, function (alrt) {
2578 var aca = egCore.idl.fromHash('aca', alrt);
2579 aca.alert_type(ccat_map[alrt.alert_type]);
2581 $scope.copy_alert_list.push(aca);
2585 $scope.focusNote = true;
2586 $scope.copy_alert = {
2591 $scope.ok = function(copy_alert) {
2593 if (!working.copy_alerts) {
2594 working.copy_alerts = [];
2597 working.copy_alerts.length = 0;
2599 angular.forEach($scope.copy_alert_list, function(alrt) {
2600 if (alrt.ack_time() == null) {
2601 working.copy_alerts.push({
2604 alert_type : alrt.alert_type().id()
2609 if (typeof(copy_alert.note) != 'undefined' &&
2610 copy_alert.note != '') {
2611 working.copy_alerts.push({
2612 note : copy_alert.note,
2613 temp : copy_alert.temp ? 't' : 'f',
2614 alert_type : copy_alert.alert_type
2618 $uibModalInstance.close();
2621 $scope.cancel = function($event) {
2622 $uibModalInstance.dismiss();
2623 $event.preventDefault();
2629 $scope.status_list = [];
2630 itemSvc.get_magic_statuses().then(function(list){
2631 $scope.magic_status_list = list;
2633 itemSvc.get_statuses().then(function(list){
2634 $scope.status_list = list;
2636 createSimpleUpdateWatcher('status');
2638 $scope.circ_modifier_list = [];
2639 itemSvc.get_circ_mods().then(function(list){
2640 $scope.circ_modifier_list = list;
2642 createSimpleUpdateWatcher('circ_modifier');
2644 $scope.circ_type_list = [];
2645 itemSvc.get_circ_types().then(function(list){
2646 $scope.circ_type_list = list;
2648 createSimpleUpdateWatcher('circ_as_type');
2650 $scope.age_protect_list = [];
2651 itemSvc.get_age_protects().then(function(list){
2652 $scope.age_protect_list = list;
2654 createSimpleUpdateWatcher('age_protect');
2656 $scope.floating_list = [];
2657 itemSvc.get_floating_groups().then(function(list){
2658 $scope.floating_list = list;
2660 createSimpleUpdateWatcher('floating');
2662 createSimpleUpdateWatcher('circulate');
2663 createSimpleUpdateWatcher('holdable');
2664 createSimpleUpdateWatcher('fine_level');
2665 createSimpleUpdateWatcher('loan_duration');
2666 createSimpleUpdateWatcher('cost');
2667 createSimpleUpdateWatcher('deposit');
2668 createSimpleUpdateWatcher('deposit_amount');
2669 createSimpleUpdateWatcher('mint_condition');
2670 createSimpleUpdateWatcher('opac_visible');
2671 createSimpleUpdateWatcher('ref');
2673 $scope.suffix_list = [];
2674 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
2675 $scope.suffix_list = list;
2678 $scope.prefix_list = [];
2679 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
2680 $scope.prefix_list = list;
2683 $scope.classification_list = [];
2684 itemSvc.get_classifications().then(function(list){
2685 $scope.classification_list = list;
2688 createSimpleUpdateWatcher('working.callnumber.classification');
2689 createSimpleUpdateWatcher('working.callnumber.prefix');
2690 createSimpleUpdateWatcher('working.callnumber.suffix');