summaryrefslogtreecommitdiffstats
path: root/install/static/entity.js
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2010-11-19 23:52:33 -0600
committerAdam Young <ayoung@redhat.com>2010-11-30 14:58:30 -0500
commitc90bff232dcc9dbab2cd6d5a1bb482cb1c5f16f9 (patch)
treee270c50dbff183e94590bd20d0d8e42100abc390 /install/static/entity.js
parentd644d17adf117321747db1e4e22a771fbea3b09e (diff)
downloadfreeipa-c90bff232dcc9dbab2cd6d5a1bb482cb1c5f16f9.tar.gz
freeipa-c90bff232dcc9dbab2cd6d5a1bb482cb1c5f16f9.tar.xz
freeipa-c90bff232dcc9dbab2cd6d5a1bb482cb1c5f16f9.zip
Multicolumn association facet
The association facet has been modified to support multiple columns. By default the facet will have one column which is the primary key of the associated object (e.g. username of a group member), so the existing code will work like before. Other fields (e.g. user's full name) can be added by subclassing the ipa_association_facet class and specifying the additional columns to display. These additional fields will be retrieved using a batch operation. Previously a single association facet instance will be used for all associations in an entity. Now each association will have its own association facet. This way each association facet can be customized differently as needed. The <entity>-enroll URL parameter has been removed because it's no longer needed. The ipa_entity.create_association_facets() is provided to generate the default association facets with one column for the primary key. The column click handler has been moved out of ipa_column to provide more flexibility for customization. The get_action_panel() and get_client_area() have been modified to search within the entity's container. The group entity has been fully converted to use the new UI framework. Association facets that have been modified to use multiple columns are: - User Group's member_user - HBAC Service Group's member_hbacsvc - SUDO Command Group's member_sudocmd - Service's managedby_host New test data files have been added. Unit tests have been updated.
Diffstat (limited to 'install/static/entity.js')
-rw-r--r--install/static/entity.js85
1 files changed, 49 insertions, 36 deletions
diff --git a/install/static/entity.js b/install/static/entity.js
index 713dbf31..5d59b3c7 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -68,11 +68,11 @@ function ipa_facet(spec) {
}
that.get_client_area = function() {
- return $('#' + that.entity_name+' .client');
+ return $('.client', that.container);
};
that.get_action_panel = function() {
- return $('#' + that.entity_name+' .action-panel');
+ return $('.action-panel', that.container);
};
that.facet_init = that.init;
@@ -100,6 +100,8 @@ function ipa_entity(spec) {
that.facet_name = null;
+ that.autogenerate_associations = false;
+
that.associations = [];
that.associations_by_name = {};
@@ -149,7 +151,46 @@ function ipa_entity(spec) {
return config;
};
+ that.create_association_facet = function(other_entity, attribute_member) {
+
+ var label = IPA.metadata[other_entity].label;
+
+ if (!attribute_member) {
+ attribute_member = ipa_get_member_attribute(
+ that.entity_name, other_entity
+ );
+ }
+
+ return ipa_association_facet({
+ 'name': attribute_member+'_'+other_entity,
+ 'label': label,
+ 'other_entity': other_entity
+ });
+ };
+
+ that.create_association_facets = function() {
+
+ var attribute_members = IPA.metadata[that.name].attribute_members;
+
+ for (var attribute_member in attribute_members) {
+ var other_entities = attribute_members[attribute_member];
+
+ for (var j = 0; j < other_entities.length; j++) {
+ var other_entity = other_entities[j];
+
+ var facet = that.create_association_facet(other_entity, attribute_member);
+ if (that.get_facet(facet.name)) continue;
+ that.add_facet(facet);
+ }
+ }
+ };
+
that.init = function() {
+
+ if (that.autogenerate_associations) {
+ that.create_association_facets();
+ }
+
for (var i=0; i<that.facets.length; i++) {
var facet = that.facets[i];
facet.init();
@@ -261,26 +302,11 @@ function ipa_entity_set_details_definition(entity_name, sections) {
}
}
-function ipa_entity_get_association_facet(entity_name) {
-
- var entity = ipa_get_entity(entity_name);
-
- var facet = entity.get_facet('associate');
- if (facet) return facet;
-
- facet = ipa_association_facet({
- 'name': 'associate'
- });
- entity.add_facet(facet);
-
- return facet;
-}
-
function ipa_entity_set_association_definition(entity_name, data) {
var entity = ipa_get_entity(entity_name);
- ipa_entity_get_association_facet(entity_name);
+ entity.autogenerate_associations = true;
for (var other_entity in data) {
var config = data[other_entity];
@@ -353,10 +379,10 @@ function ipa_facet_create_action_panel(container) {
})
}).appendTo(container);
- function build_link(other_facet,label,other_entity){
+ function build_link(other_facet,label){
var li = $('<li/>', {
"class" : other_facet.display_class,
- title: other_entity,
+ title: other_facet.name,
text: label,
click: function(entity_name, other_facet_name) {
return function() {
@@ -366,7 +392,7 @@ function ipa_facet_create_action_panel(container) {
var this_pkey = $('input[id=pkey]', action_panel).val();
IPA.switch_and_show_page(
entity_name, other_facet_name,
- this_pkey, other_entity);
+ this_pkey);
return false;
};
@@ -390,7 +416,7 @@ function ipa_facet_create_action_panel(container) {
var other_facet = entity.facets[0];
var other_facet_name = other_facet.name;
- var main_facet = build_link(other_facet,other_facet.label)
+ var main_facet = build_link(other_facet,other_facet.label);
/*assumeing for now that entities with only a single facet
do not have search*/
@@ -404,20 +430,7 @@ function ipa_facet_create_action_panel(container) {
other_facet = entity.facets[i];
other_facet_name = other_facet.name;
- if (other_facet.label) {
- ul.append(build_link(other_facet,other_facet.label));
-
- } else { // For now empty label indicates an association facet
- var attribute_members = IPA.metadata[entity_name].attribute_members;
- for (var attribute_member in attribute_members) {
- var other_entities = attribute_members[attribute_member];
- for (var j = 0; j < other_entities.length; j++) {
- var other_entity = other_entities[j];
- var label = IPA.metadata[other_entity].label;
- ul.append(build_link(other_facet,label,other_entity));
- }
- }
- }
+ ul.append(build_link(other_facet,other_facet.label));
}
/*When we land on the search page, disable all facets