From 9afe4b98da13bbf1ce2fd68a660ee1d77fd84f2f Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 24 Oct 2011 14:53:29 +0200 Subject: Page is cleared before it is visible https://fedorahosted.org/freeipa/ticket/1459 Changes: * added clear method to widgets, section, search, details, association facets * clear and refresh method in facet are called only if key/filter was changed * added id generator for widgets --- install/ui/association.js | 21 +++++++++---- install/ui/certificate.js | 9 ++++++ install/ui/details.js | 21 +++++++++++-- install/ui/entity.js | 28 ++++++++++++++--- install/ui/host.js | 12 +++++++ install/ui/search.js | 20 +++++++++--- install/ui/service.js | 5 +++ install/ui/user.js | 5 +++ install/ui/widget.js | 80 +++++++++++++++++++++++++++++++++++++++++------ 9 files changed, 173 insertions(+), 28 deletions(-) diff --git a/install/ui/association.js b/install/ui/association.js index d3b66132..d3d6b124 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -871,8 +871,6 @@ IPA.association_facet = function (spec) { that.facet_create_header(container); - that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); - if (!that.read_only) { that.remove_button = IPA.action_button({ name: 'remove', @@ -908,12 +906,13 @@ IPA.association_facet = function (spec) { span.append(IPA.messages.association.show_results); span.append(' '); - var direct_id = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-direct-radio'; + var name = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-type-radio'; + var direct_id = name + '-direct'; that.direct_radio = $('', { id: direct_id, type: 'radio', - name: 'type', + name: name, value: 'direct', click: function() { that.association_type = $(this).val(); @@ -929,12 +928,12 @@ IPA.association_facet = function (spec) { span.append(' '); - var indirect_id = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-indirect-radio'; + var indirect_id = name + '-indirect'; that.indirect_radio = $('', { id: indirect_id, type: 'radio', - name: 'type', + name: name, value: 'indirect', click: function() { that.association_type = $(this).val(); @@ -1201,6 +1200,16 @@ IPA.association_facet = function (spec) { command.execute(); }; + that.clear = function() { + that.header.clear(); + that.table.clear(); + }; + + that.needs_update = function() { + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); + return that.pkey !== pkey; + }; + /*initialization*/ var adder_columns = spec.adder_columns || []; for (var i=0; i', { id: id, type: 'radio', - name: that.name, + name: name, value: option.value }).appendTo(container); @@ -991,7 +1010,7 @@ IPA.radio_widget = function(spec) { that.create_undo(container); } - var input = $('input[name="'+that.name+'"]', that.container); + var input = $(that.selector, that.container); input.change(function() { that.set_dirty(that.test_dirty()); }); @@ -1008,20 +1027,20 @@ IPA.radio_widget = function(spec) { }; that.save = function() { - var input = $('input[name="'+that.name+'"]:checked', that.container); + var input = $(that.selector+':checked', that.container); if (!input.length) return []; return [input.val()]; }; that.update = function() { - $('input[name="'+that.name+'"]', that.container).each(function() { + $(that.selector, that.container).each(function() { var input = this; input.checked = false; }); var value = that.values && that.values.length ? that.values[0] : ''; - var input = $('input[name="'+that.name+'"][value="'+value+'"]', that.container); + var input = $(that.selector+'[value="'+value+'"]', that.container); if (input.length) { input.attr('checked', true); } @@ -1032,6 +1051,10 @@ IPA.radio_widget = function(spec) { return false; }; + that.clear = function() { + $(that.selector, that.container).attr('checked', false); + }; + // methods that should be invoked by subclasses that.radio_create = that.create; that.radio_save = that.save; @@ -1104,6 +1127,10 @@ IPA.select_widget = function(spec) { $('option', that.select).remove(); }; + that.clear = function() { + that.empty(); + }; + // methods that should be invoked by subclasses that.select_load = that.load; that.select_save = that.save; @@ -1166,6 +1193,10 @@ IPA.textarea_widget = function (spec) { that.input.val(value); }; + that.clear = function() { + that.input.val(''); + }; + return that; }; @@ -1639,6 +1670,12 @@ IPA.table_widget = function (spec) { } }; + that.clear = function() { + that.empty(); + that.summary.text(''); + }; + + //column initialization if (spec.columns) { for (var i=0; i