In the adder dialog for groups the checkbox has been modified to use
the correct field name "nonposix" and be checked by default.

Note: This is a temporary fix to minimize the changes due to release
schedule. Eventually the field label will be changed into "Non-POSIX
group" and the checkbox will be unchecked by default, which is more
consistent with CLI.

Ticket #1799

--
Endi S. Dewata
From 1dac389949b79ee83a58051c069138affa8c9894 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Wed, 14 Sep 2011 12:36:58 -0500
Subject: [PATCH] Fixed posix group checkbox.

In the adder dialog for groups the checkbox has been modified to use
the correct field name "nonposix" and be checked by default.

Note: This is a temporary fix to minimize the changes due to release
schedule. Eventually the field label will be changed into "Non-POSIX
group" and the checkbox will be unchecked by default, which is more
consistent with CLI.

Ticket #1799
---
 install/ui/group.js  |   21 ++++++++++++++++++---
 install/ui/widget.js |   24 +++++++++++++++---------
 2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/install/ui/group.js b/install/ui/group.js
index 410a295d4ac98da161cee9455b910660ec608469..f8d42ea37fdbb3420008b332ca1a1717b3d36170 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -92,13 +92,28 @@ IPA.entity_factories.group =  function () {
                 'cn',
                 'description',
                 {
-                    factory:IPA.checkbox_widget,
-                    name: 'posix',
+                    factory: IPA.nonposix_checkbox_widget,
+                    name: 'nonposix',
                     label: IPA.messages.objects.group.posix,
                     undo: false,
-                    checked: 'checked'
+                    checked: true
                 },
                 'gidnumber']
         }).
         build();
 };
+
+IPA.nonposix_checkbox_widget = function (spec) {
+
+    spec = spec || {};
+
+    var that = IPA.checkbox_widget(spec);
+
+    that.save = function() {
+        var value = that.checkbox_save()[0];
+        // convert posix into non-posix
+        return [!value];
+    };
+
+    return that;
+};
\ No newline at end of file
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 58698486894ce9e72842ea1cf011a5fb75286421..d4a46bd37a9ccfac48469c312d81081105816b4f 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -760,9 +760,10 @@ IPA.multivalued_text_widget = function(spec) {
 IPA.checkbox_widget = function (spec) {
 
     spec = spec || {};
+
     var that = IPA.widget(spec);
 
-    that.checked = spec.checked || '';
+    that.checked = spec.checked;
 
     that.create = function(container) {
 
@@ -773,7 +774,7 @@ IPA.checkbox_widget = function (spec) {
         that.input = $('<input/>', {
             type: 'checkbox',
             name: that.name,
-            checked : that.checked,
+            checked: that.checked,
             title: that.tooltip,
             change: function() {
                 that.set_dirty(that.test_dirty());
@@ -796,17 +797,22 @@ IPA.checkbox_widget = function (spec) {
     };
 
     that.update = function() {
-        var value = that.values && that.values.length ? that.values[0] : false;
-        if (value ==="FALSE"){
-            value = false;
-        }
-        if (value ==="TRUE"){
-            value = true;
+        var checked = that.checked || false;
+        if (that.values && that.values.length) {
+            var value = that.values[0];
+            if (value === "FALSE") {
+                checked = false;
+            }
+            if (value === "TRUE") {
+                checked = true;
+            }
         }
 
-        that.input.attr('checked', value);
+        that.input.attr('checked', checked);
     };
 
+    that.checkbox_save = that.save;
+
     return that;
 };
 
-- 
1.7.5.1

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

Reply via email to