diff --git a/install/ui/association.js b/install/ui/association.js index 5354117d0..9f315a0e1 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -762,13 +762,17 @@ IPA.association_facet = function (spec) { that.table.prev_page = function() { if (that.table.current_page > 1) { - IPA.nav.push_state({ page: that.table.current_page-1 }); + var state = {}; + state[that.entity_name+'-page'] = that.table.current_page - 1; + IPA.nav.push_state(state); } }; that.table.next_page = function() { if (that.table.current_page < that.table.total_pages) { - IPA.nav.push_state({ page: that.table.current_page+1 }); + var state = {}; + state[that.entity_name+'-page'] = that.table.current_page + 1; + IPA.nav.push_state(state); } }; @@ -778,16 +782,21 @@ IPA.association_facet = function (spec) { } else if (page > that.total_pages) { page = that.total_pages; } - IPA.nav.push_state({ page: page }); + var state = {}; + state[that.entity_name+'-page'] = page; + IPA.nav.push_state(state); }; that.table.refresh = function() { - var page = parseInt(IPA.nav.get_state('page'), 10) || 1; + var state = {}; + var page = parseInt(IPA.nav.get_state(that.entity_name+'-page'), 10) || 1; if (page < 1) { - IPA.nav.push_state({ page: 1 }); + state[that.entity_name+'-page'] = 1; + IPA.nav.push_state(state); return; } else if (page > that.table.total_pages) { - IPA.nav.push_state({ page: that.table.total_pages }); + state[that.entity_name+'-page'] = that.table.total_pages; + IPA.nav.push_state(state); return; } that.table.current_page = page; diff --git a/install/ui/entity.js b/install/ui/entity.js index 83687fe7e..a2386b816 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -48,6 +48,8 @@ IPA.facet = function (spec) { // facet group name that.facet_group = spec.facet_group; + that.state = {}; + that.__defineGetter__('entity_name', function() { return that._entity_name; }); @@ -467,6 +469,7 @@ IPA.entity = function (spec) { that.redirect_facet = spec.redirect_facet; that.containing_entity = null; + that.get_dialog = function(name) { return that.dialogs.get(name); }; diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 2f39d8b31..605a36125 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -39,6 +39,8 @@ IPA.navigation = function(spec) { that.tabs = []; that.tabs_by_name = {}; + that.path = {}; + that.set_tabs = function(tabs) { that.tabs = tabs; that.tabs_by_name = {}; @@ -96,16 +98,30 @@ IPA.navigation = function(spec) { return path_state; }; - var state = $.bbq.getState(); - that.push_state = function(params) { - if (IPA.current_entity) { - var facet = IPA.current_entity.get_facet(); + var param_path = {}; + var param_state = {}; - if (facet.is_dirty()) { + for (var key in params) { + var value = params[key]; + if (key.indexOf('-') < 0) { + param_path[key] = value; + } else { + param_state[key] = value; + } + } + + var state = {}; + + var prev_entity = IPA.current_entity; + var prev_facet = prev_entity ? prev_entity.facet : null; + + if (prev_facet) { + + if (prev_facet.is_dirty()) { var dialog = IPA.dirty_dialog({ - facet: facet + facet: prev_facet }); dialog.callback = function() { @@ -117,57 +133,68 @@ IPA.navigation = function(spec) { return false; } + + // get prev facet state + $.extend(state, prev_facet.state); } - for ( var param in params){ - state[param] = params[param]; + // merge existing path with new path + $.extend(that.path, param_path); + + // find the tab pointed by the path + var tab = that.get_current_tab(that.path); + + // find the active tab at the lowest level + while (!tab.entity) { + var index = tab.container.tabs('option', 'selected'); + tab = tab.children[index]; } - var url_state ={}; - var key = that.root; - while(state[key]){ - var value = state[key]; - url_state[key] = value; - key = value; + var facet_name; + if (tab.entity == prev_entity) { + // merge prev facet state with new state to find new facet name + $.extend(state, param_state); + facet_name = state[tab.entity.name+'-facet']; + + } else { + // find new facet name in the new state + facet_name = param_state[tab.entity.name+'-facet']; } - /*We are at the leaf node, which is the sleected entity.*/ - var entity = value; - for (var key2 in state){ - if ((key2 === entity) || (key2.search('^'+entity +'-') > -1)){ - url_state[key2] = state[key2]; + var facet = tab.entity.get_facet(facet_name); + + // update new facet state with new state + $.extend(facet.state, param_state); + + var entity = tab.entity.containing_entity; + while (entity) { + var facet2 = entity.get_facet(); + + var key_names = entity.get_key_names(); + for (var i=0; i').append($('', { + var tab_li = $('
  • ').append($('', { href: '#'+tab_id, title: tab.label, html: tab.label })); - if (tab.hidden){ - tab_li.css('display','none'); + if (tab.hidden) { + tab_li.css('display', 'none'); } - tab.container = $('
    ', { + tab.children_container = $('
    ', { id: tab_id, name: tab.name }); if (tab.children && tab.children.length) { var kids = - that._create(tab.children, tab.container, depth+1); + that._create(tab.children, tab.children_container, depth+1); /*If there are no child tabs, remove the container */ - if (kids === 0){ - tabs.splice(i,1); + if (kids === 0) { + tabs.splice(i, 1); i -= 1; continue; } } created_count += 1; tab_li.appendTo(ul); - tab.container.appendTo(container); + tab.children_container.appendTo(container); } return created_count; }; @@ -305,6 +337,8 @@ IPA.navigation = function(spec) { var parent_name = container.attr('name'); var tab_name = that.get_state(parent_name); + if (!tab_name) tab_name = that.path[parent_name]; + that.path[parent_name] = tab_name; var index = 0; while (index < tabs.length && tabs[index].name != tab_name) index++; @@ -313,13 +347,13 @@ IPA.navigation = function(spec) { container.tabs('select', index); var tab = tabs[index]; - if (tab.hidden){ - depth = depth -1; + if (tab.hidden) { + depth--; } if (tab.children && tab.children.length) { var next_depth = depth + 1; - that._update(tab.children, tab.container, next_depth); + that._update(tab.children, tab.children_container, next_depth); } else if (tab.entity) {