From 68a345712c040d30e57d31a7881619567f7d35c5 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 19 Aug 2011 10:20:40 -0500 Subject: Updated add and delete association dialog titles. The association table widget and facet have been modified to accept titles for the add and delete dialogs. The table and facet definitions have been modified to specify the appropriate titles. Some unused code have been removed. Ticket #1629 --- install/ui/association.js | 45 +++++--- install/ui/entity.js | 3 + install/ui/hbac.js | 110 ++++++++---------- install/ui/host.js | 23 +--- install/ui/service.js | 18 --- install/ui/sudo.js | 222 +++++++++++-------------------------- install/ui/test/data/ipa_init.json | 22 +++- ipalib/plugins/internal.py | 22 +++- 8 files changed, 187 insertions(+), 278 deletions(-) diff --git a/install/ui/association.js b/install/ui/association.js index 4ee4e72ce..4ee36934d 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -278,6 +278,11 @@ IPA.association_config = function (spec) { IPA.association_table_widget = function (spec) { spec = spec || {}; + + var index = spec.name.indexOf('_'); + spec.attribute_member = spec.attribute_member || spec.name.substring(0, index); + spec.other_entity = spec.other_entity || spec.name.substring(index+1); + spec.managed_entity_name = spec.other_entity; var that = IPA.table_widget(spec); @@ -289,6 +294,9 @@ IPA.association_table_widget = function (spec) { that.add_method = spec.add_method || 'add_member'; that.remove_method = spec.remove_method || 'remove_member'; + that.add_title = spec.add_title || IPA.messages.association.add.member; + that.remove_title = spec.remove_title || IPA.messages.association.remove.member; + that.adder_columns = $.ordered_map(); that.get_adder_column = function(name) { @@ -489,11 +497,9 @@ IPA.association_table_widget = function (spec) { that.create_add_dialog = function() { var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity].label; - var title = IPA.messages.association.add; - title = title.replace( - '${entity}', - that.entity.metadata.label_singular); + var title = that.add_title; + title = title.replace('${entity}', that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); @@ -561,11 +567,9 @@ IPA.association_table_widget = function (spec) { var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity].label; - var title = IPA.messages.association.remove; - title = title.replace( - '${entity}', - that.entity.metadata.label_singular); + var title = that.remove_title; + title = title.replace('${entity}', that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); @@ -671,8 +675,8 @@ IPA.association_facet = function (spec) { link must be set before the call to the base class, to affect the table. */ spec.link = spec.link === undefined ? true : spec.link; - spec.managed_entity_name = spec.other_entity; + var that = IPA.table_facet(spec); that.entity = spec.entity; @@ -690,6 +694,9 @@ IPA.association_facet = function (spec) { that.add_method = spec.add_method || 'add_member'; that.remove_method = spec.remove_method || 'remove_member'; + that.add_title = spec.add_title || IPA.messages.association.add.member; + that.remove_title = spec.remove_title || IPA.messages.association.remove.member; + that.adder_columns = $.ordered_map(); that.page_length = spec.page_length === undefined ? 20 : spec.page_length; @@ -724,7 +731,7 @@ IPA.association_facet = function (spec) { var i; var pkey_name; - if (that.other_entity){ + if (that.other_entity) { pkey_name = IPA.metadata.objects[that.other_entity].primary_key; } @@ -736,6 +743,12 @@ IPA.association_facet = function (spec) { }); } + if (!that.adder_columns.length) { + that.create_adder_column({ + name: pkey_name, + primary_key: true + }); + } var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity; @@ -911,11 +924,9 @@ IPA.association_facet = function (spec) { var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity; - var title = IPA.messages.association.add; - title = title.replace( - '${entity}', - that.entity.metadata.label_singular); + var title = that.add_title; + title = title.replace('${entity}', that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); @@ -970,11 +981,9 @@ IPA.association_facet = function (spec) { } var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); - var title = IPA.messages.association.remove; - title = title.replace( - '${entity}', - that.entity.metadata.label_singular); + var title = that.remove_title; + title = title.replace('${entity}', that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); diff --git a/install/ui/entity.js b/install/ui/entity.js index 6317eebf5..ce028a2eb 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -795,6 +795,9 @@ IPA.entity_builder = function(){ spec.other_entity = spec.other_entity || spec.name.substring(index+1); + spec.add_title = IPA.messages.association.add[spec.attribute_member]; + spec.remove_title = IPA.messages.association.remove[spec.attribute_member]; + spec.facet_group = spec.facet_group || spec.attribute_member; diff --git a/install/ui/hbac.js b/install/ui/hbac.js index 0e775aa0b..274c52d68 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -134,44 +134,6 @@ IPA.entity_factories.hbacsvcgroup = function() { build(); }; -IPA.hbacsvcgroup_member_hbacsvc_table_widget = function(spec) { - - spec = spec || {}; - - var that = IPA.association_table_widget(spec); - - - var column = that.create_column({ - name: 'cn', - primary_key: true, - width: '150px', - entity:that.entity, - link: true - }); - - that.create_column({ - name: 'description', - entity:that.entity, - - width: '350px' - }); - - that.create_adder_column({ - name: 'cn', - primary_key: true, - width: '100px' - }); - - that.create_adder_column({ - name: 'description', - width: '100px' - }); - - return that; -}; - - - IPA.hbacrule_details_facet = function(spec) { spec = spec || {}; @@ -224,15 +186,21 @@ IPA.hbacrule_details_facet = function(spec) { })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberuser_user', - name: 'memberuser_user', category: category, - other_entity: 'user', add_method: 'add_user', - remove_method: 'remove_user' + name: 'memberuser_user', + category: category, + add_method: 'add_user', + remove_method: 'remove_user', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberuser_group', - name: 'memberuser_group', category: category, - other_entity: 'group', add_method: 'add_user', - remove_method: 'remove_user' + name: 'memberuser_group', + category: category, + add_method: 'add_user', + remove_method: 'remove_user', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); return section; } @@ -259,15 +227,21 @@ IPA.hbacrule_details_facet = function(spec) { })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberhost_host', - name: 'memberhost_host', category: category, - other_entity: 'host', add_method: 'add_host', - remove_method: 'remove_host' + name: 'memberhost_host', + category: category, + add_method: 'add_host', + remove_method: 'remove_host', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberhost_hostgroup', - name: 'memberhost_hostgroup', category: category, - other_entity: 'hostgroup', add_method: 'add_host', - remove_method: 'remove_host' + name: 'memberhost_hostgroup', + category: category, + add_method: 'add_host', + remove_method: 'remove_host', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); return section; } @@ -295,15 +269,21 @@ IPA.hbacrule_details_facet = function(spec) { })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberservice_hbacsvc', - name: 'memberservice_hbacsvc', category: category, - other_entity: 'hbacsvc', add_method: 'add_service', - remove_method: 'remove_service' + name: 'memberservice_hbacsvc', + category: category, + add_method: 'add_service', + remove_method: 'remove_service', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-memberservice_hbacsvcgroup', - name: 'memberservice_hbacsvcgroup', category: category, - other_entity: 'hbacsvcgroup', add_method: 'add_service', - remove_method: 'remove_service' + name: 'memberservice_hbacsvcgroup', + category: category, + add_method: 'add_service', + remove_method: 'remove_service', + add_title: IPA.messages.association.add.member, + remove_title: IPA.messages.association.remove.member })); return section; } @@ -330,15 +310,21 @@ IPA.hbacrule_details_facet = function(spec) { })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-sourcehost_host', - name: 'sourcehost_host', category: category, - other_entity: 'host', add_method: 'add_sourcehost', - remove_method: 'remove_sourcehost' + name: 'sourcehost_host', + category: category, + add_method: 'add_sourcehost', + remove_method: 'remove_sourcehost', + add_title: IPA.messages.association.add.sourcehost, + remove_title: IPA.messages.association.remove.sourcehost })); section.add_field(IPA.rule_association_table_widget({ id: that.entity.name+'-sourcehost_hostgroup', - name: 'sourcehost_hostgroup', category: category, - other_entity: 'hostgroup', add_method: 'add_sourcehost', - remove_method: 'remove_sourcehost' + name: 'sourcehost_hostgroup', + category: category, + add_method: 'add_sourcehost', + remove_method: 'remove_sourcehost', + add_title: IPA.messages.association.add.sourcehost, + remove_title: IPA.messages.association.remove.sourcehost })); return section; } diff --git a/install/ui/host.js b/install/ui/host.js index 05484a030..5a786b016 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -73,8 +73,9 @@ IPA.entity_factories.host = function () { ] }]}). association_facet({ - factory: IPA.host_managedby_host_facet, - name: 'managedby_host' + name: 'managedby_host', + add_method: 'add_managedby', + remove_method: 'remove_managedby' }). association_facet({ name: 'memberof_hostgroup', @@ -622,21 +623,3 @@ IPA.host_certificate_status_widget = function (spec) { return that; }; - -IPA.host_managedby_host_facet = function (spec) { - - spec = spec || {}; - - var that = IPA.association_facet(spec); - - that.add_method = 'add_managedby'; - that.remove_method = 'remove_managedby'; - - that.create_adder_column({ - name: 'fqdn', - primary_key: true, - width: '200px' - }); - - return that; -}; diff --git a/install/ui/service.js b/install/ui/service.js index 6128dd1f6..eef909115 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -64,7 +64,6 @@ IPA.entity_factories.service = function() { }] }]}). association_facet({ - factory: IPA.service_managedby_host_facet, name: 'managedby_host', add_method: 'add_host', remove_method: 'remove_host' @@ -340,20 +339,3 @@ IPA.service_certificate_status_widget = function (spec) { return that; }; - -IPA.service_managedby_host_facet = function(spec) { - - spec = spec || {}; - - var that = IPA.association_facet(spec); - - that.create_adder_column({ - name: 'fqdn', - label: IPA.messages.objects.service.host, - primary_key: true, - width: '200px' - }); - - - return that; -}; \ No newline at end of file diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 095480a9a..375ca93ac 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -124,117 +124,8 @@ IPA.entity_factories.sudocmdgroup = function() { build(); }; - -/* -* TODO: user the serial associator to perform back end operations. -*/ -IPA.sudocmd_member_sudocmdgroup_table_widget = function(spec) { - - spec = spec || {}; - - var that = IPA.association_table_widget(spec); - - that.get_records = function(on_success, on_error) { - - var length = that.values.length; - if (!length) return; - - if (length > 100) { - length = 100; - } - - if (!that.values.length) return; - - var batch = IPA.batch_command({ - 'name': that.entity.name+'_'+that.name+'_show', - 'on_success': on_success, - 'on_error': on_error - }); - - for (var i=0; ifollow these directions to configure your browser." }, "association": { - "add": "Add ${other_entity} into ${entity} ${primary_key}", + "add": { + "ipasudorunas": "Add RunAs ${other_entity} into ${entity} ${primary_key}", + "ipasudorunasgroup": "Add RunAs Groups into ${entity} ${primary_key}", + "member": "Add ${other_entity} into ${entity} ${primary_key}", + "memberallowcmd": "Add Allow ${other_entity} into ${entity} ${primary_key}", + "memberdenycmd": "Add Deny ${other_entity} into ${entity} ${primary_key}", + "memberof": "Add ${entity} ${primary_key} into ${other_entity}", + "managedby": "Add ${other_entity} Managing ${entity} ${primary_key}", + "sourcehost": "Add Source ${other_entity} into ${entity} ${primary_key}" + }, "direct_enrollment": "Direct Enrollment", "indirect_enrollment": "Indirect Enrollment", "no_entries": "No entries.", "paging": "Showing ${start} to ${end} of ${total} entries.", - "remove": "Remove ${other_entity} from ${entity} ${primary_key}", + "remove": { + "ipasudorunas": "Remove RunAs ${other_entity} from ${entity} ${primary_key}", + "ipasudorunasgroup": "Remove RunAs Groups from ${entity} ${primary_key}", + "member": "Remove ${other_entity} from ${entity} ${primary_key}", + "memberallowcmd": "Remove Allow ${other_entity} from ${entity} ${primary_key}", + "memberdenycmd": "Remove Deny ${other_entity} from ${entity} ${primary_key}", + "memberof": "Remove ${entity} ${primary_key} from ${other_entity}", + "managedby": "Remove ${other_entity} Managing ${entity} ${primary_key}", + "sourcehost": "Remove Source ${other_entity} from ${entity} ${primary_key}" + }, "show_results": "Show Results" }, "buttons": { diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index 7fae78e24..785dc1680 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -400,12 +400,30 @@ class i18n_messages(Command): "automount":_("Automount") }, "association": { - "add":_("Add ${other_entity} into ${entity} ${primary_key}"), + "add": { + "ipasudorunas":_("Add RunAs ${other_entity} into ${entity} ${primary_key}"), + "ipasudorunasgroup":_("Add RunAs Groups into ${entity} ${primary_key}"), + "member":_("Add ${other_entity} into ${entity} ${primary_key}"), + "memberallowcmd":_("Add Allow ${other_entity} into ${entity} ${primary_key}"), + "memberdenycmd":_("Add Deny ${other_entity} into ${entity} ${primary_key}"), + "memberof":_("Add ${entity} ${primary_key} into ${other_entity}"), + "managedby":_("Add ${other_entity} Managing ${entity} ${primary_key}"), + "sourcehost":_("Add Source ${other_entity} into ${entity} ${primary_key}"), + }, "direct_enrollment":_("Direct Enrollment"), "indirect_enrollment":_("Indirect Enrollment"), "no_entries":_("No entries."), "paging":_("Showing ${start} to ${end} of ${total} entries."), - "remove":_("Remove ${other_entity} from ${entity} ${primary_key}"), + "remove": { + "ipasudorunas":_("Remove RunAs ${other_entity} from ${entity} ${primary_key}"), + "ipasudorunasgroup":_("Remove RunAs Groups from ${entity} ${primary_key}"), + "member":_("Remove ${other_entity} from ${entity} ${primary_key}"), + "memberallowcmd":_("Remove Allow ${other_entity} from ${entity} ${primary_key}"), + "memberdenycmd":_("Remove Deny ${other_entity} from ${entity} ${primary_key}"), + "memberof":_("Remove ${entity} ${primary_key} from ${other_entity}"), + "managedby":_("Remove ${other_entity} Managing ${entity} ${primary_key}"), + "sourcehost":_("Remove Source ${other_entity} from ${entity} ${primary_key}"), + }, "show_results":_("Show Results"), }, "widget": { -- cgit