Nodequeue provides buttons for:

  • Shuffling/randomizing the order
  • Reversing the order
  • Clearing the queue

It would be nice to have the same options.

Comments

jojonaloha’s picture

Status: Active » Needs review
StatusFileSize
new3.6 KB

Attached patch adds the Shuffle, Reverse and Clear actions. I tried making them #type=button instead of #type=submit, so that you stayed on the edit form like Nodequeue does, but it doesn't seem that the form values are updated appropriately (at least the way I'm doing it in this patch) when I do that.

amateescu’s picture

Status: Needs review » Needs work

We should try to make these operations work via AJAX. Right now, the action happens and you're redirected to the queue listing, which is.. not the best user experience :)

jojonaloha’s picture

Version: » 7.x-1.x-dev
Status: Needs work » Needs review
StatusFileSize
new5.12 KB
new2.68 KB

Updated patch makes the buttons use ajax. Currently clicking one of these buttons doesn't add a "Changes will not be saved until the form is submitted" message because that will just make this issue worse #2154115: Duplicate "Changes will not be saved until the form is submitted." warnings

amateescu’s picture

  1. +++ b/entityqueue.module
    @@ -1010,3 +1010,13 @@ function entityqueue_field_widget_ajax_callback($form, $form_state) {
    +  $subqueue = $form_state['entityqueue_subqueue'];
    

    This is not used in the function.

  2. +++ b/plugins/ctools/export_ui/entityqueue_export_ui.class.php
    @@ -286,6 +286,12 @@ function entityqueue_subqueue_edit_form($form, &$form_state, EntityQueue $queue,
    +  // We don't use drupal_html_id() here because we don't want the wrapper id
    +  // to change each time the ajax form is submitted.
    +  $field_name = _entityqueue_get_target_field_name($queue->target_type);
    +  $wrapper_id = drupal_clean_css_identifier($field_name . '-wrapper');
    +  $form[$field_name]['#id'] = $wrapper_id;
    

    This means that the field wrapper will have the same id if we have multiple instances of this form on the same page. It would be easier to add a div wrapper with #prefix and #suffix, and use drupal_html_id() for its id.

jojonaloha’s picture

Attached patch uses drupal_html_id() for the wrapper id. In order for that to work the entire form needs to be replaced, otherwise the second or third click of one of the ajax buttons will not work because they are referencing the old wrapper id.

This means that the field wrapper will have the same id if we have multiple instances of this form on the same page.

This also means that the code in entityqueue_field_widget_form() would need to be updated. Also, I'm wondering when we'd have multiple instances of the form on the same page? I was thinking that IEF might be an example, but doesn't that still only have one instance of the form on the page at a time?

amateescu’s picture

There was a bug/feature request in nodequeue (back in the day..) about a custom module that provided queue forms in blocks and that's how they ended up with multiple queue forms on one page :)

I don't think returning the entire form bothers us too much, so the patch looks good to me.

jojonaloha’s picture

Ok, I think I'm going to commit this and create a follow-up issue for the widget form then.

amateescu’s picture

Go right ahead :)

jojonaloha’s picture

Status: Needs review » Fixed

Committed 0518829

Status: Fixed » Closed (fixed)

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