From 039a6f7b4ff392974408cb9e274f8a3777e009fd Mon Sep 17 00:00:00 2001 From: Pavel Vomacka Date: Wed, 5 Oct 2016 12:00:33 +0200 Subject: Possibility to set list of table attributes which will be added to _del command 'additional_table_attrs' can contain array of names of columns. Value from each column with its name will be added to the batch _del command. in case that the column with set name does not exists - the name is skipped. Part of: https://fedorahosted.org/freeipa/ticket/5426 Reviewed-By: Martin Basti Reviewed-By: Petr Vobornik --- install/ui/src/freeipa/search.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'install') diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js index 6820f54cc..ee0052288 100644 --- a/install/ui/src/freeipa/search.js +++ b/install/ui/src/freeipa/search.js @@ -350,6 +350,15 @@ IPA.search_deleter_dialog = function(spec) { var that = IPA.deleter_dialog(spec); that.pkey_prefix = spec.pkey_prefix || []; + /** + * List of attributes from table from search facet, which + * are added to remove command as options. In case that there is not column + * with this name, then the option is skipped + * + * @property {String} + */ + that.additional_table_attrs = spec.additional_table_attrs || []; + that.create_command = function() { var batch = rpc.batch_command({ error_message: '@i18n:search.partial_delete', @@ -369,7 +378,8 @@ IPA.search_deleter_dialog = function(spec) { for (var key in value) { if (value.hasOwnProperty(key)) { if (key === 'pkey'){ - command.add_arg(value[key]); + value = value[key]; + command.add_arg(value); } else { command.set_option(key, value[key]); } @@ -379,6 +389,11 @@ IPA.search_deleter_dialog = function(spec) { command.add_arg(value); } + var add_attrs = that.additional_table_attrs; + if (add_attrs && add_attrs.length && add_attrs.length > 0) { + command = that.extend_command(command, add_attrs, value); + } + batch.add_command(command); } @@ -405,6 +420,25 @@ IPA.search_deleter_dialog = function(spec) { batch.execute(); }; + that.extend_command = function(command, add_attrs, pkey) { + var records = that.facet.fetch_records(); + var pkey_name = that.entity.metadata.primary_key; + + for (var i=0,l=records.length; i