https://fedorahosted.org/freeipa/ticket/3764
--
Petr Vobornik
From c7e435978e82c76483f71fb82fce1a3fabf016a7 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <[email protected]>
Date: Fri, 28 Jun 2013 14:52:11 +0200
Subject: [PATCH] Disable checkboxes and radios for readonly attributes

https://fedorahosted.org/freeipa/ticket/3764
---
 install/ui/src/freeipa/widget.js | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index ac93b91d6960de127ba0e6b71a6efbe81771a59f..06fcef563ca416e6e3e1cc454f2e1dd665c68f26 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -914,7 +914,7 @@ IPA.option_widget_base = function(spec, that) {
 
                 if (option.nested) {
                     var selected = parents_selected.indexOf(option.value) > -1;
-                    option.widget.set_enabled(selected);
+                    option.widget.set_enabled(selected, true);
                 }
             }
         }
@@ -958,9 +958,13 @@ IPA.option_widget_base = function(spec, that) {
             // uncheck all inputs
             check(that._selector, true /*uncheck*/);
 
+            var writable = !that.read_only && !!that.writable;
+            if (!that.nested) {
+                that.set_enabled(writable);
+            }
+
             if (values && values.length > 0) {
 
-
                 if (that.default_on_empty && that.default_value !== null) {
                     for (var i=0; i<values.length; i++) {
                         if (values[i] === '') {
@@ -982,7 +986,7 @@ IPA.option_widget_base = function(spec, that) {
                         check(that._selector+'[value="'+ option.value +'"]');
                     }
                     if (option.widget) {
-                        option.widget.set_enabled(has_opt);
+                        option.widget.set_enabled(writable && has_opt, false);
                     }
                 }
             } else {
@@ -996,19 +1000,22 @@ IPA.option_widget_base = function(spec, that) {
             }
 
             for (var j=0; j<that._child_widgets.length; j++) {
-                that._child_widgets[j].update(values);
+                var widget = that._child_widgets[j];
+                widget.writable = that.writable;
+                widget.read_only = that.read_only;
+                widget.update(values);
             }
         }
 
         that.updated.notify([], that);
     };
 
-    that.set_enabled = function(enabled) {
+    that.set_enabled = function(enabled, clear) {
 
         $(that._selector, that.container).prop('disabled', !enabled);
-        if (!enabled) that.clear();
-        for (var i=0; i<that._child_widgets.length;i++){
-            that._child_widgets[i].set_enabled(enabled);
+        if (!enabled && clear) that.clear();
+        for (var i=0; i<that._child_widgets.length;i++) {
+            that._child_widgets[i].set_enabled(enabled, clear);
         }
     };
 
-- 
1.8.1.4

_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to