web staff: noncat checkouts
authorBill Erickson <berick@esilibrary.com>
Fri, 13 Dec 2013 22:16:06 +0000 (17:16 -0500)
committerBill Erickson <berick@esilibrary.com>
Fri, 13 Dec 2013 22:16:06 +0000 (17:16 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/patron/t_checkout.tt2
Open-ILS/src/templates/staff/circ/patron/t_checkout_table.tt2
Open-ILS/src/templates/staff/circ/patron/t_noncat_dialog.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/circ/patron/app.js

index d5d5174..a11700f 100644 (file)
             <span class="caret"></span>
           </button>
           <ul class="dropdown-menu">
-            <li><a href='' ng-click="checkoutArgs.type='barcode';focusMe=true">
+            <li><a href='' ng-click="checkoutArgs.noncat_type='barcode';focusMe=true">
               [% l('Barcode') %]</a>
             </li>
             <li class="divider"></li>
             <li><a href='' ng-repeat='type in nonCatTypes'
-              ng-click="checkoutArgs.type=type.id()">{{type.name()}}</a>
+              ng-click="checkoutArgs.noncat_type=type.id()">{{type.name()}}</a>
             </li>
           </ul>
         </div>
 
         <input focus-me="focusMe" class="form-control"
           ng-model="checkoutArgs.copy_barcode" 
-          ng-disabled="checkoutArgs.type != 'barcode'"
+          ng-disabled="checkoutArgs.noncat_type != 'barcode'"
           id="patron-checkout-barcode" type="text"/> 
 
         <input class="btn btn-default" type="submit" value="[% l('Submit') %]"/>
index 13c8480..86ae2ab 100644 (file)
@@ -11,7 +11,8 @@ COLUMNS = [
 {label => l('Title'),      name => 'payload.record.title', display => 1},
 {label => l('Author'),     name => 'payload.record.author', display => 1},
 {label => l('Call Number'),name => 'payload.copy.call_number.label', display => 1},
-{label => l('Alert Msg'),  name => 'payload.copy.alert_message' display => 1},
+{label => l('Alert Msg'),  name => 'payload.copy.alert_message', display => 1},
+{label => l('Noncat #'),   name => 'noncat_count' display => 1},
 ]
 %]
 
