Hi ,

I have been improving this module as part of a project and would be interested with maintenance, as the status is looking for co-maintainer.

Please find the patch attached, it solves the following tickets:
- #1114510: Nested taxonomy lists collapse unintentionally (using an identical approach of the proposed patch)
- #789712: Enable option to force selection of parents terms
- other non reported small issues were addressed

Please review the patch and get back to me about the maintenance. I'll have more improvements coming up, that will add extra functionality to it.
Please note that these improvements were sponsored; it is alway appreciated the use of --author in patch commits :-)

Thanks!
Nuno

CommentFileSizeAuthor
#1 taxonomy_tree_select-1351972.patch9.33 KBnunoveloso

Comments

nunoveloso’s picture

Status: Active » Needs review
StatusFileSize
new9.33 KB

And now the patch file :-)

danillonunes’s picture

Status: Needs review » Needs work

Hello Nuno,

+++ b/taxonomy_tree_select.cssundefined
+++ b/taxonomy_tree_select.cssundefined
@@ -24,7 +24,7 @@ div.item-list ul.taxonomy-tree li.expansable div.item-list ul {

@@ -24,7 +24,7 @@ div.item-list ul.taxonomy-tree li.expansable div.item-list ul {
 }
 div.item-list ul.taxonomy-tree label {
   cursor: pointer;
-  display: block;
+/*  display: block;*/
   padding: 1px 5px;
 }
 div.item-list ul.taxonomy-tree label:hover {

Please do not comment a piece of code. If you want to remove something, just remove it.

+++ b/taxonomy_tree_select.cssundefined
@@ -24,7 +24,7 @@ div.item-list ul.taxonomy-tree li.expansable div.item-list ul {
@@ -47,4 +47,9 @@ div.item-list ul.taxonomy-tree-theme-garland label:hover {

@@ -47,4 +47,9 @@ div.item-list ul.taxonomy-tree-theme-garland label:hover {
 }
 div.item-list ul.taxonomy-tree-theme-garland div.active label {
   background-color: #027AC6;
+}
+
+/* indentat sub-levels*/
+div.item-list ul.taxonomy-tree ul.expansable {
+  margin-left: 20px;
 }

I don't know if we should rely on this property or leave it to theme layer.

+++ b/taxonomy_tree_select.jsundefined
@@ -1,18 +1,24 @@
+    ¶

Extra whitespace.

+++ b/taxonomy_tree_select.jsundefined
@@ -29,6 +35,16 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {
+
+            // select parent terms in the tree
+            if ($force_parents) {
+              // get parent term wrapper
+              $parent = $item.parent().parent().parent().parent();
+              // checks its input and sync rest of the inputs
+              $parent.children('div.form-item').eq(0).children('label').children('input')
+                .attr('checked', 'checked')
+                .trigger('sync');
+            }

I think this needs a server-side validation too.

+++ b/taxonomy_tree_select.jsundefined
@@ -29,6 +35,16 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {
@@ -40,15 +56,15 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {

@@ -40,15 +56,15 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {
 
     $expansables
       // Make sure all lists that have active children starts expanded
-      .bind('init', function(e) {
+      .bind('init', function(event) {
         var $item = $(this);
         if ($item.find('.active').length) {
           $item.trigger('expand');
         }
       })
       // Collapse list
-      .bind('collapse', function(e) {
-        e.stopPropagation();
+      .bind('collapse', function(event) {
+        event.stopPropagation();
         var $item = $(this),
             $child = $item.children('div.item-list').children('ul');
         $child.slideUp('fast');
@@ -57,8 +73,8 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {

@@ -57,8 +73,8 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {
           .addClass('collapsed');
       })
       // Expand list
-      .bind('expand', function(e) {
-        e.stopPropagation();
+      .bind('expand', function(event) {
+        event.stopPropagation();
         var $item = $(this),
             $child = $item.children('div.item-list').children('ul');
         $child.slideDown('fast');
@@ -67,8 +83,8 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {

@@ -67,8 +83,8 @@ Drupal.behaviors.taxonomyTreeSelect = function(context) {
           .addClass('expanded');
       })
       // Expand or collapse
-      .bind('toggle', function(e) {
-        e.stopPropagation();
+      .bind('toggle', function(event) {
+        event.stopPropagation();
         var $item = $(this),
             $child = $item.children('div.item-list').children('ul');
         if ($child.is(':visible')) {

This was already commited, but I liked the more descriptive 'event' variable name.

+++ b/taxonomy_tree_select.moduleundefined
@@ -158,7 +178,8 @@ function theme_taxonomy_tree_select_nested_lists($element, $tree = array(), $par
+    ¶

Extra whitespace.

--

Please send a separate patch in #789712: Enable option to force selection of parents terms with only their related changes. Also, if you want, submit a follow-up patch in #1114510: Nested taxonomy lists collapse unintentionally with the event variable name changes.

Thank you.