summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-01-27 17:20:25 +0100
committerEndi S. Dewata <edewata@redhat.com>2012-02-01 12:47:42 -0600
commitc00267308e2844b2a345c22df5c045117fcff9a2 (patch)
tree6b3c5f864b23e5cd8750c8545f167012a8c53ecb /install
parentb73fc6e550fed9a1b6d83a03fa16f43b361ec8aa (diff)
downloadfreeipa-c00267308e2844b2a345c22df5c045117fcff9a2.tar.gz
freeipa-c00267308e2844b2a345c22df5c045117fcff9a2.tar.xz
freeipa-c00267308e2844b2a345c22df5c045117fcff9a2.zip
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
Diffstat (limited to 'install')
-rw-r--r--install/ui/entity.js5
-rw-r--r--install/ui/facet.js79
-rw-r--r--install/ui/navigation.js44
3 files changed, 95 insertions, 33 deletions
diff --git a/install/ui/entity.js b/install/ui/entity.js
index acfc9c440..6b2be9e66 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -377,7 +377,7 @@ IPA.entity_builder = function() {
that.facet(spec);
- add_redirect_info();
+ add_redirect_info(spec.name);
return that;
};
@@ -487,8 +487,9 @@ IPA.entity_builder = function() {
}
function add_redirect_info(facet_name){
+ facet_name = facet_name || 'search';
if (!entity.redirect_facet){
- entity.redirect_facet = 'search';
+ entity.redirect_facet = facet_name;
}
}
diff --git a/install/ui/facet.js b/install/ui/facet.js
index 6247ebde6..9821fddc8 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -36,6 +36,7 @@ IPA.facet = function(spec) {
that.name = spec.name;
that.label = spec.label;
that.title = spec.title || that.label;
+ that.tab_label = spec.tab_label || that.label;
that.display_class = spec.display_class;
that.disable_breadcrumb = spec.disable_breadcrumb;
@@ -50,6 +51,8 @@ IPA.facet = function(spec) {
// facet group name
that.facet_group = spec.facet_group;
+ that.redirect_info = spec.redirect_info;
+
that.state = {};
that.get_dialog = function(name) {
@@ -132,15 +135,39 @@ IPA.facet = function(spec) {
that.content.append('<p>'+error_thrown.message+'</p>');
};
- that.redirect = function() {
+ that.get_redirect_facet = function() {
+
var entity = that.entity;
while (entity.containing_entity) {
entity = entity.get_containing_entity();
}
+ var facet_name = that.entity.redirect_facet;
+ var entity_name = entity.name;
+ var tab_name, facet;
+
+ if (that.redirect_info) {
+ entity_name = that.redirect_info.entity || entity_name;
+ facet_name = that.redirect_info.facet || facet_name;
+ tab_name = that.redirect_info.tab;
+ }
+
+ if (tab_name) {
+ facet = IPA.nav.get_tab_facet(tab_name);
+ }
+
+ if (!facet) {
+ entity = IPA.get_entity(entity_name);
+ facet = entity.get_facet(facet_name);
+ }
- IPA.nav.show_page(
- entity.name,
- that.entity.redirect_facet);
+ return facet;
+ };
+
+ that.redirect = function() {
+
+ var facet = that.get_redirect_facet();
+ if (!facet) return;
+ IPA.nav.show_page(facet.entity.name, facet.name);
};
var redirect_error_codes = [4001];
@@ -149,12 +176,10 @@ IPA.facet = function(spec) {
/*If the error is in talking to the server, don't attempt to redirect,
as there is nothing any other facet can do either. */
- if (that.entity.redirect_facet) {
- for (var i=0; i<redirect_error_codes.length; i++) {
- if (error_thrown.code === redirect_error_codes[i]) {
- that.redirect();
- return;
- }
+ for (var i=0; i<redirect_error_codes.length; i++) {
+ if (error_thrown.code === redirect_error_codes[i]) {
+ that.redirect();
+ return;
}
}
};
@@ -244,7 +269,7 @@ IPA.facet_header = function(spec) {
that.title_container.empty();
var h3 = $('<h3/>').appendTo(that.title_container);
- h3.append(that.facet.title);
+ h3.append(that.facet.label);
h3.append(': ');
$('<span/>', {
@@ -272,7 +297,7 @@ IPA.facet_header = function(spec) {
}).appendTo(container);
$('<a/>', {
- text: other_facet.label,
+ text: other_facet.tab_label,
id: other_facet.name
}).appendTo(li);
};
@@ -310,13 +335,10 @@ IPA.facet_header = function(spec) {
'class': 'back-link'
}).appendTo(that.breadcrumb);
- var entity = that.facet.entity;
- while (entity.containing_entity) {
- entity = entity.get_containing_entity();
- }
+ var redirect_facet = that.facet.get_redirect_facet();
$('<a/>', {
- text: entity.metadata.label,
+ text: redirect_facet.label,
click: function() {
that.facet.redirect();
return false;
@@ -334,7 +356,7 @@ IPA.facet_header = function(spec) {
}).appendTo(container);
var span = $('<h3/>', {
- text: that.facet.entity.label
+ text: that.facet.label
}).appendTo(that.title_container);
if (!that.facet.disable_facet_tabs) {
@@ -384,9 +406,9 @@ IPA.facet_header = function(spec) {
var values = result ? result[facet.name] : null;
if (values) {
- link.text(facet.label+' ('+values.length+')');
+ link.text(facet.tab_label+' ('+values.length+')');
} else {
- link.text(facet.label);
+ link.text(facet.tab_label);
}
}
}
@@ -415,6 +437,7 @@ IPA.table_facet = function(spec) {
that.row_enabled_attribute = spec.row_enabled_attribute;
that.row_disabled_attribute = spec.row_disabled_attribute;
+ that.details_facet_name = spec.details_facet || 'default';
that.columns = $.ordered_map();
@@ -701,7 +724,7 @@ IPA.table_facet = function(spec) {
if (column.link && column.primary_key) {
column.link_handler = function(value) {
- IPA.nav.show_page(entity.name, 'default', value);
+ IPA.nav.show_page(entity.name, that.details_facet_name, value);
return false;
};
}
@@ -834,7 +857,8 @@ IPA.facet_builder = function(entity) {
that.prepare_search_spec = function(spec) {
spec.title = spec.title || entity.metadata.label;
- spec.label = spec.label || IPA.messages.facets.search;
+ spec.label = spec.label || entity.metadata.label;
+ spec.tab_label = spec.tab_label || IPA.messages.facets.search;
spec.factory = spec.factory || IPA.search_facet;
add_redirect_info();
@@ -844,7 +868,8 @@ IPA.facet_builder = function(entity) {
that.prepare_nested_search_spec = function(spec) {
spec.title = spec.title || entity.metadata.label_singular;
- spec.label = spec.label || IPA.messages.facets.search;
+ spec.label = spec.label || entity.metadata.label;
+ spec.tab_label = spec.tab_label || IPA.messages.facets.search;
spec.factory = spec.factory || IPA.nested_search_facet;
return spec;
@@ -852,7 +877,8 @@ IPA.facet_builder = function(entity) {
that.prepare_details_spec = function(spec) {
spec.title = spec.title || entity.metadata.label_singular;
- spec.label = spec.label || IPA.messages.facets.details;
+ spec.label = spec.label || entity.metadata.label_singular;
+ spec.tab_label = spec.tab_label || IPA.messages.facets.details;
spec.factory = spec.factory || IPA.details_facet;
return spec;
@@ -875,9 +901,8 @@ IPA.facet_builder = function(entity) {
spec.factory = spec.factory || IPA.association_facet;
- spec.title = spec.label || entity.metadata.label_singular;
-
- spec.label = spec.label ||
+ spec.label = spec.label || entity.metadata.label_singular;
+ spec.tab_label = spec.tab_label ||
(IPA.metadata.objects[spec.other_entity] ?
IPA.metadata.objects[spec.other_entity].label : spec.other_entity);
diff --git a/install/ui/navigation.js b/install/ui/navigation.js
index 84df7f4da..72c914268 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 = $('<div/>', {
- name: tab.name,
- title: tab.label,
+ name: tab.entity.name,
+ title: tab.entity.label,
'class': 'entity'
}).appendTo(that.content);
tab.entity.create(tab.content);