In the D7 version it used to be a lot of options to configure the widget.
This issue is just about bringing these main settings back.

CommentFileSizeAuthor
#32 term_reference_tree-widget_config-2837672-32-8.x.patch18.07 KBbrad.bulger
#31 term_reference_tree-widget_config-2837672-31-8.x.patch18.1 KBbrad.bulger
#29 term_reference_tree-widget_config-2837672-29-8.x.patch18.1 KBn3or
#28 term_reference_tree-widget_config-2837672-28-8.x.patch18.09 KBn3or
#24 widget-form.png92.92 KBwebcultist
#24 not-selected.png54.71 KBwebcultist
#22 term_reference_tree-widget_config-2837672-22-8.x.patch18.09 KBmahalakshmi.g
#22 interdiff-2837672-17-22.txt749 bytesmahalakshmi.g
#20 term_reference_tree-widget_config-2837672-18-8.x.patch18.09 KBmahalakshmi.g
#20 interdiff-2837672-17-18.txt749 bytesmahalakshmi.g
#17 term_reference_tree-widget_config-2837672-17-8.x.patch18.13 KBcrzdev
#17 interdiff-2837672-10-17.txt9.76 KBcrzdev
#16 term_reference_tree-widget_config-2837672-16-8.x.patch18.13 KBcrzdev
#16 interdiff-2837672-10-16.txt9.76 KBcrzdev
#14 term_reference_tree-widget_config-2837672-14-8.x.patch17.39 KBcrzdev
#14 interdiff-2837672-10-14.txt10.37 KBcrzdev
#12 term_ref_tree-formatter_settings_form-2837672-12.patch14.9 KBdeasly
#10 term_ref_tree-formatter_settings_form-2837672-10.patch14.9 KBcgmonroe
#8 term_ref_tree-formatter_settings_form-2837672-8.patch67.42 KBcgmonroe
#7 term_ref_tree-formatter_settings_form-2837672-7.patch14.21 KBn3or
#5 term_ref_tree-formatter_settings_form-2837672-5.patch12.15 KBn3or
#4 term_ref_tree-formatter_settings_form-2837672-4.patch12.24 KBn3or
#3 term_ref_tree-formatter_settings_form-2837672-3.patch9.51 KBn3or
#2 term_ref_tree-formatter_settings_form-2837672-2.patch4.81 KBduaelfr

Comments

DuaelFr created an issue. See original summary.

duaelfr’s picture

Status: Active » Needs review
StatusFileSize
new4.81 KB
n3or’s picture

I 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.

n3or’s picture

Now the "parents select" should also work as expected..

n3or’s picture

Removed debug code..

webcultist’s picture

Looks good to me!

n3or’s picture

Added 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

cgmonroe’s picture

Found 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

cgmonroe’s picture

cgmonroe’s picture

The patch in #8 was not created correctly. Attached is the correct patch.

liampower’s picture

Patch 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.

deasly’s picture

The patch in #10 Updated to remove the depreciated .size() jQuery function causing parent selection to break.

.size() replaced with .length

liampower’s picture

Status: Needs review » Needs work

The selection of parent terms seems to have stopped working for 8.4

crzdev’s picture

Here 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!

crzdev’s picture

Status: Needs work » Needs review
crzdev’s picture

StatusFileSize
new9.76 KB
new18.13 KB

Forgot to include schema config, these are new files.

Please review, thanks!

crzdev’s picture

StatusFileSize
new9.76 KB
new18.13 KB

New version with notice fix on field validation.

s-jack’s picture

Patch works well for me with Drupal8.4.2.
Thanks.

pavlosdan’s picture

Status: Needs review » Reviewed & tested by the community

Patch works well for us as well.

mahalakshmi.g’s picture

Issue with Cascading Selection solved.

Status: Reviewed & tested by the community » Needs work
mahalakshmi.g’s picture

Status: Needs work » Needs review
StatusFileSize
new749 bytes
new18.09 KB

Issue with Cascading Selection solved. Included with correct # and version.

jcisio’s picture

Status: Needs review » Reviewed & tested by the community

The last change fixed well cascading selection option. So back to RTBC.

webcultist’s picture

Issue summary: View changes
StatusFileSize
new54.71 KB
new92.92 KB

I 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?

webcultist’s picture

Status: Reviewed & tested by the community » Needs work
Anonymous’s picture

I 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?

Anonymous’s picture

Just noticed that if I edit the field itself (/admin/structure/types/manage/....) that uses this module and patch #22, it throws an error:

Notice: Undefined index: target_id in Drupal\term_reference_tree\Element\CheckboxTree::valueCallback() (line 82 of modules/term_reference_tree/src/Element/CheckboxTree.php).
Drupal\term_reference_tree\Element\CheckboxTree::valueCallback(Array, , Object)
call_user_func_array(Array, Array) (Line: 1269)
Drupal\Core\Form\FormBuilder->handleInputElement('field_config_edit_form', Array, Object) (Line: 986)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 1056)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 1056)
Drupal\Core\Form\FormBuilder->doBuildForm('field_config_edit_form', Array, Object) (Line: 557)
Drupal\Core\Form\FormBuilder->processForm('field_config_edit_form', Array, Object) (Line: 314)
Drupal\Core\Form\FormBuilder->buildForm('field_config_edit_form', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Everything seems to work anyway, so would it be ok to just check if the target_id exists or not and act on that..?

n3or’s picture

I 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..

n3or’s picture

Status: Needs work » Needs review
StatusFileSize
new18.1 KB

Fixed a problem with hierarchy levels > 2.

duaelfr’s picture

@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?

brad.bulger’s picture

Re-roll to fix missing line ending.

brad.bulger’s picture

Sorry, try that again.

brad.bulger’s picture

I 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.

jonraedeke’s picture

Status: Needs review » Reviewed & tested by the community

#32 Works well for me. All patches should be against dev, so that's not an issue.

pifagor’s picture

Look good

  • alex_optim committed 7de4dd8 on 8.x-1.x
    Issue #2837672 by brad.bulger, alex_optim: Allow to configure widget...
alex_optim’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
alex_optim’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.