|
43 | 43 | * <li>.isDisabled - (Boolean) set to true to disable the action |
44 | 44 | * <li>.isSeparator - (Boolean) set to true if this is a placeholder for a separator rather than an action |
45 | 45 | * </ul> |
| 46 | + * @param {function (item))} hideMenuForItemFn function(item) Used to hide all menu actions for a particular item |
| 47 | + * @param {function (item))} menuClassForItemFn function(item) Used to specify a class for an item's dropdown kebab |
46 | 48 | * @param {function (action, item))} updateMenuActionForItemFn function(action, item) Used to update a menu action based on the current item |
47 | 49 | * @param {object} customScope Object containing any variables/functions used by the transcluded html, access via customScope.<xxx> |
48 | 50 | * @example |
|
55 | 57 | action-buttons="actionButtons" |
56 | 58 | enable-button-for-item-fn="enableButtonForItemFn" |
57 | 59 | menu-actions="menuActions" |
58 | | - update-menu-action-for-item-fn="updateMenuActionForItemFn"> |
| 60 | + update-menu-action-for-item-fn="updateMenuActionForItemFn" |
| 61 | + menu-class-for-item-fn="getMenuClass" |
| 62 | + hide-menu-for-item-fn="hideMenuActions"> |
59 | 63 | <div class="list-view-pf-description"> |
60 | 64 | <div class="list-group-item-heading"> |
61 | 65 | {{item.name}} |
|
238 | 242 | }, |
239 | 243 | ]; |
240 | 244 |
|
| 245 | + $scope.getMenuClass = function (item) { |
| 246 | + var menuClass = ""; |
| 247 | + if (item.name === "Jim Beam") { |
| 248 | + menuClass = 'red'; |
| 249 | + } |
| 250 | + return menuClass; |
| 251 | + }; |
| 252 | +
|
| 253 | + $scope.hideMenuActions = function (item) { |
| 254 | + return (item.name === "Marie Edwards"); |
| 255 | + }; |
| 256 | +
|
241 | 257 | var performAction = function (action, item) { |
242 | 258 | $scope.eventText = item.name + " : " + action.name + "\r\n" + $scope.eventText; |
243 | 259 | }; |
@@ -315,6 +331,8 @@ angular.module('patternfly.views').directive('pfListView', function ($timeout, $ |
315 | 331 | actionButtons: '=?', |
316 | 332 | enableButtonForItemFn: '=?', |
317 | 333 | menuActions: '=?', |
| 334 | + hideMenuForItemFn: '=?', |
| 335 | + menuClassForItemFn: '=?', |
318 | 336 | updateMenuActionForItemFn: '=?', |
319 | 337 | actions: '=?', |
320 | 338 | updateActionForItemFn: '=?', |
@@ -391,6 +409,24 @@ angular.module('patternfly.views').directive('pfListView', function ($timeout, $ |
391 | 409 | } |
392 | 410 | }; |
393 | 411 |
|
| 412 | + $scope.getMenuClassForItem = function (item) { |
| 413 | + var menuClass = ''; |
| 414 | + if (angular.isFunction($scope.menuClassForItemFn)) { |
| 415 | + menuClass = $scope.menuClassForItemFn(item); |
| 416 | + } |
| 417 | + |
| 418 | + return menuClass; |
| 419 | + }; |
| 420 | + |
| 421 | + $scope.hideMenuForItem = function (item) { |
| 422 | + var hideMenu = false; |
| 423 | + if (angular.isFunction($scope.hideMenuForItemFn)) { |
| 424 | + hideMenu = $scope.hideMenuForItemFn(item); |
| 425 | + } |
| 426 | + |
| 427 | + return hideMenu; |
| 428 | + }; |
| 429 | + |
394 | 430 | $scope.setupActions = function (item, event) { |
395 | 431 | // Ignore disabled items completely |
396 | 432 | if ($scope.checkDisabled(item)) { |
|
0 commit comments