]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/PermGrp.js
LP1615805 No inputs after submit in patron search (AngularJS)
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / PermGrp.js
1 if(!dojo._hasResource["openils.PermGrp"]){
2     dojo.provide("openils.PermGrp");
3     dojo.require('openils.Util');
4
5     dojo.declare( "openils.PermGrp", null, {});
6
7     openils.PermGrp.groupTree = null;
8     openils.PermGrp.groupIdMap = {};
9
10     openils.PermGrp.fetchGroupTree = function(onload) {
11         if(openils.PermGrp.groupTree) 
12             return onload();
13         fieldmapper.standardRequest(
14             ['open-ils.actor', 'open-ils.actor.groups.tree.retrieve'],
15             {   async: true,
16                 oncomplete: function(r) {
17                     openils.PermGrp.groupTree = openils.Util.readResponse(r);
18                     onload();
19                 }
20             }
21         );
22     };
23
24     /**
25      * Flatten the group tree into a id => object map for easy access
26      */
27     openils.PermGrp.flatten = function(node) {
28         if(!node) node = 
29             openils.PermGrp.groupTree;
30         openils.PermGrp.groupIdMap[node.id()] = node;
31         for(var idx in node.children())
32             openils.PermGrp.flatten(node.children()[idx]);
33     };
34 }