webstaff: add egOrg.root() method
authorGalen Charlton <gmc@esilibrary.com>
Mon, 5 Oct 2015 20:21:23 +0000 (20:21 +0000)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:48 +0000 (14:58 -0500)
Also, start adding some documentation for egOrg.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/services/org.js

index dcf1d52..e9fcc2d 100644 (file)
@@ -1,7 +1,19 @@
 /**
  * Core Service - egOrg
  *
- * TODO: more docs
+ * This provides access to the organizational unit tree and
+ * caches it in browser session storage.
+ *
+ * Methods include:
+ *   get()  - retrieve OU based on ID or aou object
+ *   list() - retrieve flattened list of OUs
+ *   tree() - retrieve OU as tree
+ *   root() - get aou object representing root of the OU tree
+ *   ancestors() - get ancestors of supplied OU
+ *   descendants() - get descendants of supplied OU
+ * 
+ * TODO more to document
+ * 
  */
 angular.module('egCoreMod')
 
@@ -29,6 +41,11 @@ function($q,  egEnv,  egAuth,  egNet) {
         return egEnv.aou.tree;
     }
 
+    // get the root OU
+    service.root = function() {
+        return egEnv.aou.list[0];
+    }
+
     // list of org_unit objects or IDs for ancestors + me
     service.ancestors = function(node_or_id, as_id) {
         var node = service.get(node_or_id);