diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2015-04-27 14:23:16 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2015-05-20 14:04:10 +0200 |
commit | 3c2a8b408ec1af284af0ebe218832f3fab85c008 (patch) | |
tree | 3a8aa34748bea78685e7ffab304bcae73b24e8ee /install | |
parent | 17aafc36b4c94cffa8427c8f4b2aef2292bba40d (diff) | |
download | freeipa-3c2a8b408ec1af284af0ebe218832f3fab85c008.tar.gz freeipa-3c2a8b408ec1af284af0ebe218832f3fab85c008.tar.xz freeipa-3c2a8b408ec1af284af0ebe218832f3fab85c008.zip |
webui: custom facet groups in a facet
Facets use to inherit facet groups from entity. There was no option to define
cross-entity facet groups for different facets which belong one entity.
In other words it was not possible to have 'user search' and 'stage user search'
tab in one facet group.
Reviewed-By: David Kupka <dkupka@redhat.com>
Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/src/freeipa/entity.js | 13 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 32 |
2 files changed, 39 insertions, 6 deletions
diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js index 1b9cae7b7..61698e859 100644 --- a/install/ui/src/freeipa/entity.js +++ b/install/ui/src/freeipa/entity.js @@ -323,7 +323,7 @@ exp.entity = IPA.entity = function(spec) { */ that.get_facet = function(name) { - var i, l, facets; + var i, l, facets, facet; //build all facets on the first time if(!that.facets_created) { @@ -331,7 +331,7 @@ exp.entity = IPA.entity = function(spec) { var facet_specs = that.facet_specs; for (i=0,l=facet_specs.length; i<l; i++) { var type_name = that.create_facet_type(facet_specs[i].name); - var facet = reg.facet.get(type_name); + facet = reg.facet.get(type_name); that.add_facet(facet); if (facet.name === 'search') { that.add_redirect_info(facet.name); @@ -358,7 +358,14 @@ exp.entity = IPA.entity = function(spec) { return that.facets.values[0]; } - return that.facets.get(name); + + facet = that.facets.get(name); + // maybe the facet is in central facet registry + if (!facet) { + facet = reg.facet.get(that.create_facet_type(name)); + } + + return facet; }; /** diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 42949215d..74c13353f 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -284,6 +284,17 @@ exp.facet = IPA.facet = function(spec, no_init) { that.dom_node = null; /** + * Facet groups + * + * Entity facet groups are used if not defined + * + * @property {IPA.facet_group[]} + */ + that.facet_groups = builder.build('', spec.facet_groups, {}, { + $factory: IPA.facet_group + }); + + /** * Facet group name * @property {string} */ @@ -1280,12 +1291,27 @@ exp.facet_header = IPA.facet_header = function(spec) { var facets = facet_group.facets.values; for (var i=0; i<facets.length; i++) { - var facet = facets[i]; + var facet = reg.facet.get(facets[i]); that.create_facet_link(ul, facet); } }; /** + * Get facet groups for current facet. + * + * By default facet groups are defined in entity. In certain circumstances + * it could be overridden, i.e., if different facet contained in the facet + * groups uses different entity. + * @return {Array} Array of facet groups + */ + that.get_facet_groups = function() { + if (that.facet.facet_groups) { + return that.facet.facet_groups; + } + return that.facet.entity.facet_groups.values; + }; + + /** * Create header's HTML * @param {jQuery} container */ @@ -1308,7 +1334,7 @@ exp.facet_header = IPA.facet_header = function(spec) { 'class': 'facet-tabs' }).appendTo(container); - var facet_groups = that.facet.entity.facet_groups.values; + var facet_groups = that.get_facet_groups(); for (var i=0; i<facet_groups.length; i++) { var facet_group = facet_groups[i]; if (facet_group.facets.length) { @@ -2080,7 +2106,7 @@ exp.facet_group = IPA.facet_group = function(spec) { * Facet collection * @property {ordered_map} */ - that.facets = $.ordered_map(); + that.facets = $.ordered_map(spec.facets); /** * Add facet to the map |