VBO has a validation mechanism to prevent submitting an action unless a selection is made - that works great, but requires a page reload.

Since there's already lots of javascript UI goodness on the page, it doesn't seem like too big a stretch to request that the "submit" button not be enabled until the user makes a selection.

That way, we prevent the user from making a new request which we can easily predict is invalid.

Comments

aaronbauman created an issue. See original summary.

aaronbauman’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new663 bytes

Pretty simple JS-only patch to accomplish this.
Includes alert message.

hgoto’s picture

+1 for this improvement. The patch #2 works well.

I'd like to propose another approach. The patch #2 seems to add an alert box when the submit button is clicked. I believe, we can use the HTML "disabled" property directly to disable buttons.

This patch introduces the following function in VBO views:

  • Submit buttons are enabled only when at least one item is checked and an item is selected in the operation selectbox.
  • In other words, submit buttons are disabled if no item is checked in the list or no item is selected in the operation selectbox.

(To support bulk select checkboxes, we should write JS code instead of using #states API, I think.)

joelpittet’s picture

Status: Needs review » Fixed

I like this a lot, it works with the select and the actions as a button. Hopefully admin themes style [disabled] which would make this every better.

I've committed this to the dev branch.

  • joelpittet committed ccc0503 on 7.x-3.x authored by hgoto
    Issue #2790293 by aaronbauman, hgoto, joelpittet: Disable submit button...
hgoto’s picture

@joelpittet, thank you!

plazik’s picture

Status: Fixed » Needs work
StatusFileSize
new3.59 KB

It work on "Table" format, but it doesn't work on "Unformatted list" format and "Select all items on this page" checkbox.

See attached view export.

hgoto’s picture

Status: Needs work » Needs review
StatusFileSize
new1.27 KB

Thank you, @Plazik. Surely "Select all items on this page" checkbox isn't supported by the patch #3.

I created a new patch to support the "Unformatted list" format additionally. As the patch #3 has no problem with the "Table" format and IMHO it's OK to just add a new patch, I think. I'd like someone to review this.

The following change in this patch is not for supporting "Unfromatted list". This is just an adjustment for consistency with the existing code :)

-    var checkedCheckboxes = $('input.vbo-select:checked', form);
+    var checkedCheckboxes = $('.vbo-select:checked', form);
joelpittet’s picture

Status: Needs review » Fixed

That work and fixes the format that's not the table. And we don't need the polyfix for removeProperty because checked and disabled are both boolean properties, so true/false works for both.

Thanks for testing @Plazik, didn't test that scenario.

joelpittet’s picture

StatusFileSize
new2.12 KB

The patch I committed for posterity.

  • joelpittet committed 9764cd5 on 7.x-3.x authored by hgoto
    Issue #2790293 by hgoto, aaronbauman, Plazik: Disable submit button...
plazik’s picture

It works, thank you.

hgoto’s picture

@joelpittet @Plazik thanks!

Status: Fixed » Closed (fixed)

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

joelpittet’s picture

hgoto’s picture

@joelpittet thank you for sharing the issues! Yes, I'll check them. (I'm sorry for introducing the problems.)

joelpittet’s picture

No worries, it's bound to happen without tests and JS test are a bit tricky in 7 to boot.

joseph.olstad’s picture

StatusFileSize
new2.07 KB

***EDIT*** still investigating

ignore this comment
ignore patch
different issue.

here instead #2856944: 'Please select at least one item' - after upgrading to 7.x-3.4