mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -283,6 +283,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,11 +1291,26 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user