*/
-angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod'])
+angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod', 'egUserMod'])
.config(function($routeProvider, $locationProvider) {
['$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
* 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