Creating CSV values in UI is unnecessary and error-prone because server converts them back to list. Possible problems with values containing commas may occur. All occurrences of CSV joining were therefore removed.

https://fedorahosted.org/freeipa/ticket/2227
--
Petr Vobornik
From 04a88c28ef64c3f56f17458b27b7381d3d476658 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 29 Feb 2012 18:53:11 +0100
Subject: [PATCH] Removed CSV creation from UI

Creating CSV values in UI is unnecessary and error-prone because server converts them back to list. Possible problems with values containing commas may occur.  All occurrences of CSV joining were therefore removed.

https://fedorahosted.org/freeipa/ticket/2227
---
 install/ui/aci.js         |   14 ++++----------
 install/ui/add.js         |   12 +++++-------
 install/ui/association.js |   24 ++++++------------------
 install/ui/details.js     |    2 --
 install/ui/dns.js         |    2 +-
 install/ui/field.js       |    1 -
 install/ui/rule.js        |    2 +-
 install/ui/widget.js      |    2 +-
 8 files changed, 18 insertions(+), 41 deletions(-)

diff --git a/install/ui/aci.js b/install/ui/aci.js
index ec3c8065b8d13e7feede2947188504ec6919230e..ba4a22bf1f2fa4179f093c0bf9eb89a7c7e31c8b 100644
--- a/install/ui/aci.js
+++ b/install/ui/aci.js
@@ -46,7 +46,6 @@ IPA.aci.permission_entity = function(spec) {
                 {
                     type: 'rights',
                     name: 'permissions',
-                    join: true,
                     widget: 'rights.permissions'
                 },
                 {
@@ -142,7 +141,6 @@ IPA.aci.permission_entity = function(spec) {
                 {
                     type: 'rights',
                     name: 'permissions',
-                    join: true,
                     widget: 'general.permissions'
                 },
                 {
@@ -407,14 +405,12 @@ IPA.aci.delegation_entity = function(spec) {
                             type: 'entity_select',
                             name: 'memberof',
                             other_entity: that.group_entity,
-                            other_field: 'cn',
-                            join: true
+                            other_field: 'cn'
                         },
                         {
                             type: 'attributes',
                             name: 'attrs',
-                            object_type: 'user',
-                            join: true
+                            object_type: 'user'
                         }
                     ]
                 }
@@ -434,14 +430,12 @@ IPA.aci.delegation_entity = function(spec) {
                     type: 'entity_select',
                     name: 'memberof',
                     other_entity: that.group_entity,
-                    other_field: 'cn',
-                    join: true
+                    other_field: 'cn'
                 },
                 {
                     type: 'attributes',
                     name: 'attrs',
-                    object_type: 'user',
-                    join: true
+                    object_type: 'user'
                 }
             ]
         });
diff --git a/install/ui/add.js b/install/ui/add.js
index 9b473ccc28befceeb7d38ac675ec3019e724459c..671d3f1fcbd3c9be195db8d102a6d6c80bb5c041 100644
--- a/install/ui/add.js
+++ b/install/ui/add.js
@@ -123,16 +123,14 @@ IPA.entity_adder_dialog = function(spec) {
             var field = fields[j];
 
             var values = record[field.param];
-            if (!values) continue;
-
-            // TODO: Handle multi-valued attributes like in detail facet's update()
-            var value = values.join(',');
-            if (!value) continue;
+            if (!values || values.length === 0) continue;
 
             if (field.param === pkey_name) {
-                command.add_arg(value);
+                command.add_arg(values[0]);
+            } else if (values.length === 1) {
+                command.set_option(field.param, values[0]);
             } else {
-                command.set_option(field.param, value);
+                command.set_option(field.param, values);
             }
         }
 
diff --git a/install/ui/association.js b/install/ui/association.js
index 72e1f0c0e380fbb0169eb852e41b8c0f587835e6..b170b39d231ef6ce22161a199b039390faca0a34 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -110,29 +110,17 @@ IPA.bulk_associator = function(spec) {
             return;
         }
 
