Skip to content

Commit bc4be52

Browse files
committed
Detail view: support per-action filtering
Adds support for adding preFilter on a per-action basis, to assist in plugin development. If action.preFilter function is passed, and returns true/false, the action is shown/hidden. If no preFilter is specified, then the action will be passed through the detail view's standard filter. Example: testAction: { label: 'Test Action', ... preFilter: function(args) { return false; // Action will be hidden }, ... }
1 parent 318e497 commit bc4be52

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ui/scripts/ui/widgets/detailView.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,11 @@
835835
});
836836

837837
$.each(actions, function(key, value) {
838-
if ($.inArray(key, allowedActions) == -1 ||
838+
if ((!value.preFilter && $.inArray(key, allowedActions) == -1) ||
839+
(value.preFilter && !value.preFilter({ context: options.context })) ||
839840
(options.ignoreAddAction && key == 'add') ||
840841
(key == 'edit' && options.compact)) {
842+
841843
return true;
842844
}
843845

0 commit comments

Comments
 (0)