In 8.x-1.0 there was a VERY useful feature: if you dragged the cross thingy to the right, the current item would "stick" to the previous one and go with it wherever you drag the latter. It allowed you to build a "chain" of items and then move them all in sequence to another place in the whole list. After I upgraded to 8.x-1.2 it doesn't work for me anymore. Am I missing something obvious? I don't believe it was even documented anywhere, I just discovered it by sheer chance and used it extensively ever since (until now, that is).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ndlarge created an issue. See original summary.

marassa’s picture

Did a little digging and found out that in the very end of src/Plugin/views/field/DraggableViewsField.php, where drupal_attach_tabledrag is called with options, the 'relationship' => 'parent' option (8.x-1.0) was replaced with 'relationship' => 'group' in 8.x-1.2.
Was that done on purpose? Can't quite see what it achieves but it certainly breaks useful existing functionality.

marassa’s picture

Title: Is the "drag right to attach to previous" feature gone in 8.x-1.2? » Group dragging feature lost in 8.x-1.2
marassa’s picture

Here's a patch that restores the group dragging functionality.

marassa’s picture

Status: Active » Needs review
marassa’s picture

singhkiran’s picture

FileSize
141.87 KB

Hey @ndlarge , this patch not worked for me .

marassa’s picture

@sinhgkiran, I'm afraid you'll have to be more specific. What exactly doesn't work for you and did it work in 8.x-1.0?

singhkiran’s picture

@ndlarge I have updated my module from 8.x-1.0 to 8.x-1.2 , then i have lost the group dragging feature , so i have applied the #4 patch .
But it didn't work for me .
Thanks

marassa’s picture

@sinhgkiran, just in case, did you clear the cache after applying the patch?
If you look into my patch you will see that I reverted a single line of code back to what it was before 8.x-1.2 and it immediately worked for me (simple one-level list, no hierarchy). If it doesn't work for you (and it did before) then it probably means that 8.x-1.2 broke something else elsewhere and you will have to find what and where.
Based on your description "this patch not worked for me" I cannot reproduce your issue.

Harlor’s picture

The patch does work for me!

How ever I had troubles with endless recursions that produced fatal errors like "Error: Maximum function nesting level of '256' reached, aborting! in Drupal\draggableviews\DraggableViews->getIndex()" which make the whole site unusable.

This patch does not fix the issue with endless recursions but avoids the fatal errors.

Harlor’s picture

FileSize
7.71 KB

Here with Node IDs

goodDenis’s picture

Thanks, @marassa
I did not see any 'fatal error', after apply the patch #11, but there is some problem with using 'drag and drop'.
1) I cannot return 'parent value to '0'
2) I have the wrong sort order after saving an item with deep more than 3.

I returned to version 1.0

goodDenis’s picture

If we change only 'relationship' => 'group' to 'relationship' => 'parent'.
So #4 works for me.
I have some problem but after 'TRUNCATE' the 'draggableviews_structure' table it works perfectly for me.

iStryker’s picture

Status: Needs review » Needs work

#2747327: Various clean-ups removed horizontal (hierarchy) dragging. Currently, hierarchy is not supported in 8.x. I am willing to change it back, but first I would like to see a setting to enable/disable hierarchy dragging.

marassa’s picture

#2747327: Various clean-ups removed horizontal (hierarchy) dragging

It's probably worth mentioning that it was removed arbitrarily (by the patch author's own admission), in a patch dealing with many different issues at the same time (not a good idea according to Drupal patch guidelines) and clearly without even understanding why the code was there and what the change was breaking.
There are people in this thread who lost functionality after that change, and my patch restored it.
I can't see a single person in this thread who really needs a setting and can coherently explain the reason why ;)
Just my two kopecks ;)

agentrickard’s picture

Revised patch for 2.0.x. Does not include the requested settings change, however.

rang501’s picture

Added a fix for the hierarchy support, it had one issue on the getIndex method (it assumed nid was the default which is wrong, custom entities usually use just id), which also fixes possible issues with custom entities where I had a problem with some special view configuration where watchdog table was filled with notice messages ($item->nid didn't exist) until the disk was full.
Quick testing shows that hierarchy works fine.

rang501’s picture

Found additional issue - the depth calculation method was not correct, also the getIndex() was also not doing what it should because of in_array() function. Now it should work fine

rang501’s picture

Version: 8.x-1.2 » 2.0.x-dev
FileSize
2.78 KB

This patch will fix the notices thrown in some cases

iStryker’s picture

Patch looks pretty good. My only concern is we keep changing the relationship from group to parent then back....not in this issue but previous issues.

What is the correct answer?

rang501’s picture

I think its because we need some hierarchy support - I'm not too familiar with the tabledrag options, so not fully sure and I didn't test with other options.
Anyway, this patch seems to fix issues with hierarchy for my projects and seems to be stable.
The only thing that's probably is missing to control this hierarchy option - maybe there should be a setting way to turn it off?

rang501’s picture

Version: 2.0.x-dev » 2.1.x-dev

Created issue fork and fixed the patch so it applies to 2.1.x.

rang501’s picture

I did add changes to make this work with Claro theme in Drupal 10. The structure was not preserved when dragging rows around and it did cause some weird issues where relationships were lost.

rang501’s picture

Status: Needs work » Needs review

I saw some changes that were done here were added by the #2867348: Not working with Group By feature. I modified the code so this will apply with the latest patch from that issue.
At the moment this will fix

  • Hierarchy functionality - it is broken in the Claro theme, it needs one header class, and rendering the indentation part was not correct, it did remove the SVG and there were no visible parent-child relationship lines available
  • custom entities (at the moment it expects 'nid' as entity id key, but others have 'id' usually)

I did test this and did not find any weird behavior related to moving things around. Previously it messed things up, ordering was wrong, indentation incorrect, and was lost.

Hopefully, someone can take a look at this with the other issue and see if it is possible to merge these things to a new release.

rang501’s picture