-        var value = that.values.shift();
-        if (!value) {
-            that.on_success();
-            return;
-        }
-
-        while (that.values.length > 0) {
-            value += ',' + that.values.shift();
-        }
-
-        var args = [that.pkey];
-        var options = { 'all': true };
-        options[that.other_entity.name] = value;
-
         var command = IPA.command({
             entity: that.entity.name,
             method: that.method,
-            args: args,
-            options: options,
+            args: [that.pkey],
+            options: { 'all': true },
             on_success: that.on_success,
             on_error: that.on_error
         });
 
+        command.set_option(that.other_entity.name, that.values);
+
         //alert(JSON.stringify(command.to_json()));
 
         command.execute();
@@ -556,7 +544,7 @@ IPA.association_table_widget = function (spec) {
             on_success: on_success,
             on_error: on_error
         });
-        command.set_option(that.other_entity.name, values.join(','));
+        command.set_option(that.other_entity.name, values);
 
         command.execute();
     };
@@ -619,7 +607,7 @@ IPA.association_table_widget = function (spec) {
             on_error: on_error
         });
 
-        command.set_option(that.other_entity.name, values.join(','));
+        command.set_option(that.other_entity.name, values);
 
         command.execute();
     };
diff --git a/install/ui/details.js b/install/ui/details.js
index d68ebd07cb63e11efdc81e2017754431f945c90b..8d5dcff685da99b73ecad4a35bbf3f02dc620a67 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -844,8 +844,6 @@ IPA.command_builder = function() {
             if (field.metadata.primary_key) return;
             if (values.length === 1) {
                 command.set_option(name, values[0]);
-            } else if (field.join) {
-                command.set_option(name, values.join(','));
             } else {
                 command.set_option(name, values);
             }
diff --git a/install/ui/dns.js b/install/ui/dns.js
index 4182074a87f8e50fc5cd6177dcb019287b32e057..4cc6d4c533fb7c81429a58cf81cfe132812ca2ed 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -1613,7 +1613,7 @@ IPA.dns.record_type_table_widget = function(spec) {
         });
 
         var record_name = that.dnstype.toLowerCase()+'record';
-        command.set_option(record_name, values.join(','));
+        command.set_option(record_name, values);
         command.set_option('structured', true);
 
         command.execute();
diff --git a/install/ui/field.js b/install/ui/field.js
index a6553b1a8de38a9cbcff211302a89fe312f77a00..5f073705d665b1b1af72e6e21686af545e4f55ab 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -52,7 +52,6 @@ IPA.field = function(spec) {
     that.enabled = spec.enabled === undefined ? true : spec.enabled;
 
     that.undo = spec.undo === undefined ? true : spec.undo;
-    that.join = spec.join;
 
     that.metadata = spec.metadata;
     that.validators = spec.validators || [];
diff --git a/install/ui/rule.js b/install/ui/rule.js
index 2a164832129f87b68fc45cd5cdbcb3e3935d767d..b7e6a74a238537f8f23121eb0da5f54c9e6dda88 100644
--- a/install/ui/rule.js
+++ b/install/ui/rule.js
@@ -213,7 +213,7 @@ IPA.rule_association_table_field = function(spec) {
                     options: {all: true, rights: true}
                 });
 
-                command.set_option(that.widget.other_entity.name, values.join(','));
+                command.set_option(that.widget.other_entity.name, values);
                 update_info.append_command(command, that.priority);
             }
         }
diff --git a/install/ui/widget.js b/install/ui/widget.js
index d288a9bf415bdbae220b541fa38167dfe6c032df..f906d165c6202b3e2b54b9299cfcafed9bccb0e4 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1916,7 +1916,7 @@ IPA.attribute_table_widget = function(spec) {
             on_error: on_error
         });
 
-        command.set_option(that.attribute_name, values.join(','));
+        command.set_option(that.attribute_name, values);
 
         var additional_options = that.get_additional_options();
         for (var i=0; i<additional_options.length; i++) {
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to