[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Freeipa-devel] [PATCH] 118-119 DNS forward policy: checkboxes changed to radio buttons



DNS forward policy fields were using mutually exclusive checkboxes. Such behavior is unusual for users.

Checkboxes were changed to radios with new option 'none/default' to set empty value ''.

https://fedorahosted.org/freeipa/ticket/2599

Second patch removes mutex option from checkboxes. Not sure if needed.
--
Petr Vobornik
From 99eec2431d4e98e16b339f6103318ab96af34843 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni redhat com>
Date: Wed, 4 Apr 2012 10:49:16 +0200
Subject: [PATCH] DNS forward policy: checkboxes changed to radio buttons

DNS forward policy fields were using mutually exclusive checkboxes. Such behavior is unusual for users.

Checkboxes were changed to radios with new option 'none/default' to set empty value ''.

https://fedorahosted.org/freeipa/ticket/2599
---
 install/ui/dns.js                  |   22 ++++++++++++++++------
 install/ui/ipa.js                  |   21 +++++++++++++--------
 install/ui/test/data/ipa_init.json |    1 +
 ipalib/plugins/internal.py         |    1 +
 4 files changed, 31 insertions(+), 14 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 6a684b9ea207feee2425c8f14dd398918fcaca6b..5a0f5194d9c91434608bfec904368dd3d59c4f9a 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -52,10 +52,15 @@ IPA.dns.config_entity = function(spec) {
                             validators: [IPA.dnsforwarder_validator()]
                         },
                         {
-                            type: 'checkboxes',
+                            type: 'radio',
                             name: 'idnsforwardpolicy',
-                            mutex: true,
-                            options: IPA.create_options(['only', 'first'])
+                            options: IPA.create_options([
+                                {
+                                    value: '',
+                                    label: IPA.messages.widget.none_default
+                                },
+                                'only', 'first'
+                            ])
                         },
                         'idnszonerefresh'
                     ]
@@ -170,10 +175,15 @@ IPA.dns.zone_entity = function(spec) {
                         validators: [IPA.dnsforwarder_validator()]
                     },
                     {
-                        type: 'checkboxes',
+                        type: 'radio',
                         name: 'idnsforwardpolicy',
-                        mutex: true,
-                        options: IPA.create_options(['only', 'first'])
+                        options: IPA.create_options([
+                            {
+                                value: '',
+                                label: IPA.messages.widget.none_default
+                            },
+                            'only', 'first'
+                        ])
                     },
                     {
                         type: 'checkbox',
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index be87481018654c6803b9c610df3723566a4efac2..eeac030531302fffc0af79e70a835dca8120f674 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -1516,17 +1516,22 @@ IPA.limit_text = function(value, max_length) {
     return limited_text;
 };
 
-IPA.create_options = function(labels, values) {
-
-    if(!values) values = labels;
+IPA.create_options = function(values) {
 
     var options = [];
 
-    for (var i=0; i<labels.length; i++) {
-        options.push({
-            label: labels[i],
-            value: values[i]
-        });
+    for (var i=0; i<values.length; i++) {
+        var val = values[i];
+        var option = val;
+
+        if (typeof val === 'string') {
+            option = {
+                value: val,
+                label: val
+            };
+        }
+
+        options.push(option);
     }
 
     return options;
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 6eed01e924abac09eaba843be7d2be8d5b75ce9c..e394a63ddc7bb9284b306049e934256175ec18ef 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -439,6 +439,7 @@
                     "true": "True",
                     "widget": {
                         "next": "Next",
+                        "none_default": "none/default",
                         "page": "Page",
                         "prev": "Prev",
                         "undo": "undo",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 8ce3a00678fec4396cf5bbcdcd2b596bdb751820..fb409d96009272691c22e109547b74001e322657 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -578,6 +578,7 @@ class i18n_messages(Command):
         "true": _("True"),
         "widget": {
             "next": _("Next"),
+            "none_default": _("none/default"),
             "page": _("Page"),
             "prev": _("Prev"),
             "undo": _("undo"),
-- 
1.7.7.6

From 596ce427047f80dfd965204e13edab5ece00271e Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni redhat com>
Date: Wed, 4 Apr 2012 11:04:33 +0200
Subject: [PATCH] Removed mutex option from checkboxes

Mutually exclusive checkboxes were unusual. They are not in use anymore. The functionality is removed.

https://fedorahosted.org/freeipa/ticket/2599
---
 install/ui/widget.js |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/install/ui/widget.js b/install/ui/widget.js
index 4ddff81f9c9a922be2ea3a1454d9f4c8f166d6c9..ff77597479a3799a47fee49d66d2aa6ddfe7ff64 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -660,7 +660,6 @@ IPA.checkboxes_widget = function (spec) {
 
     that.options = spec.options || [];
     that.direction = spec.direction || 'vertical';
-    that.mutex = spec.mutex;
 
     that.create = function(container) {
 
@@ -695,15 +694,6 @@ IPA.checkboxes_widget = function (spec) {
 
         var input = $('input[name="'+that.name+'"]', that.container);
         input.change(function() {
-
-            var checkbox = $(this);
-            var checked = checkbox.is(':checked');
-
-            if (that.mutex && checked) {
-                that.clear();
-                checkbox.attr('checked', true);
-            }
-
             that.value_changed.notify([that.save()], that);
         });
 
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]