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_by_org = 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.fetch_locations = function(locs) {
169 return egCore.pcrud.search('acpl',
174 acpl : ['owning_lib']
176 order_by : { acpl : 'name' }
182 service.get_suffixes = function(org) {
183 return egCore.pcrud.search('acns',
184 {owning_lib : egCore.org.fullPath(org, true)},
185 {order_by : { acns : 'label_sortkey' }}, {atomic : true}
190 service.get_magic_statuses = function() {
191 /* TODO: make these more configurable per lp1616170 */
196 ,8 /* On holds shelf */
197 ,16 /* Long overdue */
198 ,18 /* Canceled Transit */
202 service.get_statuses = function() {
204 return $q.when(egCore.env.ccs.list);
206 return egCore.pcrud.retrieveAll('ccs', {order_by : { ccs : 'name' }}, {atomic : true}).then(
208 egCore.env.absorbList(list, 'ccs');
215 service.get_circ_mods = function() {
217 return $q.when(egCore.env.ccm.list);
219 return egCore.pcrud.retrieveAll('ccm', {}, {atomic : true}).then(
221 egCore.env.absorbList(list, 'ccm');
228 service.get_circ_types = function() {
230 return $q.when(egCore.env.citm.list);
232 return egCore.pcrud.retrieveAll('citm', {}, {atomic : true}).then(
234 egCore.env.absorbList(list, 'citm');
241 service.get_age_protects = function() {
242 if (egCore.env.crahp)
243 return $q.when(egCore.env.crahp.list);
245 return egCore.pcrud.retrieveAll('crahp', {}, {atomic : true}).then(
247 egCore.env.absorbList(list, 'crahp');
254 service.get_floating_groups = function() {
256 return $q.when(egCore.env.cfg.list);
258 return egCore.pcrud.retrieveAll('cfg', {}, {atomic : true}).then(
260 egCore.env.absorbList(list, 'cfg');
267 service.bmp_parts = {};
268 service.get_parts = function(rec) {
269 if (service.bmp_parts[rec])
270 return $q.when(service.bmp_parts[rec]);
272 return egCore.pcrud.search('bmp',
273 {record : rec, deleted : 'f'},
274 null, {atomic : true}
275 ).then(function(list) {
276 service.bmp_parts[rec] = list;
282 service.get_acp_templates = function() {
283 // Already downloaded for this user? Return local copy. Changing users or logging out causes another download
284 // so users always have their own templates, and any changes made on other machines appear as expected.
285 if (egCore.hatch.getSessionItem('cat.copy.templates.usr') == egCore.auth.user().id()) {
286 return egCore.hatch.getItem('cat.copy.templates').then(function(templ) {
290 // this can be disabled for debugging to force a re-download and translation of test templates
291 egCore.hatch.setSessionItem('cat.copy.templates.usr', egCore.auth.user().id());
292 return service.load_remote_acp_templates();
297 service.save_acp_templates = function(t) {
298 egCore.hatch.setItem('cat.copy.templates', t);
299 egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
300 egCore.auth.token(), egCore.auth.user().id(), { "webstaff.cat.copy.templates": t });
301 // console.warn('Saved ' + JSON.stringify({"webstaff.cat.copy.templates": t}));
304 service.load_remote_acp_templates = function() {
305 // After the XUL Client is completely removed everything related
306 // to staff_client.copy_editor.templates and convert_xul_templates
307 // can be thrown away.
308 return egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.retrieve.authoritative',
309 egCore.auth.token(), egCore.auth.user().id(),
310 ['webstaff.cat.copy.templates','staff_client.copy_editor.templates']).then(function(settings) {
311 if (settings['webstaff.cat.copy.templates']) {
312 egCore.hatch.setItem('cat.copy.templates', settings['webstaff.cat.copy.templates']);
313 return settings['webstaff.cat.copy.templates'];
315 if (settings['staff_client.copy_editor.templates']) {
316 var new_templ = service.convert_xul_templates(settings['staff_client.copy_editor.templates']);
317 egCore.hatch.setItem('cat.copy.templates', new_templ);
318 // console.warn('Saving: ' + JSON.stringify({'webstaff.cat.copy.templates' : new_templ}));
319 egCore.net.request('open-ils.actor', 'open-ils.actor.patron.settings.update',
320 egCore.auth.token(), egCore.auth.user().id(), {'webstaff.cat.copy.templates' : new_templ});
328 service.convert_xul_templates = function(xultempl) {
330 var templ_names = Object.keys(xultempl);
341 for (i=0; i < templ_names.length; i++) {
342 name = templ_names[i];
345 xul_t = xultempl[name];
346 fields = Object.keys(xul_t);
348 if (fields.length > 0) {
349 for (j=0; j < fields.length; j++) {
350 curr_field = xul_t[fields[j]];
351 var field_name = curr_field["field"];
353 if ( field_name == null ) { continue; }
354 if ( curr_field["value"] == "<HACK:KLUDGE:NULL>" ) { continue; }
356 // floating changed from a boolean to an integer at one point;
357 // take this opportunity to remove the boolean from any old templates
358 if ( curr_field["type"] === "attribute" && field_name === "floating" ) {
359 if ( curr_field["value"].match(/[tf]/) ) { continue; }
362 if ( curr_field["type"] === "stat_cat" ) {
363 stat_cats[field_name] = parseInt(curr_field["value"]);
365 tmp_val = curr_field['value'];
366 if ( tmp_val.toString().match(/^[-0-9.]+$/)) {
367 tmp_val = parseFloat(tmp_val);
370 if (field_name.match(/^batch_.*_menulist$/)) {
371 // special handling for volume fields
372 if (!("callnumber" in curr_templ)) curr_templ["callnumber"] = {};
373 if (field_name === "batch_class_menulist") curr_templ["callnumber"]["classification"] = tmp_val;
374 if (field_name === "batch_prefix_menulist") curr_templ["callnumber"]["prefix"] = tmp_val;
375 if (field_name === "batch_suffix_menulist") curr_templ["callnumber"]["suffix"] = tmp_val;
377 curr_templ[field_name] = tmp_val;
382 if ( (Object.keys(stat_cats)).length > 0 ) {
383 curr_templ["statcats"] = stat_cats;
386 conv_templ[name] = curr_templ;
396 acp : ['call_number','parts','stat_cat_entries', 'notes', 'tags'],
397 acn : ['label_class','prefix','suffix'],
402 service.addCopy = function (cp) {
404 if (!cp.parts()) cp.parts([]); // just in case...
406 service.get_copy_alerts(cp.id()).then(function(aca) {
410 var lib = cp.call_number().owning_lib();
411 var cn = cp.call_number().id();
413 if (!service.tree[lib]) service.tree[lib] = {};
414 if (!service.tree[lib][cn]) service.tree[lib][cn] = [];
416 service.tree[lib][cn].push(cp);
417 service.copies.push(cp);
420 service.checkDuplicateBarcode = function(bc, id) {
422 return egCore.pcrud.search('acp', { deleted : 'f', 'barcode' : bc, id : { '!=' : id } })
424 function () { return final },
425 function () { return final },
426 function () { final = true; }
430 service.fetchIds = function(idList) {
431 service.tree = {}; // clear the tree on fetch
432 service.copies = []; // clear the copy list on fetch
433 return egCore.pcrud.search('acp', { 'id' : idList }, service.flesh).then(null,null,
435 service.addCopy(copy);
440 // create a new acp object with default values
441 // (both hard-coded and coming from OU settings)
442 service.generateNewCopy = function(callNumber, owningLib, isFastAdd, isNew) {
443 var cp = new egCore.idl.acp();
444 cp.id( --service.new_cp_id );
448 cp.circ_lib( owningLib );
449 cp.call_number( callNumber );
452 cp.deposit_amount(0);
453 cp.fine_level(2); // Normal
454 cp.loan_duration(2); // Normal
455 cp.location(1); // Stacks
458 cp.opac_visible('t');
460 cp.mint_condition('t');
461 cp.empty_barcode = true;
463 var status_setting = isFastAdd ?
464 'cat.default_copy_status_fast' :
465 'cat.default_copy_status_normal';
469 ).then(function(set) {
470 var default_ccs = parseInt(set[status_setting]);
471 if (isNaN(default_ccs))
472 default_ccs = (isFastAdd ? 0 : 5); // 0 is Available, 5 is In Process
473 cp.status(default_ccs);
482 .directive("egVolCopyEdit", function () {
488 '<div class="col-xs-5" ng-class="{'+"'has-error'"+':barcode_has_error}">'+
489 '<input id="{{callNumber.id()}}_{{copy.id()}}"'+
490 ' eg-enter="nextBarcode(copy.id())" class="form-control"'+
491 ' type="text" ng-model="barcode" ng-change="updateBarcode()"/>'+
492 '<div class="label label-danger" ng-if="duplicate_barcode">{{duplicate_barcode_string}}</div>'+
493 '<div class="label label-danger" ng-if="empty_barcode">{{empty_barcode_string}}</div>'+
495 '<div class="col-xs-3"><input class="form-control" type="number" min="1" ng-model="copy_number" ng-change="updateCopyNo()"/></div>'+
496 '<div class="col-xs-4"><eg-basic-combo-box eg-disabled="record == 0" list="parts" selected="part"></eg-basic-combo-box></div>'+
499 scope: { focusNext: "=", copy: "=", callNumber: "=", index: "@", record: "@" },
500 controller : ['$scope','itemSvc','egCore',
501 function ( $scope , itemSvc , egCore ) {
502 $scope.new_part_id = 0;
503 $scope.barcode_has_error = false;
504 $scope.duplicate_barcode = false;
505 $scope.empty_barcode = false;
506 $scope.duplicate_barcode_string = window.duplicate_barcode_string;
507 $scope.empty_barcode_string = window.empty_barcode_string;
509 if (!$scope.copy.barcode()) $scope.copy.empty_barcode = true;
511 $scope.nextBarcode = function (i) {
512 $scope.focusNext(i, $scope.barcode);
515 $scope.updateBarcode = function () {
516 if ($scope.barcode != '') {
517 $scope.copy.empty_barcode = $scope.empty_barcode = false;
518 $scope.barcode_has_error = !Boolean(itemSvc.checkBarcode($scope.barcode));
519 itemSvc.checkDuplicateBarcode($scope.barcode, $scope.copy.id())
520 .then(function (state) { $scope.copy.duplicate_barcode = $scope.duplicate_barcode = state });
522 $scope.copy.empty_barcode = $scope.empty_barcode = true;
525 $scope.copy.barcode($scope.barcode);
526 $scope.copy.ischanged(1);
527 if (itemSvc.currently_generating)
528 $scope.focusNext($scope.copy.id(), $scope.barcode);
531 $scope.updateCopyNo = function () { $scope.copy.copy_number($scope.copy_number); $scope.copy.ischanged(1); };
532 $scope.updatePart = function () {
534 var p = $scope.part_list.filter(function (x) {
535 return x.label() == $scope.part
537 if (p.length > 0) { // preexisting part
539 } else { // create one...
540 var part = new egCore.idl.bmp();
541 part.id( --$scope.new_part_id );
543 part.label( $scope.part );
544 part.record( $scope.callNumber.record() );
545 $scope.copy.parts([part]);
546 $scope.copy.ischanged(1);
549 $scope.copy.parts([]);
551 $scope.copy.ischanged(1);
555 $scope.part_list = [];
557 itemSvc.get_parts($scope.callNumber.record())
558 .then(function(list){
559 $scope.part_list = list;
560 angular.forEach(list, function(p){ $scope.parts.push(p.label()) });
561 $scope.parts = angular.copy($scope.parts);
563 $scope.$watch('part', $scope.updatePart);
564 if ($scope.copy.parts()) {
565 var the_part = $scope.copy.parts()[0];
566 if (the_part) $scope.part = the_part.label();
570 $scope.barcode = $scope.copy.barcode();
571 $scope.copy_number = $scope.copy.copy_number();
579 .directive("egVolRow", function () {
586 '<div class="col-xs-2">'+
587 '<select ng-disabled="record == 0" class="form-control" ng-model="classification" ng-change="updateClassification()" ng-options="cl.name() for cl in classification_list"/>'+
589 '<div class="col-xs-1">'+
590 '<select ng-disabled="record == 0" class="form-control" ng-model="prefix" ng-change="updatePrefix()" ng-options="p.label() for p in prefix_list"/>'+
592 '<div class="col-xs-2">'+
593 '<input ng-disabled="record == 0" class="form-control" type="text" ng-change="updateLabel()" ng-model="label"/>'+
594 '<div class="label label-danger" ng-if="empty_label">{{empty_label_string}}</div>'+
596 '<div class="col-xs-1">'+
597 '<select ng-disabled="record == 0" class="form-control" ng-model="suffix" ng-change="updateSuffix()" ng-options="s.label() for s in suffix_list"/>'+
599 '<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>'+
600 '<div ng-hide="onlyVols" class="col-xs-5">'+
601 '<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>'+
605 scope: {focusNext: "=", allcopies: "=", copies: "=", onlyVols: "=", record: "@" },
606 controller : ['$scope','itemSvc','egCore',
607 function ( $scope , itemSvc , egCore ) {
608 $scope.callNumber = $scope.copies[0].call_number();
609 if (!$scope.callNumber.label()) $scope.callNumber.empty_label = true;
611 $scope.empty_label = false;
612 $scope.empty_label_string = window.empty_label_string;
614 $scope.idTracker = function (x) { if (x && x.id) return x.id() };
616 // XXX $() is not working! arg
617 $scope.focusNextBarcode = function (i, prev_bc) {
620 angular.forEach($scope.copies, function (cp) {
628 if (yep) n = cp.id();
632 var next = '#' + $scope.callNumber.id() + '_' + n;
635 if (!itemSvc.currently_generating) el.focus();
636 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
637 itemSvc.nextBarcode(prev_bc).then(function(bc){
640 el.trigger('change');
643 itemSvc.currently_generating = false;
647 $scope.focusNext($scope.callNumber.id(),prev_bc)
651 $scope.suffix_list = [];
652 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
653 $scope.suffix_list = list;
654 $scope.$watch('callNumber.suffix()', function (v) {
655 if (angular.isObject(v)) v = v.id();
656 $scope.suffix = $scope.suffix_list.filter( function (s) {
662 $scope.updateSuffix = function () {
663 angular.forEach($scope.copies, function(cp) {
664 cp.call_number().suffix($scope.suffix);
665 cp.call_number().ischanged(1);
669 $scope.prefix_list = [];
670 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
671 $scope.prefix_list = list;
672 $scope.$watch('callNumber.prefix()', function (v) {
673 if (angular.isObject(v)) v = v.id();
674 $scope.prefix = $scope.prefix_list.filter(function (p) {
680 $scope.updatePrefix = function () {
681 angular.forEach($scope.copies, function(cp) {
682 cp.call_number().prefix($scope.prefix);
683 cp.call_number().ischanged(1);
686 $scope.$watch('callNumber.owning_lib()', function(oldLib, newLib) {
687 if (oldLib == newLib) return;
688 var currentPrefix = $scope.callNumber.prefix();
689 if (angular.isObject(currentPrefix)) currentPrefix = currentPrefix.id();
690 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
691 $scope.prefix_list = list;
692 var newPrefixId = $scope.prefix_list.filter(function (p) {
693 return p.id() == currentPrefix;
695 if (newPrefixId.id) newPrefixId = newPrefixId.id();
696 $scope.prefix = $scope.prefix_list.filter(function (p) {
697 return p.id() == newPrefixId;
699 if ($scope.newPrefixId != currentPrefix) {
700 $scope.callNumber.prefix($scope.prefix);
703 var currentSuffix = $scope.callNumber.suffix();
704 if (angular.isObject(currentSuffix)) currentSuffix = currentSuffix.id();
705 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
706 $scope.suffix_list = list;
707 var newSuffixId = $scope.suffix_list.filter(function (s) {
708 return s.id() == currentSuffix;
710 if (newSuffixId.id) newSuffixId = newSuffixId.id();
711 $scope.suffix = $scope.suffix_list.filter(function (s) {
712 return s.id() == newSuffixId;
714 if ($scope.newSuffixId != currentSuffix) {
715 $scope.callNumber.suffix($scope.suffix);
720 $scope.classification_list = [];
721 itemSvc.get_classifications().then(function(list){
722 $scope.classification_list = list;
723 $scope.$watch('callNumber.label_class()', function (v) {
724 if (angular.isObject(v)) v = v.id();
725 $scope.classification = $scope.classification_list.filter(function (c) {
731 $scope.updateClassification = function () {
732 angular.forEach($scope.copies, function(cp) {
733 cp.call_number().label_class($scope.classification);
734 cp.call_number().ischanged(1);
738 $scope.updateLabel = function () {
739 angular.forEach($scope.copies, function(cp) {
740 cp.call_number().label($scope.label);
741 cp.call_number().ischanged(1);
745 $scope.$watch('callNumber.label()', function (v) {
747 if ($scope.label == '') {
748 $scope.callNumber.empty_label = $scope.empty_label = true;
750 $scope.callNumber.empty_label = $scope.empty_label = false;
754 $scope.prefix = $scope.callNumber.prefix();
755 $scope.suffix = $scope.callNumber.suffix();
756 $scope.classification = $scope.callNumber.label_class();
757 $scope.label = $scope.callNumber.label();
759 $scope.copy_count = $scope.copies.length;
760 $scope.orig_copy_count = $scope.copy_count;
762 $scope.changeCPCount = function () {
763 while ($scope.copy_count > $scope.copies.length) {
764 var cp = itemSvc.generateNewCopy(
766 $scope.callNumber.owning_lib(),
770 $scope.copies.push( cp );
771 $scope.allcopies.push( cp );
775 if ($scope.copy_count >= $scope.orig_copy_count) {
776 var how_many = $scope.copies.length - $scope.copy_count;
778 var dead = $scope.copies.splice($scope.copy_count,how_many);
779 $scope.callNumber.copies($scope.copies);
781 // Trimming the global list is a bit more tricky
782 angular.forEach( dead, function (d) {
783 angular.forEach( $scope.allcopies, function (l, i) {
784 if (l === d) $scope.allcopies.splice(i,1);
797 .directive("egVolEdit", function () {
803 '<div class="col-xs-1"><eg-org-selector alldisabled="{{record == 0}}" selected="owning_lib" disable-test="cant_have_vols"></eg-org-selector></div>'+
804 '<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>'+
805 '<div class="col-xs-10">'+
806 '<eg-vol-row only-vols="onlyVols" record="{{record}}"'+
807 'ng-repeat="(cn,copies) in struct" '+
808 'focus-next="focusNextFirst" copies="copies" allcopies="allcopies">'+
813 scope: { focusNext: "=", allcopies: "=", struct: "=", lib: "@", record: "@", onlyVols: "=" },
814 controller : ['$scope','itemSvc','egCore',
815 function ( $scope , itemSvc , egCore ) {
816 $scope.first_cn = Object.keys($scope.struct)[0];
817 $scope.full_cn = $scope.struct[$scope.first_cn][0].call_number();
819 $scope.defaults = {};
820 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
826 $scope.focusNextFirst = function(prev_cn,prev_bc) {
829 angular.forEach(Object.keys($scope.struct).sort(), function (cn) {
841 var next = '#' + n + '_' + $scope.struct[n][0].id();
844 if (!itemSvc.currently_generating) el.focus();
845 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
846 itemSvc.nextBarcode(prev_bc).then(function(bc){
849 el.trigger('change');
852 itemSvc.currently_generating = false;
856 $scope.focusNext($scope.lib, prev_bc);
860 $scope.cn_count = Object.keys($scope.struct).length;
861 $scope.orig_cn_count = $scope.cn_count;
863 $scope.owning_lib = egCore.org.get($scope.lib);
864 $scope.$watch('owning_lib', function (oldLib, newLib) {
865 if (oldLib == newLib) return;
866 angular.forEach( Object.keys($scope.struct), function (cn) {
867 $scope.struct[cn][0].call_number().owning_lib( $scope.owning_lib.id() );
868 $scope.struct[cn][0].call_number().ischanged(1);
872 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
874 $scope.$watch('cn_count', function (n) {
875 var o = Object.keys($scope.struct).length;
876 if (n > o) { // adding
877 for (var i = o; o < n; o++) {
878 var cn = new egCore.idl.acn();
879 cn.id( --itemSvc.new_cn_id );
881 cn.prefix( $scope.defaults.prefix || -1 );
882 cn.suffix( $scope.defaults.suffix || -1 );
883 cn.label_class( $scope.defaults.classification || 1 );
884 cn.owning_lib( $scope.owning_lib.id() );
885 cn.record( $scope.full_cn.record() );
887 var cp = itemSvc.generateNewCopy(
889 $scope.owning_lib.id(),
894 $scope.struct[cn.id()] = [cp];
895 $scope.allcopies.push(cp);
896 if (!$scope.defaults.classification) {
898 ['cat.default_classification_scheme'],
900 ).then(function (val) {
901 cn.label_class(val['cat.default_classification_scheme']);
905 } else if (n < o && n >= $scope.orig_cn_count) { // removing
906 var how_many = o - n;
909 .sort(function(a, b){return parseInt(a)-parseInt(b)})
910 .filter(function(x){ return parseInt(x) <= 0 });
911 for (var i = 0; i < how_many; i++) {
912 // Trimming the global list is a bit more tricky
913 angular.forEach($scope.struct[list[i]], function (d) {
914 angular.forEach( $scope.allcopies, function (l, j) {
915 if (l === d) $scope.allcopies.splice(j,1);
918 delete $scope.struct[list[i]];
931 .controller('EditCtrl',
932 ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$uibModal',
933 function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $uibModal) {
935 $scope.forms = {}; // Accessed by t_attr_edit.tt2
936 $scope.i18n = egCore.i18n;
938 $scope.defaults = { // If defaults are not set at all, allow everything
939 barcode_checkdigit : false,
940 auto_gen_barcode : false,
946 loan_duration : true,
951 deposit_amount : true,
955 mint_condition : true,
958 circ_modifier : true,
968 $scope.new_lib_to_add = egCore.org.get(egCore.auth.user().ws_ou());
969 $scope.changeNewLib = function (org) {
970 $scope.new_lib_to_add = org;
972 $scope.addLibToStruct = function () {
973 var newLib = $scope.new_lib_to_add;
974 var cn = new egCore.idl.acn();
975 cn.id( --itemSvc.new_cn_id );
977 cn.prefix( $scope.defaults.prefix || -1 );
978 cn.suffix( $scope.defaults.suffix || -1 );
979 cn.label_class( $scope.defaults.classification || 1 );
980 cn.owning_lib( newLib.id() );
981 cn.record( $scope.record_id );
983 var cp = itemSvc.generateNewCopy(
990 $scope.data.addCopy(cp);
992 if (!$scope.defaults.classification) {
994 ['cat.default_classification_scheme'],
996 ).then(function (val) {
997 cn.label_class(val['cat.default_classification_scheme']);
1002 $scope.embedded = ($routeParams.mode && $routeParams.mode == 'embedded') ? true : false;
1003 $scope.edit_templates = ($location.path().match(/edit_template/)) ? true : false;
1005 $scope.saveDefaults = function () {
1006 egCore.hatch.setItem('cat.copy.defaults', $scope.defaults);
1009 $scope.fetchDefaults = function () {
1010 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
1012 $scope.defaults = t;
1013 if (!$scope.batch) $scope.batch = {};
1014 $scope.batch.classification = $scope.defaults.classification;
1015 $scope.batch.prefix = $scope.defaults.prefix;
1016 $scope.batch.suffix = $scope.defaults.suffix;
1017 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
1019 typeof $scope.defaults.statcat_filter == 'object' &&
1020 Object.keys($scope.defaults.statcat_filter).length > 0
1022 // want fieldmapper object here...
1023 $scope.defaults.statcat_filter =
1024 egCore.idl.Clone($scope.defaults.statcat_filter);
1026 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
1028 if ($scope.defaults.always_volumes) $scope.show_vols = true;
1029 if ($scope.defaults.barcode_checkdigit) itemSvc.barcode_checkdigit = true;
1030 if ($scope.defaults.auto_gen_barcode) itemSvc.auto_gen_barcode = true;
1034 $scope.fetchDefaults();
1036 $scope.$watch('defaults.statcat_filter', function() {
1037 $scope.saveDefaults();
1039 $scope.$watch('defaults.auto_gen_barcode', function (n,o) {
1040 itemSvc.auto_gen_barcode = n
1043 $scope.$watch('defaults.barcode_checkdigit', function (n,o) {
1044 itemSvc.barcode_checkdigit = n
1047 $scope.dirty = false;
1048 $scope.$watch('dirty',
1049 function(newVal, oldVal) {
1050 if (newVal && newVal != oldVal) {
1051 $($window).on('beforeunload.edit', function(){
1052 return 'There is unsaved data!'
1055 $($window).off('beforeunload.edit');
1060 $scope.only_vols = false;
1061 $scope.show_vols = true;
1062 $scope.show_copies = true;
1064 $scope.tracker = function (x,f) { if (x) return x[f]() };
1065 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
1066 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1068 $scope.orgById = function (id) { return egCore.org.get(id) }
1069 $scope.statusById = function (id) {
1070 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
1072 $scope.locationById = function (id) {
1073 return $scope.location_cache[''+id];
1076 $scope.workingToComplete = function () {
1077 angular.forEach( $scope.workingGridControls.selectedItems(), function (c) {
1078 angular.forEach( itemSvc.copies, function (w, i) {
1080 $scope.completed_copies = $scope.completed_copies.concat(itemSvc.copies.splice(i,1));
1087 $scope.completeToWorking = function () {
1088 angular.forEach( $scope.completedGridControls.selectedItems(), function (c) {
1089 angular.forEach( $scope.completed_copies, function (w, i) {
1091 itemSvc.copies = itemSvc.copies.concat($scope.completed_copies.splice(i,1));
1098 createSimpleUpdateWatcher = function (field,exclude_copies_with_one_of_these_values) {
1099 return $scope.$watch('working.' + field, function () {
1100 var newval = $scope.working[field];
1102 if (typeof newval != 'undefined') {
1103 delete $scope.working.MultiMap[field];
1104 if (angular.isObject(newval)) { // we'll use the pkey
1105 if (newval.id) newval = newval.id();
1106 else if (newval.code) newval = newval.code();
1109 if (""+newval == "" || newval == null) {
1110 $scope.working[field] = undefined;
1114 if ($scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1116 $scope.workingGridControls.selectedItems(),
1118 if (exclude_copies_with_one_of_these_values
1119 && exclude_copies_with_one_of_these_values.indexOf(cp[field](),0) > -1) {
1122 if (cp[field]() !== newval) {
1125 $scope.dirty = true;
1138 statcat_filter: undefined
1141 $scope.copyAlertUpdate = function (alerts) {
1142 if (!$scope.in_item_select &&
1143 $scope.workingGridControls &&
1144 $scope.workingGridControls.selectedItems) {
1145 itemSvc.get_copy_alert_types().then(function(ccat) {
1147 $scope.alert_types = ccat;
1148 angular.forEach(ccat, function(t) {
1149 ccat_map[t.id()] = t;
1152 $scope.workingGridControls.selectedItems(),
1154 $scope.dirty = true;
1155 angular.forEach(alerts, function(alrt) {
1156 var a = egCore.idl.fromHash('aca', alrt);
1158 a.create_staff(egCore.auth.user().id());
1159 a.alert_type(ccat_map[a.alert_type()]);
1162 cp.copy_alerts().push( a );
1171 $scope.copyNoteUpdate = function (notes) {
1172 if (!$scope.in_item_select &&
1173 $scope.workingGridControls &&
1174 $scope.workingGridControls.selectedItems) {
1176 $scope.workingGridControls.selectedItems(),
1178 $scope.dirty = true;
1179 angular.forEach(notes, function(note) {
1180 var n = egCore.idl.fromHash('acpn', note);
1182 n.creator(egCore.auth.user().id());
1183 n.owning_copy(cp.id());
1184 cp.notes().push( n );
1193 $scope.statcatUpdate = function (id) {
1194 var newval = $scope.working.statcats[id];
1196 if (typeof newval != 'undefined') {
1197 if (angular.isObject(newval)) { // we'll use the pkey
1198 newval = newval.id();
1201 if (""+newval == "" || newval == null) {
1202 $scope.working.statcats[id] = undefined;
1206 if (!$scope.in_item_select && $scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1208 $scope.workingGridControls.selectedItems(),
1210 $scope.dirty = true;
1212 cp.stat_cat_entries(
1213 angular.forEach( cp.stat_cat_entries(), function (e) {
1214 if (e.stat_cat() == id) { // mark deleted
1221 var e = new egCore.idl.asce();
1226 cp.stat_cat_entries(
1227 cp.stat_cat_entries() ?
1228 cp.stat_cat_entries().concat([ e ]) :
1234 // trim out all deleted ones; the API used to
1235 // do the update doesn't actually consult
1236 // isdeleted for stat cat entries
1237 cp.stat_cat_entries(
1238 cp.stat_cat_entries().filter(function (e) {
1239 return !Boolean(e.isdeleted());
1250 var dataKey = $routeParams.dataKey;
1251 console.debug('dataKey: ' + dataKey);
1253 if ((dataKey && dataKey.length > 0) || $scope.edit_templates) {
1255 $scope.templates = {};
1256 $scope.template_name = '';
1257 $scope.template_name_list = [];
1259 $scope.fetchTemplates = function () {
1260 itemSvc.get_acp_templates().then(function(t) {
1262 $scope.templates = t;
1263 $scope.template_name_list = Object.keys(t).sort();
1266 egCore.hatch.getItem('cat.copy.last_template').then(function(t) {
1267 if (t) $scope.template_name = t;
1270 $scope.fetchTemplates();
1272 $scope.applyTemplate = function (n) {
1273 angular.forEach($scope.templates[n], function (v,k) {
1274 if (k == 'circ_lib') {
1275 $scope.working[k] = egCore.org.get(v);
1276 } else if (k == 'copy_notes' && v.length) {
1277 $scope.copyNoteUpdate(v);
1278 } else if (k == 'copy_alerts' && v.length) {
1279 $scope.copyAlertUpdate(v);
1280 } else if (!angular.isObject(v)) {
1281 $scope.working[k] = angular.copy(v);
1283 angular.forEach(v, function (sv,sk) {
1284 if (k == 'callnumber') {
1285 angular.forEach(v, function (cnv,cnk) {
1286 $scope.batch[cnk] = cnv;
1288 $scope.applyBatchCNValues();
1290 $scope.working[k][sk] = angular.copy(sv);
1291 if (k == 'statcats') $scope.statcatUpdate(sk);
1296 delete $scope.working.MultiMap[k];
1297 egCore.hatch.setItem('cat.copy.last_template', n);
1300 $scope.copytab = 'working';
1301 $scope.tab = 'edit';
1302 $scope.summaryRecord = null;
1303 $scope.record_id = null;
1305 $scope.completed_copies = [];
1306 $scope.location_orgs = [];
1307 $scope.location_cache = {};
1308 $scope.statcats = [];
1309 if (!$scope.batch) $scope.batch = {};
1311 $scope.applyBatchCNValues = function () {
1312 if ($scope.data.tree) {
1313 angular.forEach($scope.data.tree, function(cn_hash) {
1314 angular.forEach(cn_hash, function(copies) {
1315 angular.forEach(copies, function(cp) {
1316 if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') {
1317 var label_class = $scope.classification_list.filter(function(p){ return p.id() == $scope.batch.classification })[0];
1318 cp.call_number().label_class(label_class);
1319 cp.call_number().ischanged(1);
1320 $scope.dirty = true;
1322 if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') {
1323 var prefix = $scope.prefix_list.filter(function(p){ return p.id() == $scope.batch.prefix })[0];
1324 cp.call_number().prefix(prefix);
1325 cp.call_number().ischanged(1);
1326 $scope.dirty = true;
1328 if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') {
1329 cp.call_number().label($scope.batch.label);
1330 cp.call_number().ischanged(1);
1331 $scope.dirty = true;
1333 if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') {
1334 var suffix = $scope.suffix_list.filter(function(p){ return p.id() == $scope.batch.suffix })[0];
1335 cp.call_number().suffix(suffix);
1336 cp.call_number().ischanged(1);
1337 $scope.dirty = true;
1345 $scope.clearWorking = function () {
1346 angular.forEach($scope.working, function (v,k,o) {
1347 if (!angular.isObject(v)) {
1348 if (typeof v != 'undefined')
1349 $scope.working[k] = undefined;
1350 } else if (k != 'circ_lib') {
1351 angular.forEach(v, function (sv,sk) {
1352 if (typeof v != 'undefined')
1353 $scope.working[k][sk] = undefined;
1357 $scope.working.circ_lib = undefined; // special
1360 $scope.completedGridDataProvider = egGridDataProvider.instance({
1361 get : function(offset, count) {
1362 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1363 return this.arrayNotifier($scope.completed_copies, offset, count);
1367 $scope.completedGridControls = {};
1369 $scope.workingGridDataProvider = egGridDataProvider.instance({
1370 get : function(offset, count) {
1371 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1372 return this.arrayNotifier(itemSvc.copies, offset, count);
1376 $scope.workingGridControls = {};
1377 $scope.add_vols_copies = false;
1378 $scope.is_fast_add = false;
1380 // Generate some functions for selecting items by column value in the working grid
1382 ['circulate','status','circ_lib','ref','location','opac_visible','circ_modifier','price',
1383 'loan_duration','cost','circ_as_type','deposit','holdable','deposit_amount','age_protect',
1384 'mint_condition','fine_level','floating'],
1386 $scope['select_by_' + field] = function (x) {
1387 $scope.workingGridControls.selectItemsByValue(field,x);
1392 var truthy = /^t|1/;
1393 $scope.labelYesNo = function (x) {
1394 return truthy.test(x) ? egCore.strings.YES : egCore.strings.NO;
1397 $scope.orgShortname = function (x) {
1398 return egCore.org.get(x).shortname();
1401 $scope.statusName = function (x) {
1402 var s = $scope.status_list.filter(function(y) {
1409 $scope.locationName = function (x) {
1410 var s = $scope.location_list.filter(function(y) {
1414 return $scope.i18n.ou_qualified_location_name(s[0]);
1417 $scope.durationLabel = function (x) {
1418 return [egCore.strings.SHORT, egCore.strings.NORMAL, egCore.strings.EXTENDED][-1 + x]
1421 $scope.fineLabel = function (x) {
1422 return [egCore.strings.LOW, egCore.strings.NORMAL, egCore.strings.HIGH][-1 + x]
1425 $scope.circTypeValue = function (x) {
1426 if (x === null) return egCore.strings.UNSET;
1427 var s = $scope.circ_type_list.filter(function(y) {
1428 return y.code() == x;
1431 return s[0].value();
1434 $scope.ageprotectName = function (x) {
1435 if (x === null) return egCore.strings.UNSET;
1436 var s = $scope.age_protect_list.filter(function(y) {
1443 $scope.floatingName = function (x) {
1444 if (x === null) return egCore.strings.UNSET;
1445 var s = $scope.floating_list.filter(function(y) {
1452 $scope.circmodName = function (x) {
1453 if (x === null) return egCore.strings.UNSET;
1454 var s = $scope.circ_modifier_list.filter(function(y) {
1455 return y.code() == x;
1463 'open-ils.actor.anon_cache.get_value',
1464 dataKey, 'edit-these-copies'
1465 ).then(function (data) {
1468 if (data.hide_vols && !$scope.defaults.always_volumes) $scope.show_vols = false;
1469 if (data.hide_copies) {
1470 $scope.show_copies = false;
1471 $scope.only_vols = true;
1474 $scope.record_id = data.record_id;
1476 function fetchRaw () {
1477 if (!$scope.only_vols) $scope.dirty = true;
1478 $scope.add_vols_copies = true;
1480 /* data.raw data structure looks like this:
1482 * callnumber : $cn_id, // optional, to add a copy to a cn
1483 * owner : $org, // optional, defaults to cn.owning_lib or ws_ou
1484 * label : $cn_label, // optional, to supply a label on a new cn
1485 * barcode : $cp_barcode // optional, to supply a barcode on a new cp
1486 * fast_add : boolean // optional, to specify whether this came
1490 * All can be left out and a completely empty vol/copy combo will be vivicated.
1497 if (proto.fast_add) $scope.is_fast_add = true;
1498 if (proto.callnumber) {
1499 promises.push(egCore.pcrud.retrieve('acn', proto.callnumber)
1500 .then(function(cn) {
1501 var cp = new itemSvc.generateNewCopy(
1503 proto.owner || cn.owning_lib(),
1505 ((!$scope.only_vols) ? true : false)
1508 if (proto.barcode) {
1509 cp.barcode( proto.barcode );
1510 cp.empty_barcode = false;
1516 var cn = new egCore.idl.acn();
1517 cn.id( --itemSvc.new_cn_id );
1519 cn.prefix( $scope.defaults.prefix || -1 );
1520 cn.suffix( $scope.defaults.suffix || -1 );
1521 cn.owning_lib( proto.owner || egCore.auth.user().ws_ou() );
1522 cn.record( $scope.record_id );
1523 egCore.org.settings(
1524 ['cat.default_classification_scheme'],
1526 ).then(function (val) {
1528 $scope.defaults.classification ||
1529 val['cat.default_classification_scheme'] ||
1533 cn.label( proto.label );
1537 'open-ils.cat.biblio.record.marc_cn.retrieve',
1540 ).then(function(cn_array) {
1541 if (cn_array.length > 0) {
1542 for (var field in cn_array[0]) {
1543 cn.label( cn_array[0][field] );
1551 // If we are adding an empty vol,
1552 // this is ultimately just a placeholder copy
1553 // which gets removed before saving.
1554 // TODO: consider ways to remove this
1556 var cp = new itemSvc.generateNewCopy(
1558 proto.owner || cn.owning_lib(),
1563 if (proto.barcode) {
1564 cp.barcode( proto.barcode );
1565 cp.empty_barcode = false;
1573 angular.forEach(itemSvc.copies, function(c){
1574 var cn = c.call_number();
1575 var copy_id = c.id();
1577 cn.not_ephemeral = true;
1581 return $q.all(promises);
1584 if (data.copies && data.copies.length)
1585 return itemSvc.fetchIds(data.copies).then(fetchRaw);
1591 }).then( function() {
1593 return itemSvc.fetch_locations(
1594 itemSvc.copies.map(function(cp){
1595 return cp.location();
1596 }).filter(function(e,i,a){
1597 return a.lastIndexOf(e) === i;
1599 ).then(function(list){
1600 $scope.data = itemSvc;
1601 $scope.location_list = list;
1602 $scope.workingGridDataProvider.refresh();
1607 $scope.can_save = false;
1608 function check_saveable () {
1609 var can_save = true;
1614 if (!$scope.only_vols) {
1615 if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) {
1618 } else if (i.call_number().empty_label) {
1624 if (!$scope.only_vols && $scope.forms.myForm && $scope.forms.myForm.$invalid) {
1628 $scope.can_save = can_save;
1631 $scope.disableSave = function () {
1633 return !$scope.can_save;
1636 $scope.focusNextFirst = function(prev_lib,prev_bc) {
1639 angular.forEach(Object.keys($scope.data.tree).sort(), function (lib) {
1642 if (lib == prev_lib) {
1651 var first_cn = Object.keys($scope.data.tree[n])[0];
1652 var next = '#' + first_cn + '_' + $scope.data.tree[n][first_cn][0].id();
1655 if (!itemSvc.currently_generating) el.focus();
1656 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
1657 itemSvc.nextBarcode(prev_bc).then(function(bc){
1660 el.trigger('change');
1663 itemSvc.currently_generating = false;
1669 $scope.in_item_select = false;
1670 $scope.afterItemSelect = function() { $scope.in_item_select = false };
1671 $scope.handleItemSelect = function (item_list) {
1672 if (item_list && item_list.length > 0) {
1673 $scope.in_item_select = true;
1675 angular.forEach(Object.keys($scope.defaults.attributes), function (attr) {
1677 var value_hash = {};
1678 var value_list = [];
1679 angular.forEach(item_list, function (item) {
1681 var v = item[attr]()
1682 if (angular.isObject(v)) {
1683 if (v.id) v = v.id();
1684 else if (v.code) v = v.code();
1691 $scope.working.MultiMap[attr] = value_list;
1693 if (Object.keys(value_hash).length == 1) {
1694 if (attr == 'circ_lib') {
1695 $scope.working[attr] = egCore.org.get(item_list[0][attr]());
1697 $scope.working[attr] = item_list[0][attr]();
1700 $scope.working[attr] = undefined;
1704 angular.forEach($scope.statcats, function (sc) {
1707 var value_hash = {};
1709 angular.forEach(item_list, function (item) {
1710 if (item.stat_cat_entries()) {
1711 if (item.stat_cat_entries().length > 0) {
1712 var right_sc = item.stat_cat_entries().filter(function (e) {
1713 return e.stat_cat() == sc.id() && !Boolean(e.isdeleted());
1716 if (right_sc.length > 0) {
1717 value_hash[right_sc[0].id()] = right_sc[0].id();
1729 if (!none && Object.keys(value_hash).length == 1) {
1730 $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]];
1731 $scope.working.statcats_multi[sc.id()] = false;
1732 } else if (item_list.length > 1 && Object.keys(value_hash).length > 0) {
1733 $scope.working.statcats[sc.id()] = undefined;
1734 $scope.working.statcats_multi[sc.id()] = true;
1736 $scope.working.statcats[sc.id()] = undefined;
1737 $scope.working.statcats_multi[sc.id()] = false;
1743 $scope.clearWorking();
1748 $scope.$watch('data.copies.length', function () {
1749 if ($scope.data.copies) {
1750 var base_orgs = $scope.data.copies.map(function(cp){
1751 if (isNaN(cp.circ_lib())) return Number(cp.circ_lib().id());
1752 return Number(cp.circ_lib());
1754 $scope.data.copies.map(function(cp){
1755 if (isNaN(cp.call_number().owning_lib())) return Number(cp.call_number().owning_lib().id());
1756 return Number(cp.call_number().owning_lib());
1759 [egCore.auth.user().ws_ou()]
1760 ).filter(function(e,i,a){
1761 return a.lastIndexOf(e) === i;
1765 angular.forEach(base_orgs, function(o) {
1766 all_orgs = all_orgs.concat( egCore.org.fullPath(o, true) );
1769 var final_orgs = all_orgs.filter(function(e,i,a){
1770 return a.lastIndexOf(e) === i;
1771 }).sort(function(a, b){return a-b});
1773 if ($scope.location_orgs.toString() != final_orgs.toString()) {
1774 $scope.location_orgs = final_orgs;
1775 if ($scope.location_orgs.length) {
1776 itemSvc.get_locations_by_org($scope.location_orgs).then(function(list){
1777 angular.forEach(list, function(l) {
1778 $scope.location_cache[ ''+l.id() ] = l;
1780 $scope.location_list = list;
1781 }).then(function() {
1782 $scope.statcat_filter_list = [];
1783 angular.forEach($scope.location_orgs, function (o) {
1784 $scope.statcat_filter_list.push(egCore.org.get(o));
1787 itemSvc.get_statcats($scope.location_orgs).then(function(list){
1788 $scope.statcats = list;
1789 angular.forEach($scope.statcats, function (s) {
1791 if (!$scope.working)
1792 $scope.working = { statcats_multi: {}, statcats: {}, statcat_filter: undefined};
1793 if (!$scope.working.statcats_multi)
1794 $scope.working.statcats_multi = {};
1795 if (!$scope.working.statcats)
1796 $scope.working.statcats = {};
1798 if (!$scope.in_item_select) {
1799 $scope.working.statcats[s.id()] = undefined;
1801 createStatcatUpdateWatcher(s.id());
1803 $scope.in_item_select = false;
1804 // do a refresh here to work around a race
1805 // condition that can result in stat cats
1806 // not being selected.
1807 $scope.workingGridDataProvider.refresh();
1812 $scope.workingGridDataProvider.refresh();
1817 $scope.statcat_visible = function (sc_owner) {
1818 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
1819 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
1820 if ($scope.working.statcat_filter == ancestor_org.id())
1826 $scope.suffix_list = [];
1827 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1828 $scope.suffix_list = list;
1831 $scope.prefix_list = [];
1832 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1833 $scope.prefix_list = list;
1836 $scope.classification_list = [];
1837 itemSvc.get_classifications().then(function(list){
1838 $scope.classification_list = list;
1841 $scope.$watch('completed_copies.length', function () {
1842 $scope.completedGridDataProvider.refresh();
1845 $scope.location_list = [];
1846 createSimpleUpdateWatcher('location');
1848 $scope.status_list = [];
1849 itemSvc.get_magic_statuses().then(function(list){
1850 $scope.magic_status_list = list;
1851 createSimpleUpdateWatcher('status',$scope.magic_status_list);
1853 itemSvc.get_statuses().then(function(list){
1854 $scope.status_list = list;
1857 $scope.circ_modifier_list = [];
1858 itemSvc.get_circ_mods().then(function(list){
1859 $scope.circ_modifier_list = list;
1861 createSimpleUpdateWatcher('circ_modifier');
1863 $scope.circ_type_list = [];
1864 itemSvc.get_circ_types().then(function(list){
1865 $scope.circ_type_list = list;
1867 createSimpleUpdateWatcher('circ_as_type');
1869 $scope.age_protect_list = [];
1870 itemSvc.get_age_protects().then(function(list){
1871 $scope.age_protect_list = list;
1873 createSimpleUpdateWatcher('age_protect');
1875 $scope.floating_list = [];
1876 itemSvc.get_floating_groups().then(function(list){
1877 $scope.floating_list = list;
1879 createSimpleUpdateWatcher('floating');
1881 createSimpleUpdateWatcher('circ_lib');
1882 createSimpleUpdateWatcher('circulate');
1883 createSimpleUpdateWatcher('holdable');
1884 createSimpleUpdateWatcher('fine_level');
1885 createSimpleUpdateWatcher('loan_duration');
1886 createSimpleUpdateWatcher('price');
1887 createSimpleUpdateWatcher('cost');
1888 createSimpleUpdateWatcher('deposit');
1889 createSimpleUpdateWatcher('deposit_amount');
1890 createSimpleUpdateWatcher('mint_condition');
1891 createSimpleUpdateWatcher('opac_visible');
1892 createSimpleUpdateWatcher('ref');
1894 $scope.saveCompletedCopies = function (and_exit) {
1896 var perCnCopies = {};
1897 angular.forEach( $scope.completed_copies, function (cp) {
1898 var cn = cp.call_number();
1899 var cn_cps = cp.call_number().copies();
1900 cp.call_number().copies([]);
1901 var cn_id = cp.call_number().id();
1902 cp.call_number(cn_id); // prevent loops in JSON-ification
1903 if (!cnHash[cn_id]) {
1904 cnHash[cn_id] = egCore.idl.Clone(cn);
1905 perCnCopies[cn_id] = [egCore.idl.Clone(cp)];
1907 perCnCopies[cn_id].push(egCore.idl.Clone(cp));
1909 cp.call_number(cn); // put the data back
1910 cp.call_number().copies(cn_cps);
1911 if (typeof cnHash[cn_id].prefix() == 'object')
1912 cnHash[cn_id].prefix(cnHash[cn_id].prefix().id()); // un-object-ize some fields
1913 if (typeof cnHash[cn_id].suffix() == 'object')
1914 cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields
1917 if ($scope.only_vols) { // strip off copies when we're in vol-only mode
1918 angular.forEach(cnHash, function (v, k) {
1919 cnHash[k].copies([]);
1922 angular.forEach(perCnCopies, function (v, k) {
1923 cnHash[k].copies(v);
1928 angular.forEach(cnHash, function (v, k) {
1934 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1935 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1, return_copy_ids : 1 }
1936 ).then(function(copy_ids) {
1938 $scope.dirty = false;
1939 if ($scope.defaults.print_item_labels) {
1942 'open-ils.actor.anon_cache.set_value',
1943 null, 'print-labels-these-copies', {
1946 ).then(function(key) {
1948 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1949 $timeout(function() { $window.open(url, '_blank') }).then(
1950 function() { $timeout(function(){$window.close()}); }
1953 alert('Could not create anonymous cache key!');
1957 $timeout(function(){$window.close()});
1963 $scope.saveAndContinue = function () {
1964 $scope.saveCompletedCopies(false);
1967 $scope.workingSaveAndExit = function () {
1968 $scope.workingToComplete();
1969 $scope.saveAndExit();
1972 $scope.saveAndExit = function () {
1973 $scope.saveCompletedCopies(true);
1978 $scope.copy_notes_dialog = function(copy_list) {
1979 var default_pub = Boolean($scope.defaults.copy_notes_pub);
1980 if (!angular.isArray(copy_list)) copy_list = [copy_list];
1982 return $uibModal.open({
1983 templateUrl: './cat/volcopy/t_copy_notes',
1987 ['$scope','$uibModalInstance',
1988 function($scope , $uibModalInstance) {
1989 $scope.focusNote = true;
1991 creator : egCore.auth.user().id(),
1997 $scope.require_initials = false;
1998 egCore.org.settings([
1999 'ui.staff.require_initials.copy_notes'
2000 ]).then(function(set) {
2001 $scope.require_initials_ous = Boolean(set['ui.staff.require_initials.copy_notes']);
2004 $scope.are_initials_required = function() {
2005 $scope.require_initials = $scope.require_initials_ous && ($scope.note.value.length > 0 || $scope.note.title.length > 0);
2008 $scope.$watch('note.value.length', $scope.are_initials_required);
2009 $scope.$watch('note.title.length', $scope.are_initials_required);
2011 $scope.note_list = [];
2012 if (copy_list.length == 1) {
2013 $scope.note_list = copy_list[0].notes();
2016 $scope.ok = function(note) {
2018 if (note.value.length > 0 || note.title.length > 0) {
2019 if ($scope.initials) {
2020 note.value = egCore.strings.$replace(
2021 egCore.strings.COPY_NOTE_INITIALS, {
2023 initials : $scope.initials,
2024 ws_ou : egCore.org.get(
2025 egCore.auth.user().ws_ou()).shortname()
2029 angular.forEach(copy_list, function (cp) {
2030 if (!angular.isArray(cp.notes())) cp.notes([]);
2031 var n = new egCore.idl.acpn();
2033 n.creator(note.creator);
2035 n.title(note.title);
2036 n.value(note.value);
2037 n.owning_copy(cp.id());
2038 cp.notes().push( n );
2042 $uibModalInstance.close();
2045 $scope.cancel = function($event) {
2046 $uibModalInstance.dismiss();
2047 $event.preventDefault();
2053 $scope.copy_tags_dialog = function(copy_list) {
2054 if (!angular.isArray(copy_list)) copy_list = [copy_list];
2056 return $uibModal.open({
2057 templateUrl: './cat/volcopy/t_copy_tags',
2061 ['$scope','$uibModalInstance',
2062 function($scope , $uibModalInstance) {
2064 $scope.tag_map = [];
2066 var shared_tags = {};
2067 angular.forEach(copy_list, function (cp) {
2068 angular.forEach(cp.tags(), function(tag) {
2069 if (!(tag.tag().id() in shared_tags)) {
2070 shared_tags[tag.tag().id()] = 1;
2072 shared_tags[tag.tag().id()]++;
2074 if (!(tag.tag().id() in tag_hash)) {
2075 tag_hash[tag.tag().id()] = tag;
2079 angular.forEach(tag_hash, function(value, key) {
2080 if (shared_tags[key] == copy_list.length) {
2081 $scope.tag_map.push(value);
2085 $scope.tag_types = [];
2086 egCore.pcrud.retrieveAll('cctt', {order_by : { cctt : 'label' }}, {atomic : true}).then(function(list) {
2087 $scope.tag_types = list;
2088 $scope.tag_type = $scope.tag_types[0].code(); // just pick a default
2091 $scope.getTags = function(val) {
2092 return egCore.pcrud.search('acpt',
2094 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2095 label : { 'startwith' : {
2096 transform: 'evergreen.lowercase',
2097 value : [ 'evergreen.lowercase', val ]
2099 tag_type : $scope.tag_type
2101 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2102 ).then(function(list) {
2103 return list.map(function(item) {
2104 return item.label();
2109 $scope.addTag = function() {
2110 var tagLabel = $scope.selectedLabel;
2111 // clear the typeahead
2112 $scope.selectedLabel = "";
2114 // first, check tags already associated with the copy
2115 var foundMatch = false;
2116 angular.forEach($scope.tag_map, function(tag) {
2117 if (tag.tag().label() == tagLabel && tag.tag().tag_type() == $scope.tag_type) {
2119 if (tag.isdeleted()) tag.isdeleted(0); // just deleting the mapping
2123 egCore.pcrud.search('acpt',
2125 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2127 tag_type : $scope.tag_type
2129 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2130 ).then(function(list) {
2131 if (list.length > 0) {
2132 var newMap = new egCore.idl.acptcm();
2134 newMap.copy(copy_list[0].id());
2135 newMap.tag(egCore.idl.Clone(list[0]));
2136 $scope.tag_map.push(newMap);
2138 var newTag = new egCore.idl.acpt();
2140 newTag.owner(egCore.auth.user().ws_ou());
2141 newTag.label(tagLabel);
2143 newTag.tag_type($scope.tag_type);
2145 var newMap = new egCore.idl.acptcm();
2147 newMap.copy(copy_list[0].id());
2149 $scope.tag_map.push(newMap);
2155 $scope.ok = function(note) {
2156 // in the multi-item case, this works OK for
2157 // adding new maps to existing tags, but doesn't handle
2158 // all possibilities
2159 angular.forEach(copy_list, function (cp) {
2160 cp.tags($scope.tag_map);
2162 $uibModalInstance.close();
2165 $scope.cancel = function($event) {
2166 $uibModalInstance.dismiss();
2167 $event.preventDefault();
2173 $scope.copy_alerts_dialog = function(copy_list) {
2174 if (!angular.isArray(copy_list)) copy_list = [copy_list];
2176 return $uibModal.open({
2177 templateUrl: './cat/volcopy/t_copy_alerts',
2180 ['$scope','$uibModalInstance',
2181 function($scope , $uibModalInstance) {
2183 itemSvc.get_copy_alert_types().then(function(ccat) {
2184 $scope.alert_types = ccat;
2187 $scope.focusNote = true;
2188 $scope.copy_alert = {
2189 create_staff : egCore.auth.user().id(),
2194 egCore.hatch.getItem('cat.copy.alerts.last_type').then(function(t) {
2195 if (t) $scope.copy_alert.alert_type = t;
2198 if (copy_list.length == 1) {
2199 $scope.copy_alert_list = copy_list[0].copy_alerts();
2202 $scope.ok = function(copy_alert) {
2204 if (typeof(copy_alert.note) != 'undefined' &&
2205 copy_alert.note != '') {
2206 angular.forEach(copy_list, function (cp) {
2207 var a = new egCore.idl.aca();
2209 a.create_staff(copy_alert.create_staff);
2210 a.note(copy_alert.note);
2211 a.temp(copy_alert.temp ? 't' : 'f');
2215 $scope.alert_types.filter(function(at) {
2216 return at.id() == copy_alert.alert_type;
2219 cp.copy_alerts().push( a );
2222 if (copy_alert.alert_type) {
2223 egCore.hatch.setItem(
2224 'cat.copy.alerts.last_type',
2225 copy_alert.alert_type
2231 $uibModalInstance.close();
2234 $scope.cancel = function($event) {
2235 $uibModalInstance.dismiss();
2236 $event.preventDefault();
2244 .directive("egVolTemplate", function () {
2248 template: '<div ng-include="'+"'/eg/staff/cat/volcopy/t_attr_edit'"+'"></div>',
2252 controller : ['$scope','$window','itemSvc','egCore','ngToast','$uibModal',
2253 function ( $scope , $window , itemSvc , egCore , ngToast , $uibModal) {
2255 $scope.i18n = egCore.i18n;
2257 $scope.defaults = { // If defaults are not set at all, allow everything
2258 barcode_checkdigit : false,
2259 auto_gen_barcode : false,
2266 loan_duration : true,
2271 deposit_amount : true,
2272 opac_visible : true,
2275 mint_condition : true,
2278 circ_modifier : true,
2279 circ_as_type : true,
2287 $scope.fetchDefaults = function () {
2288 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
2290 $scope.defaults = t;
2291 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
2293 typeof $scope.defaults.statcat_filter == 'object' &&
2294 Object.keys($scope.defaults.statcat_filter).length > 0
2296 // want fieldmapper object here...
2297 $scope.defaults.statcat_filter =
2298 egCore.idl.Clone($scope.defaults.statcat_filter);
2300 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
2305 $scope.fetchDefaults();
2307 $scope.dirty = false;
2308 $scope.$watch('dirty',
2309 function(newVal, oldVal) {
2310 if (newVal && newVal != oldVal) {
2311 $($window).on('beforeunload.template', function(){
2312 return 'There is unsaved template data!'
2315 $($window).off('beforeunload.template');
2320 $scope.template_controls = true;
2322 $scope.fetchTemplates = function () {
2323 itemSvc.get_acp_templates().then(function(t) {
2325 $scope.templates = t;
2326 $scope.template_name_list = Object.keys(t).sort();
2330 $scope.fetchTemplates();
2332 $scope.applyTemplate = function (n) {
2333 angular.forEach($scope.templates[n], function (v,k) {
2334 if (k == 'circ_lib') {
2335 $scope.working[k] = egCore.org.get(v);
2336 } else if (angular.isArray(v) || !angular.isObject(v)) {
2337 $scope.working[k] = angular.copy(v);
2339 angular.forEach(v, function (sv,sk) {
2340 if (!(k in $scope.working))
2341 $scope.working[k] = {};
2342 $scope.working[k][sk] = angular.copy(sv);
2346 $scope.template_name = '';
2349 $scope.deleteTemplate = function (n) {
2351 delete $scope.templates[n]
2352 $scope.template_name_list = Object.keys($scope.templates).sort();
2353 $scope.template_name = '';
2354 itemSvc.save_acp_templates($scope.templates);
2355 $scope.$parent.fetchTemplates();
2356 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_DELETE);
2360 $scope.saveTemplate = function (n) {
2364 angular.forEach($scope.working, function (v,k) {
2365 if (angular.isObject(v)) { // we'll use the pkey
2366 if (v.id) v = v.id();
2367 else if (v.code) v = v.code();
2368 else v = angular.copy(v); // Should only be statcats and callnumbers currently
2374 $scope.templates[n] = tmpl;
2375 $scope.template_name_list = Object.keys($scope.templates).sort();
2377 itemSvc.save_acp_templates($scope.templates);
2378 $scope.$parent.fetchTemplates();
2380 $scope.dirty = false;
2382 // save all templates, as we might do after an import
2383 itemSvc.save_acp_templates($scope.templates);
2384 $scope.$parent.fetchTemplates();
2386 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_SAVE);
2389 $scope.templates = {};
2390 $scope.imported_templates = { data : '' };
2391 $scope.template_name = '';
2392 $scope.template_name_list = [];
2394 $scope.$watch('imported_templates.data', function(newVal, oldVal) {
2395 if (newVal && newVal != oldVal) {
2397 var newTemplates = JSON.parse(newVal);
2398 if (!Object.keys(newTemplates).length) return;
2399 angular.forEach(Object.keys(newTemplates), function (k) {
2400 $scope.templates[k] = newTemplates[k];
2402 itemSvc.save_acp_templates($scope.templates);
2403 $scope.fetchTemplates();
2405 console.log('tried to import an invalid copy template file');
2410 $scope.tracker = function (x,f) { if (x) return x[f]() };
2411 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
2412 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
2414 $scope.orgById = function (id) { return egCore.org.get(id) }
2415 $scope.statusById = function (id) {
2416 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
2418 $scope.locationById = function (id) {
2419 return $scope.location_cache[''+id];
2422 createSimpleUpdateWatcher = function (field) {
2423 $scope.$watch('working.' + field, function () {
2424 var newval = $scope.working[field];
2426 if (typeof newval != 'undefined') {
2427 $scope.dirty = true;
2428 if (angular.isObject(newval)) { // we'll use the pkey
2429 if (newval.id) $scope.working[field] = newval.id();
2430 else if (newval.code) $scope.working[field] = newval.code();
2433 if (""+newval == "" || newval == null) {
2434 $scope.working[field] = undefined;
2445 statcat_filter: undefined
2448 $scope.statcat_visible = function (sc_owner) {
2449 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
2450 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
2451 if ($scope.working.statcat_filter == ancestor_org.id())
2457 createStatcatUpdateWatcher = function (id) {
2458 return $scope.$watch('working.statcats[' + id + ']', function () {
2459 if ($scope.working.statcats) {
2460 var newval = $scope.working.statcats[id];
2462 if (typeof newval != 'undefined') {
2463 $scope.dirty = true;
2464 if (angular.isObject(newval)) { // we'll use the pkey
2465 newval = newval.id();
2468 if (""+newval == "" || newval == null) {
2469 $scope.working.statcats[id] = undefined;
2478 $scope.clearWorking = function () {
2479 angular.forEach($scope.working, function (v,k,o) {
2480 $scope.working.MultiMap[k] = [];
2481 if (!angular.isObject(v)) {
2482 if (typeof v != 'undefined')
2483 $scope.working[k] = undefined;
2484 } else if (k != 'circ_lib') {
2485 angular.forEach(v, function (sv,sk) {
2486 $scope.working[k][sk] = undefined;
2490 $scope.working.circ_lib = undefined; // special
2491 $scope.dirty = false;
2494 $scope.working = {};
2495 $scope.location_orgs = [];
2496 $scope.location_cache = {};
2498 $scope.location_list = [];
2499 itemSvc.get_locations_by_org(
2500 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2501 ).then(function(list){
2502 $scope.location_list = list;
2504 createSimpleUpdateWatcher('location');
2506 $scope.statcat_filter_list = egCore.org.fullPath( egCore.auth.user().ws_ou() );
2508 $scope.statcats = [];
2509 itemSvc.get_statcats(
2510 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2511 ).then(function(list){
2512 $scope.statcats = list;
2513 angular.forEach($scope.statcats, function (s) {
2515 if (!$scope.working)
2516 $scope.working = { statcats: {}, statcat_filter: undefined};
2517 if (!$scope.working.statcats)
2518 $scope.working.statcats = {};
2520 $scope.working.statcats[s.id()] = undefined;
2521 createStatcatUpdateWatcher(s.id());
2525 $scope.copy_notes_dialog = function() {
2526 var default_pub = Boolean($scope.defaults.copy_notes_pub);
2527 var working = $scope.working;
2529 return $uibModal.open({
2530 templateUrl: './cat/volcopy/t_copy_notes',
2533 ['$scope','$uibModalInstance',
2534 function($scope , $uibModalInstance) {
2535 $scope.focusNote = true;
2542 $scope.require_initials = false;
2543 egCore.org.settings([
2544 'ui.staff.require_initials.copy_notes'
2545 ]).then(function(set) {
2546 $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
2549 $scope.note_list = [];
2550 angular.forEach(working.copy_notes, function(note) {
2551 var acpn = egCore.idl.fromHash('acpn', note);
2552 $scope.note_list.push(acpn);
2555 $scope.ok = function(note) {
2557 if (!working.copy_notes) {
2558 working.copy_notes = [];
2562 working.copy_notes.length = 0;
2563 angular.forEach($scope.note_list, function(existing_note) {
2564 if (!existing_note.isdeleted()) {
2565 working.copy_notes.push({
2566 pub : existing_note.pub() ? 't' : 'f',
2567 title : existing_note.title(),
2568 value : existing_note.value()
2573 // add new note, if any
2574 if (note.initials) note.value += ' [' + note.initials + ']';
2575 note.pub = note.pub ? 't' : 'f';
2576 if (note.title.length && note.value.length) {
2577 working.copy_notes.push(note);
2580 $uibModalInstance.close();
2583 $scope.cancel = function($event) {
2584 $uibModalInstance.dismiss();
2585 $event.preventDefault();
2591 $scope.copy_alerts_dialog = function() {
2592 var working = $scope.working;
2594 return $uibModal.open({
2595 templateUrl: './cat/volcopy/t_copy_alerts',
2598 ['$scope','$uibModalInstance',
2599 function($scope , $uibModalInstance) {
2601 itemSvc.get_copy_alert_types().then(function(ccat) {
2603 $scope.alert_types = ccat;
2604 angular.forEach(ccat, function(t) {
2605 ccat_map[t.id()] = t;
2607 $scope.copy_alert_list = [];
2608 angular.forEach(working.copy_alerts, function (alrt) {
2609 var aca = egCore.idl.fromHash('aca', alrt);
2610 aca.alert_type(ccat_map[alrt.alert_type]);
2612 $scope.copy_alert_list.push(aca);
2616 $scope.focusNote = true;
2617 $scope.copy_alert = {
2622 $scope.ok = function(copy_alert) {
2624 if (!working.copy_alerts) {
2625 working.copy_alerts = [];
2628 working.copy_alerts.length = 0;
2630 angular.forEach($scope.copy_alert_list, function(alrt) {
2631 if (alrt.ack_time() == null) {
2632 working.copy_alerts.push({
2635 alert_type : alrt.alert_type().id()
2640 if (typeof(copy_alert.note) != 'undefined' &&
2641 copy_alert.note != '') {
2642 working.copy_alerts.push({
2643 note : copy_alert.note,
2644 temp : copy_alert.temp ? 't' : 'f',
2645 alert_type : copy_alert.alert_type
2649 $uibModalInstance.close();
2652 $scope.cancel = function($event) {
2653 $uibModalInstance.dismiss();
2654 $event.preventDefault();
2660 $scope.status_list = [];
2661 itemSvc.get_magic_statuses().then(function(list){
2662 $scope.magic_status_list = list;
2664 itemSvc.get_statuses().then(function(list){
2665 $scope.status_list = list;
2667 createSimpleUpdateWatcher('status');
2669 $scope.circ_modifier_list = [];
2670 itemSvc.get_circ_mods().then(function(list){
2671 $scope.circ_modifier_list = list;
2673 createSimpleUpdateWatcher('circ_modifier');
2675 $scope.circ_type_list = [];
2676 itemSvc.get_circ_types().then(function(list){
2677 $scope.circ_type_list = list;
2679 createSimpleUpdateWatcher('circ_as_type');
2681 $scope.age_protect_list = [];
2682 itemSvc.get_age_protects().then(function(list){
2683 $scope.age_protect_list = list;
2685 createSimpleUpdateWatcher('age_protect');
2687 $scope.floating_list = [];
2688 itemSvc.get_floating_groups().then(function(list){
2689 $scope.floating_list = list;
2691 createSimpleUpdateWatcher('floating');
2693 createSimpleUpdateWatcher('circulate');
2694 createSimpleUpdateWatcher('holdable');
2695 createSimpleUpdateWatcher('fine_level');
2696 createSimpleUpdateWatcher('loan_duration');
2697 createSimpleUpdateWatcher('cost');
2698 createSimpleUpdateWatcher('deposit');
2699 createSimpleUpdateWatcher('deposit_amount');
2700 createSimpleUpdateWatcher('mint_condition');
2701 createSimpleUpdateWatcher('opac_visible');
2702 createSimpleUpdateWatcher('ref');
2704 $scope.suffix_list = [];
2705 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
2706 $scope.suffix_list = list;
2709 $scope.prefix_list = [];
2710 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
2711 $scope.prefix_list = list;
2714 $scope.classification_list = [];
2715 itemSvc.get_classifications().then(function(list){
2716 $scope.classification_list = list;
2719 createSimpleUpdateWatcher('working.callnumber.classification');
2720 createSimpleUpdateWatcher('working.callnumber.prefix');
2721 createSimpleUpdateWatcher('working.callnumber.suffix');