Empty sortables not possible / Allow two sortables with shared items / Allow items containing form elements

salgar - February 13, 2008 - 10:38
Project:jQuery Interface Sortable
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I have two sortables where the first one is empty per default. The user can drag elements from the second one and drop them on the first one. This works perfect, except if the first one is empty. Then there are warnings and the outer-div is missing on the page.
Suggested fix:

90a91,97 interface_sortable.module
>   if (empty($element['#items'])) {
>     $order = array();
>     $sortables = array(
>       '#type' => 'markup',
>       '#value' => $sortables['#prefix'] . $sortables['#suffix']
>     );
>   }

#1

marcp - February 14, 2008 - 04:47

Any chance you could provide a separate patch to interface_sortable_demos.module that demonstrates this?

Thanks,

Marc

#2

salgar - February 14, 2008 - 08:32

I ran into some other problems... I'll make a separate patch to interface_sortable_demos.module and submit it together with an updated patch for interface_sortable.module.

Salgar

#3

salgar - February 14, 2008 - 11:36
Title:Empty sortables not possible» Empty sortables not possible / Allow two sortables with shared items

I've attached a patch which demonstrates the issue.

There are also issues when the name of a sortable element contains underscores and/or hyphens, but I had no time to investigate this. (I simply changed the names in my module...)

AttachmentSize
two_sortables.patch 5.44 KB

#4

salgar - February 20, 2008 - 15:03
Title:Empty sortables not possible / Allow two sortables with shared items» Empty sortables not possible / Allow two sortables with shared items / Allow items containing form elements

I've attached a new version of the patch, which allows to integrate form elements into the items of a sortable. See the advanced demo for an example. It would be great if you could integrate this stuff.

Salgar

AttachmentSize
two_sortables_2.patch 7.13 KB

#5

salgar - February 27, 2008 - 19:00

I found out, that using #options as attribute name for the form element is not a good idea. It's used by select elements and drupal may print out a validation error in some cases (see misc/form.inc line 547) when submitting. Best thing is to unset($elements["options"]) at the end of function interface_sortable_process. I've attached a new patch which adresses this issue.

AttachmentSize
two_sortables_3.patch 7.2 KB

#6

marcp - March 17, 2008 - 20:54
Status:active» needs work

salgar,

Thank you for this patch. I took some time to apply and test it on Firefox and am impressed by the additional functionality. I was wondering if you would have the time to tweak a few things in the patch because I think it would be better coming from you as the author:

1. Document, in the function header, the $subst parameter to interface_get_sort()
2. Document, in the function header, the $inner_id extra argument that's processed via interface_sortable_process() -- I'm still a little confused as to why it's needed (this module has always been hard for me to keep my head around)
3. Come up with a better name for your super advanced drag-and-drop demo, and put a little bit of descriptive text on the form telling the user that they can drag and drop the items from one region to the other
4. Run it through Coder to make sure it's all up to Drupal standard coding practices (except for the Javascript which has confused Coder in the past)

The first thing I did after applying the patch was to make sure that it didn't break Nodeorder and I was pleased to see that Nodeorder was still working just fine.

- Marc

#7

nath - May 6, 2008 - 08:34

Any progress on this?

 
 

Drupal is a registered trademark of Dries Buytaert.