Re: [Freeipa-devel] [PATCH] 019 Disables gid field if not posix group in group adder dialog

2011-10-05 Thread Petr Vobornik

On 10/04/2011 11:59 PM, Adam Young wrote:

On 10/04/2011 12:43 PM, Petr Vobornik wrote:

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

gidNumber is not an allowed attribute for a non-posix group. When
adding a non-posix group from the UI, unchecking the Is this a POSIX
group?: box should disable the GID: field.


Patch would not apply, for some reason. I forced it in by hand. I need
to set up another IPA server to test it, which I will do later on tonight


It applies (git am) on ipa-2-1. With -3 even on master. For completeness 
I attached rebased patch for master.



--
Petr Vobornik
From 975dba79198755dbea7d5037b8819884b1550108 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Tue, 4 Oct 2011 18:38:08 +0200
Subject: [PATCH] Disables gid field if not posix group in group adder dialog

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

gidNumber is not an allowed attribute for a non-posix group.  When adding a non-posix group from the UI, unchecking the Is this a POSIX group?: box should disable the GID: field.
---
 install/ui/group.js  |   29 -
 install/ui/widget.js |   11 +++
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/install/ui/group.js b/install/ui/group.js
index b9664ea6141736e7a2415d2548f838ecd15de1fd..a63a7800a0b668152188bfccfd372e8548e484fd 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -102,6 +102,7 @@ IPA.entity_factories.group =  function () {
 }).
 standard_association_facets().
 adder_dialog({
+factory: IPA.group_adder_dialog,
 fields: [
 'cn',
 {
@@ -133,4 +134,30 @@ IPA.group_nonposix_checkbox_widget = function (spec) {
 };
 
 return that;
-};
\ No newline at end of file
+};
+
+IPA.group_adder_dialog = function (spec) {
+
+spec = spec || {};
+
+var that = IPA.add_dialog(spec);
+
+var init = function() {
+
+var posix_field = that.get_field('nonposix');
+posix_field.value_changed.attach(that.on_posix_change);
+};
+
+that.on_posix_change = function (value) {
+
+var gid_field = that.get_field('gidnumber');
+if(value) {
+gid_field.reset();
+}
+gid_field.set_enabled(!value);
+};
+
+init();
+
+return that;
+};
diff --git a/install/ui/widget.js b/install/ui/widget.js
index b25dc8f7f085dedb839d37631509621290008610..d869b57edffeac3078e8b054f30994cec377f5a4 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -468,6 +468,15 @@ IPA.text_widget = function(spec) {
 }
 };
 
+that.set_enabled = function(value) {
+
+if(value) {
+that.input.removeAttr('disabled');
+} else {
+that.input.attr('disabled', 'disabled');
+}
+};
+
 // methods that should be invoked by subclasses
 that.text_load = that.load;
 
@@ -771,6 +780,7 @@ IPA.checkbox_widget = function (spec) {
 
 // default value
 that.checked = spec.checked || false;
+that.value_changed = IPA.observer();
 
 that.create = function(container) {
 
@@ -785,6 +795,7 @@ IPA.checkbox_widget = function (spec) {
 title: that.tooltip,
 change: function() {
 that.set_dirty(that.test_dirty());
+that.value_changed.notify(that.save(), that);
 }
 }).appendTo(container);
 
-- 
1.7.6

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

[Freeipa-devel] [PATCH] 019 Disables gid field if not posix group in group adder dialog

2011-10-04 Thread Petr Vobornik

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

gidNumber is not an allowed attribute for a non-posix group.  When 
adding a non-posix group from the UI, unchecking the Is this a POSIX 
group?: box should disable the GID: field.


--
Petr Vobornik
From 3e329f7f6e26cf839681c95d163625223fb2c546 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Tue, 4 Oct 2011 18:38:08 +0200
Subject: [PATCH] Disables gid field if not posix group in group adder dialog

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

gidNumber is not an allowed attribute for a non-posix group.  When adding a non-posix group from the UI, unchecking the Is this a POSIX group?: box should disable the GID: field.
---
 install/ui/group.js  |   29 -
 install/ui/widget.js |   11 +++
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/install/ui/group.js b/install/ui/group.js
index ad705eb21e4ed06298319110ca4822e86ec701dc..b4753a7ebbeead25ba6e17c8e7e306708606904d 100644
--- a/install/ui/group.js
+++ b/install/ui/group.js
@@ -88,6 +88,7 @@ IPA.entity_factories.group =  function () {
 }).
 standard_association_facets().
 adder_dialog({
+factory: IPA.group_adder_dialog,
 fields: [
 'cn',
 'description',
@@ -115,4 +116,30 @@ IPA.group_nonposix_checkbox_widget = function (spec) {
 };
 
 return that;
-};
\ No newline at end of file
+};
+
+IPA.group_adder_dialog = function (spec) {
+
+spec = spec || {};
+
+var that = IPA.add_dialog(spec);
+
+var init = function() {
+
+var posix_field = that.get_field('nonposix');
+posix_field.value_changed.attach(that.on_posix_change);
+};
+
+that.on_posix_change = function (value) {
+
+var gid_field = that.get_field('gidnumber');
+if(value) {
+gid_field.reset();
+}
+gid_field.set_enabled(!value);
+};
+
+init();
+
+return that;
+};
diff --git a/install/ui/widget.js b/install/ui/widget.js
index f46d79e72309ce367a7f0b3f1fb1f974871ca402..b86f6e04c593f7fbe145f120865e622333092f8e 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -468,6 +468,15 @@ IPA.text_widget = function(spec) {
 }
 };
 
+that.set_enabled = function(value) {
+
+if(value) {
+that.input.removeAttr('disabled');
+} else {
+that.input.attr('disabled', 'disabled');
+}
+};
+
 // methods that should be invoked by subclasses
 that.text_load = that.load;
 
@@ -771,6 +780,7 @@ IPA.checkbox_widget = function (spec) {
 
 // default value
 that.checked = spec.checked || false;
+that.value_changed = IPA.observer();
 
 that.create = function(container) {
 
@@ -785,6 +795,7 @@ IPA.checkbox_widget = function (spec) {
 title: that.tooltip,
 change: function() {
 that.set_dirty(that.test_dirty());
+that.value_changed.notify(that.save(), that);
 }
 }).appendTo(container);
 
-- 
1.7.6

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