<li ng-repeat-start="group in actionGroups">
<span style="padding-left: 1em;" ng-if="group.label"><strong><u>{{group.label}}</u></strong></span>
</li>
- <li ng-repeat="action in group.actions" ng-class="{divider: action.divider}" ng-hide="actionHide(action)">
+ <li ng-repeat="action in group.actions" ng-class="{divider: action.divider, disabled: actionDisable(action)}" ng-hide="actionHide(action)">
<a ng-if="!action.divider" href
- ng-click="actionLauncher(action)">{{action.label}}</a>
+ ng-click="!actionDisable(action) && actionLauncher(action)">{{action.label}}</a>
</li>
<span ng-repeat-end/>
</ul>
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) {
label : '@', // Action label
handler : '=', // Action function handler
hide : '=',
+ disabled : '=', // function
divider : '='
},
link : function(scope, element, attrs, egGridCtrl) {
group : scope.group,
label : scope.label,
divider : scope.divider,
- handler : scope.handler
+ handler : scope.handler,
+ disabled : scope.disabled,
});
scope.$destroy();
}