From 0b239aea409c4207a2045b4bc14dd6cd751ba28d Mon Sep 17 00:00:00 2001 From: Jonathan Rossi Date: Tue, 22 Dec 2015 13:18:49 -0500 Subject: [PATCH] Refactored tree initialization --- .../net/apachegui/ConfigurationTree.js | 13 +++++++++---- .../apachegui/globalsettings/GlobalTree.js | 19 +++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/main/webapp/resources/net/apachegui/ConfigurationTree.js b/src/main/webapp/resources/net/apachegui/ConfigurationTree.js index 3bf68667..2688aad1 100644 --- a/src/main/webapp/resources/net/apachegui/ConfigurationTree.js +++ b/src/main/webapp/resources/net/apachegui/ConfigurationTree.js @@ -1,5 +1,5 @@ //TODO stub out this file into a re-usable widget for GlobalTree.js -//TODO VirtualHost js should end up using this widget +//TODO VirtualHost js should end up using this widget (started) define([ "dojo/_base/declare", "dojo/dom", @@ -27,7 +27,11 @@ define([ menu: null, currentTreeItem: null, editable: true, - treeJSON: {}, + treeJSON: { + identifier: "id", + items: [], + label: "name" + }, autoExpand: false, inputAutoSuggest: null, @@ -52,7 +56,7 @@ define([ */ constructor: function(params){ this.id = params.id; - this.treeJSON = params.treeJSON || {}; + this.treeJSON = params.treeJSON || this.treeJSON; this.autoExpand = params.autoExpand || false; this.loadTreeJSON = params.loadTreeJSON || this.loadTreeJSON; @@ -111,7 +115,7 @@ define([ }); this.menu.addChild(new MenuItem({ - label : "Exapnd All", + label : "Expand All", onClick : function() { that.expandAll(); } @@ -163,6 +167,7 @@ define([ startup: function() { this.tree.startup(); + this.reload(); }, destroy: function() { diff --git a/src/main/webapp/resources/net/apachegui/globalsettings/GlobalTree.js b/src/main/webapp/resources/net/apachegui/globalsettings/GlobalTree.js index 731dedf7..121978f2 100755 --- a/src/main/webapp/resources/net/apachegui/globalsettings/GlobalTree.js +++ b/src/main/webapp/resources/net/apachegui/globalsettings/GlobalTree.js @@ -34,19 +34,14 @@ define([ }, buildGlobalTree: function() { - var that = this; - - this.loadGlobalTreeJSON(function(treeJSON) { - that.configTree = new ConfigurationTree({ - id: 'global_tree', - treeJSON: treeJSON, - loadTreeJSON: that.loadGlobalTreeJSON - }); - that.configTree.startup(); - that.addListeners(); - - domConstruct.place(that.configTree.domNode, dom.byId('global_tree_container'), 'last'); + this.configTree = new ConfigurationTree({ + id: 'global_tree', + loadTreeJSON: this.loadGlobalTreeJSON }); + this.configTree.startup(); + this.addListeners(); + + domConstruct.place(this.configTree.domNode, dom.byId('global_tree_container'), 'last'); }, addListeners: function() {