web staff: checkin continued
authorBill Erickson <berick@esilibrary.com>
Wed, 27 Nov 2013 14:36:21 +0000 (09:36 -0500)
committerBill Erickson <berick@esilibrary.com>
Wed, 27 Nov 2013 14:36:21 +0000 (09:36 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/circ/checkin/index.tt2
Open-ILS/src/templates/staff/circ/checkin/t_checkin_table.tt2
Open-ILS/src/templates/staff/circ/patron/t_event_override_dialog.tt2
Open-ILS/src/templates/staff/parts/alert_dialog.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/parts/confirm_dialog.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/circ/checkin/app.js
Open-ILS/web/js/ui/default/staff/services/ui.js

index 135a96e..08095e5 100644 (file)
@@ -24,7 +24,8 @@
   <div class="col-lg-10">
     <div class="pad-horiz">
       <form ng-submit="checkin(checkinArgs)">
-        <input focus-me="focusMe" ng-model="checkinArgs.copy_barcode" 
+        <input focus-me="focusMe" blur-me="blurMe" 
+          ng-model="checkinArgs.copy_barcode" 
           id="patron-checkin-barcode" type="text"/> 
         <span class="pad-horiz"></span>
         <input type="submit" value="[% l('Submit') %]"/>
 
 [% INCLUDE 'staff/circ/checkin/t_checkin_table.tt2' %]
 
+<!-- load small, commonly used dialogs inline -->
+<script type="text/ng-template" id="uncat_alert_dialog">
+  [% INCLUDE 'staff/parts/alert_dialog.tt2' dialog_body=
+    l('Copy "{{args.copy_barcode}}" was mis-scanned or is not cataloged') %]
+</script>
+
 
 [% END %]
index 37c31f7..ad6a227 100644 (file)
@@ -24,7 +24,7 @@ checkins.setColumns([
 ])">
 </div>
 
-<div class="row">
+<div class="row" ng-cloak>
   <div class="col-lg-12">
     <table class="table table-hover table-condensed table-striped">
       <thead>
index c2f2569..7ff0a79 100644 (file)
@@ -17,7 +17,7 @@
       <div class="modal-footer">
         <i>[% |l %]
 If overridden, subsequent checkouts during this patron's session will
-auto-override this event[% END %]</i>
+auto-override this event[% END %]</i><!--'vim-->
         <br/><br/>
         <input type="submit" class="btn btn-primary" 
             value="[% l('Force Checkout?') %]"/>
diff --git a/Open-ILS/src/templates/staff/parts/alert_dialog.tt2 b/Open-ILS/src/templates/staff/parts/alert_dialog.tt2
new file mode 100644 (file)
index 0000000..ffb1a9f
--- /dev/null
@@ -0,0 +1,19 @@
+<!-- 
+  Generic alert dialog.
+  The only user action allowed is the 'OK' button.
+-->
+<div class="modal-dialog">
+  <div class="modal-content">
+    <div class="modal-header">
+      <button type="button" class="close" 
+        ng-click="ok()" aria-hidden="true">&times;</button>
+      <h4 class="modal-title alert alert-danger">[% l('Alert') %]</h4>
+    </div>
+    <div class="modal-body">[% dialog_body %]</div>
+    <div class="modal-footer">
+      [% dialog_footer %]
+      <input type="submit" class="btn btn-primary" 
+        ng-click="ok()" value="[% l('OK') %]"/>
+    </div>
+  </div> <!-- modal-content -->
+</div> <!-- modal-dialog -->
diff --git a/Open-ILS/src/templates/staff/parts/confirm_dialog.tt2 b/Open-ILS/src/templates/staff/parts/confirm_dialog.tt2
new file mode 100644 (file)
index 0000000..9502c73
--- /dev/null
@@ -0,0 +1,25 @@
+<!--
+  Generic confirmation dialog
+  User can click OK -> $scope.ok() or Cancel -> $scope.cancel()
+-->
+<form class="form-validated" novalidate ng-submit="ok()">
+  <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>
+        [% IF dialog_title %] 
+          <h4 class="modal-title">[% dialog_title %]</h4> 
+        [% END %]
+      </div>
+      [% IF dialog_body %]
+        <div class="modal-body">[% dialog_body %]</div>
+      [% END %]
+      <div class="modal-footer">
+        [% dialog_footer %]
+        <input type="submit" class="btn btn-primary" value="[% l('OK') %]"/>
+        <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+      </div>
+    </div> <!-- modal-content -->
+  </div> <!-- modal-dialog -->
+</form>
index c319f88..dd57d36 100644 (file)
@@ -20,10 +20,10 @@ function($q,  egList,  egNet,  egAuth,  egUser,  egEnv,  egOrg,  egList) {
 
 /**
  * Manages checkin
- * */
+ */
 .controller('CheckinCtrl',
-       ['$scope','egStartup','checkinSvc','egNet','egAuth',
-function($scope,  egStartup,  checkinSvc,  egNet,  egAuth) {
+       ['$scope','$modal','egStartup','checkinSvc','egNet','egAuth',
+function($scope,  $modal,  egStartup,  checkinSvc,  egNet,  egAuth) {
 
     // run egStartup here since it's not handled via resolver
     egStartup.go().then(
@@ -36,8 +36,12 @@ function($scope,  egStartup,  checkinSvc,  egNet,  egAuth) {
     $scope.checkins = checkinSvc.checkins;
 
     $scope.checkin = function(args) {
-        performCheckin(angular.copy(args));
-        args.copy_barcode = ''; // reset UI
+        if (args && args.copy_barcode) {
+            performCheckin(angular.copy(args));
+            args.copy_barcode = ''; // reset UI
+        } 
+
+        $scope.focusMe = true;
     }
 
     function performCheckin(args, override) {
@@ -60,13 +64,14 @@ function($scope,  egStartup,  checkinSvc,  egNet,  egAuth) {
     }
 
     function handleCheckinResponse(evt, args, override) {
-
         switch (evt.textcode) {
             case 'SUCCESS':
             case 'ROUTE_ITEM':
-            case 'ASSET_COPY_NOT_FOUND':
                 checkinSvc.checkins.items.push(evt);
                 break;
+            case 'ASSET_COPY_NOT_FOUND':
+                openAlertDialog('uncat_alert_dialog', evt, args);
+                break;
             default:
                 console.warn('unhandled checkin response : ' + evt.textcode);
                 console.debug('checkin: ' + js2JSON(evt));
@@ -75,5 +80,20 @@ function($scope,  egStartup,  checkinSvc,  egNet,  egAuth) {
                 $scope.checkins.items.push(evt);
         }
     }
+
+    function openAlertDialog(id, evt, args) {
+        // avoid unintended checkins while the dialog is open
+        $scope.blurMe = true;
+        $modal.open({
+            templateUrl: id,
+            controller: 
+                ['$scope', '$modalInstance', 
+                function($scope, $modalInstance) {
+                $scope.args = args;
+                $scope.ok = function() {$modalInstance.close()}
+            }]
+        }).result.then(function() {$scope.focusMe = true});
+    }
+
 }])
 
index 786750f..4a9d892 100644 (file)
@@ -25,6 +25,29 @@ function($timeout, $parse) {
     };
 }])
 
+/**
+ * <input blur-me="pleaseBlurMe"/>
+ * $scope.pleaseBlurMe = true
+ * Useful for de-focusing when no other obvious focus target exists
+ */
+.directive('blurMe', 
+['$timeout', '$parse', 
+function($timeout, $parse) {
+    return {
+        link: function(scope, element, attrs) {
+            var model = $parse(attrs.blurMe);
+            scope.$watch(model, function(value) {
+                if(value === true) 
+                    $timeout(function() {element[0].blur()});
+            });
+            element.bind('focus', function() {
+                scope.$apply(model.assign(scope, false));
+            })
+        }
+    };
+}])
+
+
 // <input select-me="iWantToBeSelected"/>
 // $scope.iWantToBeSelected = true;
 .directive('selectMe',