From bcb2ce7f2464281923dd54396fa18d62e48ffebe Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Fri, 11 Apr 2014 09:24:06 +0200 Subject: [PATCH] webui: display undo and multivalued delete buttons in input-group Reviewed-By: Endi Sukma Dewata --- install/ui/ipa.css | 5 +- install/ui/src/freeipa/widget.js | 105 +++++++++++++++++++++++-------- ipatests/test_webui/ui_driver.py | 6 +- 3 files changed, 85 insertions(+), 31 deletions(-) diff --git a/install/ui/ipa.css b/install/ui/ipa.css index 0bfa7806e..3ec10e0b3 100644 --- a/install/ui/ipa.css +++ b/install/ui/ipa.css @@ -531,8 +531,9 @@ table.scrollable tbody { margin-top: 3px; } -.combobox-widget .undo { - margin-top: 3px; +.input-group .combobox-widget-input .form-control { + position: initial; + float: inherit; } /* ---- HBAC Test ---- */ diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 6bec38275..c17f7ca27 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -609,6 +609,8 @@ IPA.input_widget = function(spec) { that.widget_hide_error = that.hide_error; that.widget_show_error = that.show_error; that.widget_set_valid = that.set_valid; + that.widget_hide_undo = that.hide_undo; + that.widget_show_undo = that.show_undo; return that; }; @@ -682,6 +684,8 @@ IPA.text_widget = function(spec) { var id = IPA.html_util.get_next_id(that.name); + that.input_group = $('
').appendTo(container); + that.input = $('', { type: that.input_type, name: that.name, @@ -692,18 +696,23 @@ IPA.text_widget = function(spec) { keyup: function() { that.on_value_changed(); } - }).appendTo(container); + }).appendTo(that.input_group); + + that.input_group_btn = $('
', { + 'class': 'input-group-btn' + }).appendTo(that.input_group); that.input.bind('input', function() { that.on_value_changed(); }); if (that.undo) { - that.create_undo(container); + that.create_undo(that.input_group_btn); } that.create_error_link(container); that.set_enabled(that.enabled); + that.update_input_group_state(); }; /** @@ -715,11 +724,11 @@ IPA.text_widget = function(spec) { if (!that.is_writable()) { that.display_control.text(value); that.display_control.css('display', ''); - that.input.css('display', 'none'); + that.input_group.css('display', 'none'); } else { that.input.val(value); that.display_control.css('display', 'none'); - that.input.css('display', ''); + that.input_group.css('display', ''); } that.on_value_changed(); @@ -757,6 +766,31 @@ IPA.text_widget = function(spec) { } }; + /** + * Display undo button + */ + that.show_undo = function() { + that.widget_show_undo(); + that.update_input_group_state(); + }; + + /** + * Hide undo button + */ + that.hide_undo = function() { + that.widget_hide_undo(); + that.update_input_group_state(); + }; + + /** + * Set 'input_group' class to input group if input_group_btn has any + * visible content. + */ + that.update_input_group_state = function() { + var visible = $(':visible', that.input_group_btn).length > 0; + that.input_group.toggleClass('input-group', visible); + }; + // methods that should be invoked by subclasses that.text_load = that.load; @@ -799,11 +833,11 @@ IPA.multivalued_widget = function(spec) { that.on_child_value_changed = function(row) { if (that.test_dirty_row(row)) { + that.toggle_remove_link(row, false); row.widget.show_undo(); - row.remove_link.hide(); } else { row.widget.hide_undo(); - row.remove_link.show(); + that.toggle_remove_link(row, true); } if (that.updating) return; @@ -828,7 +862,7 @@ IPA.multivalued_widget = function(spec) { var row = that.rows[i]; row.widget.hide_undo(); if (that.is_writable()) { - row.remove_link.show(); + that.toggle_remove_link(row, true); } } }; @@ -971,29 +1005,44 @@ IPA.multivalued_widget = function(spec) { that.emit('error-show', { source: that }); }); - row.remove_link = $('', { + var remove_link_visible = !(row.is_new || !that.is_writable()); + row.remove_link = $('