<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 %]
])">
</div>
-<div class="row">
+<div class="row" ng-cloak>
<div class="col-lg-12">
<table class="table table-hover table-condensed table-striped">
<thead>
<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?') %]"/>
--- /dev/null
+<!--
+ 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">×</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 -->
--- /dev/null
+<!--
+ 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">×</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>
/**
* 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(
$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) {
}
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));
$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});
+ }
+
}])
};
}])
+/**
+ * <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',