[Rt-commit] rt branch, 4.0/cascade-cf-with-multi-selected-parent, created. rt-4.0.13-157-g1030b88

? sunnavy sunnavy at bestpractical.com
Mon Jul 15 09:39:42 EDT 2013


The branch, 4.0/cascade-cf-with-multi-selected-parent has been created
        at  1030b884c928f309e6e9261c45986399d0e1455f (commit)

- Log -----------------------------------------------------------------
commit 39c62c66bc27c9e3ec9355c5326e192df58e867a
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jul 15 21:12:47 2013 +0800

    cascaded cf's parent might have multiple values selected
    
    see also #16336

diff --git a/share/html/Elements/EditCustomFieldSelect b/share/html/Elements/EditCustomFieldSelect
index 8668bc4..6cceb5a 100644
--- a/share/html/Elements/EditCustomFieldSelect
+++ b/share/html/Elements/EditCustomFieldSelect
@@ -72,7 +72,7 @@ jQuery(  function () {
         basedon.onchange = function () {
             filter_cascade(
                 <% "$id-Values" |n,j%>,
-                basedon.value,
+                jQuery(basedon).val(),
                 1
             );
             if (oldchange != null)
diff --git a/share/html/NoAuth/js/cascaded.js b/share/html/NoAuth/js/cascaded.js
index 349d181..9f347a7 100644
--- a/share/html/NoAuth/js/cascaded.js
+++ b/share/html/NoAuth/js/cascaded.js
@@ -45,9 +45,12 @@
 %# those contributions and any derivatives thereof.
 %#
 %# END BPS TAGGED BLOCK }}}
-function filter_cascade (id, val) {
+function filter_cascade (id, vals) {
     var select = document.getElementById(id);
     var complete_select = document.getElementById(id + "-Complete" );
+    if ( !( vals instanceof Array ) ) {
+        vals = [vals];
+    }
 
     if (!select) { return };
     var i;
@@ -60,6 +63,10 @@ function filter_cascade (id, val) {
 
         var complete_children = complete_select.childNodes;
 
+        var cloned_labels = {};
+        var cloned_empty_label;
+        for ( i in vals ) {
+        val = vals[i];
         if ( val == '' && arguments.length == 3 ) {
             // no category, and the category is from a hierchical cf;
             // leave this set of options empty
@@ -71,20 +78,43 @@ function filter_cascade (id, val) {
                     select.appendChild(new_option);
                 }
             }
+            break;
         }
         else {
+            var labels_to_clone = {};
             for (i in complete_children) {
                 if (!complete_children[i].label ||
                       (complete_children[i].hasAttribute &&
-                            !complete_children[i].hasAttribute('label') ) ||
-                        complete_children[i].label.substr(0, val.length) == val ) {
-                    if ( complete_children[i].cloneNode ) {
-                        new_option = complete_children[i].cloneNode(true);
-                        select.appendChild(new_option);
+                            !complete_children[i].hasAttribute('label') ) ) {
+                    if ( cloned_empty_label ) {
+                        continue;
+                    }
+                }
+                else if ( complete_children[i].label.substr(0, val.length) == val ) {
+                    if ( cloned_labels[complete_children[i].label] ) {
+                        continue;
                     }
+                    labels_to_clone[complete_children[i].label] = true;
+                }
+                else {
+                    continue;
                 }
+
+                if ( complete_children[i].cloneNode ) {
+                    new_option = complete_children[i].cloneNode(true);
+                    select.appendChild(new_option);
+                }
+            }
+
+            if ( !cloned_empty_label )
+                cloned_empty_label = true;
+
+            for ( label in labels_to_clone ) {
+                if ( !cloned_labels[label] )
+                    cloned_labels[label] = true;
             }
         }
+        }
     }
     else {
 // for back compatibility

commit 1030b884c928f309e6e9261c45986399d0e1455f
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Mon Jul 15 21:37:00 2013 +0800

    nothing else but indent fix

diff --git a/share/html/NoAuth/js/cascaded.js b/share/html/NoAuth/js/cascaded.js
index 9f347a7..787d06d 100644
--- a/share/html/NoAuth/js/cascaded.js
+++ b/share/html/NoAuth/js/cascaded.js
@@ -66,55 +66,55 @@ function filter_cascade (id, vals) {
         var cloned_labels = {};
         var cloned_empty_label;
         for ( i in vals ) {
-        val = vals[i];
-        if ( val == '' && arguments.length == 3 ) {
-            // no category, and the category is from a hierchical cf;
-            // leave this set of options empty
-        } else if ( val == '' ) {
-            // no category, let's clone all node
-            for (i in complete_children) {
-                if ( complete_children[i].cloneNode ) {
-                    new_option = complete_children[i].cloneNode(true);
-                    select.appendChild(new_option);
+            val = vals[i];
+            if ( val == '' && arguments.length == 3 ) {
+                // no category, and the category is from a hierchical cf;
+                // leave this set of options empty
+            } else if ( val == '' ) {
+                // no category, let's clone all node
+                for (i in complete_children) {
+                    if ( complete_children[i].cloneNode ) {
+                        new_option = complete_children[i].cloneNode(true);
+                        select.appendChild(new_option);
+                    }
                 }
+                break;
             }
-            break;
-        }
-        else {
-            var labels_to_clone = {};
-            for (i in complete_children) {
-                if (!complete_children[i].label ||
-                      (complete_children[i].hasAttribute &&
-                            !complete_children[i].hasAttribute('label') ) ) {
-                    if ( cloned_empty_label ) {
-                        continue;
+            else {
+                var labels_to_clone = {};
+                for (i in complete_children) {
+                    if (!complete_children[i].label ||
+                          (complete_children[i].hasAttribute &&
+                                !complete_children[i].hasAttribute('label') ) ) {
+                        if ( cloned_empty_label ) {
+                            continue;
+                        }
                     }
-                }
-                else if ( complete_children[i].label.substr(0, val.length) == val ) {
-                    if ( cloned_labels[complete_children[i].label] ) {
+                    else if ( complete_children[i].label.substr(0, val.length) == val ) {
+                        if ( cloned_labels[complete_children[i].label] ) {
+                            continue;
+                        }
+                        labels_to_clone[complete_children[i].label] = true;
+                    }
+                    else {
                         continue;
                     }
-                    labels_to_clone[complete_children[i].label] = true;
-                }
-                else {
-                    continue;
-                }
 
-                if ( complete_children[i].cloneNode ) {
-                    new_option = complete_children[i].cloneNode(true);
-                    select.appendChild(new_option);
+                    if ( complete_children[i].cloneNode ) {
+                        new_option = complete_children[i].cloneNode(true);
+                        select.appendChild(new_option);
+                    }
                 }
-            }
 
-            if ( !cloned_empty_label )
-                cloned_empty_label = true;
+                if ( !cloned_empty_label )
+                    cloned_empty_label = true;
 
-            for ( label in labels_to_clone ) {
-                if ( !cloned_labels[label] )
-                    cloned_labels[label] = true;
+                for ( label in labels_to_clone ) {
+                    if ( !cloned_labels[label] )
+                        cloned_labels[label] = true;
+                }
             }
         }
-        }
     }
     else {
 // for back compatibility

-----------------------------------------------------------------------


More information about the Rt-commit mailing list