summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPavel Vomacka <pvomacka@redhat.com>2016-10-05 12:00:33 +0200
committerMartin Basti <mbasti@redhat.com>2017-03-14 10:40:10 +0100
commit039a6f7b4ff392974408cb9e274f8a3777e009fd (patch)
treecd59e4fc9b5f89c0d49ef5efccce1807f87a6427 /install
parent2e6e0698865e7d530c6ebf87a12e46f990ac1d87 (diff)
downloadfreeipa-039a6f7b4ff392974408cb9e274f8a3777e009fd.tar.gz
freeipa-039a6f7b4ff392974408cb9e274f8a3777e009fd.tar.xz
freeipa-039a6f7b4ff392974408cb9e274f8a3777e009fd.zip
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 <mbasti@redhat.com> Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Diffstat (limited to 'install')
-rw-r--r--install/ui/src/freeipa/search.js36
1 files changed, 35 insertions, 1 deletions
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<l; i++) {
+ var record = records[i];
+ var curr_pkey = record[pkey_name][0];
+ if (curr_pkey && curr_pkey === pkey) {
+ for (var j=0,k=add_attrs.length; j<k; j++) {
+ var attr = add_attrs[j];
+ var val = record[attr];
+ if (val) command.set_option(attr, val);
+ }
+ }
+ }
+
+ return command;
+ };
+
that.search_deleter_dialog_create_command = that.create_command;
return that;