LP#1402797 Teach the autogrid how to hide actions
authorMike Rylander <mrylander@gmail.com>
Mon, 9 Feb 2015 17:50:44 +0000 (12:50 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 25 Feb 2015 16:16:08 +0000 (11:16 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/share/t_autogrid.tt2
Open-ILS/web/js/ui/default/staff/services/grid.js

index 912b644..7db04a9 100644 (file)
@@ -70,7 +70,7 @@
         [% l('Actions') %] <span class="caret"></span>                       
       </button>                                                              
       <ul class="dropdown-menu pull-right">                                  
-        <li ng-repeat="action in actions" ng-class="{divider: action.divider}">
+        <li ng-repeat="action in actions" ng-class="{divider: action.divider}" ng-hide="actionHide(action)">
           <a ng-if="!action.divider" href
             ng-click="actionLauncher(action)">{{action.label}}</a>
         </li>
index 50c2786..3b8a467 100644 (file)
@@ -457,6 +457,14 @@ angular.module('egGridMod',
                 return ''+item; 
             }
 
+            // fires the hide handler function for a context action
+            $scope.actionHide = function(action) {
+                if (!action.hide) {
+                    return false;
+                }
+                return action.hide(action);
+            }
+
             // fires the action handler function for a context action
             $scope.actionLauncher = function(action) {
                 if (!action.handler) {
@@ -896,10 +904,12 @@ angular.module('egGridMod',
         scope : {
             label   : '@', // Action label
             handler : '=',  // Action function handler
+            hide    : '=',
             divider : '='
         },
         link : function(scope, element, attrs, egGridCtrl) {
             egGridCtrl.addAction({
+                hide  : scope.hide,
                 label : scope.label,
                 divider : scope.divider,
                 handler : scope.handler