From 470d3c27c745200a87c19e5a8187454a53c527b3 Mon Sep 17 00:00:00 2001 From: Endi S. Dewata Date: Thu, 2 Dec 2010 17:16:34 -0600 Subject: [PATCH] Fixed association links The create_association_facets() has been modified such that it does not generate duplicate links. This is done by assigning the proper labels and hiding non-assignable associations. Each association will get a label based on the attribute used: - memberof: Membership in - member.*: Members - managedby: Managed by The following associations will be hidden: - memberindirect - enrolledby The internal.py was modified to return localized labels. The test data has been updated. --- install/static/entity.js | 24 ++++++++++++++++++++---- install/static/group.js | 2 +- install/static/hbacsvcgroup.js | 2 +- install/static/host.js | 2 +- install/static/service.js | 2 +- install/static/sudocmdgroup.js | 2 +- install/static/test/data/ipa_init.json | 5 +++++ ipalib/plugins/internal.py | 4 ++++ 8 files changed, 34 insertions(+), 9 deletions(-) diff --git a/install/static/entity.js b/install/static/entity.js index 6e2b501b0989b4549123888bef0fcc69a7b23b0d..548623e2d838bfa931d50273fee16132d1cb0499 100644 --- a/install/static/entity.js +++ b/install/static/entity.js @@ -151,9 +151,7 @@ function ipa_entity(spec) { return config; }; - that.create_association_facet = function(other_entity, attribute_member) { - - var label = IPA.metadata[other_entity].label; + that.create_association_facet = function(attribute_member, other_entity, label) { if (!attribute_member) { attribute_member = ipa_get_member_attribute( @@ -173,12 +171,30 @@ function ipa_entity(spec) { var attribute_members = IPA.metadata[that.name].attribute_members; for (var attribute_member in attribute_members) { + + // skip non-assignable associations + if (attribute_member === 'memberindirect') continue; + if (attribute_member === 'enrolledby') continue; + var other_entities = attribute_members[attribute_member]; for (var j = 0; j < other_entities.length; j++) { var other_entity = other_entities[j]; + var other_entity_name = IPA.metadata[other_entity].label; - var facet = that.create_association_facet(other_entity, attribute_member); + var label = other_entity_name; + + if (attribute_member.match(/^memberof$/)) { + label = IPA.messages.association.membershipin+' '+other_entity_name; + + } else if (attribute_member.match(/^member/)) { + label = other_entity_name+' '+IPA.messages.association.members; + + } else if (attribute_member.match(/^managedby$/)) { + label = IPA.messages.association.managedby+' '+other_entity_name; + } + + var facet = that.create_association_facet(attribute_member, other_entity, label); if (that.get_facet(facet.name)) continue; that.add_facet(facet); } diff --git a/install/static/group.js b/install/static/group.js index bcac40982d1bddaec55bdb46173df0b65e2bfb68..b44463439d73d6059b32751c07530c41b6d1a4dc 100644 --- a/install/static/group.js +++ b/install/static/group.js @@ -64,7 +64,7 @@ function ipa_group() { facet = ipa_group_member_user_facet({ 'name': 'member_user', - 'label': 'Users', + 'label': IPA.metadata['user'].label+' '+IPA.messages.association.members, 'other_entity': 'user' }); that.add_facet(facet); diff --git a/install/static/hbacsvcgroup.js b/install/static/hbacsvcgroup.js index 9cc1cdea4fba86c36ab99fbcf2f96ceda50b99b1..94a79c026a5846632534508de427bc8e1474ab4b 100755 --- a/install/static/hbacsvcgroup.js +++ b/install/static/hbacsvcgroup.js @@ -55,7 +55,7 @@ function ipa_hbacsvcgroup() { facet = ipa_hbacsvcgroup_member_hbacsvc_facet({ 'name': 'member_hbacsvc', - 'label': 'Services', + 'label': IPA.metadata['hbacsvc'].label+' '+IPA.messages.association.members, 'other_entity': 'hbacsvc' }); that.add_facet(facet); diff --git a/install/static/host.js b/install/static/host.js index 4f3a636ebe3169cea87dd59536d822015191b041..484b64771ecf6f1be948974f424606476375a276 100644 --- a/install/static/host.js +++ b/install/static/host.js @@ -60,7 +60,7 @@ function ipa_host() { facet = ipa_host_managedby_host_facet({ 'name': 'managedby_host', - 'label': 'Managed by Hosts', + 'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label, 'other_entity': 'host' }); that.add_facet(facet); diff --git a/install/static/service.js b/install/static/service.js index 670737468103eabf25544592635f1852f31e4b7b..5d9e21ad118d9ece595dc413aa65149e5113cbde 100644 --- a/install/static/service.js +++ b/install/static/service.js @@ -55,7 +55,7 @@ function ipa_service() { facet = ipa_service_managedby_host_facet({ 'name': 'managedby_host', - 'label': 'Hosts', + 'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label, 'other_entity': 'host' }); that.add_facet(facet); diff --git a/install/static/sudocmdgroup.js b/install/static/sudocmdgroup.js index 09b2a741c9a7656b50abfedc2bf754a955581db8..2d2b32983b78ec23e9d82442bd805b092a65d7ba 100755 --- a/install/static/sudocmdgroup.js +++ b/install/static/sudocmdgroup.js @@ -55,7 +55,7 @@ function ipa_sudocmdgroup() { facet = ipa_sudocmdgroup_member_sudocmd_facet({ 'name': 'member_sudocmd', - 'label': 'Commands', + 'label': IPA.metadata['sudocmd'].label+' '+IPA.messages.association.members, 'other_entity': 'sudocmd' }); that.add_facet(facet); diff --git a/install/static/test/data/ipa_init.json b/install/static/test/data/ipa_init.json index b868df8838f927e2bda1149f571eceefb3de03f5..26c7e730369cfa905678615bbde6d5ae5a01693a 100644 --- a/install/static/test/data/ipa_init.json +++ b/install/static/test/data/ipa_init.json @@ -4846,6 +4846,11 @@ "ajax": { "401": "Your kerberos ticket no longer valid.Please run KInit and then click 'retry'If this is your first time running the IPA Web UI Follow these directions to configure your browser." }, + "association": { + "managedby": "Managed by", + "members": "Members", + "membershipin": "Membership in" + }, "button": { "add": "Add", "enroll": "Enroll", diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index 708d829bea90d9b827e19d817f9761bda8341226..2e5d879b0f4d8002bf0dbd07c41370a0492acc74 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -97,6 +97,10 @@ class i18n_messages(Command): "employee":_(" Employee Information"), "misc":_("Misc. Information"), "to_top":_("Back to Top")}, + "association":{ + "managedby":_("Managed by"), + "members":_("Members"), + "membershipin":_("Membership in")}, "ajax":{ "401":_("Your kerberos ticket no longer valid."+ "Please run KInit and then click 'retry'"+ -- 1.6.6.1