From ec63456b7c1fba6bd8d9073e63c27ef685f08c60 Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Wed, 5 Oct 2016 10:09:20 +0200 Subject: Allow to set another other_entity name Association table's add, del commands needs as option list of cn of other_entity, which is added or deleted. There is a case (currently in vaults) that the name of option is different than the name of other_entity. In this situation we can set 'other_option_name' and put there the option name. This option name will be used instead of 'other_entity' name. Part of: https://fedorahosted.org/freeipa/ticket/5426 Reviewed-By: Martin Basti Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/association.js | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'install') diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js index d44f8c805..02f990a7f 100644 --- a/install/ui/src/freeipa/association.js +++ b/install/ui/src/freeipa/association.js @@ -429,6 +429,22 @@ IPA.association_table_widget = function (spec) { */ that.additional_add_del_field = spec.additional_add_del_field; + /** + * Can be used in situations when the *_add_member command needs entity + * as a parameter, but parameter has different name than entity. + * i.e. vault_add_member --services=[values] ... this needs values from service + * entity, but option is called services, that we can set by setting + * this option in spec to other_option_name: 'services' + * + * @property {String} other_option_name + */ + that.other_option_name = spec.other_option_name; + + /** + * Entity which is added into member table. + * + * @property {String} other_entity + */ that.other_entity = IPA.get_entity(spec.other_entity); that.attribute_member = spec.attribute_member; @@ -683,9 +699,9 @@ IPA.association_table_widget = function (spec) { on_success: on_success, on_error: on_error }); - command.set_option(that.other_entity.name, values); that.join_additional_option(command); + that.handle_entity_option(command, values); command.execute(); }; @@ -701,6 +717,14 @@ IPA.association_table_widget = function (spec) { } }; + that.handle_entity_option = function(command, values) { + var option_name = that.other_option_name; + if (!option_name) { + option_name = that.other_entity.name; + } + command.set_option(option_name, values); + }; + that.show_remove_dialog = function() { var selected_values = that.get_selected_values(); @@ -745,7 +769,6 @@ IPA.association_table_widget = function (spec) { ); }; - dialog.open(); }; @@ -761,8 +784,8 @@ IPA.association_table_widget = function (spec) { on_error: on_error }); - command.set_option(that.other_entity.name, values); that.join_additional_option(command); + that.handle_entity_option(command, values); command.execute(); }; -- cgit