summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-06-28 14:52:11 +0200
committerRob Crittenden <rcritten@redhat.com>2013-07-09 11:48:19 -0400
commit9f223871a77dfb2f16680036c4662352d56e0c10 (patch)
tree91f3cb65de2b7165329f4e851de70623e7a4ed46
parent30e75797805b3483942ea76a21c9bb8a99d24ce1 (diff)
downloadfreeipa-9f223871a77dfb2f16680036c4662352d56e0c10.tar.gz
freeipa-9f223871a77dfb2f16680036c4662352d56e0c10.tar.xz
freeipa-9f223871a77dfb2f16680036c4662352d56e0c10.zip
Disable checkboxes and radios for readonly attributes
https://fedorahosted.org/freeipa/ticket/3764
-rw-r--r--install/ui/src/freeipa/widget.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index 53e5ae605..62a71f0a5 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,8 +958,12 @@ IPA.option_widget_base = function(spec, that) {
// uncheck all inputs
check(that._selector, true /*uncheck*/);
- if (values && values.length > 0) {
+ 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++) {
@@ -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);
}
};