From 43fc996f855edc85218149f4a8795bf87ff66e7f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 28 Dec 2011 13:20:09 -0500 Subject: [PATCH] Fix the post-fetch display of the path control. --- web_frontend/path_control.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/web_frontend/path_control.js b/web_frontend/path_control.js index c72689b..e8792c1 100644 --- a/web_frontend/path_control.js +++ b/web_frontend/path_control.js @@ -96,7 +96,7 @@ armadillo.PathControl.prototype.decorateInternal = function(element) { var path = ''; $.each(components, function (i, part) { - this.element_.append(this.createComponentNode_(path, part), true); + this.element_.append(this.createComponentNode_(path, part)); path = app.joinPath(path, part); }.bind(this)); @@ -150,16 +150,16 @@ armadillo.PathControl.prototype.createComponentNode_ = function(path, name) { * @param {goog.ui.Menu} The menu to attach items to */ armadillo.PathControl.prototype.fetchMenuContents_ = function(path, name, menu) { + var fullPath = this.path_; var callback = function(data, status, xhr) { if (data['error']) { app.showError(data['message']); return; } - if (path == '') { - // If this is the root path element, make sure the root is accessible for - // moving items. - data.splice(0, 1, '/'); - } + + // Create an empty node for the current directory. + data.splice(0, 1, '/'); + menu.empty(); $.each(data, function (i, caption) { // It only makes sense to be able to move into directories. @@ -167,9 +167,10 @@ armadillo.PathControl.prototype.fetchMenuContents_ = function(path, name, menu) return; } var item = $.createDom('option'); - item.val(app.joinPath(path, name, caption)).text(caption); + var componentPath = app.joinPath(path, name, caption); + item.val(componentPath).text(caption); menu.append(item); - if (caption == name) { + if (fullPath.substr(0, componentPath.length) == componentPath) { item.attr('selected', 'selected'); } }); -- 2.43.5