LP#1708291: add a egShareDepthSelector directive
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 9 May 2017 18:56:04 +0000 (14:56 -0400)
committerKathy Lussier <klussier@masslnc.org>
Wed, 30 Aug 2017 18:43:13 +0000 (14:43 -0400)
This directive implements a selector for OU-sharing depths; depths
and names come from the actor.org_unit_type table. If there are
multiple types defined for a given depth, the display value in
the selector is the concatenation of their names.

The initial use of this directive is for specifying how broadly
prediction pattern templates should be seen.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/share/t_share_depth_selector.tt2 [new file with mode: 0644]
Open-ILS/web/js/ui/default/staff/services/ui.js

diff --git a/Open-ILS/src/templates/staff/share/t_share_depth_selector.tt2 b/Open-ILS/src/templates/staff/share/t_share_depth_selector.tt2
new file mode 100644 (file)
index 0000000..2633eac
--- /dev/null
@@ -0,0 +1,4 @@
+<select
+  ng-options="item.id as item.name for item in values"
+  ng-model="ngModel"
+</select>
index d1f87a7..ff7cfd8 100644 (file)
@@ -976,6 +976,42 @@ function($window , egStrings) {
     }
 })
 
+/*
+ *  egShareDepthSelector - widget for selecting a share depth
+ */
+.directive('egShareDepthSelector', function() {
+    return {
+        restrict : 'E',
+        transclude : true,
+        scope : {
+            ngModel : '=',
+        },
+        require: 'ngModel',
+        templateUrl : './share/t_share_depth_selector',
+        controller : ['$scope','egCore', function($scope , egCore) {
+            $scope.values = [];
+            egCore.pcrud.search('aout',
+                { id : {'!=' : null} },
+                { order_by : {aout : ['depth', 'name']} },
+                { atomic : true }
+            ).then(function(list) {
+                var scratch = [];
+                angular.forEach(list, function(aout) {
+                    var depth = parseInt(aout.depth());
+                    if (depth in scratch) {
+                        scratch[depth].push(aout.name());
+                    } else {
+                        scratch[depth] = [ aout.name() ]
+                    }
+                });
+                scratch.forEach(function(val, idx) {
+                    $scope.values.push({ id : idx,  name : scratch[idx].join(' / ') });
+                });
+            });
+        }]
+    }
+})
+
 .factory('egWorkLog', ['egCore', function(egCore) {
     var service = {};