</div>
<div class="col-md-2">
+ <!--
<input type="text" class="form-control"
placeholder="[% l('Profile Group') %]"
ng-model="searchArgs.profile"
typeahead="grp as grp.name for grp in profiles | filter:$viewValue"
typeahead-editable="false" />
- </div>
-
- <div class="col-md-2">
- <input type="text" class="form-control"
- placeholder="[% l('Home Library') %]"
- ng-model="searchArgs.home_ou"
- typeahead="org as org.shortname for org in org_units | filter:$viewValue"
- typeahead-editable="false" />
+ -->
+
+ <div class="btn-group patron-search-selector" dropdown>
+ <button type="button" class="btn btn-default dropdown-toggle">
+ <span style="padding-right: 5px;">{{searchArgs.profile.name() || "[% l('Profile Group') %]"}}</span>
+ <span class="caret"></span>
+ </button>
+ <ul class="dropdown-menu">
+ <li ng-repeat="grp in profiles">
+ <a href dropdown-toggle
+ style="padding-left: {{pgt_depth(grp) * 10 + 5}}px"
+ ng-click="searchArgs.profile = grp">{{grp.name()}}</a>
+ </li>
+ </ul>
+ </div>
+ </div>
+
+ <div class="col-md-2">
+ <eg-org-selector label="[% l('Home Library') %]"
+ selected="searchArgs.home_ou">
+ </eg-org-selector>
</div>
<div class="col-md-2">
]).then(function(settings) { egCore.env.aous = settings });
}
+ // local stat cats are displayed in the summary bar on each page.
egCore.env.classLoaders.actsc = function() {
return egCore.pcrud.search('actsc',
{owner : egCore.org.ancestors(
service.holds = [];
service.hold_ids = [];
service.checkout_overrides = {};
+ service.patron_stats = null;
service.hasAlerts = false;
service.alertsShown = false;
service.patronExpired = false;
}
service.resetPatronLists(); // initialize
- // sets the default user, fetching as necessary
- service.setDefault = function(id, user, force) {
+ // sets the primary display user, fetching data as necessary.
+ service.setPrimary = function(id, user, force) {
+ var user_id = id ? id : (user ? user.id() : null);
+
+ console.debug('setting primary user to: ' + user_id);
+
+ // avoid running multiple retrievals for the same patron, which
+ // can happen during dbl-click by maintaining a single running
+ // data retrieval promise
+ if (service.primaryUserPromise) {
+ if (service.primaryUserId == user_id) {
+ return service.primaryUserPromise.promise;
+ } else {
+ service.primaryUserPromise = null;
+ }
+ }
+
+ service.primaryUserPromise = $q.defer();
+ service.primaryUserId = user_id;
+
+ service.getPrimary(id, user, force)
+ .then(function() {
+ var p = service.primaryUserPromise;
+ service.primaryUserId = null;
+ // clear before resolution just to be safe.
+ service.primaryUserPromise = null;
+ p.resolve();
+ });
+
+ return service.primaryUserPromise.promise;
+ }
+
+ service.getPrimary = function(id, user, force) {
+
if (user) {
if (!force && service.current &&
service.current.id() == user.id()) {
if (patron_id) {
$scope.patron_id = patron_id;
- return patronSvc.setDefault($scope.patron_id)
+ return patronSvc.setPrimary($scope.patron_id)
.then(function() {return patronSvc.checkAlerts()})
.then(redirectToAlertPanel);
}
['$scope','$location','egCore','egConfirmDialog','egUser','patronSvc',
function($scope , $location , egCore , egConfirmDialog , egUser , patronSvc) {
$scope.selectMe = true; // focus text input
- patronSvc.setDefault(); // clear the default user
+ patronSvc.setPrimary(); // clear the default user
// jump to the patron checkout UI
function loadPatron(user_id) {
function() {return $scope.gridControls.selectedItems()},
function(list) {
if (list[0])
- patronSvc.setDefault(null, list[0]);
+ patronSvc.setPrimary(null, list[0]);
},
true
);
$scope.patronSearchGridProvider = provider;
if (egCore.env.pgt) {
- $scope.profiles = egCore.env.pgt.list.map(
- function(grp) {return {name : grp.name(), id : grp.id() }})
+ $scope.profiles = egCore.env.pgt.list;
} 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.profiles = egCore.env.pgt.list;
}
);
}
- $scope.org_units = egCore.env.aou.list.map(
- function(org) {return {shortname : org.shortname(), id : org.id() }})
+ // determine the tree depth of the profile group
+ $scope.pgt_depth = function(grp) {
+ var d = 0;
+ while (grp = egCore.env.pgt.map[grp.parent()]) d++;
+ return d;
+ }
$scope.applyShowExtras = function($event, bool) {
$scope.showExtras = bool;
angular.forEach(args, function(val, key) {
if (!val) return;
if (key == 'profile') {
- search.profile = {value : args.profile.id, group : 0};
- //search.profile = {value : search.profile, group : 0};
+ search.profile = {value : args.profile.id(), group : 0};
} else if (key == 'home_ou') {
- search.home_ou = args.home_ou.id; // passed separately
+ search.home_ou = args.home_ou.id(); // passed separately
} else if (key == 'inactive') {
search.inactive = val;
} else {
activeGrid.refresh();
// force a refresh of the user, since they may now
// have blocking penalties, etc.
- patronSvc.setDefault(patronSvc.current.id(), null, true);
+ patronSvc.setPrimary(patronSvc.current.id(), null, true);
});
}
);
activeGrid.refresh();
// force a refresh of the user, since they may now
// have blocking penalties, etc.
- patronSvc.setDefault(patronSvc.current.id(), null, true);
+ patronSvc.setPrimary(patronSvc.current.id(), null, true);
});
}
);