From bc4be5272b123fd2d38262c3430b8ac06ca0b05d Mon Sep 17 00:00:00 2001 From: Brian Federle Date: Wed, 18 Jun 2014 14:02:16 -0700 Subject: [PATCH] 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 }, ... } --- ui/scripts/ui/widgets/detailView.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js index 6ff36c444bb..8824adc2249 100644 --- a/ui/scripts/ui/widgets/detailView.js +++ b/ui/scripts/ui/widgets/detailView.js @@ -835,9 +835,11 @@ }); $.each(actions, function(key, value) { - if ($.inArray(key, allowedActions) == -1 || + if ((!value.preFilter && $.inArray(key, allowedActions) == -1) || + (value.preFilter && !value.preFilter({ context: options.context })) || (options.ignoreAddAction && key == 'add') || (key == 'edit' && options.compact)) { + return true; }