From 31aa4a56919511db52af7d89d14190f3a3d1c15f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 16 Oct 2015 22:21:14 +0000 Subject: [PATCH] webstaff: teach egOrgSelector how to be sticky In order to make the org unit selector in the holdings view to be "sticky", the egOrgSelector directive now accepts an optional stickySetting attribute specifying the name of a preference key for storing the last selected org unit. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../staff/cat/catalog/t_holdings.tt2 | 2 +- .../web/js/ui/default/staff/services/ui.js | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 index 5a79b1f715..e1eaa084f2 100644 --- a/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 +++ b/Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2 @@ -4,7 +4,7 @@
[% l('Show holdings at or below') %] - +
diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index fefe0c41f1..d52382cfb6 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -290,7 +290,11 @@ function($modal, $interpolate) { onchange : '=', // optional primary drop-down button label - label : '@' + label : '@', + + // optional name of settings key for persisting + // the last selected org unit + stickySetting : '@' }, // any reason to move this into a TT2 template? @@ -310,8 +314,8 @@ function($modal, $interpolate) { + '' + '', - controller : ['$scope','$timeout','egOrg','egAuth', - function($scope , $timeout , egOrg , egAuth) { + controller : ['$scope','$timeout','egOrg','egAuth','egCore', + function($scope , $timeout , egOrg , egAuth , egCore) { if ($scope.alldisabled) { $scope.disable_button = $scope.alldisabled == 'true' ? true : false; @@ -321,6 +325,7 @@ function($modal, $interpolate) { $scope.egOrg = egOrg; // for use in the link function $scope.egAuth = egAuth; // for use in the link function + $scope.hatch = egCore.hatch // for use in the link function // avoid linking the full fleshed tree to the scope by // tossing in a flattened list. @@ -340,6 +345,9 @@ function($modal, $interpolate) { $scope.orgChanged = function(org) { $scope.selected = egOrg.get(org.id); + if ($scope.stickySetting) { + egCore.hatch.setLocalItem($scope.stickySetting, org.id); + } if ($scope.onchange) $scope.onchange($scope.selected); } @@ -357,6 +365,13 @@ function($modal, $interpolate) { } ); + if (scope.stickySetting) { + var orgId = scope.hatch.getLocalItem(scope.stickySetting); + if (orgId) { + scope.selected = scope.egOrg.get(orgId); + } + } + if (!scope.selected && !scope.nodefault) scope.selected = scope.egOrg.get(scope.egAuth.user().ws_ou()); } -- 2.43.2