]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js
webstaff: Enable Fast Item Add functionality in the MARC editor, and improve button...
[working/Evergreen.git] / Open-ILS / web / js / ui / default / staff / cat / volcopy / app.js
1 /**
2  * Vol/Copy Editor
3  */
4
5 angular.module('egVolCopy',
6     ['ngRoute', 'ui.bootstrap', 'egCoreMod', 'egUiMod', 'egGridMod'])
7
8 .filter('boolText', function(){
9     return function (v) {
10         return v == 't';
11     }
12 })
13
14 .config(function($routeProvider, $locationProvider, $compileProvider) {
15     $locationProvider.html5Mode(true);
16     $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export
17
18     var resolver = {
19         delay : ['egStartup', function(egStartup) { return egStartup.go(); }]
20     };
21
22     $routeProvider.when('/cat/volcopy/:dataKey', {
23         templateUrl: './cat/volcopy/t_view',
24         controller: 'EditCtrl',
25         resolve : resolver
26     });
27
28 })
29
30 .factory('itemSvc', 
31        ['egCore','$q',
32 function(egCore , $q) {
33
34     var service = {
35         new_cp_id : 0,
36         new_cn_id : 0,
37         tree : {}, // holds lib->cn->copy hash stack
38         copies : [] // raw copy list
39     };
40
41     // returns a promise resolved with the list of circ mods
42     service.get_classifications = function() {
43         if (egCore.env.acnc)
44             return $q.when(egCore.env.acnc.list);
45
46         return egCore.pcrud.retrieveAll('acnc', null, {atomic : true})
47         .then(function(list) {
48             egCore.env.absorbList(list, 'acnc');
49             return list;
50         });
51     };
52
53     service.get_prefixes = function(org) {
54         return egCore.pcrud.search('acnp',
55             {owning_lib : egCore.org.fullPath(org, true)},
56             null, {atomic : true}
57         );
58
59     };
60
61     service.get_statcats = function(orgs) {
62         return egCore.pcrud.search('asc',
63             {owner : orgs},
64             { flesh : 1,
65               flesh_fields : {
66                 asc : ['owner','entries']
67               }
68             },
69             { atomic : true }
70         );
71     };
72
73     service.get_locations = function(orgs) {
74         return egCore.pcrud.search('acpl',
75             {owning_lib : orgs},
76             null, {atomic : true}
77         );
78     };
79
80     service.get_suffixes = function(org) {
81         return egCore.pcrud.search('acns',
82             {owning_lib : egCore.org.fullPath(org, true)},
83             null, {atomic : true}
84         );
85
86     };
87
88     service.get_statuses = function() {
89         if (egCore.env.ccs)
90             return $q.when(egCore.env.ccs.list);
91
92         return egCore.pcrud.retrieveAll('ccs', {}, {atomic : true}).then(
93             function(list) {
94                 egCore.env.absorbList(list, 'ccs');
95                 return list;
96             }
97         );
98
99     };
100
101     service.get_circ_mods = function() {
102         if (egCore.env.ccm)
103             return $q.when(egCore.env.ccm.list);
104
105         return egCore.pcrud.retrieveAll('ccm', {}, {atomic : true}).then(
106             function(list) {
107                 egCore.env.absorbList(list, 'ccm');
108                 return list;
109             }
110         );
111
112     };
113
114     service.get_circ_types = function() {
115         if (egCore.env.citm)
116             return $q.when(egCore.env.citm.list);
117
118         return egCore.pcrud.retrieveAll('citm', {}, {atomic : true}).then(
119             function(list) {
120                 egCore.env.absorbList(list, 'citm');
121                 return list;
122             }
123         );
124
125     };
126
127     service.get_age_protects = function() {
128         if (egCore.env.crahp)
129             return $q.when(egCore.env.crahp.list);
130
131         return egCore.pcrud.retrieveAll('crahp', {}, {atomic : true}).then(
132             function(list) {
133                 egCore.env.absorbList(list, 'crahp');
134                 return list;
135             }
136         );
137
138     };
139
140     service.bmp_parts = {};
141     service.get_parts = function(rec) {
142         if (service.bmp_parts[rec])
143             return $q.when(service.bmp_parts[rec]);
144
145         return egCore.pcrud.search('bmp',
146             {record : rec},
147             null, {atomic : true}
148         ).then(function(list) {
149             service.bmp_parts[rec] = list;
150             return list;
151         });
152
153     };
154
155     service.flesh = {   
156         flesh : 3, 
157         flesh_fields : {
158             acp : ['call_number','parts','stat_cat_entries', 'notes'],
159             acn : ['label_class','prefix','suffix']
160         }
161     }
162
163     service.addCopy = function (cp) {
164
165         if (!cp.parts()) cp.parts([]); // just in case...
166
167         var lib = cp.call_number().owning_lib();
168         var cn = cp.call_number().id();
169
170         if (!service.tree[lib]) service.tree[lib] = {};
171         if (!service.tree[lib][cn]) service.tree[lib][cn] = [];
172
173         service.tree[lib][cn].push(cp);
174         service.copies.push(cp);
175     }
176
177     service.fetchIds = function(idList) {
178         service.tree = {}; // clear the tree on fetch
179         service.copies = []; // clear the copy list on fetch
180         return egCore.pcrud.search('acp', { 'id' : idList }, service.flesh).then(null,null,
181             function(copy) {
182                 service.addCopy(copy);
183             }
184         );
185     }
186
187     return service;
188 }])
189
190 .directive("egVolCopyEdit", function () {
191     return {
192         restrict: 'E',
193         replace: true,
194         template:
195             '<div class="row">'+
196                 '<div class="col-xs-5">'+
197                     '<input id="{{callNumber.id()}}.{{copy.id()}}"'+
198                     ' eg-enter="nextBarcode()" class="form-control"'+
199                     ' type="text" ng-model="barcode" ng-change="updateBarcode()"/>'+
200                 '</div>'+
201                 '<div class="col-xs-3"><input class="form-control" type="number" ng-model="copy_number" ng-change="updateCopyNo()"/></div>'+
202                 '<div class="col-xs-4"><eg-basic-combo-box list="parts" selected="part"></eg-basic-combo-box></div>'+
203             '</div>',
204
205         scope: { copy: "=", callNumber: "=", index: "@" },
206         controller : ['$scope','itemSvc','egCore',
207             function ( $scope , itemSvc , egCore ) {
208                 $scope.new_part_id = 0;
209
210                 $scope.nextBarcode = function (i) {
211                     $scope.$parent.focusNextBarcode($scope.copy.id());
212                 }
213
214                 $scope.updateBarcode = function () { $scope.copy.barcode($scope.barcode); $scope.copy.ischanged(1); };
215                 $scope.updateCopyNo = function () { $scope.copy.copy_number($scope.copy_number); $scope.copy.ischanged(1); };
216                 $scope.updatePart = function () {
217                     if ($scope.part) {
218                         var p = $scope.part_list.filter(function (x) {
219                             return x.label() == $scope.part
220                         });
221                         if (p.length > 0) { // preexisting part
222                             $scope.copy.parts(p)
223                         } else { // create one...
224                             var part = new egCore.idl.bmp();
225                             part.id( --$scope.new_part_id );
226                             part.isnew( true );
227                             part.label( $scope.part );
228                             part.record( $scope.callNumber.owning_lib() );
229                             $scope.copy.parts([part]);
230                             $scope.copy.ischanged(1);
231                         }
232                     } else {
233                         $scope.copy.parts([]);
234                     }
235                 }
236                 $scope.$watch('part', $scope.updatePart);
237
238                 $scope.barcode = $scope.copy.barcode();
239                 $scope.copy_number = $scope.copy.copy_number();
240
241                 if ($scope.copy.parts()) {
242                     $scope.part = $scope.copy.parts()[0];
243                     if ($scope.part) $scope.part = $scope.part.label();
244                 };
245
246                 $scope.parts = [];
247                 $scope.part_list = [];
248
249                 itemSvc.get_parts($scope.callNumber.record()).then(function(list){
250                     $scope.part_list = list;
251                     angular.forEach(list, function(p){ $scope.parts.push(p.label()) });
252                     $scope.parts = angular.copy($scope.parts);
253                 });
254
255             }
256         ]
257
258     }
259 })
260
261 .directive("egVolRow", function () {
262     return {
263         restrict: 'E',
264         replace: true,
265         transclude: true,
266         template:
267             '<div class="row">'+
268                 '<div class="col-xs-2">'+
269                     '<select class="form-control" ng-model="classification" ng-options="cl.name() for cl in classification_list track by idTracker(cl)"/>'+
270                 '</div>'+
271                 '<div class="col-xs-1">'+
272                     '<select class="form-control" ng-model="prefix" ng-change="updatePrefix()" ng-options="p.label() for p in prefix_list track by idTracker(p)"/>'+
273                 '</div>'+
274                 '<div class="col-xs-2"><input class="form-control" type="text" ng-change="updateLabel()" ng-model="label"/></div>'+
275                 '<div class="col-xs-1">'+
276                     '<select class="form-control" ng-model="suffix" ng-change="updateSuffix()" ng-options="s.label() for s in suffix_list track by idTracker(s)"/>'+
277                 '</div>'+
278                 '<div class="col-xs-1"><input class="form-control" type="number" ng-model="copy_count" min="{{orig_copy_count}}" ng-change="changeCPCount()"></div>'+
279                 '<div class="col-xs-5">'+
280                     '<eg-vol-copy-edit ng-repeat="cp in copies track by idTracker(cp)" copy="cp" call-number="callNumber"></eg-vol-copy-edit>'+
281                 '</div>'+
282             '</div>',
283
284         scope: {allcopies: "=", copies: "=" },
285         controller : ['$scope','itemSvc','egCore',
286             function ( $scope , itemSvc , egCore ) {
287                 $scope.callNumber =  $scope.copies[0].call_number();
288
289                 $scope.idTracker = function (x) { if (x) return x.id() };
290
291                 // XXX $() is not working! arg
292                 $scope.focusNextBarcode = function (i) {
293                     var n;
294                     var yep = false;
295                     angular.forEach($scope.copies, function (cp) {
296                         if (n) return;
297
298                         if (cp.id() == i) {
299                             yep = true;
300                             return;
301                         }
302
303                         if (yep) n = cp.id();
304                     });
305
306                     if (n) {
307                         var next = '#' + $scope.callNumber.id() + '.' + n;
308                         var el = $(next).get(0);
309                         if (el) el.focus()
310                     }
311                 }
312
313                 $scope.suffix_list = [];
314                 itemSvc.get_suffixes($scope.callNumber.owning_lib()).then(function(list){
315                     $scope.suffix_list = list;
316                 });
317                 $scope.updateSuffix = function () {
318                     angular.forEach($scope.copies, function(cp) {
319                         cp.call_number().suffix($scope.suffix);
320                         cp.call_number().ischanged(1);
321                     });
322                 }
323
324                 $scope.prefix_list = [];
325                 itemSvc.get_prefixes($scope.callNumber.owning_lib()).then(function(list){
326                     $scope.prefix_list = list;
327                 });
328                 $scope.updatePrefix = function () {
329                     angular.forEach($scope.copies, function(cp) {
330                         cp.call_number().prefix($scope.prefix);
331                         cp.call_number().ischanged(1);
332                     });
333                 }
334
335                 $scope.classification_list = [];
336                 itemSvc.get_classifications().then(function(list){
337                     $scope.classification_list = list;
338                 });
339                 $scope.updateClassification = function () {
340                     angular.forEach($scope.copies, function(cp) {
341                         cp.call_number().label_class($scope.classification);
342                         cp.call_number().ischanged(1);
343                     });
344                 }
345
346                 $scope.updateLabel = function () {
347                     angular.forEach($scope.copies, function(cp) {
348                         cp.call_number().label($scope.label);
349                         cp.call_number().ischanged(1);
350                     });
351                 }
352
353                 $scope.$watch('callNumber.prefix()', function (v) {
354                     if (typeof v != 'object') {
355                         $scope.prefix = $scope.prefix_list.filter(function (p) {
356                             return p.id() == v;
357                         })[0];
358                         $scope.callNumber.prefix($scope.prefix);
359                     }
360                 });
361
362                 $scope.$watch('callNumber.suffix()', function (v) {
363                     if (typeof v != 'object') {
364                         $scope.suffix = $scope.suffix_list.filter( function (s) {
365                             return s.id() == v;
366                         })[0];
367                         $scope.callNumber.suffix($scope.suffix);
368                     }
369                 });
370
371                 $scope.$watch('callNumber.label_class()', function (v) {
372                     if (typeof v != 'object') {
373                         $scope.classification = $scope.classification_list.filter(function (c) {
374                             return c.id() == v;
375                         })[0];
376                         $scope.callNumber.label_class($scope.classification);
377                     }
378                 });
379
380                 $scope.$watch('callNumber.label()', function (v) {
381                     $scope.label = v;
382                 });
383
384                 $scope.prefix = $scope.callNumber.prefix();
385                 $scope.suffix = $scope.callNumber.suffix();
386                 $scope.classification = $scope.callNumber.label_class();
387                 $scope.label = $scope.callNumber.label();
388
389                 $scope.copy_count = $scope.copies.length;
390                 $scope.orig_copy_count = $scope.copy_count;
391
392                 $scope.changeCPCount = function () {
393                     while ($scope.copy_count > $scope.copies.length) {
394                         var cp = new egCore.idl.acp();
395                         cp.id( --itemSvc.new_cp_id );
396                         cp.isnew( true );
397                         cp.circ_lib( $scope.lib );
398                         cp.call_number( $scope.callNumber );
399                         $scope.copies.push( cp );
400                         $scope.allcopies.push( cp );
401                     }
402
403                     if ($scope.copy_count >= $scope.orig_copy_count) {
404                         var how_many = $scope.copies.length - $scope.copy_count;
405                         if (how_many > 0) {
406                             var dead = $scope.copies.splice($scope.copy_count,how_many);
407                             $scope.callNumber.copies($scope.copies);
408
409                             // Trimming the global list is a bit more tricky
410                             angular.forEach( dead, function (d) {
411                                 angular.forEach( $scope.allcopies, function (l, i) { 
412                                     if (l === d) $scope.allcopies.splice(i,1);
413                                 });
414                             });
415                         }
416                     }
417                 }
418
419             }
420         ]
421
422     }
423 })
424
425 .directive("egVolEdit", function () {
426     return {
427         restrict: 'E',
428         replace: true,
429         template:
430             '<div class="row">'+
431                 '<div class="col-xs-1"><eg-org-selector selected="owning_lib" disableTest="cant_have_vols"></eg-org-selector></div>'+
432                 '<div class="col-xs-1"><input class="form-control" type="number" min="{{orig_cn_count}}" ng-model="cn_count" ng-change="changeCNCount()"/></div>'+
433                 '<div class="col-xs-10">'+
434                     '<eg-vol-row ng-repeat="(cn,copies) in struct track by cn" copies="copies" allcopies="allcopies"></eg-vol-row>'+
435                 '</div>'+
436             '</div>',
437
438         scope: { allcopies: "=", struct: "=", lib: "@", record: "@" },
439         controller : ['$scope','itemSvc','egCore',
440             function ( $scope , itemSvc , egCore ) {
441                 $scope.first_cn = Object.keys($scope.struct)[0];
442                 $scope.full_cn = $scope.struct[$scope.first_cn][0].call_number();
443
444                 $scope.cn_count = Object.keys($scope.struct).length;
445                 $scope.orig_cn_count = $scope.cn_count;
446
447                 $scope.owning_lib = egCore.org.get($scope.lib);
448                 $scope.$watch('owning_lib', function (l) {
449                     angular.forEach( $scope.struct[$scope.first_cn], function (cp) {
450                         cp.call_number().owning_lib( $scope.owning_lib.id() );
451                     });
452                 });
453
454                 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
455
456                 $scope.$watch('cn_count', function (n) {
457                     var o = Object.keys($scope.struct).length;
458                     if (n > o) { // adding
459                         for (var i = o; o < n; o++) {
460                             var cn = new egCore.idl.acn();
461                             cn.id( --itemSvc.new_cn_id );
462                             cn.isnew( true );
463                             cn.owning_lib( $scope.owning_lib.id() );
464                             cn.record( $scope.full_cn.record() );
465
466                             var cp = new egCore.idl.acp();
467                             cp.id( --itemSvc.new_cp_id );
468                             cp.isnew( true );
469                             cp.circ_lib( $scope.owning_lib.id() );
470                             cp.call_number( cn );
471
472                             $scope.struct[cn.id()] = [cp];
473                             $scope.allcopies.push(cp);
474                         }
475                     } else if (n < o && n >= $scope.orig_cn_count) { // removing
476                         var how_many = o - n;
477                         var list = Object
478                                 .keys($scope.struct)
479                                 .sort(function(a, b){return a-b})
480                                 .reverse();
481                         for (var i = how_many; i > 0; i--) {
482                             // Trimming the global list is a bit more tricky
483                             angular.forEach($scope.struct[list[i]], function (d) {
484                                 angular.forEach( $scope.allcopies, function (l, j) { 
485                                     if (l === d) $scope.allcopies.splice(j,1);
486                                 });
487                             });
488                             delete $scope.struct[list[i]];
489                         }
490                     }
491                 });
492             }
493         ]
494
495     }
496 })
497
498 /**
499  * Edit controller!
500  */
501 .controller('EditCtrl', 
502        ['$scope','$q','$window','$routeParams','$location','$timeout','egCore','egNet','egGridDataProvider','itemSvc','$modal',
503 function($scope , $q , $window , $routeParams , $location , $timeout , egCore , egNet , egGridDataProvider , itemSvc , $modal) {
504
505     $scope.defaults = { // If defaults are not set at all, allow everything
506         statcats : true,
507         copy_notes : true,
508         attributes : {
509             status : true,
510             loan_duration : true,
511             fine_level : true,
512             cost : true,
513             alerts : true,
514             deposit : true,
515             deposit_amount : true,
516             opac_visible : true,
517             price : true,
518             circulate : true,
519             mint_condition : true,
520             circ_lib : true,
521             ref : true,
522             circ_modifier : true,
523             circ_as_type : true,
524             location : true,
525             holdable : true,
526             age_protect : true
527         }
528     };
529
530     $scope.saveDefaults = function () {
531         egCore.hatch.setItem('cat.copy.defaults', $scope.defaults);
532     }
533
534     $scope.fetchDefaults = function () {
535         egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
536             if (t) {
537                 $scope.defaults = t;
538                 if (!$scope.batch) $scope.batch = {};
539                 $scope.batch.classification = $scope.defaults.classification;
540                 $scope.batch.prefix = $scope.defaults.prefix;
541                 $scope.batch.suffix = $scope.defaults.suffix;
542                 $scope.working.statcat_filter = $scope.defaults.statcat_filter;
543                 if ($scope.defaults.always_vols) $scope.show_vols = true;
544             }
545         });
546     }
547     $scope.fetchDefaults();
548
549     $scope.dirty = false;
550     $scope.$watch('dirty',
551         function(newVal, oldVal) {
552             if (newVal && newVal != oldVal) {
553                 $($window).on('beforeunload.edit', function(){
554                     return 'There is unsaved data!'
555                 });
556             } else {
557                 $($window).off('beforeunload.edit');
558             }
559         }
560     );
561
562     $scope.show_vols = true;
563     $scope.show_copies = true;
564
565     $scope.tracker = function (x,f) { if (x) return x[f]() };
566     $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
567     $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
568
569     $scope.orgById = function (id) { return egCore.org.get(id) }
570     $scope.statusById = function (id) {
571         return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
572     }
573     $scope.locationById = function (id) {
574         return $scope.location_cache[''+id];
575     }
576
577     $scope.workingToComplete = function () {
578         angular.forEach( $scope.workingGridControls.selectedItems(), function (c) {
579             angular.forEach( itemSvc.copies, function (w, i) {
580                 if (c === w)
581                     $scope.completed_copies = $scope.completed_copies.concat(itemSvc.copies.splice(i,1));
582             });
583         });
584     }
585
586     $scope.completeToWorking = function () {
587         angular.forEach( $scope.completedGridControls.selectedItems(), function (c) {
588             angular.forEach( $scope.completed_copies, function (w, i) {
589                 if (c === w)
590                     itemSvc.copies = itemSvc.copies.concat($scope.completed_copies.splice(i,1));
591             });
592         });
593     }
594
595     createSimpleUpdateWatcher = function (field) {
596         return $scope.$watch('working.' + field, function () {
597             var newval = $scope.working[field];
598
599             if (typeof newval != 'undefined') {
600                 if (angular.isObject(newval)) { // we'll use the pkey
601                     if (newval.id) newval = newval.id();
602                     else if (newval.code) newval = newval.code();
603                 }
604
605                 if (""+newval == "" || newval == null) {
606                     $scope.working[field] = undefined;
607                     newval = null;
608                 }
609
610                 if ($scope.workingGridControls && $scope.workingGridControls.selectedItems) {
611                     angular.forEach(
612                         $scope.workingGridControls.selectedItems(),
613                         function (cp) {
614                             if (cp[field]() !== newval) {
615                                 cp[field](newval);
616                                 cp.ischanged(1);
617                                 $scope.dirty = true;
618                             }
619                         }
620                     );
621                 }
622             }
623         });
624     }
625
626     $scope.working = {
627         statcats: {},
628         statcat_filter: undefined
629     };
630
631     $scope.statcatUpdate = function (id) {
632         var newval = $scope.working.statcats[id];
633
634         if (typeof newval != 'undefined') {
635             if (angular.isObject(newval)) { // we'll use the pkey
636                 newval = newval.id();
637             }
638     
639             if (""+newval == "" || newval == null) {
640                 $scope.working.statcats[id] = undefined;
641                 newval = null;
642             }
643     
644             if (!$scope.in_item_select && $scope.workingGridControls && $scope.workingGridControls.selectedItems) {
645                 angular.forEach(
646                     $scope.workingGridControls.selectedItems(),
647                     function (cp) {
648                         $scope.dirty = true;
649
650                         cp.stat_cat_entries(
651                             angular.forEach( cp.stat_cat_entries(), function (e) {
652                                 if (e.stat_cat() == id) { // mark deleted
653                                     e.isdeleted(1);
654                                 }
655                             })
656                         );
657     
658                         if (newval) {
659                             var e = new egCore.idl.ascecm();
660                             e.isnew( 1 );
661                             e.owning_copy( cp.id() );
662                             e.stat_cat( id );
663                             e.stat_cat_entry( newval );
664
665                             cp.stat_cat_entries(
666                                 cp.stat_cat_entries().concat([ e ])
667                             );
668
669                         }
670
671                         cp.stat_cat_entries( // trim out ephemeral deleted ones
672                             cp.stat_cat_entries().filter(function (e) {
673                                 if (Boolean(e.isnew())) {
674                                     if (Boolean(e.isdeleted())) {
675                                         return false;
676                                     }
677                                 }
678                                 return true;
679                             })
680                         );
681    
682                         cp.ischanged(1);
683                     }
684                 );
685             }
686         }
687     }
688
689     var dataKey = $routeParams.dataKey;
690     console.debug('dataKey: ' + dataKey);
691
692     if (dataKey && dataKey.length > 0) {
693
694         $scope.templates = {};
695         $scope.template_name = '';
696         $scope.template_name_list = [];
697
698         $scope.fetchTemplates = function () {
699             egCore.hatch.getItem('cat.copy.templates').then(function(t) {
700                 if (t) {
701                     $scope.templates = t;
702                     $scope.template_name_list = Object.keys(t);
703                 }
704             });
705         }
706         $scope.fetchTemplates();
707
708          $scope.applyTemplate = function (n) {
709             angular.forEach($scope.templates[n], function (v,k) {
710                 if (!angular.isObject(v)) {
711                     $scope.working[k] = angular.copy(v);
712                 } else {
713                     angular.forEach(v, function (sv,sk) {
714                         if (k == 'callnumber') {
715                             angular.forEach(v, function (cnv,cnk) {
716                                 $scope.batch[cnk] = cnv;
717                             });
718                             $scope.applyBatchCNValues();
719                         } else {
720                             $scope.working[k][sk] = angular.copy(sv);
721                             if (k == 'statcats') $scope.statcatUpdate(sk);
722                         }
723                     });
724                 }
725             });
726             $scope.template_name = '';
727         }
728
729         $scope.copytab = 'working';
730         $scope.tab = 'edit';
731         $scope.summaryRecord = null;
732         $scope.record_id = null;
733         $scope.data = {};
734         $scope.completed_copies = [];
735         $scope.location_orgs = [];
736         $scope.location_cache = {};
737         $scope.statcats = [];
738         if (!$scope.batch) $scope.batch = {};
739
740         $scope.applyBatchCNValues = function () {
741             if ($scope.data.tree) {
742                 angular.forEach($scope.data.tree, function(cn_hash) {
743                     angular.forEach(cn_hash, function(copies) {
744                         angular.forEach(copies, function(cp) {
745                             if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '')
746                                 cp.call_number().label_class($scope.batch.classification);
747                                 $scope.dirty = true;
748                             if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '')
749                                 cp.call_number().prefix($scope.batch.prefix);
750                                 $scope.dirty = true;
751                             if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '')
752                                 cp.call_number().label($scope.batch.label);
753                                 $scope.dirty = true;
754                             if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '')
755                                 cp.call_number().suffix($scope.batch.suffix);
756                                 $scope.dirty = true;
757                         });
758                     });
759                 });
760             }
761         }
762
763         $scope.clearWorking = function () {
764             angular.forEach($scope.working, function (v,k,o) {
765                 if (!angular.isObject(v)) {
766                     if (typeof v != 'undefined')
767                         $scope.working[k] = undefined;
768                 } else if (k != 'circ_lib') {
769                     angular.forEach(v, function (sv,sk) {
770                         if (typeof v != 'undefined')
771                             $scope.working[k][sk] = undefined;
772                     });
773                 }
774             });
775             $scope.working.circ_lib = undefined; // special
776         }
777
778         $scope.completedGridDataProvider = egGridDataProvider.instance({
779             get : function(offset, count) {
780                 //return provider.arrayNotifier(itemSvc.copies, offset, count);
781                 return this.arrayNotifier($scope.completed_copies, offset, count);
782             }
783         });
784
785         $scope.completedGridControls = {};
786
787         $scope.workingGridDataProvider = egGridDataProvider.instance({
788             get : function(offset, count) {
789                 //return provider.arrayNotifier(itemSvc.copies, offset, count);
790                 return this.arrayNotifier(itemSvc.copies, offset, count);
791             }
792         });
793
794         $scope.workingGridControls = {};
795
796         egNet.request(
797             'open-ils.actor',
798             'open-ils.actor.anon_cache.get_value',
799             dataKey, 'edit-these-copies'
800         ).then(function (data) {
801
802             if (data) {
803                 if (data.hide_vols && !$scope.defaults.always_vols) $scope.show_vols = false;
804                 if (data.hide_copies) $scope.show_copies = false;
805
806                 $scope.record_id = data.record_id;
807
808                 if (data.copies && data.copies.length)
809                     return itemSvc.fetchIds(data.copies);
810
811                 if (data.raw && data.raw.length) {
812                     $scope.dirty = true;
813
814                     /* data.raw data structure looks like this:
815                      * [{
816                      *      callnumber : $cn_id, // optional, to add a copy to a cn
817                      *      owner      : $org, // optional, defaults to ws_ou
818                      *      label      : $cn_label, // optional, to supply a label on a new cn
819                      *      barcode    : $cp_barcode // optional, to supply a barcode on a new cp
820                      * },...]
821                      * 
822                      * All can be left out and a completely empty vol/copy combo will be vivicated.
823                      */
824
825                     angular.forEach(
826                         data.raw,
827                         function (proto) {
828                             if (proto.callnumber) {
829                                 return egCore.pcrud.retrieve('acn', proto.callnumber)
830                                 .then(function(cn) {
831                                     var cp = new egCore.idl.acp();
832                                     cp.call_number( cn );
833                                     cp.id( --itemSvc.new_cp_id );
834                                     cp.isnew( true );
835                                     cp.circ_lib( $scope.record_id );
836                                     if (proto.barcode) cp.barcode( proto.barcode );
837
838                                     itemSvc.addCopy(cp)
839                                 });
840                             } else {
841                                 var cn = new egCore.idl.acn();
842                                 cn.id( --itemSvc.new_cn_id );
843                                 cn.isnew( true );
844                                 cn.owning_lib( proto.owner || egCore.auth.user().ws_ou() );
845                                 cn.record( $scope.record_id );
846                                 if (proto.label) cn.label( proto.label );
847
848                                 var cp = new egCore.idl.acp();
849                                 cp.call_number( cn );
850                                 cp.id( --itemSvc.new_cp_id );
851                                 cp.isnew( true );
852                                 cp.circ_lib( $scope.record_id );
853                                 if (proto.barcode) cp.barcode( proto.barcode );
854
855                                 itemSvc.addCopy(cp)
856                             }
857     
858                         }
859                     );
860
861                     return itemSvc.copies;
862                 }
863             }
864
865         }).then( function() {
866             $scope.data = itemSvc;
867             $scope.workingGridDataProvider.refresh();
868         });
869
870         $scope.in_item_select = false;
871         $scope.afterItemSelect = function() { $scope.in_item_select = false };
872         $scope.handleItemSelect = function (item_list) {
873             if (item_list && item_list.length > 0) {
874                 $scope.in_item_select = true;
875
876                 angular.forEach(Object.keys($scope.defaults.attributes), function (attr) {
877
878                     var value_hash = {};
879                     angular.forEach(item_list, function (item) {
880                         if (item[attr]) {
881                             var v = item[attr]()
882                             if (angular.isObject(v)) {
883                                 if (v.id) v = v.id();
884                                 else if (v.code) v = v.code();
885                             }
886                             value_hash[v] = 1;
887                         }
888                     });
889
890                     if (Object.keys(value_hash).length == 1) {
891                         if (attr == 'circ_lib') {
892                             $scope.working[attr] = egCore.org.get(item_list[0][attr]());
893                         } else {
894                             $scope.working[attr] = item_list[0][attr]();
895                         }
896                     } else {
897                         $scope.working[attr] = undefined;
898                     }
899                 });
900
901                 angular.forEach($scope.statcats, function (sc) {
902
903                     var counter = -1;
904                     var value_hash = {};
905                     var none = false;
906                     angular.forEach(item_list, function (item) {
907                         if (item.stat_cat_entries()) {
908                             if (item.stat_cat_entries().length > 0) {
909                                 var right_sc = item.stat_cat_entries().filter(function (e) {
910                                     return e.stat_cat() == sc.id() && !Boolean(e.isdeleted());
911                                 });
912
913                                 if (right_sc.length > 0) {
914                                     value_hash[right_sc[0].stat_cat_entry()] = right_sc[0].stat_cat_entry();
915                                 } else {
916                                     none = true;
917                                 }
918                             }
919                         } else {
920                             none = true;
921                         }
922                     });
923
924                     if (!none && Object.keys(value_hash).length == 1) {
925                         $scope.working.statcats[sc.id()] = value_hash[Object.keys(value_hash)[0]];
926                     } else {
927                         $scope.working.statcats[sc.id()] = undefined;
928                     }
929                 });
930
931             } else {
932                 $scope.clearWorking();
933             }
934
935         }
936
937         $scope.$watch('data.copies.length', function () {
938             if ($scope.data.copies) {
939                 var base_orgs = $scope.data.copies.map(function(cp){
940                     return cp.circ_lib()
941                 }).concat(
942                     $scope.data.copies.map(function(cp){
943                         return cp.call_number().owning_lib()
944                     })
945                 ).concat(
946                     [egCore.auth.user().ws_ou()]
947                 ).filter(function(e,i,a){
948                     return a.lastIndexOf(e) === i;
949                 });
950
951                 var all_orgs = [];
952                 angular.forEach(base_orgs, function(o) {
953                     all_orgs = all_orgs.concat( egCore.org.fullPath(o, true) );
954                 });
955
956                 var final_orgs = all_orgs.filter(function(e,i,a){
957                     return a.lastIndexOf(e) === i;
958                 }).sort(function(a,b){return b-a});
959
960                 if ($scope.location_orgs.toString() != final_orgs.toString()) {
961                     $scope.location_orgs = final_orgs;
962                     if ($scope.location_orgs.length) {
963                         itemSvc.get_locations($scope.location_orgs).then(function(list){
964                             angular.forEach(list, function(l) {
965                                 $scope.location_cache[ ''+l.id() ] = l;
966                             });
967                             $scope.location_list = list;
968                         });
969
970                         $scope.statcat_filter_list = [];
971                         angular.forEach($scope.location_orgs, function (o) {
972                             $scope.statcat_filter_list.push(egCore.org.get(o));
973                         });
974
975                         itemSvc.get_statcats($scope.location_orgs).then(function(list){
976                             $scope.statcats = list;
977                             angular.forEach($scope.statcats, function (s) {
978
979                                 if (!$scope.working)
980                                     $scope.working = { statcats: {}, statcat_filter: undefined};
981                                 if (!$scope.working.statcats)
982                                     $scope.working.statcats = {};
983
984                                 if (!$scope.in_item_select) {
985                                     $scope.working.statcats[s.id()] = undefined;
986                                 }
987                                 createStatcatUpdateWatcher(s.id());
988                             });
989                             $scope.in_item_select = false;
990                         });
991                     }
992                 }
993             }
994
995             $scope.workingGridDataProvider.refresh();
996         });
997
998         $scope.suffix_list = [];
999         itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1000             $scope.suffix_list = list;
1001         });
1002
1003         $scope.prefix_list = [];
1004         itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1005             $scope.prefix_list = list;
1006         });
1007
1008         $scope.classification_list = [];
1009         itemSvc.get_classifications().then(function(list){
1010             $scope.classification_list = list;
1011         });
1012
1013         $scope.$watch('completed_copies.length', function () {
1014             $scope.completedGridDataProvider.refresh();
1015         });
1016
1017         $scope.location_list = [];
1018         itemSvc.get_locations().then(function(list){
1019             $scope.location_list = list;
1020         });
1021         createSimpleUpdateWatcher('location');
1022
1023         $scope.status_list = [];
1024         itemSvc.get_statuses().then(function(list){
1025             $scope.status_list = list;
1026         });
1027         createSimpleUpdateWatcher('status');
1028
1029         $scope.circ_modifier_list = [];
1030         itemSvc.get_circ_mods().then(function(list){
1031             $scope.circ_modifier_list = list;
1032         });
1033         createSimpleUpdateWatcher('circ_modifier');
1034
1035         $scope.circ_type_list = [];
1036         itemSvc.get_circ_types().then(function(list){
1037             $scope.circ_type_list = list;
1038         });
1039         createSimpleUpdateWatcher('circ_as_type');
1040
1041         $scope.age_protect_list = [];
1042         itemSvc.get_age_protects().then(function(list){
1043             $scope.age_protect_list = list;
1044         });
1045         createSimpleUpdateWatcher('age_protect');
1046
1047         createSimpleUpdateWatcher('circ_lib');
1048         createSimpleUpdateWatcher('circulate');
1049         createSimpleUpdateWatcher('holdable');
1050         createSimpleUpdateWatcher('fine_level');
1051         createSimpleUpdateWatcher('loan_duration');
1052         createSimpleUpdateWatcher('cost');
1053         createSimpleUpdateWatcher('deposit');
1054         createSimpleUpdateWatcher('deposit_amount');
1055         createSimpleUpdateWatcher('mint_condition');
1056         createSimpleUpdateWatcher('opac_visible');
1057         createSimpleUpdateWatcher('ref');
1058
1059         $scope.saveCompletedCopies = function (and_exit) {
1060             var cnHash = {};
1061             var perCnCopies = {};
1062             angular.forEach( $scope.completed_copies, function (cp) {
1063                 var cn_id = cp.call_number().id();
1064                 if (!cnHash[cn_id]) {
1065                     cnHash[cn_id] = cp.call_number();
1066                     perCnCopies[cn_id] = [cp];
1067                 } else {
1068                     perCnCopies[cn_id].push(cp);
1069                 }
1070                 cp.call_number(cn_id); // prevent loops in JSON-ification
1071             });
1072
1073             angular.forEach(perCnCopies, function (v, k) {
1074                 cnHash[k].copies(v);
1075             });
1076
1077             cnList = [];
1078             angular.forEach(cnHash, function (v, k) {
1079                 cnList.push(v);
1080             });
1081
1082             egNet.request(
1083                 'open-ils.cat',
1084                 'open-ils.cat.asset.volume.fleshed.batch.update.override',
1085                 egCore.auth.token(), cnList, 1, { auto_merge_vols : 1, create_parts : 1 }
1086             ).then(function(update_count) {
1087                 if (and_exit) {
1088                     $scope.dirty = false;
1089                     $timeout(function(){$window.close()});
1090                 }
1091             });
1092         }
1093
1094         $scope.saveAndExit = function () {
1095             $scope.saveCompletedCopies(true);
1096         }
1097
1098     }
1099
1100     $scope.copy_notes_dialog = function(copy_list) {
1101         var default_pub = Boolean($scope.defaults.copy_notes_pub);
1102         if (!angular.isArray(copy_list)) copy_list = [copy_list];
1103
1104         return $modal.open({
1105             templateUrl: './cat/volcopy/t_copy_notes',
1106             animation: true,
1107             controller:
1108                    ['$scope','$modalInstance',
1109             function($scope , $modalInstance) {
1110                 $scope.focusNote = true;
1111                 $scope.note = {
1112                     creator : egCore.auth.user().id(),
1113                     title   : '',
1114                     value   : '',
1115                     pub     : default_pub,
1116                 };
1117
1118                 $scope.require_initials = false;
1119                 egCore.org.settings([
1120                     'ui.staff.require_initials.copy_notes'
1121                 ]).then(function(set) {
1122                     $scope.require_initials = Boolean(set['ui.staff.require_initials.copy_notes']);
1123                 });
1124
1125                 $scope.note_list = [];
1126                 if (copy_list.length == 1) {
1127                     $scope.note_list = copy_list[0].notes();
1128                 }
1129
1130                 $scope.ok = function(note) {
1131
1132                     if (note.initials) note.value += ' [' + note.initials + ']';
1133                     angular.forEach(copy_list, function (cp) {
1134                         var n = new egCore.idl.acpn();
1135                         n.creator(note.creator);
1136                         n.pub(note.pub);
1137                         n.title(note.title);
1138                         n.value(note.value);
1139                         n.owning_copy(cp.id());
1140                         cp.notes().push( n );
1141                     });
1142
1143                     $modalInstance.close();
1144                 }
1145
1146                 $scope.cancel = function($event) {
1147                     $modalInstance.dismiss();
1148                     $event.preventDefault();
1149                 }
1150             }]
1151         });
1152     }
1153
1154 }])
1155
1156 .directive("egVolTemplate", function () {
1157     return {
1158         restrict: 'E',
1159         replace: true,
1160         template: '<div ng-include="'+"'/eg/staff/cat/volcopy/t_attr_edit'"+'"></div>',
1161         scope: { },
1162         controller : ['$scope','$window','itemSvc','egCore',
1163             function ( $scope , $window , itemSvc , egCore ) {
1164
1165                 $scope.defaults = { // If defaults are not set at all, allow everything
1166                     statcats : true,
1167                     copy_notes : true,
1168                     attributes : {
1169                         status : true,
1170                         loan_duration : true,
1171                         fine_level : true,
1172                         cost : true,
1173                         alerts : true,
1174                         deposit : true,
1175                         deposit_amount : true,
1176                         opac_visible : true,
1177                         price : true,
1178                         circulate : true,
1179                         mint_condition : true,
1180                         circ_lib : true,
1181                         ref : true,
1182                         circ_modifier : true,
1183                         circ_as_type : true,
1184                         location : true,
1185                         holdable : true,
1186                         age_protect : true
1187                     }
1188                 };
1189
1190                 $scope.fetchDefaults = function () {
1191                     egCore.hatch.getItem('cat.copy.defaults').then(function(t) {
1192                         if (t) {
1193                             $scope.defaults = t;
1194                             $scope.working.statcat_filter = $scope.defaults.statcat_filter;
1195                         }
1196                     });
1197                 }
1198                 $scope.fetchDefaults();
1199
1200                 $scope.dirty = false;
1201                 $scope.$watch('dirty',
1202                     function(newVal, oldVal) {
1203                         if (newVal && newVal != oldVal) {
1204                             $($window).on('beforeunload.template', function(){
1205                                 return 'There is unsaved template data!'
1206                             });
1207                         } else {
1208                             $($window).off('beforeunload.template');
1209                         }
1210                     }
1211                 );
1212
1213                 $scope.template_controls = true;
1214
1215                 $scope.fetchTemplates = function () {
1216                     egCore.hatch.getItem('cat.copy.templates').then(function(t) {
1217                         if (t) {
1218                             $scope.templates = t;
1219                             $scope.template_name_list = Object.keys(t);
1220                         }
1221                     });
1222                 }
1223                 $scope.fetchTemplates();
1224             
1225                 $scope.applyTemplate = function (n) {
1226                     angular.forEach($scope.templates[n], function (v,k) {
1227                         if (!angular.isObject(v)) {
1228                             $scope.working[k] = angular.copy(v);
1229                         } else {
1230                             angular.forEach(v, function (sv,sk) {
1231                                 $scope.working[k][sk] = angular.copy(sv);
1232                             });
1233                         }
1234                     });
1235                     $scope.template_name = '';
1236                 }
1237
1238                 $scope.deleteTemplate = function (n) {
1239                     if (n) {
1240                         delete $scope.templates[n]
1241                         $scope.template_name_list = Object.keys($scope.templates);
1242                         $scope.template_name = '';
1243                         egCore.hatch.setItem('cat.copy.templates', $scope.templates);
1244                         $scope.$parent.fetchTemplates();
1245                     }
1246                 }
1247
1248                 $scope.saveTemplate = function (n) {
1249                     if (n) {
1250                         var tmpl = {};
1251             
1252                         angular.forEach($scope.working, function (v,k) {
1253                             if (angular.isObject(v)) { // we'll use the pkey
1254                                 if (v.id) v = v.id();
1255                                 else if (v.code) v = v.code();
1256                             }
1257             
1258                             tmpl[k] = v;
1259                         });
1260             
1261                         $scope.templates[n] = tmpl;
1262                         $scope.template_name_list = Object.keys($scope.templates);
1263             
1264                         egCore.hatch.setItem('cat.copy.templates', $scope.templates);
1265                         $scope.$parent.fetchTemplates();
1266
1267                         $scope.dirty = false;
1268                     }
1269                 }
1270             
1271                 $scope.templates = {};
1272                 $scope.template_name = '';
1273                 $scope.template_name_list = [];
1274             
1275                 $scope.tracker = function (x,f) { if (x) return x[f]() };
1276                 $scope.idTracker = function (x) { if (x) return $scope.tracker(x,'id') };
1277                 $scope.cant_have_vols = function (id) { return !egCore.org.CanHaveVolumes(id); };
1278             
1279                 $scope.orgById = function (id) { return egCore.org.get(id) }
1280                 $scope.statusById = function (id) {
1281                     return $scope.status_list.filter( function (s) { return s.id() == id } )[0];
1282                 }
1283                 $scope.locationById = function (id) {
1284                     return $scope.location_cache[''+id];
1285                 }
1286             
1287                 createSimpleUpdateWatcher = function (field) {
1288                     $scope.$watch('working.' + field, function () {
1289                         var newval = $scope.working[field];
1290             
1291                         if (typeof newval != 'undefined') {
1292                             $scope.dirty = true;
1293                             if (angular.isObject(newval)) { // we'll use the pkey
1294                                 if (newval.id) $scope.working[field] = newval.id();
1295                                 else if (newval.code) $scope.working[field] = newval.code();
1296                             }
1297             
1298                             if (""+newval == "" || newval == null) {
1299                                 $scope.working[field] = undefined;
1300                             }
1301             
1302                         }
1303                     });
1304                 }
1305             
1306                 $scope.working = {
1307                     statcats: {},
1308                     statcat_filter: undefined
1309                 };
1310             
1311                 createStatcatUpdateWatcher = function (id) {
1312                     return $scope.$watch('working.statcats[' + id + ']', function () {
1313                         if ($scope.working.statcats) {
1314                             var newval = $scope.working.statcats[id];
1315                 
1316                             if (typeof newval != 'undefined') {
1317                                 $scope.dirty = true;
1318                                 if (angular.isObject(newval)) { // we'll use the pkey
1319                                     newval = newval.id();
1320                                 }
1321                 
1322                                 if (""+newval == "" || newval == null) {
1323                                     $scope.working.statcats[id] = undefined;
1324                                     newval = null;
1325                                 }
1326                 
1327                             }
1328                         }
1329                     });
1330                 }
1331
1332                 $scope.clearWorking = function () {
1333                     angular.forEach($scope.working, function (v,k,o) {
1334                         if (!angular.isObject(v)) {
1335                             if (typeof v != 'undefined')
1336                                 $scope.working[k] = undefined;
1337                         } else if (k != 'circ_lib') {
1338                             angular.forEach(v, function (sv,sk) {
1339                                 $scope.working[k][sk] = undefined;
1340                             });
1341                         }
1342                     });
1343                     $scope.working.circ_lib = undefined; // special
1344                     $scope.dirty = false;
1345                 }
1346
1347                 $scope.working = {};
1348                 $scope.location_orgs = [];
1349                 $scope.location_cache = {};
1350             
1351                 $scope.location_list = [];
1352                 itemSvc.get_locations(
1353                     egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
1354                 ).then(function(list){
1355                     $scope.location_list = list;
1356                 });
1357                 createSimpleUpdateWatcher('location');
1358
1359                 $scope.statcat_filter_list = egCore.org.fullPath( egCore.auth.user().ws_ou() );
1360
1361                 $scope.statcats = [];
1362                 itemSvc.get_statcats(
1363                     egCore.org.fullPath( egCore.auth.user().ws_ou(), true )
1364                 ).then(function(list){
1365                     $scope.statcats = list;
1366                     angular.forEach($scope.statcats, function (s) {
1367
1368                         if (!$scope.working)
1369                             $scope.working = { statcats: {}, statcat_filter: undefined};
1370                         if (!$scope.working.statcats)
1371                             $scope.working.statcats = {};
1372
1373                         $scope.working.statcats[s.id()] = undefined;
1374                         createStatcatUpdateWatcher(s.id());
1375                     });
1376                 });
1377             
1378                 $scope.status_list = [];
1379                 itemSvc.get_statuses().then(function(list){
1380                     $scope.status_list = list;
1381                 });
1382                 createSimpleUpdateWatcher('status');
1383             
1384                 $scope.circ_modifier_list = [];
1385                 itemSvc.get_circ_mods().then(function(list){
1386                     $scope.circ_modifier_list = list;
1387                 });
1388                 createSimpleUpdateWatcher('circ_modifier');
1389             
1390                 $scope.circ_type_list = [];
1391                 itemSvc.get_circ_types().then(function(list){
1392                     $scope.circ_type_list = list;
1393                 });
1394                 createSimpleUpdateWatcher('circ_as_type');
1395             
1396                 $scope.age_protect_list = [];
1397                 itemSvc.get_age_protects().then(function(list){
1398                     $scope.age_protect_list = list;
1399                 });
1400                 createSimpleUpdateWatcher('age_protect');
1401             
1402                 createSimpleUpdateWatcher('circ_lib');
1403                 createSimpleUpdateWatcher('circulate');
1404                 createSimpleUpdateWatcher('holdable');
1405                 createSimpleUpdateWatcher('fine_level');
1406                 createSimpleUpdateWatcher('loan_duration');
1407                 createSimpleUpdateWatcher('cost');
1408                 createSimpleUpdateWatcher('deposit');
1409                 createSimpleUpdateWatcher('deposit_amount');
1410                 createSimpleUpdateWatcher('mint_condition');
1411                 createSimpleUpdateWatcher('opac_visible');
1412                 createSimpleUpdateWatcher('ref');
1413
1414                 $scope.suffix_list = [];
1415                 itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
1416                     $scope.suffix_list = list;
1417                 });
1418
1419                 $scope.prefix_list = [];
1420                 itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
1421                     $scope.prefix_list = list;
1422                 });
1423
1424                 $scope.classification_list = [];
1425                 itemSvc.get_classifications().then(function(list){
1426                     $scope.classification_list = list;
1427                 });
1428
1429                 createSimpleUpdateWatcher('working.callnumber.classification');
1430                 createSimpleUpdateWatcher('working.callnumber.prefix');
1431                 createSimpleUpdateWatcher('working.callnumber.suffix');
1432             }
1433         ]
1434     }
1435 })
1436
1437