summaryrefslogtreecommitdiffstats
path: root/install/ui/src
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2015-04-24 16:04:45 +0200
committerPetr Vobornik <pvoborni@redhat.com>2015-05-20 14:04:10 +0200
commitae62bd6914dcdd24667dc1ff149413d9a7adc017 (patch)
tree3fc28a50377fe2ff4fac32e29f3f6924c954299d /install/ui/src
parentde374a0d3a1147a650b63bb5c267a857fba015dd (diff)
downloadfreeipa-ae62bd6914dcdd24667dc1ff149413d9a7adc017.tar.gz
freeipa-ae62bd6914dcdd24667dc1ff149413d9a7adc017.tar.xz
freeipa-ae62bd6914dcdd24667dc1ff149413d9a7adc017.zip
webui: entity facets in facet registry
All entity facets are automatically registered as a new type in reg.facet. The type name is: <entity_name>_<facet_name> The name of facets is kept same, mainly to support the same url routes. This change allows to get facet instance by calling, e.g.: reg.facet.get('user_details') It allows to make declarative links to facet which are not yet instantiated. Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
Diffstat (limited to 'install/ui/src')
-rw-r--r--install/ui/src/freeipa/association.js5
-rw-r--r--install/ui/src/freeipa/details.js5
-rw-r--r--install/ui/src/freeipa/entity.js43
-rw-r--r--install/ui/src/freeipa/facet.js8
-rw-r--r--install/ui/src/freeipa/search.js10
5 files changed, 56 insertions, 15 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 03a358c60..d786bfd47 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -823,9 +823,8 @@ exp.association_facet_pre_op = function(spec, context) {
return has_indirect;
};
- var entity = context.entity;
su.context_entity(spec, context);
- spec.entity = entity;
+ var entity = reg.entity.get(spec.entity);
var index = spec.name.lastIndexOf('_');
spec.attribute_member = spec.attribute_member ||
@@ -1298,8 +1297,8 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
*/
exp.attribute_facet_pre_op = function(spec, context) {
- var entity = context.entity;
su.context_entity(spec, context);
+ var entity = reg.entity.get(spec.entity);
spec.title = spec.title || entity.metadata.label_singular;
spec.label = spec.label || entity.metadata.label_singular;
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index e428dc908..d18788e88 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -461,8 +461,8 @@ exp.facet_policies = IPA.facet_policies = function(spec) {
*/
exp.details_facet_pre_op = function(spec, context) {
- var entity = context.entity;
su.context_entity(spec, context);
+ var entity = reg.entity.get(spec.entity);
spec.name = spec.name || 'details';
spec.title = spec.title || entity.metadata.label_singular;
@@ -2019,7 +2019,8 @@ exp.register = function() {
factory: IPA.details_facet,
pre_ops: [
exp.details_facet_pre_op
- ]
+ ],
+ spec: { name: 'details' }
});
};
diff --git a/install/ui/src/freeipa/entity.js b/install/ui/src/freeipa/entity.js
index eb2d98a55..461873400 100644
--- a/install/ui/src/freeipa/entity.js
+++ b/install/ui/src/freeipa/entity.js
@@ -299,6 +299,14 @@ exp.entity = IPA.entity = function(spec) {
}
};
+ that.create_facet_type = function(facet_name) {
+
+ // Keep names unique among all facets.
+ // Facets added later should also follow this pattern but it's not
+ // enforced.
+ return that.name + '_' + facet_name;
+ };
+
/**
* Get facet with given name.
*
@@ -315,13 +323,15 @@ exp.entity = IPA.entity = function(spec) {
*/
that.get_facet = function(name) {
- var i, facets;
+ var i, l, facets;
//build all facets on the first time
if(!that.facets_created) {
- facets = builder.build('facet', that.facet_specs, { entity: that });
- for (i=0; i<facets.length; i++) {
- var facet = facets[i];
+
+ 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);
that.add_facet(facet);
if (facet.name === 'search') {
that.add_redirect_info(facet.name);
@@ -361,7 +371,6 @@ exp.entity = IPA.entity = function(spec) {
* @param {string} facet.facet_group - facet group to add the facet
*/
that.add_facet = function(facet) {
- facet.entity = that;
that.facets.put(facet.name, facet);
@@ -788,6 +797,27 @@ exp.entity_post_ops = {
entity.builder.deleter_dialog(spec.deleter_dialog);
}
return entity;
+ },
+
+ facets: function(entity, spec, context) {
+
+ var facet_specs = entity.facet_specs;
+
+ for (var i=0,l=facet_specs.length; i<l; i++) {
+ var f_spec = facet_specs[i];
+
+ if (!f_spec.entity) {
+ f_spec.entity = entity;
+ }
+
+ reg.facet.register_from_spec(function(spec) {
+ // replace the original spec with the merged one so there is
+ // only one
+ facet_specs[i] = spec;
+ return entity.create_facet_type(spec.name);
+ }, f_spec);
+ }
+ return entity;
}
};
@@ -1066,7 +1096,8 @@ registry.builder.post_ops.push(
exp.entity_post_ops.containing_entity,
exp.entity_post_ops.standard_association_facets,
exp.entity_post_ops.adder_dialog,
- exp.entity_post_ops.deleter_dialog);
+ exp.entity_post_ops.deleter_dialog,
+ exp.entity_post_ops.facets);
return exp;
});
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index b0121c75f..42949215d 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -321,6 +321,14 @@ exp.facet = IPA.facet = function(spec, no_init) {
*/
that.state = new FacetState();
+
+ that.get_full_name = function() {
+ if (that.entity) {
+ return that.entity.create_facet_type(that.name);
+ }
+ return that.name;
+ };
+
/**
* Set and normalize pkeys. Merges with existing if present. If keys length
* differs, the alignment is from the last one to the first one.
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index 35c533473..a59ea1ee4 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -74,8 +74,8 @@ exp.search_facet_control_buttons_pre_op = function(spec, context) {
exp.search_facet_pre_op = function(spec, context) {
- var entity = context.entity;
su.context_entity(spec, context);
+ var entity = reg.entity.get(spec.entity);
spec.name = spec.name || 'search';
spec.title = spec.title || entity.metadata.label;
@@ -397,8 +397,8 @@ IPA.search_deleter_dialog = function(spec) {
exp.nested_search_facet_preop = function(spec, context) {
- var entity = context.entity;
su.context_entity(spec, context);
+ var entity = reg.entity.get(spec.entity);
spec.name = spec.name || 'search';
spec.title = spec.title || entity.metadata.label_singular;
@@ -597,7 +597,8 @@ exp.register = function() {
factory: IPA.search_facet,
pre_ops: [
exp.search_facet_pre_op
- ]
+ ],
+ spec: { name: 'search' }
});
f.register({
@@ -605,7 +606,8 @@ exp.register = function() {
factory: IPA.nested_search_facet,
pre_ops: [
exp.nested_search_facet_preop
- ]
+ ],
+ spec: { name: 'nestedsearch' }
});
};