From bbf86eafe514ea3a5abc147a8117d9395f507292 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 13 May 2014 15:54:08 -0400 Subject: [PATCH] in-house-use UI Signed-off-by: Bill Erickson --- .../templates/staff/circ/in_house_use/index.tt2 | 79 ++++++++++++++ Open-ILS/src/templates/staff/navbar.tt2 | 6 ++ .../js/ui/default/staff/circ/in_house_use/app.js | 117 +++++++++++++++++++++ 3 files changed, 202 insertions(+) create mode 100644 Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 create mode 100644 Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js diff --git a/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 b/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 new file mode 100644 index 0000000000..6b87db2904 --- /dev/null +++ b/Open-ILS/src/templates/staff/circ/in_house_use/index.tt2 @@ -0,0 +1,79 @@ +[% + WRAPPER "staff/base.tt2"; + ctx.page_title = l("In-House Use"); + ctx.page_app = "egInHouseUseApp"; + ctx.page_ctrl = "InHouseUseCtrl"; +%] + +[% BLOCK APP_JS %] + + + +[% END %] + + + +
+
+ +
+
+ + +
+
+ +
+ +
+
+ + +
+ + + +
+ +
+
+
+ + + + + + + + + + +[% END %] diff --git a/Open-ILS/src/templates/staff/navbar.tt2 b/Open-ILS/src/templates/staff/navbar.tt2 index c2de8b846d..db4ffc9bbf 100644 --- a/Open-ILS/src/templates/staff/navbar.tt2 +++ b/Open-ILS/src/templates/staff/navbar.tt2 @@ -74,6 +74,12 @@ [% l('Verify Credentials') %] +
  • + + + [% l('Record In-House Use') %] + +
  • diff --git a/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js new file mode 100644 index 0000000000..5f7723eec7 --- /dev/null +++ b/Open-ILS/web/js/ui/default/staff/circ/in_house_use/app.js @@ -0,0 +1,117 @@ +angular.module('egInHouseUseApp', + ['ngRoute', 'egCoreMod', 'egUiMod', 'egGridMod']) + +.config(function($routeProvider, $locationProvider, $compileProvider) { + $locationProvider.html5Mode(true); + $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/); // grid export + + +}) + +.controller('InHouseUseCtrl', + ['$scope','egCore','egGridDataProvider','egConfirmDialog', +function($scope, egCore, egGridDataProvider , egConfirmDialog) { + + var countCap; + var countMax; + + egCore.startup.go().then(function() { + + // grab our non-cat types after startup + egCore.pcrud.search('cnct', + {owning_lib : + egCore.org.fullPath(egCore.auth.user().ws_ou(), true)}, + null, {atomic : true} + ).then(function(list) { + egCore.env.absorbList(list, 'cnct'); + $scope.nonCatTypes = list + }); + + // org settings for max and warning in-house-use counts + + egCore.org.settings([ + 'ui.circ.in_house_use.entry_cap', + 'ui.circ.in_house_use.entry_warn' + ]).then(function(set) { + countWarn = set['ui.circ.in_house_use.entry_warn'] || 20; + $scope.countMax = countMax = + set['ui.circ.in_house_use.entry_cap'] || 99; + }); + }); + + $scope.useFocus = true; + $scope.args = {noncat_type : 'barcode', num_uses : 1}; + var checkouts = []; + + var provider = egGridDataProvider.instance({}); + provider.get = function(offset, count) { + return provider.arrayNotifier(checkouts, offset, count); + } + + provider.itemFieldValue = provider.nestedItemFieldValue; + $scope.gridDataProvider = provider; + + // currently selected non-cat type + $scope.selectedNcType = function() { + if (!egCore.env.cnct) return null; // too soon + var type = egCore.env.cnct.map[$scope.args.noncat_type]; + return type ? type.name() : null; + } + + $scope.checkout = function(args) { + var coArgs = { + count : args.num_uses, + 'location' : egCore.auth.user().ws_ou() + }; + + if (args.noncat_type == 'barcode') { + + egCore.pcrud.search('acp', + {barcode : args.barcode, deleted : 'f'}, + { flesh : 3, + flesh_fields : { + acp : ['call_number','location'], + acn : ['record'], + bre : ['simple_record'] + }, + select : { bre : ['id'] } // avoid fleshing MARC + } + ).then(null, null, function(copy) { + coArgs.copyid = copy.id(); + + performCheckout( + 'open-ils.circ.in_house_use.create', + coArgs, {copy:copy} + ); + }); + + } else { + coArgs.non_cat_type = args.noncat_type; + performCheckout( + 'open-ils.circ.non_cat_in_house_use.create', + coArgs, {title : $scope.selectedNcType()} + ); + } + } + + function performCheckout(method, args, data) { + + // FIXME: make this API stream + egCore.net.request( + 'open-ils.circ', method, egCore.auth.token(), args + + ).then(function(resp) { + if (evt = egCore.evt.parse(resp)) return alert(evt); + + var item = {num_uses : resp.length}; + item.copy = data.copy; + item.title = data.title || + data.copy.call_number().record().simple_record().title(); + item.index = checkouts.length; + + checkouts.unshift(item); + provider.increment(); + }); + } + +}]) -- 2.11.0