Items nested in other items were created in root list instead of nested list.

Note: this feature is not used in current UI but it's likely to be used by a plugin
--
Petr Vobornik
From 0f83a4bfb5d164f0fbd6d6520091fbea21887673 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 11 Jul 2014 16:38:56 +0200
Subject: [PATCH] webui: fix nested items creation in dropdown list

Items nested in other items were created in root list instead of nested list.
---
 install/ui/src/freeipa/widgets/DropdownWidget.js | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/install/ui/src/freeipa/widgets/DropdownWidget.js b/install/ui/src/freeipa/widgets/DropdownWidget.js
index 181cfc5cfeb6f68852b7b00f4d7a0b178795e5fc..1f925a80a09782274226e7faf32c0c370fd32e04 100644
--- a/install/ui/src/freeipa/widgets/DropdownWidget.js
+++ b/install/ui/src/freeipa/widgets/DropdownWidget.js
@@ -191,7 +191,7 @@ define(['dojo/_base/declare',
         _itemsSetter: function(value) {
             this._clear_items();
             this.items = value;
-            this._render_items(this.items, this.dom_node);
+            this._render_items(this.items);
         },
 
         _clear_items: function() {
@@ -201,9 +201,9 @@ define(['dojo/_base/declare',
             }
         },
 
-        _render_list: function(container) {
+        _render_list: function(container, nested) {
 
-            var ul = this.ul_node = construct.create('ul', {
+            var ul = construct.create('ul', {
                 'class': 'dropdown-menu'
             });
             if (this.right_aligned) {
@@ -212,14 +212,15 @@ define(['dojo/_base/declare',
             if (container) {
                 construct.place(ul, container);
             }
+            if (!nested) this.ul_node = ul;
             return ul;
         },
 
         _render_items: function(items, container) {
 
-            var ul = this.ul_node;
+            if (!container) container = this.ul_node;
             array.forEach(items, function(item) {
-                this._render_item(item, ul);
+                this._render_item(item, container);
             }, this);
         },
 
@@ -257,7 +258,8 @@ define(['dojo/_base/declare',
 
             if (item.items && item.items.length > 0) {
                 dom_class.add(li, 'dropdown-submenu');
-                this._render_items(item.items, li);
+                var ul = this._render_list(li, true);
+                this._render_items(item.items, ul);
             } else {
                 on(a, 'click', lang.hitch(this, function(event) {
                     this.on_item_click(event, item);
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to