luci2: Introduce 'add' option to LuCI2.cbi.AbstractValue.depends() to support increme...
[project/luci2/ui.git] / luci2 / htdocs / luci2 / luci2.js
index 6e66128..00365ae 100644 (file)
@@ -5240,7 +5240,7 @@ function LuCI2()
                        return (i.disabled || i.error.text() == '');
                },
 
-               depends: function(d, v)
+               depends: function(d, v, add)
                {
                        var dep;
 
@@ -5285,7 +5285,11 @@ function LuCI2()
                        if ($.isEmptyObject(dep))
                                return this;
 
-                       this.dependencies.push(dep);
+                       if (!add || !this.dependencies.length)
+                               this.dependencies.push(dep);
+                       else
+                               for (var i = 0; i < this.dependencies.length; i++)
+                                       $.extend(this.dependencies[i], dep);
 
                        return this;
                },