webstaff: Add a "Batch Apply" template row above call numbers
authorMike Rylander <mrylander@gmail.com>
Wed, 19 Aug 2015 17:43:23 +0000 (13:43 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:16 +0000 (15:44 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index b616e03..496d853 100644 (file)
@@ -3,26 +3,57 @@
 <style> select { width: 80px } </style>
 
 <accordion close-others="false">
-    <accordion-group heading="Volume Editor" is-open="show_vols">
+    <accordion-group heading="Volume/Copy Details" is-open="show_vols">
 
         <div class="container-fluid">
+            <div class="row bg-info">
+                <div class="col-xs-2"><h4 class="center-block">[% l('Batch Apply') %]</h4></div>
+                <div class="col-xs-10">
+                    <div class="container-fluid">
+                        <div class="row">
+                            <div class="col-xs-1">
+                                <select ng-model="batch.classification" ng-options="cl.id() as cl.name() for cl in classification_list">
+                                    <option value="">[% l('(Unset)') %]</option>
+                                </select>
+                            </div>
+                            <div class="col-xs-1">
+                                <select ng-model="batch.prefix" ng-options="p.id() as p.label() for p in prefix_list">
+                                    <option value="">[% l('(Unset)') %]</option>
+                                </select>
+                            </div>
+                            <div class="col-xs-3">
+                                <input type="text" ng-model="batch.label"/>
+                            </div>
+                            <div class="col-xs-1">
+                                <select ng-model="batch.suffix" ng-options="s.id() as s.label() for s in suffix_list">
+                                    <option value="">[% l('(Unset)') %]</option>
+                                </select>
+                            </div>
+                            <div class="col-xs-1"></div>
+                            <div class="col-xs-5">
+                                <button class="btn btn-default center-block" ng-click="applyBatchCNValues()" type="button">Apply</button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+            </div> <!-- row -->
             <div class="row">
-                <div class="col-xs-1">[% l('Library') %]</div>
-                <div class="col-xs-1">[% l('Volumes') %]</div>
+                <div class="col-xs-1"><h5>[% l('Library') %]</h5></div>
+                <div class="col-xs-1"><h5>[% l('Volumes') %]</h5></div>
                 <div class="col-xs-10">
                     <div class="container-fluid">
                         <div class="row">
-                            <div class="col-xs-1">[% l('Classification') %]</div>
-                            <div class="col-xs-1">[% l('Prefix') %]</div>
-                            <div class="col-xs-3">[% l('Call Number') %]</div>
-                            <div class="col-xs-1">[% l('Suffix') %]</div>
-                            <div class="col-xs-1">[% l('Copies') %]</div>
+                            <div class="col-xs-1"><h5>[% l('Classification') %]</h5></div>
+                            <div class="col-xs-1"><h5>[% l('Prefix') %]</h5></div>
+                            <div class="col-xs-3"><h5>[% l('Call Number') %]</h5></div>
+                            <div class="col-xs-1"><h5>[% l('Suffix') %]</h5></div>
+                            <div class="col-xs-1"><h5>[% l('Copies') %]</h5></div>
                             <div class="col-xs-5">
                                 <div class="container-fluid">
                                     <div class="row">
-                                        <div class="col-xs-6">[% l('Barcode') %]</div>
-                                        <div class="col-xs-3">[% l('Copy #') %]</div>
-                                        <div class="col-xs-3">[% l('Part') %]</div>
+                                        <div class="col-xs-6"><h5>[% l('Barcode') %]</h5></div>
+                                        <div class="col-xs-3"><h5>[% l('Copy #') %]</h5></div>
+                                        <div class="col-xs-3"><h5>[% l('Part') %]</h5></div>
                                     </div>
                                 </div>
                             </div>
@@ -34,7 +65,7 @@
         </div> <!-- container -->
 
     </accordion-group>
-    <accordion-group heading="Copy Editor" is-open="show_copies">
+    <accordion-group heading="Copy Attributes" is-open="show_copies">
 
         <ul ng-model="copytab" class="nav nav-tabs">
           <li ng-class="{active : copytab == 'working'}">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Circulate?') %]</b>
+                                        <h5>[% l('Circulate?') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Circulation Library') %]</b>
+                                        <h5>[% l('Circulation Library') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Shelving Location') %]</b>
+                                        <h5>[% l('Shelving Location') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Circulation Modifier') %]</b>
+                                        <h5>[% l('Circulation Modifier') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Circulate as Type') %]</b>
+                                        <h5>[% l('Circulate as Type') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Holdable?') %]</b>
+                                        <h5>[% l('Holdable?') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Loan Duration') %]</b>
+                                        <h5>[% l('Loan Duration') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Fine Level') %]</b>
+                                        <h5>[% l('Fine Level') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Age-based Hold Protection') %]</b>
+                                        <h5>[% l('Age-based Hold Protection') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Status') %]</b>
+                                        <h5>[% l('Status') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Reference?') %]</b>
+                                        <h5>[% l('Reference?') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('OPAC Visible?') %]</b>
+                                        <h5>[% l('OPAC Visible?') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Price') %]</b>
+                                        <h5>[% l('Price') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Cost') %]</b>
+                                        <h5>[% l('Cost') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Deposit?') %]</b>
+                                        <h5>[% l('Deposit?') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Deposit Amount') %]</b>
+                                        <h5>[% l('Deposit Amount') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
 
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Quality') %]</b>
+                                        <h5>[% l('Quality') %]</h5>
                                     </div>
                                 </div>
                                 <div class="row">
                             <div class="container-fluid"> <!-- third column -->
                                 <div class="row">
                                     <div class="col-md-12">
-                                        <b>[% l('Statistical Catagories') %]</b>
+                                        <h5>[% l('Statistical Catagories') %]</h5>
                                     </div>
                                 </div>
                             </div>
index 33c1928..cbad7dc 100644 (file)
@@ -49,16 +49,10 @@ function(egCore , $q) {
     };
 
     service.get_prefixes = function(org) {
-        if (egCore.env.acnp)
-            return $q.when(egCore.env.acnp.list);
-
         return egCore.pcrud.search('acnp',
             {owning_lib : egCore.org.fullPath(org, true)},
             null, {atomic : true}
-        ).then(function(list) {
-            egCore.env.absorbList(list, 'acnp');
-            return list;
-        });
+        );
 
     };
 
@@ -70,16 +64,10 @@ function(egCore , $q) {
     };
 
     service.get_suffixes = function(org) {
-        if (egCore.env.acns)
-            return $q.when(egCore.env.acns.list);
-
         return egCore.pcrud.search('acns',
             {owning_lib : egCore.org.fullPath(org, true)},
             null, {atomic : true}
-        ).then(function(list) {
-            egCore.env.absorbList(list, 'acns');
-            return list;
-        });
+        );
 
     };
 
@@ -204,7 +192,7 @@ function(egCore , $q) {
                 $scope.updateBarcode = function () { $scope.copy.barcode($scope.barcode); $scope.copy.ischanged(1); };
                 $scope.updateCopyNo = function () { $scope.copy.copy_number($scope.copy_number); $scope.copy.ischanged(1); };
                 $scope.updatePart = function () {
-                    var p = angular.filter($scope.part_list, function (x) {
+                    var p = $scope.part_list.filter(function (x) {
                         return x.label() == $scope.part
                     });
                     if (p.length > 0) { // preexisting part
@@ -308,11 +296,6 @@ function(egCore , $q) {
                     });
                 }
 
-                $scope.classification = $scope.callNumber.label_class();
-                $scope.prefix = $scope.callNumber.prefix();
-                $scope.suffix = $scope.callNumber.suffix();
-
-                $scope.label = $scope.callNumber.label();
                 $scope.updateLabel = function () {
                     angular.forEach($scope.copies, function(cp) {
                         cp.call_number().label($scope.label);
@@ -320,6 +303,42 @@ function(egCore , $q) {
                     });
                 }
 
+                $scope.$watch('callNumber.prefix()', function (v) {
+                    if (typeof v != 'object') {
+                        $scope.prefix = $scope.prefix_list.filter(function (p) {
+                            return p.id() == v;
+                        })[0];
+                        $scope.callNumber.prefix($scope.prefix);
+                    }
+                });
+
+                $scope.$watch('callNumber.suffix()', function (v) {
+                    if (typeof v != 'object') {
+                        $scope.suffix = $scope.suffix_list.filter( function (s) {
+                            return s.id() == v;
+                        })[0];
+                        $scope.callNumber.suffix($scope.suffix);
+                    }
+                });
+
+                $scope.$watch('callNumber.label_class()', function (v) {
+                    if (typeof v != 'object') {
+                        $scope.classification = $scope.classification_list.filter(function (c) {
+                            return c.id() == v;
+                        })[0];
+                        $scope.callNumber.label_class($scope.classification);
+                    }
+                });
+
+                $scope.$watch('callNumber.label()', function (v) {
+                    $scope.label = v;
+                });
+
+                $scope.prefix = $scope.callNumber.prefix();
+                $scope.suffix = $scope.callNumber.suffix();
+                $scope.classification = $scope.callNumber.label_class();
+                $scope.label = $scope.callNumber.label();
+
                 $scope.copy_count = $scope.copies.length;
                 $scope.orig_copy_count = $scope.copy_count;
 
@@ -503,6 +522,26 @@ function($scope , $q , $routeParams , $location , $timeout , egCore , egNet , eg
         $scope.completed_copies = [];
         $scope.location_orgs = [];
         $scope.location_cache = {};
+        $scope.batch = {};
+
+        $scope.applyBatchCNValues = function () {
+            if ($scope.data.tree) {
+                angular.forEach($scope.data.tree, function(cn_hash) {
+                    angular.forEach(cn_hash, function(copies) {
+                        angular.forEach(copies, function(cp) {
+                            if (typeof $scope.batch.classification != 'undefined' && $scope.batch.classification != '')
+                                cp.call_number().label_class($scope.batch.classification);
+                            if (typeof $scope.batch.prefix != 'undefined' && $scope.batch.prefix != '')
+                                cp.call_number().prefix($scope.batch.prefix);
+                            if (typeof $scope.batch.label != 'undefined' && $scope.batch.label != '')
+                                cp.call_number().label($scope.batch.label);
+                            if (typeof $scope.batch.suffix != 'undefined' && $scope.batch.suffix != '')
+                                cp.call_number().suffix($scope.batch.suffix);
+                        });
+                    });
+                });
+            }
+        }
 
         $scope.completedGridDataProvider = egGridDataProvider.instance({
             get : function(offset, count) {
@@ -592,6 +631,21 @@ function($scope , $q , $routeParams , $location , $timeout , egCore , egNet , eg
             $scope.workingGridDataProvider.refresh();
         });
 
+        $scope.suffix_list = [];
+        itemSvc.get_suffixes(egCore.auth.user().ws_ou()).then(function(list){
+            $scope.suffix_list = list;
+        });
+
+        $scope.prefix_list = [];
+        itemSvc.get_prefixes(egCore.auth.user().ws_ou()).then(function(list){
+            $scope.prefix_list = list;
+        });
+
+        $scope.classification_list = [];
+        itemSvc.get_classifications().then(function(list){
+            $scope.classification_list = list;
+        });
+
         $scope.$watch('completed_copies.length', function () {
             $scope.completedGridDataProvider.refresh();
         });