Closed (fixed)
Project:
TableField
Version:
8.x-2.x-dev
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
14 Mar 2019 at 18:38 UTC
Updated:
15 Aug 2022 at 09:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
lolandese commentedThe D8 port was created before the D7 feature request #2578261: insert new row in the middle or rearrange rows was solved. Making a one-way feature comparison, looking at what is in D8 that is also in D7, we can conclude that the 7.x-2.4 mostly reflects what is in the D8 version.
That means that most new features that are in 7.x-2.5 are not in the D8 version. The new "major" version 7.x-3.x, taken from 7.x-2.5, is a rewrite of a big part of the code, including the data structure. Ideally, a new D8 port based on that should be created (@TODO). That would then include also the "row drag" feature.
Feel free to contribute with feedback, testing or providing patches.
Comment #3
matroskeenHello guys,
Here is a patch with tabledrag integration. It seems it works well for us but it would be great to receive some feedback.
Thanks!
Comment #4
matroskeenFixed some issues and made a clean-up.
Comment #5
lolandese commentedPatch applies cleanly and works as expected.
Both Code Sniffer Drupal and Code Sniffer Drupal Best Practice pass without any errors or warnings.
Let's give it a couple of weeks and commit if no objections arise.
Thanks for the patch.
Comment #6
colanCan we use more descriptive variable naming for all of these? Longer names are cheap nowadays, and it makes the code more maintainable (e.g. easier to read and understand). There's no reason to still be using
$iand$iifor variable names. (It should be$jinstead of$iianyway. ;)So that would be something like
$row_id,$column_id,$number_of_columnsandDecrement amount of columns if there is a weight column("cols" -> "columns") respectively.We should also have one more person test it. I can't do it right now, but should be able to soon (if nobody gets a chance before I get to it).
Comment #7
lolandese commentedDoing a search for " $i " in Drupal core it finds 656 matches across 296 files. I think that, at least, we shouldn't treat this as being a blocker.
Comment #8
lolandese commentedTake note of #2868077: Disable table drag functionality in case of locked default cells under the first row and on the field settings form in general (D7) as also here we should check how locking cells might interfere with dragging rows.
Comment #9
lolandese commentedApart from #8 above that suggests disabling row drag for rows with a default value, as implemented for the D7 version, it appears that row order on existing table rows is being changed when entering Edit mode. Likely to do with wrong row weights. See screenshots below.
Comment #10
lolandese commentedThe file used for testing has been imported on a test node before applying the patch. Rename it to non-utf8.csv.
Comment #11
drupalisedmanish commentedDo we have any updates on status of the issue fix mentioned in comment #9
Comment #12
lolandese commentedNot yet. Feel free to work on it.
Comment #13
s.abbott commentedI have taken a stab at the issues raised in #8 and #9, as well as re-rolling the patch so it applies to 8.x-2.x-dev and cleaning up some unnecessary changes. I think that with this it should be ready to go.
Also the
$iivariable mentioned in #6 was there before this patch, so changing it would introduce unnecessary noise. I think that changing it is a good idea, just not bundled in with other changes.Comment #14
s.abbott commentedI realized that I accidentally left a debug value printout in #13.
Comment #15
s.abbott commentedI made a couple more small tweaks:
Comment #16
s.abbott commentedI realized I left a slight change in that should have been removed when I got rid of the
unset($row['weight']);in the last patch.Comment #17
heyehren commentedThere seems to be an issue with drag and drop when in use tablefields inside paragraphs.
When i drag the paragraph row it seems to also effect the tablefield rows as well. See attached image.
Comment #18
heyehren commentedHi s.abbott. I have applied your patch 16 and it doesn't work for me. I can not see the drag arrows in front of each row.
Comment #19
heyehren commentedSorry about the noise, actually i previously applied the patch the wrong way. Now it"s all working. Thanks heaps for this patch!
Comment #20
jay.dansand commentedI found with the patch and current HEAD of 8.x-2.x, commit b2f13ec (same commit as 8.x-2.2 release), saving tables removed all values. For what it's worth, I'm using Tablefield on a Paragraph entity. Attached is a small tweak to the #16 patch that fixed it in my case - could anyone else comment on which patch (this or #16) works for them with 8.x-2.2?
Comment #22
heyehren commented@jay.dansand, I have the same issue with patch #16. When i safe the table all content is deleted.
Now i have updated to 8.x-2.2 and can no longer apply patch #16 via composer.
But i applied your patch #20 manually and now drag and drop is working without deleting table content when saving. Thank you!
Comment #23
ducktape commentedThis broke sorting for me, with dragging and weight dropdowns, because the new order was not reflected in the values.
Updated the patch from 20.
Comment #25
ducktape commentedFixed the sort function in previous patch.
Comment #27
ducktape commentedThe change from #20 breaks testing, as the "value" index introduced in the values array is not present when installed on a fresh drupal, and thus also during testing.
However I also see this "value" index in my own project, not using Paragraphs, so I guess there might be interference from other contrib.
Comment #28
yovinceThanks @ducktape , just made a bit change to fit my project.
Comment #29
barry_fisher commentedWe tried the patch in #28 and this still appears to delete content on save. I haven't had time to investigate why, maybe I'll get a chance if we come back to this, but I wanted to flag this here in case anyone thought (as we did) that the patch in #28 was a fix from the problems described above. Nevertheless, thanks to everyone trying to progress this feature - it certainly will be useful once resolved.
Comment #30
rowanadev commentedI removed the massageFormValues function from this patch and it is working well for me.
Thank you for the patch!
Comment #31
juanolalla commentedFollowing @RowanADev suggestion and my own testing, I've removed massageFormValues from patch 24 and it's working well now for me. Uploading updated patch and interdiff.
Comment #32
juanolalla commentedThis implementation in patch #32 is adding a new column to the table to keep the weight values, so as a consequence that column was being shown by the field formatter. I've fixed that in this new patch.
Comment #33
anthonygray47 commented#32 provides the expected result.
Side note: If anyone uses Gin as their admin theme, this patch broke the Tablefield form display. I had to overwrite the following style to return the form display back to its previous state.
.paragraphs-tabs-wrapper .field-multiple-table .draggable > td + td {width: 100%; }with
.form-tablefield table td + td { width: auto; }Comment #34
jayhuskins#32 works for me. However, when using "show row weights" the weight options are always -10 to 10 and do not reflect the number of rows in the table.
Comment #35
guilherme-lima-almeidaHi there @jayhuskins,
I added the delta in the weight render element to the number of rows in the tablefield.
Comment #36
Munavijayalakshmi commented#35 working fine as per #34.
Comment #37
Munavijayalakshmi commentedComment #43
guilherme-lima-almeidaCommitted 26d63be6 and pushed to 8.x-2.x-dev.
I'll create a new release in the future for this feature.
Comment #44
guilherme-lima-almeida