When specifying a max queue size, users can continue to add more than max items to the queue before they hit save.

Once they click save, an error shows up notifying them they cannot pass the queue size limit. This is okay, but it would be better if instead it just limited the number of item fields to the max size. I.e., if the max is 6, then when I add the 6th item to the list, I shouldn't have an option to add a 7th item.

CommentFileSizeAuthor
#3 3021483.patch740 bytesamateescu
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sagesolutions created an issue. See original summary.

jsheffers’s picture

I agree that this would be a good addition to the module. Furthermore, it would also be helpful in some cases to not show the "Add another button" at all. An example would be a simple entityqueue that has minimum and maximum of 4 items. I only want it to ever contain 4 items. On the edit items screen I would see 4 autocomplete fields and the content could only be replaced with a different reference instead of adding a new item and kicking it out of the queue. Possible?

amateescu’s picture

Status: Active » Fixed
FileSize
740 bytes

It's very much possible, and quite easy to accomplish too: we can set the cardinality of the items field based on the "max size" setting of the queue :)

Committed the patch attached to 8.x-1.x.

  • amateescu committed 44e9635 on 8.x-1.x
    Issue #3021483 by sagesolutions, jsheffers: Hide "add another item" when...

Status: Fixed » Closed (fixed)

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

justcaldwell’s picture

Just wanted to note a couple of side-effects/regressions that seem to be associated with this change:

  1. This renders the 'Act as queue' feature useless. That feature allows the addition of items over the max to "bump" items off the top of the queue. With this change, it is no longer possible to exceed the maximum number of items. Maybe enforcing cardinality of the items field should be conditional on the 'Act as queue' setting?
  2. In my initial testing, the Autocomplete (draggable table) widget is now broken for queues with a max size. There are no autocomplete fields for unused queue slots, and the 'Remove' buttons for existing queue items do not work. Commenting out the lines introduced by the patch resolved the issues, but I haven't had a chance to debug further.
justcaldwell’s picture

amateescu’s picture

Another bug caused by this patch: #3055520: Simple queue with a minimum of 0 and maximum of 1 items creates error.

It's funny that such a small change managed to break so many things :/