webstaff: Allow adding new volumes to libaries that were not selected in the holdings...
authorMike Rylander <mrylander@gmail.com>
Fri, 24 Mar 2017 15:35:53 +0000 (11:35 -0400)
committerMike Rylander <mrylander@gmail.com>
Mon, 17 Apr 2017 19:11:41 +0000 (15:11 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>

Open-ILS/src/templates/staff/cat/volcopy/t_edit.tt2
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index 30ac2d3..5266734 100644 (file)
@@ -32,7 +32,7 @@
                     </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>
+                        <button class="btn btn-default center-block" ng-click="applyBatchCNValues()" type="button">[% l('Apply') %]</button>
                     </div>
                 </div>
             </div>
             allcopies="data.copies"
             struct="data.tree[lib]">
         </eg-vol-edit>
+        <hr/>
+        <div>
+            <eg-org-selector alldisabled="{{record_id == 0}}" selected="new_lib_to_add" onchange="changeNewLib" disable-test="cant_have_vols"></eg-org-selector>
+            <button class="btn btn-default" ng-click="addLibToStruct()" type="button">[% l('Add volume') %]</button>
+        </div>
     </div>
 
 </div>
index 92c2201..23bd2e8 100644 (file)
@@ -728,7 +728,7 @@ function(egCore , $q) {
 
                             $scope.struct[cn.id()] = [cp];
                             $scope.allcopies.push(cp);
-                            if (!scope.defaults.classification) {
+                            if (!$scope.defaults.classification) {
                                 egCore.org.settings(
                                     ['cat.default_classification_scheme'],
                                     cn.owning_lib()
@@ -795,6 +795,40 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
         }
     };
 
+    $scope.new_lib_to_add = egCore.org.get(egCore.auth.user().ws_ou());
+    $scope.changeNewLib = function (org) {
+        $scope.new_lib_to_add = org;
+    }
+    $scope.addLibToStruct = function () {
+        var newLib = $scope.new_lib_to_add;
+        var cn = new egCore.idl.acn();
+        cn.id( --itemSvc.new_cn_id );
+        cn.isnew( true );
+        cn.prefix( $scope.defaults.prefix || -1 );
+        cn.suffix( $scope.defaults.suffix || -1 );
+        cn.label_class( $scope.defaults.classification || 1 );
+        cn.owning_lib( newLib.id() );
+        cn.record( $scope.record_id );
+
+        var cp = itemSvc.generateNewCopy(
+            cn,
+            newLib.id(),
+            $scope.fast_add,
+            true
+        );
+
+        $scope.data.addCopy(cp);
+
+        if (!$scope.defaults.classification) {
+            egCore.org.settings(
+                ['cat.default_classification_scheme'],
+                cn.owning_lib()
+            ).then(function (val) {
+                cn.label_class(val['cat.default_classification_scheme']);
+            });
+        }
+    }
+
     $scope.embedded = ($routeParams.mode && $routeParams.mode == 'embedded') ? true : false;
     $scope.edit_templates = ($location.path().match(/edit_template/)) ? true : false;