summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2011-09-14 12:36:58 -0500
committerEndi S. Dewata <edewata@redhat.com>2011-09-20 18:50:46 +0000
commit21cd1857c86e540348cc07a2a86f3d35b51802d5 (patch)
treec5af32534d23bf160eddc33736b0e00b748b266e
parent89c4e9362d08cd67d8e49109c8073c8c5b084c77 (diff)
downloadfreeipa-21cd1857c86e540348cc07a2a86f3d35b51802d5.tar.gz
freeipa-21cd1857c86e540348cc07a2a86f3d35b51802d5.tar.xz
freeipa-21cd1857c86e540348cc07a2a86f3d35b51802d5.zip
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
-rw-r--r--install/ui/group.js21
-rw-r--r--install/ui/test/widget_tests.js2
-rw-r--r--install/ui/widget.js27
3 files changed, 40 insertions, 10 deletions
diff --git a/install/ui/group.js b/install/ui/group.js
index 410a295d4..f49c00f0b 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.group_nonposix_checkbox_widget,
+ name: 'nonposix',
label: IPA.messages.objects.group.posix,
undo: false,
- checked: 'checked'
+ checked: true
},
'gidnumber']
}).
build();
};
+
+IPA.group_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/test/widget_tests.js b/install/ui/test/widget_tests.js
index 9f0f6f0b5..caf28edcc 100644
--- a/install/ui/test/widget_tests.js
+++ b/install/ui/test/widget_tests.js
@@ -241,7 +241,7 @@ test("Testing checkbox widget.", function() {
spec = {name:'title'};
base_widget_test('test_value');
- mock_record = {'title':'something'};
+ mock_record = { 'title': 'TRUE' };
widget.load(mock_record);
same(widget.save(),[true], "Checkbox is set");
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 586984868..5438c8157 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -760,9 +760,11 @@ IPA.multivalued_text_widget = function(spec) {
IPA.checkbox_widget = function (spec) {
spec = spec || {};
+
var that = IPA.widget(spec);
- that.checked = spec.checked || '';
+ // default value
+ that.checked = spec.checked || false;
that.create = function(container) {
@@ -773,7 +775,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());
@@ -786,6 +788,7 @@ IPA.checkbox_widget = function (spec) {
};
that.load = function(record) {
+ that.widget_load(record);
that.values = record[that.name] || [false];
that.reset();
};
@@ -796,17 +799,29 @@ IPA.checkbox_widget = function (spec) {
};
that.update = function() {
- var value = that.values && that.values.length ? that.values[0] : false;
- if (value ==="FALSE"){
- value = false;
+ var value;
+
+ if (that.values && that.values.length) {
+ // use loaded value
+ value = that.values[0];
+ } else {
+ // use default value
+ value = that.checked;
}
- if (value ==="TRUE"){
+
+ // convert string into boolean
+ if (value === 'TRUE') {
value = true;
+ } else if (value === 'FALSE') {
+ value = false;
}
that.input.attr('checked', value);
};
+ that.checkbox_save = that.save;
+ that.checkbox_load = that.load;
+
return that;
};