From c00267308e2844b2a345c22df5c045117fcff9a2 Mon Sep 17 00:00:00 2001 From: Petr Voborník Date: Fri, 27 Jan 2012 17:20:25 +0100 Subject: Navigation and redirection to various facets In current implementation target facet of navigation(from menu) and redirection is always one exact facet per entity. There isn't a way to navigate to different facet from menu or redirect to different facets from various facets. This patch adds: * possibility to define menu items which can navigate to different facets of various entities. This also means that now current menu tree can contain leafs with the same entity. * possibility to define redirection target per facet - it is needed to keep breadcrumb navigation consistent with various navigation tree patch leading to same entity leafs. This functionality is needed for Automember UI. Automember UI is designed as if it was for two entities but it is in fact only one. https://fedorahosted.org/freeipa/ticket/2195 --- install/ui/navigation.js | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'install/ui/navigation.js') diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 84df7f4d..72c91426 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -191,7 +191,7 @@ IPA.navigation = function(spec) { // push entity path and facet state state = {}; - $.extend(state, that.get_path_state(tab.entity.name)); + $.extend(state, that.get_path_state(tab.name)); $.extend(state, facet.state); $.bbq.pushState(state, 2); @@ -206,6 +206,26 @@ IPA.navigation = function(spec) { $.bbq.removeState(key); }; + that.show_tab = function(tab_name, pkey) { + + var tab = that.get_tab(tab_name); + + var state = that.get_path_state(tab.name); + + if (tab.entity) { + + if (tab.facet) { + state[tab.entity.name + '-facet'] = tab.facet; + } + + if (pkey) { + state[tab.entity.name + '-pkey'] = pkey; + } + } + + return that.push_state(state); + }; + that.show_page = function(entity_name, facet_name, pkey) { var state = that.get_path_state(entity_name); @@ -243,6 +263,22 @@ IPA.navigation = function(spec) { return that.push_state(state); }; + that.get_tab_facet = function(tab_name) { + + var facet = null; + var tab = that.get_tab(tab_name); + + if (tab.entity) { + if (tab.facet) { + facet = tab.entity.get_facet(tab.facet); + } else { + facet = tab.entity.get_facet(tab.entity.redirect_facet); + } + } + + return facet; + }; + that.create = function() { @@ -279,7 +315,7 @@ IPA.navigation = function(spec) { } // selection is triggered by mouse click, update the URL state - return that.show_page(name); + return that.show_tab(name); } }); }; @@ -389,8 +425,8 @@ IPA.navigation = function(spec) { that.content); if (!entity_container.length) { tab.content = $('
', { - name: tab.name, - title: tab.label, + name: tab.entity.name, + title: tab.entity.label, 'class': 'entity' }).appendTo(that.content); tab.entity.create(tab.content); -- cgit