);
INSERT INTO config.copy_tag_type (code, label, owner) VALUES ('bookplate', 'Digital Bookplate', 1);
+
+INSERT INTO config.org_unit_setting_type
+ (name, label, description, grp, datatype)
+VALUES (
+ 'ui.staff.max_recent_patrons',
+ oils_i18n_gettext(
+ 'ui.staff.max_recent_patrons',
+ 'Number of Retrievable Recent Patrons',
+ 'coust',
+ 'label'
+ ),
+ oils_i18n_gettext(
+ 'ui.staff.max_recent_patrons',
+ 'Number of most recently accessed patrons that can be re-retrieved ' ||
+ 'in the staff client. A value of 0 or less disables the feature',
+ 'coust',
+ 'description'
+ ),
+ 'circ',
+ 'integer'
+);
+
+-- For backwards compat apply a max count value of 1 globally.
+INSERT INTO actor.org_unit_setting (org_unit, name, value)
+ SELECT id, 'ui.staff.max_recent_patrons', '1'
+ FROM actor.org_unit WHERE parent_ou IS NULL;
+
+
BEGIN;
-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
INSERT INTO config.org_unit_setting_type
(name, label, description, grp, datatype)
VALUES (
),
oils_i18n_gettext(
'ui.staff.max_recent_patrons',
- 'Number of most recently accessed patrons that can be re-retrieved in the staff client. A value of 0 or less disables the feature',
+ 'Number of most recently accessed patrons that can be re-retrieved ' ||
+ 'in the staff client. A value of 0 or less disables the feature',
'coust',
'description'
),
- 'opac',
+ 'circ',
'integer'
);
-
+-- For backwards compat apply a max count value of 1 globally.
+INSERT INTO actor.org_unit_setting (org_unit, name, value)
+ SELECT id, 'ui.staff.max_recent_patrons', '1'
+ FROM actor.org_unit WHERE parent_ou IS NULL;
COMMIT;
return $q.when();
}
+ service.getRecentPatrons = function() {
+ if (service.maxRecentPatrons < 1) return $q.when();
+ var patrons =
+ egCore.hatch.getLoginSessionItem('eg.circ.recent_patrons') || [];
+
+ var deferred = $q.defer();
+ function getNext() {
+ if (patrons.length == 0) {
+ deferred.resolve();
+ return;
+ }
+ console.debug('getRecentPatrons fetching ' + patrons[0]);
+ egUser.get(patrons[0]).then(function(usr) { // fetch first user
+ deferred.notify(usr);
+ patrons.splice(0, 1); // remove first user from list
+ getNext();
+ });
+ }
+
+ getNext();
+ return deferred.promise;
+ }
+
+
// sets the primary display user, fetching data as necessary.
service.setPrimary = function(id, user, force) {
var user_id = id ? id : (user ? user.id() : null);
if (!user_id) return $q.reject();
// when loading a new patron, update the last patron setting
- if (!service.current || service.current.id() != user_id)
- egCore.hatch.setLoginSessionItem('eg.circ.last_patron', user_id);
+ if (service.maxRecentPatrons > 0 &&
+ (!service.current || service.current.id() != user_id)) {
+ var patrons =
+ egCore.hatch.getLoginSessionItem('eg.circ.recent_patrons') || [];
+ patrons.splice(0, 0, user_id); // put this user at front
+ patrons.splice(service.maxRecentPatrons, 1); // remove excess
+ egCore.hatch.setLoginSessionItem('eg.circ.recent_patrons', patrons);
+ }
// avoid running multiple retrievals for the same patron, which
// can happen during dbl-click by maintaining a single running
$scope.aous = egCore.env.aous;
$scope.auth_user_id = egCore.auth.user().id();
+ // max recents setting is loaded during startup.
+ // cache it in a local variable for ease of access.
+ egCore.org.settings('ui.staff.max_recent_patrons').then(function(s) {
+ patronSvc.maxRecentPatrons = s['ui.staff.max_recent_patrons'] || 0;
+ });
+
if (patron_id) {
$scope.patron_id = patron_id;
return patronSvc.setPrimary($scope.patron_id)
home_ou : egCore.org.tree()
};
+ $scope.showRecentPatrons =
+ Boolean($location.path().match(/patron\/recent/));
+
// last used patron search form element
var lastFormElement;
var propagate;
var propagate_inactive;
- if (patronSvc.lastSearch) {
+ if (patronSvc.lastSearch && !$scope.showRecentPatrons) {
propagate = patronSvc.lastSearch.search;
// home_ou needs to be treated specially
propagate.home_ou = {
provider.get = function(offset, count) {
var deferred = $q.defer();
+ if ($scope.showRecentPatrons)
+ return patronSvc.getRecentPatrons();
+
var fullSearch;
if (patronSvc.urlSearch) {
fullSearch = patronSvc.urlSearch;