CAT-51 Patron Reg. Perm Group Ordering
authorVictoria Lewis <vlewis@catalystdevworks.com>
Thu, 21 Apr 2016 18:46:18 +0000 (11:46 -0700)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Reordered Permission Group choices in drop down
of Edit screen on Patron Registration page.

Signed-off-by: Victoria Lewis <vlewis@catalystdevworks.com>
 On branch dev/catalyst-vlewis/CAT-51-patron_reg_perm_group_ordering
modified:   Open-ILS/web/js/ui/default/actor/user/register.js

Open-ILS/web/js/ui/default/actor/user/register.js

index 6601745..a65d87c 100644 (file)
@@ -1388,10 +1388,122 @@ function processStageUserValues() {
 }
 
 function trimGrpTree(autoWidget) {
-    var store = autoWidget.widget.store;
-    if(!store) return;
-    // remove all groups that this user are not allowed to edit, 
-    // except the profile group of an existing user
+       var permArray = [];
+       var store = autoWidget.widget.store;
+       if(!store) return;
+       // remove all groups that this user are not allowed to edit,
+       // except the profile group of an existing user
+       var tree = autoWidget.widget.tree[0];
+       function order_perms(treeNode) {
+               if (!treeNode) return;
+               dojo.forEach(treeNode.children(), function(node){
+
+                       switch( node.id()){
+                               case 13:        //Full Privileges
+                                       permArray[0] = node;
+                                       break;
+                               case 17:        //Limited Checkout
+                                       permArray[1] = node;
+                                       break;
+                               case 26:        //Online Registration
+                                       permArray[2] = node;
+                                       break;
+                               case 90:        //PC Only Ineligible
+                                       permArray[3] = node;
+                                       break;
+                               case 15:        //Recip Limit Holds
+                                       permArray[4] = node;
+                                       break;
+                               case 23:        //Recip Limit Holds & CKO
+                                       permArray[5] = node;
+                                       break;
+                               case 25:        //Recip Limit Holds No PC
+                                       permArray[6] = node;
+                                       break;
+                               case 28:        //Parental Limit 10
+                                       permArray[7] = node;
+                                       break;
+                               case 27:        //Parental Limit 5
+                                       permArray[8] = node;
+                                       break;
+                               case 30:        //Parental No - PC & CKO
+                                       permArray[9] = node;
+                                       break;
+                               case 92:        //One Year - Full
+                                       permArray[10] = node;
+                                       break;
+                               case 93:        //One Year - Limit Holds
+                                       permArray[11] = node;
+                                       break;
+                               case 38:        //KCLS Staff
+                                       permArray[12] = node;
+                                       break;
+                                case 39:       //Branch Work
+                                       var dupNode =  node;
+                                       permArray[24] = node.a[0][0]; //CMS Recall
+                                       dupNode.a[0] = null;
+                                       permArray[13] = dupNode;
+                                       break;
+                               case 16:        //No CKO
+                                       permArray[14] = node;
+                                       break;
+                               case 31:        //Deceased
+                                       permArray[15] = node;
+                                       break;
+                               case 32:        //Summer Bus Student
+                                       permArray[16] = node;
+                                       break;
+                               case 35:        //Outreach Service
+                                       permArray[19] = node;
+                                       break;
+                               case 34:        //Outreach Staff Only
+                                       permArray[20] = node;
+                                       break;
+                               case 901:       //Student Ecard
+                                       permArray[21] = node;
+                                       break;
+                               case 902:       //Classroom Databases
+                                       permArray[22] = node;
+                                       break;
+                               case 40:        //ILL
+                                       permArray[23] = node;
+                                       break;
+                               case 91:        //Enumclaw Migration
+                                       permArray[25] = node;
+                                       break;
+                               case 1001:      //ADA - SC Approved
+                                       var copyNode =  node;
+                                       permArray[17] = node.a[0][1];   //ADA Circ Limit Holds
+                                       permArray[18] = node.a[0][0];   //ADA Circulation
+                                       copyNode.a[0] = null;
+                                       permArray[26] = copyNode;
+                                       break;
+                                case 74:       //Data Review
+                                       permArray[27] = node;
+                                       break;
+                               case 3: //Staff
+                                       permArray[28] = node;
+                                       break;
+                               case 888:       //SIP
+                                       permArray[29] = node;
+                                       break;
+                               default:
+                       }
+                       order_perms(node);
+               });
+
+               tree.children([permArray[0], permArray[1], permArray[2], permArray[3], permArray[4],
+                                          permArray[5], permArray[6], permArray[7], permArray[8], permArray[9],
+                                          permArray[10], permArray[11], permArray[12], permArray[13], permArray[14],
+                                          permArray[15], permArray[16], permArray[17], permArray[18], permArray[19],
+                                          permArray[20], permArray[21], permArray[22], permArray[23], permArray[24],
+                                          permArray[25], permArray[26], permArray[27], permArray[28], permArray[29]]);
+          }
+
+       order_perms(tree);
+
+       autoWidget.widget.startup();
+
     store.fetch({onItem : 
         function(item) {
             if(!checkGrpAppPerm(item.id[0]) && patron.profile() != item.id[0])