Closed (fixed)
Project:
Taxonomy Term Reference Tree Widget
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 Dec 2016 at 12:01 UTC
Updated:
26 May 2019 at 13:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
duaelfrComment #3
n3or commentedI started working on this issue too but didn't realize that there is already a issue for it.
Now I merged our changes into a new patch (hopefully I got all your changes) and made an addition according cascading selection.
At the moment the whole JavaScript implementation seems really buggy, major parts of it were not running at all.
Comment #4
n3or commentedNow the "parents select" should also work as expected..
Comment #5
n3or commentedRemoved debug code..
Comment #6
webcultist commentedLooks good to me!
Comment #7
n3or commentedAdded different modes for cascading selection. Now you can specify the following modes:
- None: No cascading selection
- Select / Deselect: Automatically select / deselect children
- Select only: Automatically select children, do nothing if the parent gets unselected
- Deselect only: Automatically deselect children, do nothing if the parent gets selected
Comment #8
cgmonroe commentedFound one minor problem with the patch on #7. If you have leaves only and select parents automatically set, the parent term id does not get added in hierarchical order. E.g. If you select Child1 and Child3 under Parent, the terms get stored as Child1, Parent, Child3. The hierarchical order should be Parent, Child1, Child3.
The use case for preserving order is when you are using views and need to pick only the 'highest' term by selecting the first delta in the display settings. E.g., you have a tree with top level parents like Worlds News, Local News, Sports each with children categories. And you want to show a teaser of the article with the top level category only.
This is easy to fix, just move the child set statement below the test to add the parent. Attached is a patch that does this.
E.g. with patch #7 the subcategory is first term.
Soccer - Spain Advances in World Cup
Italy - Mount Etna Erupts with Tourist on it
With the new patch, the parent is the first term.
Sports - Spain Advances in World Cup
Worlds News - Mount Etna Erupts with Tourist on it
Comment #9
cgmonroe commentedComment #10
cgmonroe commentedThe patch in #8 was not created correctly. Attached is the correct patch.
Comment #11
liampower commentedPatch works well for me, there are just some coding standard issues that will be flagged up but it looks like there are more across the module already so I would say deal with them all at once after this is merged in.
Comment #12
deasly commentedThe patch in #10 Updated to remove the depreciated .size() jQuery function causing parent selection to break.
.size() replaced with .length
Comment #13
liampower commentedThe selection of parent terms seems to have stopped working for 8.4
Comment #14
crzdev commentedHere goes a new version of the patch #10, great work!
Important: appy to the latest dev version (not alpha).
Changes are (see interdiff):
TermReferenceTree coding style.
Use .find instead .children to prevent this to fail if checkbox is inside label (bootstrap theme does this for example).
Use .length instead .size() (deprecated @see https://api.jquery.com/size/).
Use .once() properly and remove @todo.
Please review, thanks!
Comment #15
crzdev commentedComment #16
crzdev commentedForgot to include schema config, these are new files.
Please review, thanks!
Comment #17
crzdev commentedNew version with notice fix on field validation.
Comment #18
s-jack commentedPatch works well for me with Drupal8.4.2.
Thanks.
Comment #19
pavlosdanPatch works well for us as well.
Comment #20
mahalakshmi.g commentedIssue with Cascading Selection solved.
Comment #22
mahalakshmi.g commentedIssue with Cascading Selection solved. Included with correct # and version.
Comment #23
jcisio commentedThe last change fixed well cascading selection option. So back to RTBC.
Comment #24
webcultist commentedI tried the latest patch with the latest dev.
The automatic parent selection if child is selected, works pretty well.
The automatic deselection of the child elements seems not to work. On the "not-selected.png" screenshot I just unticked the parent but the child checkboxes are still all ticked. Made a screenshot of the widget form settings just to be sure everything is correct configured.
...or is here some type of misunderstanding on my side?
Comment #25
webcultist commentedComment #26
Anonymous (not verified) commentedI too am facing the problem described in #24.
At least to me it seems like there is one .parent() too much on line 124:
var children = event_target.parent().parent().next().children().find('input[id^="' + control_id + '-children"]');Quickly tested it and it seems to work if I remove one of them, and of course it makes sense as it fits the HTML structure.
The question is, is the HTML always the same or are there possibly differences caused by custom themes used on the admin side?
Comment #27
Anonymous (not verified) commentedJust noticed that if I edit the field itself (/admin/structure/types/manage/....) that uses this module and patch #22, it throws an error:
Everything seems to work anyway, so would it be ok to just check if the target_id exists or not and act on that..?
Comment #28
n3or commentedI used the change from #22 and applied the change from #26 and it works for me.
Maybe the HTML structure changed during one of the latest updates..
Comment #29
n3or commentedFixed a problem with hierarchy levels > 2.
Comment #30
duaelfr@n3or I tried to apply your patches from #28 and #29 but there is a problem. Both are trying to redefine existing files and the last one is marked as corrupted by git. Could you try to rebase your work on the 8.x-1.x head and provide a new patch please?
Comment #31
brad.bulger commentedRe-roll to fix missing line ending.
Comment #32
brad.bulger commentedSorry, try that again.
Comment #33
brad.bulger commentedI thought it was a line ending issue, but beyond that, a problem is that one of the lines being altered by the patch is different between alpha2 and the current 1.x branch. I couldn't get composer to apply the patch successfully until I changed to require drupal/term_reference_tree:1.x-dev.
Comment #34
jonraedeke commented#32 Works well for me. All patches should be against dev, so that's not an issue.
Comment #35
pifagor commentedLook good
Comment #37
alex_optimComment #38
alex_optim