From c9f3af1351b2fd60da8fd4d009fe096caf16e524 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 28 Oct 2013 09:11:40 -0400 Subject: [PATCH] ff staff web : generate org selector by perms Signed-off-by: Bill Erickson --- Open-ILS/src/templates/staff/fulfillment/index.tt2 | 1 + .../web/js/ui/default/staff/fulfillment/app.js | 28 ++++++++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Open-ILS/src/templates/staff/fulfillment/index.tt2 b/Open-ILS/src/templates/staff/fulfillment/index.tt2 index be86b3f194..ce0c3125d5 100644 --- a/Open-ILS/src/templates/staff/fulfillment/index.tt2 +++ b/Open-ILS/src/templates/staff/fulfillment/index.tt2 @@ -101,5 +101,6 @@ [% INCLUDE "staff/t_base_js.tt2" %] + diff --git a/Open-ILS/web/js/ui/default/staff/fulfillment/app.js b/Open-ILS/web/js/ui/default/staff/fulfillment/app.js index 2ed28fe1ee..78db9fb9ea 100644 --- a/Open-ILS/web/js/ui/default/staff/fulfillment/app.js +++ b/Open-ILS/web/js/ui/default/staff/fulfillment/app.js @@ -8,7 +8,7 @@ */ -angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod']) +angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod', 'egUserMod']) .config(function($routeProvider, $locationProvider) { @@ -48,9 +48,13 @@ angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod']) ['$rootScope', 'egOrg', 'egAuth', function($rootScope, egOrg, egAuth) { return { - orgList : function() { - // we want all orgs - return egOrg.list(); + orgList : function(newList) { + if (newList) { + this._orgList = newList; + } else if (!this._orgList) { + this._orgList = egOrg.list(); + } + return this._orgList; }, // currently selected org unit @@ -78,12 +82,22 @@ function($rootScope, egOrg, egAuth) { * selector. */ .controller('FFMainCtrl', -['$scope', '$route', 'egStartup', 'ffService', 'egAuth', -function ($scope, $route, egStartup, ffService, egAuth) { +['$scope', '$route', 'egStartup', 'ffService', 'egAuth', 'egUser', +function ($scope, $route, egStartup, ffService, egAuth, egUser) { // run after startup so we can guarantee access to org units egStartup.go().then(function() { - $scope.ffService = ffService; + // after startup, we want to fetch the perm orgs for our + // logged in user. From there, we can drive the org selector + // TODO: we need an FF-specific perm, since login perms are + // all or none. + egUser.hasPermAt('STAFF_LOGIN') + .then(function(orgList) { + console.log('setting login list at ' + + orgList.map(function(org) { return org.shortname() })); + ffService.orgList(orgList); + $scope.ffService = ffService; + }); }); // change the selected org unit and re-draw the page -- 2.11.0