Motivation
The tabledrag functionality does not allow avoiding a child item to become a root item. This is very useful when there is a differentiation between the root level items, and the ones below. If we have, say, type A and type B, and the business logic implies all B items MUST be children of A items, there is currently no way to allow A items do be drag only among it's sibling A items and at the same time have B items only be draggable inside the A items.
Proposed resolution
Define an attribute to limit the min-depth of a row (and perhaps max-depth also?), making it never move to the side of it's parent leveling.
Remaining tasks
Perhaps adding the same functionality but for max-depth.
API changes
// Define a row's minimum depth.
$form['table'][$row->id()]['#attributes']['data-tabledrag-min-depth'] = 1;
Comments
Comment #2
lucas.constantino commentedComment #3
lucas.constantino commentedComment #6
kristen polIf this is still relevant, it needs a reroll for 9.1.x.
Comment #7
hardik_patel_12 commentedWorking on it
Comment #8
hardik_patel_12 commentedRe-rolling against 9.1.x.
Comment #9
hardik_patel_12 commentedComment #10
kristen polThanks for the reroll. I noticed a couple nitpicks:
Extra spaces for two lines.
Comment #11
msutharsComment #12
msutharsUpdated the patch. Please review.
Comment #13
kristen polThanks for the update. The changes address the items in #10. Tagging for manual and automated testing.
Comment #14
samiullah commentedPatch applied nicely
1 Created a menu item example books with multiple child elements and child elements having sub-child elements
2. Tried drag and drop among siblings of books element
3. Looks good
I would suggest one more round of manual testing for this one
Comment #15
droplet commentednot very sure if the Core needed it.
It's buggy if the start level is less than min-depth
Remove "Needs manual testing" since it has bugs and no tests
Comment #21
varunmishra2006 commentedPatch 3002325-12.patch is not compatible with version 9.5.3.
I have created an updated patch compatible with 9.5.3.
Comment #22
_utsavsharma commentedTried to fix CCF for #21.
Comment #23
_utsavsharma commentedD10 patch.
Comment #24
nikhil_110 commentedComment #25
smustgrave commentedWas previously tagged for tests which still need to happen.