When there is no operation available (such as because of action permissions and the permissions table), the bulk operation selector drop down, "Execute" button and checkboxes should not appear. (Currently there is just one option "Choose an operation", so nothing can actually be executed.)

Assuming the view is a tabular view, the column can be removed when there are no operations by selecting the "Hide empty column" option in the Views table formatter settings.

In all cases, the "No results" configuration for the field should also take effect.

There is a patch for this same feature but for version 6.x-1.x at #1144506: Hide operations selector & checkboxes if no operation available, Drupal 6.

Comments

Bevan’s picture

StatusFileSize
new1.45 KB

This patch is for 7.x-3.x-rc1, for anyone running rc1 instead of dev and wants to patch it now.

Note there is another patch with this feature but for version 6.x-1.x at #1144506: Hide operations selector & checkboxes if no operation available, Drupal 6.

johnpitcairn’s picture

Is it possible to hide the operations fieldset (and table column?), or perhaps apply a "no-operations" class to the fieldset (and table column?)

Bevan’s picture

The column hides itself if you select the "Hide empty column" option in the Views table formatter settings, as per the description. IIRC the fieldset also hides itself. Do you want the column and fieldset to show even if there are no operations?

johnpitcairn’s picture

Duh. I'd missed the "empty column" checkbox, thanks ;-)

The select element hides but the enclosing fieldset does not hide itself. I'm currently using a simple form alter to do that:

/**
 * Implements hook_views_bulk_operations_form_alter().
 */
function mymodule_views_bulk_operations_form_alter(&$form, &$form_state, $vbo) {
  if (!isset($form['select']['operation'])) {
    $form['select']['#type'] = 'hidden';
  }
}
Sinan Erdem’s picture

I applied the patch for RC1. It removed the Operations for every user, even for user 1.

elBradford’s picture

Regarding comment #4, I updated the patch so the "Operations" fieldset is hidden for users without available actions. This is on the most recent dev version (sorry #5) and REPLACES the patch in #1. Please review and commit.

elBradford’s picture

Bump, please review.

johnpitcairn’s picture

Patch does not apply to current dev.

elBradford’s picture

Sorry, we don't really need the patch on our site anymore, so I can't test it. Look at the patch I submitted and try to adapt it to the new dev, it shouldn't be difficult.

tammo’s picture

I tried the current dev (dec 2012), but the patch was not/partly in there. Is there a plan to commit this patch, so this really wished for feature would come into the "main stream" of this module?

Anyway: when a user has no rights to start any of the VBO, he still is shown the (empty) field set for operations.

And indicating "do not show if empty" in Views did not work either...

adamtong’s picture

the patch is #6 is not work for current dev version and 7.x-3.1 version.

danepowell’s picture

StatusFileSize
new3.26 KB

Here is a version of #6 updated to work with 3.1. Additionally, #6 did not hide the 'select all' checkboxes - this version does.

bojanz’s picture

Issue summary: View changes
Status: Needs review » Fixed

I committed a much simpler solution, building upon my previous
commit in #2002300: Not able to exclude VBO field using "exclude from display":

http://drupalcode.org/project/views_bulk_operations.git/commitdiff/ee5c8...

It doesn't require any changes to the view or any field configuration, the vbo form & field just disappear if no operations are available.

EDIT: And I also forgot to credit Bevan and elBradford. Sorry guys, wasn't intentional, it's just late.

elBradford’s picture

No worries bojanz, just nice to see it's fixed. And props on a very elegant solution.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Bevan’s picture

ditto elBradford.

acbramley’s picture

Status: Closed (fixed) » Active
StatusFileSize
new545 bytes

This doesn't work in the latest stable release, the get_selected_operations() method is returning an array, not an integer, so adding a simple count() call around the method fixes the issue. Patch attached.

acbramley’s picture

Status: Active » Needs review
bojanz’s picture

Status: Needs review » Fixed

Hm, not sure how I missed that.
Thanks, committed!

  • Commit 35d0c6b on 7.x-3.x authored by acbramley, committed by bojanz:
    Issue #1618474 followup by acbramley: Hide operations selector...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.