webstaff: make iss holding_type and adhoc orthogonal concepts
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 2 Jun 2017 21:10:54 +0000 (17:10 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 2 Jun 2017 21:10:54 +0000 (17:10 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/templates/staff/serials/t_holding_code_dialog.tt2
Open-ILS/web/js/ui/default/staff/serials/directives/view-items-grid.js
Open-ILS/web/js/ui/default/staff/serials/services/core.js

index 60bd636..f792a9c 100644 (file)
       <select
         class="form-control"
           ng-model="type"
-          ng-init='types=[{n:"basic",l:"[%l('Basic')%]"},{n:"supplement",l:"[%l('Supplement')%]"},{n:"index",l:"[%l('Index')%]"},{n:"adhoc",l:"[%l('Ad Hoc')%]"}]'
+          ng-init='types=[{n:"basic",l:"[%l('Basic')%]"},{n:"supplement",l:"[%l('Supplement')%]"},{n:"index",l:"[%l('Index')%]"}]'
           ng-options='t.n as t.l for t in types'>
       </select>
     </div>
   </div>
+  <div class="row">
+    <div class="col-md-3">
+      <b>[% l('Ad hoc issue?') %]</b>
+    </div>
+    <div class="col-md-1">
+      <input type="checkbox" ng-model="args.adhoc">
+    </div>
+  </div>
 
-  <div ng-show="type=='adhoc'">
+  <div ng-show="args.adhoc">
   <div class="pad-vert row">
     <div class="col-md-3">
       <b>[% l('Issuance Label') %]</b>
@@ -37,7 +45,7 @@
   </div>
   </div>
 
-  <div ng-hide="type=='adhoc'">
+  <div ng-hide="args.adhoc">
   <div class="row container" ng-if="args.enums.length">
     <hr/>
     <h2>[% l('Enumeration labels') %]</h2>
index 9273beb..d7250fc 100644 (file)
@@ -96,9 +96,9 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF
                     title    : egCore.strings.SERIALS_EDIT_SISS_HC,
                     curr_iss : egCore.idl.fromHash('siss',item.issuance),
                     label    : item.issuance.label,
-                    type     : item.issuance.type ? item.issuance.type : 'adhoc'
+                    type     : item.issuance.type ? item.issuance.type : 'basic'
                 }).then(function(result) {
-                    if (result.type != 'adhoc') {
+                    if (result.adhoc) {
                         item.issuance.holding_code = JSON.stringify(result.holding_code);
                         item.issuance.holding_type = result.type;
                     } else {
@@ -171,16 +171,16 @@ function($scope , $q , egSerialsCoreSvc , egCore , egGridDataProvider , orderByF
     $scope.following_issuance = function (items) {
         return egSerialsCoreSvc.new_holding_code({
             title : egCore.strings.SERIALS_ISSUANCE_ADD,
-            type  : 'adhoc',
             prev_iss : egCore.idl.fromHash('siss',items[0].issuance)
         }).then(function(hc) {
-            if (hc.type == 'adhoc') {
+            if (hc.adhoc) {
                 var new_iss = new egCore.idl.siss();
                 new_iss.creator( egCore.auth.user().id() );
                 new_iss.editor( egCore.auth.user().id() );
                 new_iss.date_published( hc.date.toISOString() );
                 new_iss.subscription( $scope.ssubId );
                 new_iss.label( hc.label );
+                new_iss.holding_type( hc.type );
 
                 return egCore.pcrud.create(new_iss).then(function(issuance) {
                     var new_item = new egCore.idl.sitem();
index c3ecdfa..82c6e1c 100644 (file)
@@ -296,13 +296,14 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
         var date = args.date;
         var prev_iss = args.prev_iss;
         var curr_iss = args.curr_iss;
+        var adhoc = false;
         var link = '1.1';
 
         var sub = service.get_ssub(service.subId);
         if (!sub) return args;
 
         var scap;
-        if (prev_iss) { // we're predicting
+        if (prev_iss && prev_iss.holding_code()) { // we're predicting
             var old_link_parts = JSON.parse(prev_iss.holding_code())[3].split('.');
             var olink = old_link_parts[0];
             var oseq = parseInt(old_link_parts[1]) + 1;
@@ -329,6 +330,9 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                 });
                 if (angular.isArray(tmp) && tmp[0]) scap = tmp[0];
             }
+            if (!curr_iss.holding_code()) {
+                adhoc = true;
+            }
 
             date = new Date(curr_iss.date_published());
         } else {
@@ -418,7 +422,8 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
             enums        : enums,
             chrons       : chrons,
             others       : others,
-            freq         : freq
+            freq         : freq,
+            adhoc        : adhoc
         };
     }
 
@@ -442,7 +447,8 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                 $scope.save_label = options.save_label;
                 $scope.pubdate = options.date;
                 $scope.type = options.type || 'basic';
-                $scope.args = {};
+                $scope.args = { adhoc : false };
+                if (options.adhoc) $scope.args.adhoc = true;
 
                 function refresh (n,o) {
                     if (n && o && n !== o) {
@@ -450,7 +456,7 @@ function(egCore , orderByFilter , $q , $filter , $uibModal , ngToast , egConfirm
                             type : $scope.type,
                             date : $scope.pubdate,
                             prev_iss : options.prev_iss,
-                            curr_iss : options.curr_iss
+                            curr_iss : options.curr_iss,
                         });
 
                         if ($scope.args.type && $scope.type != $scope.args.type)