--- /dev/null
+<!-- 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">×</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>
* 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;
}
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
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());
}
}
// 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',