diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2014-03-14 16:49:48 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2014-03-20 10:02:31 +0100 |
commit | 4de360fd2c9ec2c67737821ddeb1c5a0b34737b1 (patch) | |
tree | 65a3a9773cda240e20dd7596e15103db98674d91 /install | |
parent | d40dd17fb1658731d6df8dc805a44421f99dab38 (diff) | |
download | freeipa-4de360fd2c9ec2c67737821ddeb1c5a0b34737b1.tar.gz freeipa-4de360fd2c9ec2c67737821ddeb1c5a0b34737b1.tar.xz freeipa-4de360fd2c9ec2c67737821ddeb1c5a0b34737b1.zip |
webui: reflect enabled state in child widgets of a multivalued widget
Child widgets are disabled when main widget is disabled. Also main
widget won't show "add" button.
prerequisite for:
https://fedorahosted.org/freeipa/ticket/4079
Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'install')
-rw-r--r-- | install/ui/src/freeipa/widget.js | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index f3b6c97d7..f149cd2e8 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -925,6 +925,7 @@ IPA.multivalued_widget = function(spec) { if (row.deleted || row.is_new) return true; var values = row.widget.save(); + if (!values) return false; if (row.original_values.length !== values.length) return true; @@ -965,12 +966,7 @@ IPA.multivalued_widget = function(spec) { that.initialized = true; - if (!that.is_writable()) { - that.add_link.css('display', 'none'); - } else { - that.add_link.css('display', ''); - } - + that.update_add_link_visibility(); } else { value = values[index]; var row = that.rows[index]; @@ -982,6 +978,37 @@ IPA.multivalued_widget = function(spec) { }; + that.update_add_link_visibility = function() { + var visible = that.is_writable() && that.enabled; + if (visible) { + that.add_link.css('display', ''); + } else { + that.add_link.css('display', 'none'); + } + }; + + that.set_enabled = function(enabled) { + + that.widget_set_enabled(enabled); + that.update_add_link_visibility(); + + for (var i=0,l=that.rows.length; i<l; i++) { + var row = that.rows[i]; + row.widget.set_enabled(enabled); + + if (!enabled) { + row.widget.hide_undo(); + row.remove_link.hide(); + } else { + if (row.is_new || that.test_dirty_row(row)) { + row.widget.show_undo(); + } else if (that.is_writable()) { + row.remove_link.show(); + } + } + } + }; + return that; }; |