Fixed problem bookmarking Policy/IPA Server tabs

When opening a bookmark, each tab level will be updated separately
from top to bottom according to the URL state. The navigation code
has been modified to recognize when an ancestor tab is being updated
and not change the URL state.

Ticket #1521
This commit is contained in:
Endi S. Dewata 2011-07-25 14:05:02 -05:00 committed by Adam Young
parent 87821f2049
commit 61ff6ff107

View File

@ -67,7 +67,7 @@ IPA.navigation = function(spec) {
return that.tabs_by_name[name]; return that.tabs_by_name[name];
}; };
that.get_current_tab = function(state) { that.get_active_tab = function(state) {
var name = null; var name = null;
var next = state[that.root]; var next = state[that.root];
@ -79,6 +79,15 @@ IPA.navigation = function(spec) {
return that.get_tab(name); return that.get_tab(name);
}; };
that.is_ancestor = function(tab, ancestor) {
var parent = tab.parent;
while (parent) {
if (parent == ancestor) return true;
parent = parent.parent;
}
return false;
};
that.get_path_state = function(name) { that.get_path_state = function(name) {
var path_state = {}; var path_state = {};
@ -142,7 +151,7 @@ IPA.navigation = function(spec) {
$.extend(that.path, param_path); $.extend(that.path, param_path);
// find the tab pointed by the path // find the tab pointed by the path
var tab = that.get_current_tab(that.path); var tab = that.get_active_tab(that.path);
// find the active tab at the lowest level // find the active tab at the lowest level
while (!tab.entity) { while (!tab.entity) {
@ -243,18 +252,31 @@ IPA.navigation = function(spec) {
var tabs = $('.' + that.tab_class, that.container); var tabs = $('.' + that.tab_class, that.container);
tabs.tabs({ tabs.tabs({
select: function(event, ui) { select: function(event, ui) {
// get the selected tab
var panel = $(ui.panel); var panel = $(ui.panel);
var name = panel.attr('name'); var name = panel.attr('name');
var selected_tab = that.get_tab(name);
// get the tab specified in the URL state
var state = that.get_state(); var state = that.get_state();
var tab = that.get_current_tab(state); var url_tab = that.get_active_tab(state);
if (tab && tab.name == name) { // hash change if (url_tab) {
return that.push_state(state); // if they are the same, the selection is triggered by hash change
if (url_tab == selected_tab) {
// use the URL state to update internal state
return that.push_state(state);
} else { // mouse click // if the selection is for the ancestor
return that.show_page(name); } else if (that.is_ancestor(url_tab, selected_tab)) {
// let the tab be updated and don't change the state
return true;
}
} }
// selection is triggered by mouse click, update the URL state
return that.show_page(name);
} }
}); });
}; };