diff --git a/Open-ILS/src/templates/staff/circ/patron/t_noncat_dialog.tt2 b/Open-ILS/src/templates/staff/circ/patron/t_noncat_dialog.tt2
new file mode 100644 (file)
index 0000000..98bd966
--- /dev/null
@@ -0,0 +1,26 @@
+<!-- edit bucket dialog -->
+<form class="form-validated" novalidate ng-submit="ok(count)" name="form">
+  <div class="modal-dialog">
+    <div class="modal-content">
+      <div class="modal-header">
+        <button type="button" class="close" 
+          ng-click="cancel()" aria-hidden="true">&times;</button>
+        <h4 class="modal-title">
+          [% l('Enter the number of {{type.name()}} circulating') %]
+        </h4>
+      </div>
+      <div class="modal-body">
+        <div class="form-group">
+          <label for="noncat-count" class="sr-only">[% l('Count') %]</label>
+          <input type="number" class="form-control" focus-me='focusMe' required
+            id="noncat-title" ng-model="count" placeholder="[% l('Count...') %]"/>
+        </div>
+      <div class="modal-footer">
+        <input type="submit" class="btn btn-primary" 
+            ng-disabled="form.$invalid" value="[% l('OK') %]"/>
+        <button class="btn btn-warning" 
+          ng-click="cancel()">[% l('Cancel') %]</button>
+      </div>
+    </div> <!-- modal-content -->
+  </div> <!-- modal-dialog -->
+</form>
index 0cf69e2..006e25e 100644 (file)
@@ -451,23 +451,19 @@ function($scope,  $q,  egNet,  egAuth,  egEvent,  patronSvc) {
  * Manages checkout
  */
 .controller('PatronCheckoutCtrl',
-       ['$scope','$q','$modal','$routeParams','egNet','egAuth','egUser','patronSvc','egEnv','egPCRUD','egOrg',
-function($scope,  $q,  $modal,  $routeParams,  egNet,  egAuth,  egUser,  patronSvc,  egEnv,  egPCRUD,  egOrg) {
+       ['$scope','$q','$modal','$routeParams','egNet','egAuth','egUser',
+        'egIDL','patronSvc','egEnv','egPCRUD','egOrg',
+function($scope,  $q,  $modal,  $routeParams,  egNet,  egAuth,  egUser,  
+         egIDL,  patronSvc,  egEnv,  egPCRUD,  egOrg) {
     $scope.initTab('checkout', $routeParams.id);
 
     $scope.focusMe = true;
     $scope.checkouts = patronSvc.checkouts;
-    $scope.checkoutArgs = {type : 'barcode'};
+    $scope.checkoutArgs = {noncat_type : 'barcode'};
 
     $scope.selectedNcType = function() {
-        var type;
-        if ($scope.nonCatTypes) {
-            type = $scope.nonCatTypes.filter(
-                function(t) { 
-                    return t.id() == $scope.checkoutArgs.type;
-                }
-            )[0];
-        }
+        if (!egEnv.cnct) return null; // too soon
+        var type = egEnv.cnct.map[$scope.checkoutArgs.noncat_type];
         return type ? type.name() : null;
     }
 
@@ -491,15 +487,17 @@ function($scope,  $q,  $modal,  $routeParams,  egNet,  egAuth,  egUser,  patronS
         var type = args.type;
         var coArgs = angular.copy(args);
 
-        if (!args.copy_barcode) return;
+        if (coArgs.noncat_type == 'barcode') {
 
-        args.copy_barcode = ''; // reset for UI
-        delete coArgs.type; // not a valid API arg
+            if (!args.copy_barcode) return;
+            args.copy_barcode = ''; // reset UI
 
-        if (type == 'barcode') {
+            delete coArgs.noncat_type;
             performCheckout(coArgs);
+
         } else {
-            // noncat checkout
+            console.log('noncat..');
+            openNoncatDialog(coArgs);
         }
 
         $scope.focusMe; // return focus to barcode input
@@ -533,11 +531,20 @@ function($scope,  $q,  $modal,  $routeParams,  egNet,  egAuth,  egUser,  patronS
 
     function handleCheckoutResponse(evt, args, override) {
 
-        if (args.precat && evt.payload) {
-            evt.payload.record = {
-                title  : args.dummy_title,
-                author : args.dummy_author,
-                isbn   : args.dummy_isbn
+        if (evt.payload) {
+            if (args.precat) {
+                evt.payload.record = {
+                    title  : args.dummy_title,
+                    author : args.dummy_author,
+                    isbn   : args.dummy_isbn
+                };
+            } else if (args.noncat) {
+                evt.payload.record = {
+                    title : egEnv.cnct.map[args.noncat_type].name()
+                };
+                evt.noncat_count = args.noncat_count;
+                evt.payload.circ = new egIDL.circ();
+                evt.payload.circ.due_date(evt.payload.noncat_circ.duedate());
             }
         }
 
@@ -596,6 +603,33 @@ function($scope,  $q,  $modal,  $routeParams,  egNet,  egAuth,  egUser,  patronS
 
     // define our modal dialogs
 
+    function openNoncatDialog(coArgs) {
+        coArgs.noncat = true;
+        var type = egEnv.cnct.map[coArgs.noncat_type];
+
+        $modal.open({
+            templateUrl: './circ/patron/t_noncat_dialog',
+            controller: 
+                ['$scope', '$modalInstance',
+                function($scope, $modalInstance) {
+                $scope.focusMe = true;
+                $scope.type = type;
+                $scope.count = 1;
+                $scope.ok = function(count) { $modalInstance.close(count) }
+                $scope.cancel = function () { $modalInstance.dismiss() }
+            }],
+        }).result.then(
+            function(count) {
+                $scope.focusMe = true; // main barcode input
+                if (count) {
+                    // TODO: sanity check
+                    coArgs.noncat_count = count;
+                    performCheckout(coArgs);
+                }
+            }
+        );
+    }
+
     function openPrecatDialog(copy_barcode) {
         $modal.open({
             templateUrl: './circ/patron/t_precat_dialog',