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-3"><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 '<button style="margin:-5px -15px; float:left;" ng-hide="callNumber.not_ephemeral" type="button" class="close" ng-click="removeCN()">×</button>' +
574 '<select ng-disabled="record == 0" class="form-control" ng-model="classification" ng-change="updateClassification()" ng-options="cl.name() for cl in classification_list"/>'+
576 '<div class="col-xs-1">'+
577 '<select ng-disabled="record == 0" class="form-control" ng-model="prefix" ng-change="updatePrefix()" ng-options="p.label() for p in prefix_list"/>'+
579 '<div class="col-xs-2">'+
580 '<input ng-disabled="record == 0" class="form-control" type="text" ng-change="updateLabel()" ng-model="label"/>'+
581 '<div class="label label-danger" ng-if="empty_label">{{empty_label_string}}</div>'+
583 '<div class="col-xs-1">'+
584 '<select ng-disabled="record == 0" class="form-control" ng-model="suffix" ng-change="updateSuffix()" ng-options="s.label() for s in suffix_list"/>'+
586 '<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>'+
587 '<div ng-hide="onlyVols" class="col-xs-5">'+
588 '<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>'+
592 scope: {focusNext: "=", allcopies: "=", copies: "=", onlyVols: "=", record: "@", struct:"=" },
593 controller : ['$scope','itemSvc','egCore',
594 function ( $scope , itemSvc , egCore ) {
595 $scope.callNumber = $scope.copies[0].call_number();
596 if (!$scope.callNumber.label()) $scope.callNumber.empty_label = true;
598 $scope.empty_label = false;
599 $scope.empty_label_string = window.empty_label_string;
601 $scope.idTracker = function (x) { if (x && x.id) return x.id() };
603 // XXX $() is not working! arg
604 $scope.focusNextBarcode = function (i, prev_bc) {
607 angular.forEach($scope.copies, function (cp) {
615 if (yep) n = cp.id();
619 var next = '#' + $scope.callNumber.id() + '_' + n;
622 if (!itemSvc.currently_generating) el.focus();
623 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
624 itemSvc.nextBarcode(prev_bc).then(function(bc){
627 el.trigger('change');
630 itemSvc.currently_generating = false;
634 $scope.focusNext($scope.callNumber.id(),prev_bc)
638 $scope.suffix_list = [];
639 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
640 $scope.suffix_list = list;
641 $scope.$watch('callNumber.suffix()', function (v) {
642 if (angular.isObject(v)) v = v.id();
643 $scope.suffix = $scope.suffix_list.filter( function (s) {
649 $scope.updateSuffix = function () {
650 angular.forEach($scope.copies, function(cp) {
651 cp.call_number().suffix($scope.suffix);
652 cp.call_number().ischanged(1);
656 $scope.prefix_list = [];
657 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
658 $scope.prefix_list = list;
659 $scope.$watch('callNumber.prefix()', function (v) {
660 if (angular.isObject(v)) v = v.id();
661 $scope.prefix = $scope.prefix_list.filter(function (p) {
667 $scope.updatePrefix = function () {
668 angular.forEach($scope.copies, function(cp) {
669 cp.call_number().prefix($scope.prefix);
670 cp.call_number().ischanged(1);
673 $scope.$watch('callNumber.owning_lib()', function(oldLib, newLib) {
674 if (oldLib == newLib) return;
675 var currentPrefix = $scope.callNumber.prefix();
676 if (angular.isObject(currentPrefix)) currentPrefix = currentPrefix.id();
677 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
678 $scope.prefix_list = list;
679 var newPrefixId = $scope.prefix_list.filter(function (p) {
680 return p.id() == currentPrefix;
682 if (newPrefixId.id) newPrefixId = newPrefixId.id();
683 $scope.prefix = $scope.prefix_list.filter(function (p) {
684 return p.id() == newPrefixId;
686 if ($scope.newPrefixId != currentPrefix) {
687 $scope.callNumber.prefix($scope.prefix);
690 var currentSuffix = $scope.callNumber.suffix();
691 if (angular.isObject(currentSuffix)) currentSuffix = currentSuffix.id();
692 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
693 $scope.suffix_list = list;
694 var newSuffixId = $scope.suffix_list.filter(function (s) {
695 return s.id() == currentSuffix;
697 if (newSuffixId.id) newSuffixId = newSuffixId.id();
698 $scope.suffix = $scope.suffix_list.filter(function (s) {
699 return s.id() == newSuffixId;
701 if ($scope.newSuffixId != currentSuffix) {
702 $scope.callNumber.suffix($scope.suffix);
707 $scope.classification_list = [];
708 itemSvc.get_classifications().then(function(list){
709 $scope.classification_list = list;
710 $scope.$watch('callNumber.label_class()', function (v) {
711 if (angular.isObject(v)) v = v.id();
712 $scope.classification = $scope.classification_list.filter(function (c) {
718 $scope.updateClassification = function () {
719 angular.forEach($scope.copies, function(cp) {
720 cp.call_number().label_class($scope.classification);
721 cp.call_number().ischanged(1);
725 $scope.updateLabel = function () {
726 angular.forEach($scope.copies, function(cp) {
727 cp.call_number().label($scope.label);
728 cp.call_number().ischanged(1);
732 $scope.$watch('callNumber.label()', function (v) {
734 if ($scope.label == '') {
735 $scope.callNumber.empty_label = $scope.empty_label = true;
737 $scope.callNumber.empty_label = $scope.empty_label = false;
741 $scope.prefix = $scope.callNumber.prefix();
742 $scope.suffix = $scope.callNumber.suffix();
743 $scope.classification = $scope.callNumber.label_class();
744 $scope.label = $scope.callNumber.label();
746 $scope.copy_count = $scope.copies.length;
747 $scope.orig_copy_count = $scope.copy_count;
749 $scope.removeCN = function(){
750 var cn = $scope.callNumber;
751 if (cn.not_ephemeral) return; // can't delete existing volumes
753 angular.forEach(Object.keys($scope.struct), function(k){
754 angular.forEach($scope.struct[k], function(cp){
755 var struct_cn = cp.call_number();
756 if (struct_cn.id() == cn.id()){
757 console.log("X'ed CN id" + cn.id() + " and struct CN id match!");
758 // remove any copies in $scope.struct[k]
759 angular.forEach($scope.copies, function(c){
760 var idx = $scope.allcopies.indexOf(c);
761 $scope.allcopies.splice(idx, 1);
766 delete $scope.struct[k];
771 // manually decrease cn_count numeric input
772 var cn_spinner = $("input[name='cn_count_lib"+ cn.owning_lib() +"']");
773 cn_spinner.val(parseInt(cn_spinner.val()) - 1);
777 $scope.changeCPCount = function () {
778 while ($scope.copy_count > $scope.copies.length) {
779 var cp = itemSvc.generateNewCopy(
781 $scope.callNumber.owning_lib(),
785 $scope.copies.push( cp );
786 $scope.allcopies.push( cp );
790 if ($scope.copy_count >= $scope.orig_copy_count) {
791 var how_many = $scope.copies.length - $scope.copy_count;
793 var dead = $scope.copies.splice($scope.copy_count,how_many);
794 $scope.callNumber.copies($scope.copies);
796 // Trimming the global list is a bit more tricky
797 angular.forEach( dead, function (d) {
798 angular.forEach( $scope.allcopies, function (l, i) {
799 if (l === d) $scope.allcopies.splice(i,1);
812 .directive("egVolEdit", function () {
818 '<div class="col-xs-1"><eg-org-selector alldisabled="{{record == 0}}" selected="owning_lib" disable-test="cant_have_vols"></eg-org-selector></div>'+
819 '<div class="col-xs-1"><input name="cn_count_lib{{lib}}" ng-disabled="record == 0" class="form-control" type="number" min="{{orig_cn_count}}" ng-model="cn_count" ng-change="changeCNCount()"/></div>'+
820 '<div class="col-xs-10">'+
821 '<eg-vol-row only-vols="onlyVols" record="{{record}}"'+
822 'ng-repeat="(cn,copies) in struct" '+
823 'focus-next="focusNextFirst" copies="copies" allcopies="allcopies" struct="struct">'+
828 scope: { focusNext: "=", allcopies: "=", struct: "=", lib: "@", record: "@", onlyVols: "=" },
829 controller : ['$scope','itemSvc','egCore',
830 function ( $scope , itemSvc , egCore ) {
831 $scope.first_cn = Object.keys($scope.struct)[0];
832 $scope.full_cn = $scope.struct[$scope.first_cn][0].call_number();
834 $scope.defaults = {};
835 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
841 $scope.focusNextFirst = function(prev_cn,prev_bc) {
844 angular.forEach(Object.keys($scope.struct).sort(), function (cn) {
856 var next = '#' + n + '_' + $scope.struct[n][0].id();
859 if (!itemSvc.currently_generating) el.focus();
860 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
861 itemSvc.nextBarcode(prev_bc).then(function(bc){
864 el.trigger('change');
867 itemSvc.currently_generating = false;
871 $scope.focusNext($scope.lib, prev_bc);
875 $scope.cn_count = Object.keys($scope.struct).length;
876 $scope.orig_cn_count = $scope.cn_count;
878 $scope.owning_lib = egCore.org.get($scope.lib);
879 $scope.$watch('owning_lib', function (oldLib, newLib) {
880 if (oldLib == newLib) return;
881 angular.forEach( Object.keys($scope.struct), function (cn) {
882 $scope.struct[cn][0].call_number().owning_lib( $scope.owning_lib.id() );
883 $scope.struct[cn][0].call_number().ischanged(1);
887 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
889 $scope.$watch('cn_count', function (n) {
890 var o = Object.keys($scope.struct).length;
891 if (n > o) { // adding
892 for (var i = o; o < n; o++) {
893 var cn = new egCore.idl.acn();
894 cn.id( --itemSvc.new_cn_id );
896 cn.prefix( $scope.defaults.prefix || -1 );
897 cn.suffix( $scope.defaults.suffix || -1 );
898 cn.label_class( $scope.defaults.classification || 1 );
899 cn.owning_lib( $scope.owning_lib.id() );
900 cn.record( $scope.full_cn.record() );
902 var cp = itemSvc.generateNewCopy(
904 $scope.owning_lib.id(),
909 $scope.struct[cn.id()] = [cp];
910 $scope.allcopies.push(cp);
911 if (!$scope.defaults.classification) {
913 ['cat.default_classification_scheme'],
915 ).then(function (val) {
916 cn.label_class(val['cat.default_classification_scheme']);
920 } else if (n < o && n >= $scope.orig_cn_count) { // removing
921 var how_many = o - n;
924 .sort(function(a, b){return parseInt(a)-parseInt(b)})
925 .filter(function(x){ return parseInt(x) <= 0 });
926 for (var i = 0; i < how_many; i++) {
927 // Trimming the global list is a bit more tricky
928 angular.forEach($scope.struct[list[i]], function (d) {
929 angular.forEach( $scope.allcopies, function (l, j) {
930 if (l === d) $scope.allcopies.splice(j,1);
933 delete $scope.struct[list[i]];
946 .controller('EditCtrl',
947 ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$uibModal',
948 function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $uibModal) {
950 $scope.forms = {}; // Accessed by t_attr_edit.tt2
951 $scope.i18n = egCore.i18n;
953 $scope.defaults = { // If defaults are not set at all, allow everything
954 barcode_checkdigit : false,
955 auto_gen_barcode : false,
961 loan_duration : true,
966 deposit_amount : true,
970 mint_condition : true,
973 circ_modifier : true,
983 $scope.new_lib_to_add = egCore.org.get(egCore.auth.user().ws_ou());
984 $scope.changeNewLib = function (org) {
985 $scope.new_lib_to_add = org;
987 $scope.addLibToStruct = function () {
988 var newLib = $scope.new_lib_to_add;
989 var cn = new egCore.idl.acn();
990 cn.id( --itemSvc.new_cn_id );
992 cn.prefix( $scope.defaults.prefix || -1 );
993 cn.suffix( $scope.defaults.suffix || -1 );
994 cn.label_class( $scope.defaults.classification || 1 );
995 cn.owning_lib( newLib.id() );
996 cn.record( $scope.record_id );
998 var cp = itemSvc.generateNewCopy(
1005 $scope.data.addCopy(cp);
1007 // manually increase cn_count numeric input
1008 var cn_spinner = $("input[name='cn_count_lib"+ newLib.id() +"']");
1009 cn_spinner.val(parseInt(cn_spinner.val()) + 1);
1011 if (!$scope.defaults.classification) {
1012 egCore.org.settings(
1013 ['cat.default_classification_scheme'],
1015 ).then(function (val) {
1016 cn.label_class(val['cat.default_classification_scheme']);
1021 $scope.embedded = ($routeParams.mode && $routeParams.mode == 'embedded') ? true : false;
1022 $scope.edit_templates = ($location.path().match(/edit_template/)) ? true : false;
1024 $scope.saveDefaults = function () {
1025 egCore.hatch.setItem('cat.copy.defaults', $scope.defaults);
1028 $scope.fetchDefaults = function () {
1029 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
1031 $scope.defaults = t;
1032 if (!$scope.batch) $scope.batch = {};
1033 $scope.batch.classification = $scope.defaults.classification;
1034 $scope.batch.prefix = $scope.defaults.prefix;
1035 $scope.batch.suffix = $scope.defaults.suffix;
1036 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
1038 typeof $scope.defaults.statcat_filter == 'object' &&
1039 Object.keys($scope.defaults.statcat_filter).length > 0
1041 // want fieldmapper object here...
1042 $scope.defaults.statcat_filter =
1043 egCore.idl.Clone($scope.defaults.statcat_filter);
1045 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
1047 if ($scope.defaults.always_volumes) $scope.show_vols = true;
1048 if ($scope.defaults.barcode_checkdigit) itemSvc.barcode_checkdigit = true;
1049 if ($scope.defaults.auto_gen_barcode) itemSvc.auto_gen_barcode = true;
1053 $scope.fetchDefaults();
1055 $scope.$watch('defaults.statcat_filter', function() {
1056 $scope.saveDefaults();
1058 $scope.$watch('defaults.auto_gen_barcode', function (n,o) {
1059 itemSvc.auto_gen_barcode = n
1062 $scope.$watch('defaults.barcode_checkdigit', function (n,o) {
1063 itemSvc.barcode_checkdigit = n
1066 $scope.dirty = false;
1067 $scope.$watch('dirty',
1068 function(newVal, oldVal) {
1069 if (newVal && newVal != oldVal) {
1070 $($window).on('beforeunload.edit', function(){
1071 return 'There is unsaved data!'
1074 $($window).off('beforeunload.edit');
1079 $scope.only_vols = false;
1080 $scope.show_vols = true;
1081 $scope.show_copies = true;
1083 $scope.tracker = function (x,f) { if (x) return x[f]() };
1084 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
1085 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1087 $scope.orgById = function (id) { return egCore.org.get(id) }
1088 $scope.statusById = function (id) {
1089 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
1091 $scope.locationById = function (id) {
1092 return $scope.location_cache[''+id];
1095 $scope.workingToComplete = function () {
1096 angular.forEach( $scope.workingGridControls.selectedItems(), function (c) {
1097 angular.forEach( itemSvc.copies, function (w, i) {
1099 $scope.completed_copies = $scope.completed_copies.concat(itemSvc.copies.splice(i,1));
1106 $scope.completeToWorking = function () {
1107 angular.forEach( $scope.completedGridControls.selectedItems(), function (c) {
1108 angular.forEach( $scope.completed_copies, function (w, i) {
1110 itemSvc.copies = itemSvc.copies.concat($scope.completed_copies.splice(i,1));
1117 createSimpleUpdateWatcher = function (field,exclude_copies_with_one_of_these_values) {
1118 return $scope.$watch('working.' + field, function () {
1119 var newval = $scope.working[field];
1121 if (typeof newval != 'undefined') {
1122 if (angular.isObject(newval)) { // we'll use the pkey
1123 if (newval.id) newval = newval.id();
1124 else if (newval.code) newval = newval.code();
1127 if (""+newval == "" || newval == null) {
1128 $scope.working[field] = undefined;
1132 if ($scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1134 $scope.workingGridControls.selectedItems(),
1136 if (exclude_copies_with_one_of_these_values
1137 && exclude_copies_with_one_of_these_values.indexOf(cp[field](),0) > -1) {
1140 if (cp[field]() !== newval) {
1143 $scope.dirty = true;
1155 statcat_filter: undefined
1158 $scope.copyAlertUpdate = function (alerts) {
1159 if (!$scope.in_item_select &&
1160 $scope.workingGridControls &&
1161 $scope.workingGridControls.selectedItems) {
1162 itemSvc.get_copy_alert_types().then(function(ccat) {
1164 $scope.alert_types = ccat;
1165 angular.forEach(ccat, function(t) {
1166 ccat_map[t.id()] = t;
1169 $scope.workingGridControls.selectedItems(),
1171 $scope.dirty = true;
1172 angular.forEach(alerts, function(alrt) {
1173 var a = egCore.idl.fromHash('aca', alrt);
1175 a.create_staff(egCore.auth.user().id());
1176 a.alert_type(ccat_map[a.alert_type()]);
1179 cp.copy_alerts().push( a );
1188 $scope.copyNoteUpdate = function (notes) {
1189 if (!$scope.in_item_select &&
1190 $scope.workingGridControls &&
1191 $scope.workingGridControls.selectedItems) {
1193 $scope.workingGridControls.selectedItems(),
1195 $scope.dirty = true;
1196 angular.forEach(notes, function(note) {
1197 var n = egCore.idl.fromHash('acpn', note);
1199 n.creator(egCore.auth.user().id());
1200 n.owning_copy(cp.id());
1201 cp.notes().push( n );
1210 $scope.statcatUpdate = function (id) {
1211 var newval = $scope.working.statcats[id];
1213 if (typeof newval != 'undefined') {
1214 if (angular.isObject(newval)) { // we'll use the pkey
1215 newval = newval.id();
1218 if (""+newval == "" || newval == null) {
1219 $scope.working.statcats[id] = undefined;
1223 if (!$scope.in_item_select && $scope.workingGridControls && $scope.workingGridControls.selectedItems) {
1225 $scope.workingGridControls.selectedItems(),
1227 $scope.dirty = true;
1229 cp.stat_cat_entries(
1230 angular.forEach( cp.stat_cat_entries(), function (e) {
1231 if (e.stat_cat() == id) { // mark deleted
1238 var e = new egCore.idl.asce();
1243 cp.stat_cat_entries(
1244 cp.stat_cat_entries() ?
1245 cp.stat_cat_entries().concat([ e ]) :
1251 // trim out all deleted ones; the API used to
1252 // do the update doesn't actually consult
1253 // isdeleted for stat cat entries
1254 cp.stat_cat_entries(
1255 cp.stat_cat_entries().filter(function (e) {
1256 return !Boolean(e.isdeleted());
1267 var dataKey = $routeParams.dataKey;
1268 console.debug('dataKey: ' + dataKey);
1270 if ((dataKey && dataKey.length > 0) || $scope.edit_templates) {
1272 $scope.templates = {};
1273 $scope.template_name = '';
1274 $scope.template_name_list = [];
1276 $scope.fetchTemplates = function () {
1277 itemSvc.get_acp_templates().then(function(t) {
1279 $scope.templates = t;
1280 $scope.template_name_list = Object.keys(t).sort();
1283 egCore.hatch.getItem('cat.copy.last_template').then(function(t) {
1284 if (t) $scope.template_name = t;
1287 $scope.fetchTemplates();
1289 $scope.applyTemplate = function (n) {
1290 angular.forEach($scope.templates[n], function (v,k) {
1291 if (k == 'circ_lib') {
1292 $scope.working[k] = egCore.org.get(v);
1293 } else if (k == 'copy_notes' && v.length) {
1294 $scope.copyNoteUpdate(v);
1295 } else if (k == 'copy_alerts' && v.length) {
1296 $scope.copyAlertUpdate(v);
1297 } else if (!angular.isObject(v)) {
1298 $scope.working[k] = angular.copy(v);
1300 angular.forEach(v, function (sv,sk) {
1301 if (k == 'callnumber') {
1302 angular.forEach(v, function (cnv,cnk) {
1303 $scope.batch[cnk] = cnv;
1305 $scope.applyBatchCNValues();
1307 $scope.working[k][sk] = angular.copy(sv);
1308 if (k == 'statcats') $scope.statcatUpdate(sk);
1313 egCore.hatch.setItem('cat.copy.last_template', n);
1316 $scope.copytab = 'working';
1317 $scope.tab = 'edit';
1318 $scope.summaryRecord = null;
1319 $scope.record_id = null;
1321 $scope.completed_copies = [];
1322 $scope.location_orgs = [];
1323 $scope.location_cache = {};
1324 $scope.statcats = [];
1325 if (!$scope.batch) $scope.batch = {};
1327 $scope.applyBatchCNValues = function () {
1328 if ($scope.data.tree) {
1329 angular.forEach($scope.data.tree, function(cn_hash) {
1330 angular.forEach(cn_hash, function(copies) {
1331 angular.forEach(copies, function(cp) {
1332 if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '') {
1333 var label_class = $scope.classification_list.filter(function(p){ return p.id() == $scope.batch.classification })[0];
1334 cp.call_number().label_class(label_class);
1335 cp.call_number().ischanged(1);
1336 $scope.dirty = true;
1338 if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '') {
1339 var prefix = $scope.prefix_list.filter(function(p){ return p.id() == $scope.batch.prefix })[0];
1340 cp.call_number().prefix(prefix);
1341 cp.call_number().ischanged(1);
1342 $scope.dirty = true;
1344 if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '') {
1345 cp.call_number().label($scope.batch.label);
1346 cp.call_number().ischanged(1);
1347 $scope.dirty = true;
1349 if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '') {
1350 var suffix = $scope.suffix_list.filter(function(p){ return p.id() == $scope.batch.suffix })[0];
1351 cp.call_number().suffix(suffix);
1352 cp.call_number().ischanged(1);
1353 $scope.dirty = true;
1361 $scope.clearWorking = function () {
1362 angular.forEach($scope.working, function (v,k,o) {
1363 if (!angular.isObject(v)) {
1364 if (typeof v != 'undefined')
1365 $scope.working[k] = undefined;
1366 } else if (k != 'circ_lib') {
1367 angular.forEach(v, function (sv,sk) {
1368 if (typeof v != 'undefined')
1369 $scope.working[k][sk] = undefined;
1373 $scope.working.circ_lib = undefined; // special
1376 $scope.completedGridDataProvider = egGridDataProvider.instance({
1377 get : function(offset, count) {
1378 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1379 return this.arrayNotifier($scope.completed_copies, offset, count);
1383 $scope.completedGridControls = {};
1385 $scope.workingGridDataProvider = egGridDataProvider.instance({
1386 get : function(offset, count) {
1387 //return provider.arrayNotifier(itemSvc.copies, offset, count);
1388 return this.arrayNotifier(itemSvc.copies, offset, count);
1392 $scope.workingGridControls = {};
1393 $scope.add_vols_copies = false;
1394 $scope.is_fast_add = false;
1398 'open-ils.actor.anon_cache.get_value',
1399 dataKey, 'edit-these-copies'
1400 ).then(function (data) {
1403 if (data.hide_vols && !$scope.defaults.always_volumes) $scope.show_vols = false;
1404 if (data.hide_copies) {
1405 $scope.show_copies = false;
1406 $scope.only_vols = true;
1409 $scope.record_id = data.record_id;
1411 function fetchRaw () {
1412 if (!$scope.only_vols) $scope.dirty = true;
1413 $scope.add_vols_copies = true;
1415 /* data.raw data structure looks like this:
1417 * callnumber : $cn_id, // optional, to add a copy to a cn
1418 * owner : $org, // optional, defaults to cn.owning_lib or ws_ou
1419 * label : $cn_label, // optional, to supply a label on a new cn
1420 * barcode : $cp_barcode // optional, to supply a barcode on a new cp
1421 * fast_add : boolean // optional, to specify whether this came
1425 * All can be left out and a completely empty vol/copy combo will be vivicated.
1431 if (proto.fast_add) $scope.is_fast_add = true;
1432 if (proto.callnumber) {
1433 return egCore.pcrud.retrieve('acn', proto.callnumber)
1434 .then(function(cn) {
1435 var cp = new itemSvc.generateNewCopy(
1437 proto.owner || cn.owning_lib(),
1439 ((!$scope.only_vols) ? true : false)
1442 if (proto.barcode) {
1443 cp.barcode( proto.barcode );
1444 cp.empty_barcode = false;
1450 var cn = new egCore.idl.acn();
1451 cn.id( --itemSvc.new_cn_id );
1453 cn.prefix( $scope.defaults.prefix || -1 );
1454 cn.suffix( $scope.defaults.suffix || -1 );
1455 cn.owning_lib( proto.owner || egCore.auth.user().ws_ou() );
1456 cn.record( $scope.record_id );
1457 egCore.org.settings(
1458 ['cat.default_classification_scheme'],
1460 ).then(function (val) {
1462 $scope.defaults.classification ||
1463 val['cat.default_classification_scheme'] ||
1467 cn.label( proto.label );
1471 'open-ils.cat.biblio.record.marc_cn.retrieve',
1474 ).then(function(cn_array) {
1475 if (cn_array.length > 0) {
1476 for (var field in cn_array[0]) {
1477 cn.label( cn_array[0][field] );
1485 // If we are adding an empty vol,
1486 // this is ultimately just a placeholder copy
1487 // which gets removed before saving.
1488 // TODO: consider ways to remove this
1490 var cp = new itemSvc.generateNewCopy(
1492 proto.owner || cn.owning_lib(),
1497 if (proto.barcode) {
1498 cp.barcode( proto.barcode );
1499 cp.empty_barcode = false;
1507 angular.forEach(itemSvc.copies, function(c){
1508 c.call_number().not_ephemeral = true;
1511 return itemSvc.copies;
1514 if (data.copies && data.copies.length)
1515 return itemSvc.fetchIds(data.copies).then(fetchRaw);
1521 }).then( function() {
1522 $scope.data = itemSvc;
1523 $scope.workingGridDataProvider.refresh();
1526 $scope.can_save = false;
1527 function check_saveable () {
1528 var can_save = true;
1533 if (!$scope.only_vols) {
1534 if (i.duplicate_barcode || i.empty_barcode || i.call_number().empty_label) {
1537 } else if (i.call_number().empty_label) {
1543 if (!$scope.only_vols && $scope.forms.myForm && $scope.forms.myForm.$invalid) {
1547 $scope.can_save = can_save;
1550 $scope.disableSave = function () {
1552 return !$scope.can_save;
1555 $scope.focusNextFirst = function(prev_lib,prev_bc) {
1558 angular.forEach(Object.keys($scope.data.tree).sort(), function (lib) {
1561 if (lib == prev_lib) {
1570 var first_cn = Object.keys($scope.data.tree[n])[0];
1571 var next = '#' + first_cn + '_' + $scope.data.tree[n][first_cn][0].id();
1574 if (!itemSvc.currently_generating) el.focus();
1575 if (prev_bc && itemSvc.auto_gen_barcode && el.val() == "") {
1576 itemSvc.nextBarcode(prev_bc).then(function(bc){
1579 el.trigger('change');
1582 itemSvc.currently_generating = false;
1588 $scope.in_item_select = false;
1589 $scope.afterItemSelect = function() { $scope.in_item_select = false };
1590 $scope.handleItemSelect = function (item_list) {
1591 if (item_list && item_list.length > 0) {
1592 $scope.in_item_select = true;
1594 angular.forEach(Object.keys($scope.defaults.attributes), function (attr) {
1596 var value_hash = {};
1597 angular.forEach(item_list, function (item) {
1599 var v = item[attr]()
1600 if (angular.isObject(v)) {
1601 if (v.id) v = v.id();
1602 else if (v.code) v = v.code();
1608 if (Object.keys(value_hash).length == 1) {
1609 if (attr == 'circ_lib') {
1610 $scope.working[attr] = egCore.org.get(item_list[0][attr]());
1612 $scope.working[attr] = item_list[0][attr]();
1615 $scope.working[attr] = undefined;
1619 angular.forEach($scope.statcats, function (sc) {
1622 var value_hash = {};
1624 angular.forEach(item_list, function (item) {
1625 if (item.stat_cat_entries()) {
1626 if (item.stat_cat_entries().length > 0) {
1627 var right_sc = item.stat_cat_entries().filter(function (e) {
1628 return e.stat_cat() == sc.id() && !Boolean(e.isdeleted());
1631 if (right_sc.length > 0) {
1632 value_hash[right_sc[0].id()] = right_sc[0].id();
1644 if (!none && Object.keys(value_hash).length == 1) {
1645 $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]];
1646 $scope.working.statcats_multi[sc.id()] = false;
1647 } else if (item_list.length > 1 && Object.keys(value_hash).length > 0) {
1648 $scope.working.statcats[sc.id()] = undefined;
1649 $scope.working.statcats_multi[sc.id()] = true;
1651 $scope.working.statcats[sc.id()] = undefined;
1652 $scope.working.statcats_multi[sc.id()] = false;
1658 $scope.clearWorking();
1663 $scope.$watch('data.copies.length', function () {
1664 if ($scope.data.copies) {
1665 var base_orgs = $scope.data.copies.map(function(cp){
1666 if (isNaN(cp.circ_lib())) return Number(cp.circ_lib().id());
1667 return Number(cp.circ_lib());
1669 $scope.data.copies.map(function(cp){
1670 if (isNaN(cp.call_number().owning_lib())) return Number(cp.call_number().owning_lib().id());
1671 return Number(cp.call_number().owning_lib());
1674 [egCore.auth.user().ws_ou()]
1675 ).filter(function(e,i,a){
1676 return a.lastIndexOf(e) === i;
1680 angular.forEach(base_orgs, function(o) {
1681 all_orgs = all_orgs.concat( egCore.org.fullPath(o, true) );
1684 var final_orgs = all_orgs.filter(function(e,i,a){
1685 return a.lastIndexOf(e) === i;
1686 }).sort(function(a, b){return a-b});
1688 if ($scope.location_orgs.toString() != final_orgs.toString()) {
1689 $scope.location_orgs = final_orgs;
1690 if ($scope.location_orgs.length) {
1691 itemSvc.get_locations($scope.location_orgs).then(function(list){
1692 angular.forEach(list, function(l) {
1693 $scope.location_cache[ ''+l.id() ] = l;
1695 $scope.location_list = list;
1698 $scope.statcat_filter_list = [];
1699 angular.forEach($scope.location_orgs, function (o) {
1700 $scope.statcat_filter_list.push(egCore.org.get(o));
1703 itemSvc.get_statcats($scope.location_orgs).then(function(list){
1704 $scope.statcats = list;
1705 angular.forEach($scope.statcats, function (s) {
1707 if (!$scope.working)
1708 $scope.working = { statcats_multi: {}, statcats: {}, statcat_filter: undefined};
1709 if (!$scope.working.statcats_multi)
1710 $scope.working.statcats_multi = {};
1711 if (!$scope.working.statcats)
1712 $scope.working.statcats = {};
1714 if (!$scope.in_item_select) {
1715 $scope.working.statcats[s.id()] = undefined;
1717 createStatcatUpdateWatcher(s.id());
1719 $scope.in_item_select = false;
1720 // do a refresh here to work around a race
1721 // condition that can result in stat cats
1722 // not being selected.
1723 $scope.workingGridDataProvider.refresh();
1729 $scope.workingGridDataProvider.refresh();
1732 $scope.statcat_visible = function (sc_owner) {
1733 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
1734 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
1735 if ($scope.working.statcat_filter == ancestor_org.id())
1741 $scope.suffix_list = [];
1742 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1743 $scope.suffix_list = list;
1746 $scope.prefix_list = [];
1747 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1748 $scope.prefix_list = list;
1751 $scope.classification_list = [];
1752 itemSvc.get_classifications().then(function(list){
1753 $scope.classification_list = list;
1756 $scope.$watch('completed_copies.length', function () {
1757 $scope.completedGridDataProvider.refresh();
1760 $scope.location_list = [];
1761 itemSvc.get_locations().then(function(list){
1762 $scope.location_list = list;
1764 createSimpleUpdateWatcher('location');
1766 $scope.status_list = [];
1767 itemSvc.get_magic_statuses().then(function(list){
1768 $scope.magic_status_list = list;
1769 createSimpleUpdateWatcher('status',$scope.magic_status_list);
1771 itemSvc.get_statuses().then(function(list){
1772 $scope.status_list = list;
1775 $scope.circ_modifier_list = [];
1776 itemSvc.get_circ_mods().then(function(list){
1777 $scope.circ_modifier_list = list;
1779 createSimpleUpdateWatcher('circ_modifier');
1781 $scope.circ_type_list = [];
1782 itemSvc.get_circ_types().then(function(list){
1783 $scope.circ_type_list = list;
1785 createSimpleUpdateWatcher('circ_as_type');
1787 $scope.age_protect_list = [];
1788 itemSvc.get_age_protects().then(function(list){
1789 $scope.age_protect_list = list;
1791 createSimpleUpdateWatcher('age_protect');
1793 $scope.floating_list = [];
1794 itemSvc.get_floating_groups().then(function(list){
1795 $scope.floating_list = list;
1797 createSimpleUpdateWatcher('floating');
1799 createSimpleUpdateWatcher('circ_lib');
1800 createSimpleUpdateWatcher('circulate');
1801 createSimpleUpdateWatcher('holdable');
1802 createSimpleUpdateWatcher('fine_level');
1803 createSimpleUpdateWatcher('loan_duration');
1804 createSimpleUpdateWatcher('price');
1805 createSimpleUpdateWatcher('cost');
1806 createSimpleUpdateWatcher('deposit');
1807 createSimpleUpdateWatcher('deposit_amount');
1808 createSimpleUpdateWatcher('mint_condition');
1809 createSimpleUpdateWatcher('opac_visible');
1810 createSimpleUpdateWatcher('ref');
1812 $scope.saveCompletedCopies = function (and_exit) {
1814 var perCnCopies = {};
1815 angular.forEach( $scope.completed_copies, function (cp) {
1816 var cn = cp.call_number();
1817 var cn_cps = cp.call_number().copies();
1818 cp.call_number().copies([]);
1819 var cn_id = cp.call_number().id();
1820 cp.call_number(cn_id); // prevent loops in JSON-ification
1821 if (!cnHash[cn_id]) {
1822 cnHash[cn_id] = egCore.idl.Clone(cn);
1823 perCnCopies[cn_id] = [egCore.idl.Clone(cp)];
1825 perCnCopies[cn_id].push(egCore.idl.Clone(cp));
1827 cp.call_number(cn); // put the data back
1828 cp.call_number().copies(cn_cps);
1829 if (typeof cnHash[cn_id].prefix() == 'object')
1830 cnHash[cn_id].prefix(cnHash[cn_id].prefix().id()); // un-object-ize some fields
1831 if (typeof cnHash[cn_id].suffix() == 'object')
1832 cnHash[cn_id].suffix(cnHash[cn_id].suffix().id()); // un-object-ize some fields
1835 if ($scope.only_vols) { // strip off copies when we're in vol-only mode
1836 angular.forEach(cnHash, function (v, k) {
1837 cnHash[k].copies([]);
1840 angular.forEach(perCnCopies, function (v, k) {
1841 cnHash[k].copies(v);
1846 angular.forEach(cnHash, function (v, k) {
1852 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1853 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1, return_copy_ids : 1 }
1854 ).then(function(copy_ids) {
1856 $scope.dirty = false;
1857 if ($scope.defaults.print_item_labels) {
1860 'open-ils.actor.anon_cache.set_value',
1861 null, 'print-labels-these-copies', {
1864 ).then(function(key) {
1866 var url = egCore.env.basePath + 'cat/printlabels/' + key;
1867 $timeout(function() { $window.open(url, '_blank') }).then(
1868 function() { $timeout(function(){$window.close()}); }
1871 alert('Could not create anonymous cache key!');
1875 $timeout(function(){$window.close()});
1881 $scope.saveAndContinue = function () {
1882 $scope.saveCompletedCopies(false);
1885 $scope.workingSaveAndExit = function () {
1886 $scope.workingToComplete();
1887 $scope.saveAndExit();
1890 $scope.saveAndExit = function () {
1891 $scope.saveCompletedCopies(true);
1896 $scope.copy_notes_dialog = function(copy_list) {
1897 var default_pub = Boolean($scope.defaults.copy_notes_pub);
1898 if (!angular.isArray(copy_list)) copy_list = [copy_list];
1900 return $uibModal.open({
1901 templateUrl: './cat/volcopy/t_copy_notes',
1905 ['$scope','$uibModalInstance',
1906 function($scope , $uibModalInstance) {
1907 $scope.focusNote = true;
1909 creator : egCore.auth.user().id(),
1915 $scope.require_initials = false;
1916 egCore.org.settings([
1917 'ui.staff.require_initials.copy_notes'
1918 ]).then(function(set) {
1919 $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
1922 $scope.note_list = [];
1923 if (copy_list.length == 1) {
1924 $scope.note_list = copy_list[0].notes();
1927 $scope.ok = function(note) {
1929 if ($scope.initials) {
1930 note.value = egCore.strings.$replace(
1931 egCore.strings.COPY_NOTE_INITIALS, {
1933 initials : $scope.initials,
1934 ws_ou : egCore.org.get(
1935 egCore.auth.user().ws_ou()).shortname()
1939 angular.forEach(copy_list, function (cp) {
1940 if (!angular.isArray(cp.notes())) cp.notes([]);
1941 var n = new egCore.idl.acpn();
1943 n.creator(note.creator);
1945 n.title(note.title);
1946 n.value(note.value);
1947 n.owning_copy(cp.id());
1948 cp.notes().push( n );
1951 $uibModalInstance.close();
1954 $scope.cancel = function($event) {
1955 $uibModalInstance.dismiss();
1956 $event.preventDefault();
1962 $scope.copy_tags_dialog = function(copy_list) {
1963 if (!angular.isArray(copy_list)) copy_list = [copy_list];
1965 return $uibModal.open({
1966 templateUrl: './cat/volcopy/t_copy_tags',
1970 ['$scope','$uibModalInstance',
1971 function($scope , $uibModalInstance) {
1973 $scope.tag_map = [];
1975 var shared_tags = {};
1976 angular.forEach(copy_list, function (cp) {
1977 angular.forEach(cp.tags(), function(tag) {
1978 if (!(tag.tag().id() in shared_tags)) {
1979 shared_tags[tag.tag().id()] = 1;
1981 shared_tags[tag.tag().id()]++;
1983 if (!(tag.tag().id() in tag_hash)) {
1984 tag_hash[tag.tag().id()] = tag;
1988 angular.forEach(tag_hash, function(value, key) {
1989 if (shared_tags[key] == copy_list.length) {
1990 $scope.tag_map.push(value);
1994 $scope.tag_types = [];
1995 egCore.pcrud.retrieveAll('cctt', {order_by : { cctt : 'label' }}, {atomic : true}).then(function(list) {
1996 $scope.tag_types = list;
1997 $scope.tag_type = $scope.tag_types[0].code(); // just pick a default
2000 $scope.getTags = function(val) {
2001 return egCore.pcrud.search('acpt',
2003 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2004 label : { 'startwith' : {
2005 transform: 'evergreen.lowercase',
2006 value : [ 'evergreen.lowercase', val ]
2008 tag_type : $scope.tag_type
2010 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2011 ).then(function(list) {
2012 return list.map(function(item) {
2013 return item.label();
2018 $scope.addTag = function() {
2019 var tagLabel = $scope.selectedLabel;
2020 // clear the typeahead
2021 $scope.selectedLabel = "";
2023 // first, check tags already associated with the copy
2024 var foundMatch = false;
2025 angular.forEach($scope.tag_map, function(tag) {
2026 if (tag.tag().label() == tagLabel && tag.tag().tag_type() == $scope.tag_type) {
2028 if (tag.isdeleted()) tag.isdeleted(0); // just deleting the mapping
2032 egCore.pcrud.search('acpt',
2034 owner : egCore.org.fullPath(egCore.auth.user().ws_ou(), true),
2036 tag_type : $scope.tag_type
2038 { order_by : { 'acpt' : ['label'] } }, { atomic: true }
2039 ).then(function(list) {
2040 if (list.length > 0) {
2041 var newMap = new egCore.idl.acptcm();
2043 newMap.copy(copy_list[0].id());
2044 newMap.tag(egCore.idl.Clone(list[0]));
2045 $scope.tag_map.push(newMap);
2047 var newTag = new egCore.idl.acpt();
2049 newTag.owner(egCore.auth.user().ws_ou());
2050 newTag.label(tagLabel);
2052 newTag.tag_type($scope.tag_type);
2054 var newMap = new egCore.idl.acptcm();
2056 newMap.copy(copy_list[0].id());
2058 $scope.tag_map.push(newMap);
2064 $scope.ok = function(note) {
2065 // in the multi-item case, this works OK for
2066 // adding new maps to existing tags, but doesn't handle
2067 // all possibilities
2068 angular.forEach(copy_list, function (cp) {
2069 cp.tags($scope.tag_map);
2071 $uibModalInstance.close();
2074 $scope.cancel = function($event) {
2075 $uibModalInstance.dismiss();
2076 $event.preventDefault();
2082 $scope.copy_alerts_dialog = function(copy_list) {
2083 if (!angular.isArray(copy_list)) copy_list = [copy_list];
2085 return $uibModal.open({
2086 templateUrl: './cat/volcopy/t_copy_alerts',
2089 ['$scope','$uibModalInstance',
2090 function($scope , $uibModalInstance) {
2092 itemSvc.get_copy_alert_types().then(function(ccat) {
2093 $scope.alert_types = ccat;
2096 $scope.focusNote = true;
2097 $scope.copy_alert = {
2098 create_staff : egCore.auth.user().id(),
2103 egCore.hatch.getItem('cat.copy.alerts.last_type').then(function(t) {
2104 if (t) $scope.copy_alert.alert_type = t;
2107 if (copy_list.length == 1) {
2108 $scope.copy_alert_list = copy_list[0].copy_alerts();
2111 $scope.ok = function(copy_alert) {
2113 if (typeof(copy_alert.note) != 'undefined' &&
2114 copy_alert.note != '') {
2115 angular.forEach(copy_list, function (cp) {
2116 var a = new egCore.idl.aca();
2118 a.create_staff(copy_alert.create_staff);
2119 a.note(copy_alert.note);
2120 a.temp(copy_alert.temp ? 't' : 'f');
2124 $scope.alert_types.filter(function(at) {
2125 return at.id() == copy_alert.alert_type;
2128 cp.copy_alerts().push( a );
2131 if (copy_alert.alert_type) {
2132 egCore.hatch.setItem(
2133 'cat.copy.alerts.last_type',
2134 copy_alert.alert_type
2140 $uibModalInstance.close();
2143 $scope.cancel = function($event) {
2144 $uibModalInstance.dismiss();
2145 $event.preventDefault();
2153 .directive("egVolTemplate", function () {
2157 template: '<div ng-include="'+"'/eg/staff/cat/volcopy/t_attr_edit'"+'"></div>',
2161 controller : ['$scope','$window','itemSvc','egCore','ngToast','$uibModal',
2162 function ( $scope , $window , itemSvc , egCore , ngToast , $uibModal) {
2164 $scope.i18n = egCore.i18n;
2166 $scope.defaults = { // If defaults are not set at all, allow everything
2167 barcode_checkdigit : false,
2168 auto_gen_barcode : false,
2175 loan_duration : true,
2180 deposit_amount : true,
2181 opac_visible : true,
2184 mint_condition : true,
2187 circ_modifier : true,
2188 circ_as_type : true,
2196 $scope.fetchDefaults = function () {
2197 egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
2199 $scope.defaults = t;
2200 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
2202 typeof $scope.defaults.statcat_filter == 'object' &&
2203 Object.keys($scope.defaults.statcat_filter).length > 0
2205 // want fieldmapper object here...
2206 $scope.defaults.statcat_filter =
2207 egCore.idl.Clone($scope.defaults.statcat_filter);
2209 $scope.working.statcat_filter = $scope.defaults.statcat_filter.id();
2214 $scope.fetchDefaults();
2216 $scope.dirty = false;
2217 $scope.$watch('dirty',
2218 function(newVal, oldVal) {
2219 if (newVal && newVal != oldVal) {
2220 $($window).on('beforeunload.template', function(){
2221 return 'There is unsaved template data!'
2224 $($window).off('beforeunload.template');
2229 $scope.template_controls = true;
2231 $scope.fetchTemplates = function () {
2232 itemSvc.get_acp_templates().then(function(t) {
2234 $scope.templates = t;
2235 $scope.template_name_list = Object.keys(t).sort();
2239 $scope.fetchTemplates();
2241 $scope.applyTemplate = function (n) {
2242 angular.forEach($scope.templates[n], function (v,k) {
2243 if (k == 'circ_lib') {
2244 $scope.working[k] = egCore.org.get(v);
2245 } else if (angular.isArray(v) || !angular.isObject(v)) {
2246 $scope.working[k] = angular.copy(v);
2248 angular.forEach(v, function (sv,sk) {
2249 if (!(k in $scope.working))
2250 $scope.working[k] = {};
2251 $scope.working[k][sk] = angular.copy(sv);
2255 $scope.template_name = '';
2258 $scope.deleteTemplate = function (n) {
2260 delete $scope.templates[n]
2261 $scope.template_name_list = Object.keys($scope.templates).sort();
2262 $scope.template_name = '';
2263 itemSvc.save_acp_templates($scope.templates);
2264 $scope.$parent.fetchTemplates();
2265 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_DELETE);
2269 $scope.saveTemplate = function (n) {
2273 angular.forEach($scope.working, function (v,k) {
2274 if (angular.isObject(v)) { // we'll use the pkey
2275 if (v.id) v = v.id();
2276 else if (v.code) v = v.code();
2277 else v = angular.copy(v); // Should only be statcats and callnumbers currently
2283 $scope.templates[n] = tmpl;
2284 $scope.template_name_list = Object.keys($scope.templates).sort();
2286 itemSvc.save_acp_templates($scope.templates);
2287 $scope.$parent.fetchTemplates();
2289 $scope.dirty = false;
2291 // save all templates, as we might do after an import
2292 itemSvc.save_acp_templates($scope.templates);
2293 $scope.$parent.fetchTemplates();
2295 ngToast.create(egCore.strings.VOL_COPY_TEMPLATE_SUCCESS_SAVE);
2298 $scope.templates = {};
2299 $scope.imported_templates = { data : '' };
2300 $scope.template_name = '';
2301 $scope.template_name_list = [];
2303 $scope.$watch('imported_templates.data', function(newVal, oldVal) {
2304 if (newVal && newVal != oldVal) {
2306 var newTemplates = JSON.parse(newVal);
2307 if (!Object.keys(newTemplates).length) return;
2308 angular.forEach(Object.keys(newTemplates), function (k) {
2309 $scope.templates[k] = newTemplates[k];
2311 itemSvc.save_acp_templates($scope.templates);
2312 $scope.fetchTemplates();
2314 console.log('tried to import an invalid copy template file');
2319 $scope.tracker = function (x,f) { if (x) return x[f]() };
2320 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
2321 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
2323 $scope.orgById = function (id) { return egCore.org.get(id) }
2324 $scope.statusById = function (id) {
2325 return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
2327 $scope.locationById = function (id) {
2328 return $scope.location_cache[''+id];
2331 createSimpleUpdateWatcher = function (field) {
2332 $scope.$watch('working.' + field, function () {
2333 var newval = $scope.working[field];
2335 if (typeof newval != 'undefined') {
2336 $scope.dirty = true;
2337 if (angular.isObject(newval)) { // we'll use the pkey
2338 if (newval.id) $scope.working[field] = newval.id();
2339 else if (newval.code) $scope.working[field] = newval.code();
2342 if (""+newval == "" || newval == null) {
2343 $scope.working[field] = undefined;
2354 statcat_filter: undefined
2357 $scope.statcat_visible = function (sc_owner) {
2358 var visible = typeof $scope.working.statcat_filter === 'undefined' || !$scope.working.statcat_filter;
2359 angular.forEach(egCore.org.ancestors(sc_owner), function (ancestor_org) {
2360 if ($scope.working.statcat_filter == ancestor_org.id())
2366 createStatcatUpdateWatcher = function (id) {
2367 return $scope.$watch('working.statcats[' + id + ']', function () {
2368 if ($scope.working.statcats) {
2369 var newval = $scope.working.statcats[id];
2371 if (typeof newval != 'undefined') {
2372 $scope.dirty = true;
2373 if (angular.isObject(newval)) { // we'll use the pkey
2374 newval = newval.id();
2377 if (""+newval == "" || newval == null) {
2378 $scope.working.statcats[id] = undefined;
2387 $scope.clearWorking = function () {
2388 angular.forEach($scope.working, function (v,k,o) {
2389 if (!angular.isObject(v)) {
2390 if (typeof v != 'undefined')
2391 $scope.working[k] = undefined;
2392 } else if (k != 'circ_lib') {
2393 angular.forEach(v, function (sv,sk) {
2394 $scope.working[k][sk] = undefined;
2398 $scope.working.circ_lib = undefined; // special
2399 $scope.dirty = false;
2402 $scope.working = {};
2403 $scope.location_orgs = [];
2404 $scope.location_cache = {};
2406 $scope.location_list = [];
2407 itemSvc.get_locations(
2408 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2409 ).then(function(list){
2410 $scope.location_list = list;
2412 createSimpleUpdateWatcher('location');
2414 $scope.statcat_filter_list = egCore.org.fullPath( egCore.auth.user().ws_ou() );
2416 $scope.statcats = [];
2417 itemSvc.get_statcats(
2418 egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
2419 ).then(function(list){
2420 $scope.statcats = list;
2421 angular.forEach($scope.statcats, function (s) {
2423 if (!$scope.working)
2424 $scope.working = { statcats: {}, statcat_filter: undefined};
2425 if (!$scope.working.statcats)
2426 $scope.working.statcats = {};
2428 $scope.working.statcats[s.id()] = undefined;
2429 createStatcatUpdateWatcher(s.id());
2433 $scope.copy_notes_dialog = function() {
2434 var default_pub = Boolean($scope.defaults.copy_notes_pub);
2435 var working = $scope.working;
2437 return $uibModal.open({
2438 templateUrl: './cat/volcopy/t_copy_notes',
2441 ['$scope','$uibModalInstance',
2442 function($scope , $uibModalInstance) {
2443 $scope.focusNote = true;
2450 $scope.require_initials = false;
2451 egCore.org.settings([
2452 'ui.staff.require_initials.copy_notes'
2453 ]).then(function(set) {
2454 $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
2457 $scope.note_list = [];
2458 angular.forEach(working.copy_notes, function(note) {
2459 var acpn = egCore.idl.fromHash('acpn', note);
2460 $scope.note_list.push(acpn);
2463 $scope.ok = function(note) {
2465 if (!working.copy_notes) {
2466 working.copy_notes = [];
2470 working.copy_notes.length = 0;
2471 angular.forEach($scope.note_list, function(existing_note) {
2472 if (!existing_note.isdeleted()) {
2473 working.copy_notes.push({
2474 pub : existing_note.pub() ? 't' : 'f',
2475 title : existing_note.title(),
2476 value : existing_note.value()
2481 // add new note, if any
2482 if (note.initials) note.value += ' [' + note.initials + ']';
2483 note.pub = note.pub ? 't' : 'f';
2484 if (note.title.length && note.value.length) {
2485 working.copy_notes.push(note);
2488 $uibModalInstance.close();
2491 $scope.cancel = function($event) {
2492 $uibModalInstance.dismiss();
2493 $event.preventDefault();
2499 $scope.copy_alerts_dialog = function() {
2500 var working = $scope.working;
2502 return $uibModal.open({
2503 templateUrl: './cat/volcopy/t_copy_alerts',
2506 ['$scope','$uibModalInstance',
2507 function($scope , $uibModalInstance) {
2509 itemSvc.get_copy_alert_types().then(function(ccat) {
2511 $scope.alert_types = ccat;
2512 angular.forEach(ccat, function(t) {
2513 ccat_map[t.id()] = t;
2515 $scope.copy_alert_list = [];
2516 angular.forEach(working.copy_alerts, function (alrt) {
2517 var aca = egCore.idl.fromHash('aca', alrt);
2518 aca.alert_type(ccat_map[alrt.alert_type]);
2520 $scope.copy_alert_list.push(aca);
2524 $scope.focusNote = true;
2525 $scope.copy_alert = {
2530 $scope.ok = function(copy_alert) {
2532 if (!working.copy_alerts) {
2533 working.copy_alerts = [];
2536 working.copy_alerts.length = 0;
2538 angular.forEach($scope.copy_alert_list, function(alrt) {
2539 if (alrt.ack_time() == null) {
2540 working.copy_alerts.push({
2543 alert_type : alrt.alert_type().id()
2548 if (typeof(copy_alert.note) != 'undefined' &&
2549 copy_alert.note != '') {
2550 working.copy_alerts.push({
2551 note : copy_alert.note,
2552 temp : copy_alert.temp ? 't' : 'f',
2553 alert_type : copy_alert.alert_type
2557 $uibModalInstance.close();
2560 $scope.cancel = function($event) {
2561 $uibModalInstance.dismiss();
2562 $event.preventDefault();
2568 $scope.status_list = [];
2569 itemSvc.get_magic_statuses().then(function(list){
2570 $scope.magic_status_list = list;
2572 itemSvc.get_statuses().then(function(list){
2573 $scope.status_list = list;
2575 createSimpleUpdateWatcher('status');
2577 $scope.circ_modifier_list = [];
2578 itemSvc.get_circ_mods().then(function(list){
2579 $scope.circ_modifier_list = list;
2581 createSimpleUpdateWatcher('circ_modifier');
2583 $scope.circ_type_list = [];
2584 itemSvc.get_circ_types().then(function(list){
2585 $scope.circ_type_list = list;
2587 createSimpleUpdateWatcher('circ_as_type');
2589 $scope.age_protect_list = [];
2590 itemSvc.get_age_protects().then(function(list){
2591 $scope.age_protect_list = list;
2593 createSimpleUpdateWatcher('age_protect');
2595 $scope.floating_list = [];
2596 itemSvc.get_floating_groups().then(function(list){
2597 $scope.floating_list = list;
2599 createSimpleUpdateWatcher('floating');
2601 createSimpleUpdateWatcher('circulate');
2602 createSimpleUpdateWatcher('holdable');
2603 createSimpleUpdateWatcher('fine_level');
2604 createSimpleUpdateWatcher('loan_duration');
2605 createSimpleUpdateWatcher('cost');
2606 createSimpleUpdateWatcher('deposit');
2607 createSimpleUpdateWatcher('deposit_amount');
2608 createSimpleUpdateWatcher('mint_condition');
2609 createSimpleUpdateWatcher('opac_visible');
2610 createSimpleUpdateWatcher('ref');
2612 $scope.suffix_list = [];
2613 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
2614 $scope.suffix_list = list;
2617 $scope.prefix_list = [];
2618 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
2619 $scope.prefix_list = list;
2622 $scope.classification_list = [];
2623 itemSvc.get_classifications().then(function(list){
2624 $scope.classification_list = list;
2627 createSimpleUpdateWatcher('working.callnumber.classification');
2628 createSimpleUpdateWatcher('working.callnumber.prefix');
2629 createSimpleUpdateWatcher('working.callnumber.suffix');