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
    },
    ...
}
This commit is contained in:
Brian Federle 2014-06-18 14:02:16 -07:00
parent 318e497e60
commit bc4be5272b
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}