2 * App to drive the base page.
7 angular.module('egUserPermsEditor',
8 ['ngRoute', 'ui.bootstrap', 'egCoreMod','egUiMod'])
10 .config(['$routeProvider','$locationProvider','$compileProvider',
11 function($routeProvider , $locationProvider , $compileProvider) {
13 $locationProvider.html5Mode(true);
14 $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|blob):/);
15 var resolver = {delay : function(egStartup) {return egStartup.go()}};
17 $routeProvider.when('/admin/user_perms', {
18 templateUrl: './admin/t_user_perms_lookup',
19 controller: 'UserPermsLookupCtrl',
23 $routeProvider.when('/admin/user_perms/:user_id', {
24 templateUrl: 'user-perms-template',
25 controller: 'UserPermsCtrl',
30 $routeProvider.otherwise({
31 templateUrl : 'user-perms-template',
32 controller: 'UserPermsCtrl',
37 .controller('UserPermsLookupCtrl',
38 ['$scope','$window','$location','egCore',
39 function($scope , $window , $location , egCore) {
41 $scope.selectMe = true; // focus text input
44 // find the user by barcode, the jump to the editor
45 $scope.submitBarcode = function(args) {
47 $scope.bcNotFound = null;
48 if (!args.barcode) return;
50 $scope.selectMe = false;
55 'open-ils.actor.get_barcodes',
56 egCore.auth.token(), egCore.auth.user().ws_ou(),
57 'actor', args.barcode)
59 .then(function(resp) { // get_barcodes
61 if (evt = egCore.evt.parse(resp)) {
62 console.error(evt.toString());
66 if (!resp || !resp[0]) {
67 $scope.bcNotFound = args.barcode;
68 $scope.selectMe = true;
72 // see if an opt-in request is needed
74 $location.path($location.path() + '/' + user_id);
80 .controller('UserPermsCtrl',
81 ['$scope','$routeParams','$window','$location','egCore',
82 function($scope , $routeParams , $window , $location , egCore) {
83 var user_id = $routeParams.user_id;
85 var url = $location.absUrl().replace(
86 /\/eg\/staff.*/, '/xul/server/patron/user_edit.xhtml');
88 url += '?usr=' + encodeURIComponent(user_id);
90 // user_edit does not load the session via cookie. It uses URL
91 // params or xulG instead. Pass via xulG.
93 ses : egCore.auth.token(),
94 on_patron_save : function() {
95 $scope.funcs.reload();
99 $scope.user_perms_url = url;