From c3e439ba4e52626a846563a89138fb1b1f191037 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 10 Jun 2014 15:58:55 -0400 Subject: [PATCH] patron display effeciency improvements (group trees, expire alert) Signed-off-by: Bill Erickson --- .../web/js/ui/default/staff/circ/patron/app.js | 57 +++++++++++----------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js index 28a79ac2fb..e1c8c0a1fd 100644 --- a/Open-ILS/web/js/ui/default/staff/circ/patron/app.js +++ b/Open-ILS/web/js/ui/default/staff/circ/patron/app.js @@ -18,24 +18,18 @@ angular.module('egPatronApp', ['ngRoute', 'ui.bootstrap', // fetch the org settings we care about during egStartup // and toss them into egCore.env as egCore.env.aous[name] = value. + // note: only load settings here needed by all tabs; load tab- + // specific settings from within their respective controllers egCore.env.classLoaders.aous = function() { return egCore.org.settings( [ 'circ.obscure_dob', 'ui.circ.show_billing_tab_on_bills', + 'circ.patron_expires_soon_warning' ]).then(function(settings) { egCore.env.aous = settings }); } - egCore.env.classLoaders.pgt = function() { - return egCore.pcrud.search('pgt', {parent : null}, - {flesh : -1, flesh_fields : {pgt : ['children']}} - ).then( - function(tree) {egCore.env.absorbTree(tree, 'pgt')} - ); - } - egCore.env.loadClasses.push('aous'); - egCore.env.loadClasses.push('pgt'); // app-globally modify the default flesh fields for // fleshed user retrieval @@ -249,6 +243,8 @@ function($q , $timeout , $location , egCore, egUser , $locale) { // resolves to true if the patron account has expired or will // expire soon, based on YAOUS circ.patron_expires_soon_warning + // note: returning a promise is no longer strictly necessary + // (no more async activity) if the calling function is changed too. service.testExpire = function() { var expire = Date.parse(service.current.expire_date()); @@ -256,20 +252,15 @@ function($q , $timeout , $location , egCore, egUser , $locale) { return $q.when(service.patronExpired = true); } - // account not yet expired, see if it will expire soon - return egCore.org.settings('circ.patron_expires_soon_warning') - .then(function(set) { - - var soon = set['circ.patron_expires_soon_warning']; - if (Number(soon)) { - var preExpire = new Date(); - preExpire.setDate(preExpire.getDate() + Number(soon)); - if (expire < preExpire) - return service.patronExpiresSoon = true; - } + var soon = egCore.env.aous['circ.patron_expires_soon_warning']; + if (Number(soon)) { + var preExpire = new Date(); + preExpire.setDate(preExpire.getDate() + Number(soon)); + if (expire < preExpire) + return $q.when(service.patronExpiresSoon = true); + } - return false; - }); + return $q.when(false); } // resolves to true if there is any aspect of the patron account @@ -652,13 +643,21 @@ function($scope, $q, $routeParams, $timeout, $window, $location, egCore, $scope.patronSearchGridProvider = provider; - // typeahead doesn't filter correctly with full hash objects, so - // trim them down to just name and id. This would allow us to use - // full objects (egCore.idl.toHash()) instead of manually creating - // objects... maybe later. - // http://stackoverflow.com/questions/18429967/angularjs-ui-typeahead-match-on-leading-characters - $scope.profiles = egCore.env.pgt.list.map( - function(grp) {return {name : grp.name(), id : grp.id() }}) + if (egCore.env.pgt) { + $scope.profiles = egCore.env.pgt.list.map( + function(grp) {return {name : grp.name(), id : grp.id() }}) + } else { + + egCore.pcrud.search('pgt', {parent : null}, + {flesh : -1, flesh_fields : {pgt : ['children']}} + ).then( + function(tree) { + egCore.env.absorbTree(tree, 'pgt') + $scope.profiles = egCore.env.pgt.list.map( + function(grp) {return {name : grp.name(), id : grp.id() }}) + } + ); + } $scope.org_units = egCore.env.aou.list.map( function(org) {return {shortname : org.shortname(), id : org.id() }}) -- 2.11.0