From 43309a9d305dd1251d3feedf860aa15bd98a16be Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 23 Jul 2015 17:49:36 +0000 Subject: [PATCH] webstaff: teach egGrid action menus how to conditionally disable items It is now possible to pass a function to specify if an action menu item should be disabled: Signed-off-by: Galen Charlton Signed-off-by: Jason Stephenson --- Open-ILS/src/templates/staff/share/t_autogrid.tt2 | 4 ++-- Open-ILS/web/js/ui/default/staff/services/grid.js | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 index 53265c6ff1..36c5da2535 100644 --- a/Open-ILS/src/templates/staff/share/t_autogrid.tt2 +++ b/Open-ILS/src/templates/staff/share/t_autogrid.tt2 @@ -90,9 +90,9 @@
  • {{group.label}}
  • -
  • +
  • {{action.label}} + ng-click="!actionDisable(action) && actionLauncher(action)">{{action.label}}
  • diff --git a/Open-ILS/web/js/ui/default/staff/services/grid.js b/Open-ILS/web/js/ui/default/staff/services/grid.js index ce0542f9a7..14181062f1 100644 --- a/Open-ILS/web/js/ui/default/staff/services/grid.js +++ b/Open-ILS/web/js/ui/default/staff/services/grid.js @@ -516,6 +516,14 @@ angular.module('egGridMod', return action.hide(action); } + // fires the disable handler function for a context action + $scope.actionDisable = function(action) { + if (!action.disabled) { + return false; + } + return action.disabled(action); + } + // fires the action handler function for a context action $scope.actionLauncher = function(action) { if (!action.handler) { @@ -1011,6 +1019,7 @@ angular.module('egGridMod', label : '@', // Action label handler : '=', // Action function handler hide : '=', + disabled : '=', // function divider : '=' }, link : function(scope, element, attrs, egGridCtrl) { @@ -1019,7 +1028,8 @@ angular.module('egGridMod', group : scope.group, label : scope.label, divider : scope.divider, - handler : scope.handler + handler : scope.handler, + disabled : scope.disabled, }); scope.$destroy(); } -- 2.43.2