Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-07 Thread Petr Vobornik

On 11/05/2011 01:37 AM, Endi Sukma Dewata wrote:

On 11/4/2011 11:02 AM, Petr Vobornik wrote:
Found another problem, changing page in the association facet didn't
work because pkey is still the same. See the attached patch.



ACK and pushed to master

--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-04 Thread Petr Vobornik

On 11/03/2011 10:22 PM, Endi Sukma Dewata wrote:

On 11/2/2011 11:01 AM, Petr Vobornik wrote:

Regardless, ACK and pushed to master.


Found another problem, the krbtpolicy  config need to be forced to
update. See the attached patch.


ACK and pushed to master.

--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-04 Thread Endi Sukma Dewata

On 11/4/2011 11:02 AM, Petr Vobornik wrote:

ACK and pushed to master.


Found another problem, changing page in the association facet didn't 
work because pkey is still the same. See the attached patch.


--
Endi S. Dewata
From 291626e4f4e464b907fae33291b430f8ead95055 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata edew...@redhat.com
Date: Thu, 3 Nov 2011 23:43:58 -0500
Subject: [PATCH] Fixed problem changing page in association facet.

The association facet has been modified to detect page change to
determine whether the facet needs to be updated.

Ticket #1459
---
 install/ui/association.js |   10 --
 install/ui/entity.js  |6 --
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index 6ce8fea46caa57638273d53518ce0472df58ac2d..6ef73dafe445af5c68fb506c2450fa67724efd84 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -1165,7 +1165,7 @@ IPA.association_facet = function (spec) {
 that.table.total_pages = 1;
 }
 
-that.table.current_page = 1;
+delete that.table.current_page;
 
 that.table.refresh();
 that.table.unselect_all();
@@ -1207,8 +1207,14 @@ IPA.association_facet = function (spec) {
 
 that.needs_update = function() {
 if (that._needs_update !== undefined) return that._needs_update;
+
 var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
-return that.pkey !== pkey;
+if (that.pkey !== pkey) return true;
+
+var page = parseInt(IPA.nav.get_state(that.entity_name+'-page'), 10) || 1;
+if (that.table.current_page !== page) return true;
+
+return false;
 };
 
 /*initialization*/
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 75f781e627f39489e464b950dc64f54d3063b64b..f7bf992aada9070ea81fb0271a4dce41706a7914 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -156,8 +156,10 @@ IPA.entity = function(spec) {
 var facet_name = IPA.nav.get_state(that.name+'-facet');
 that.facet = that.get_facet(facet_name);
 
+var needs_update = that.facet.needs_update();
+
 // same entity, same facet, and doesn't need updating = return
-if (that == prev_entity  that.facet == prev_facet  !that.facet.needs_update()) {
+if (that == prev_entity  that.facet == prev_facet  !needs_update) {
 return;
 }
 
@@ -175,7 +177,7 @@ IPA.entity = function(spec) {
 that.facet.create(facet_container);
 }
 
-if (that.facet.needs_update()) {
+if (needs_update) {
 that.facet.clear();
 that.facet.show();
 that.facet.header.select_tab();
-- 
1.7.5.1

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-03 Thread Endi Sukma Dewata

On 11/2/2011 11:01 AM, Petr Vobornik wrote:

Regardless, ACK and pushed to master.


Found another problem, the krbtpolicy  config need to be forced to 
update. See the attached patch.


--
Endi S. Dewata
From fc3895f69dbf15f37d81f5dffad59a17a2953a03 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata edew...@redhat.com
Date: Thu, 3 Nov 2011 16:02:32 -0500
Subject: [PATCH] Fixed blank krbtpolicy and config pages.

The details page compares the old and the new primary keys to determine
if the page needs to be reloaded. The Kerberos Ticket Policy and Config
pages do not use primary keys, so they are never loaded/updated with
data. A parameter has been added to force update on these pages.

Ticket #1459
---
 install/ui/association.js  |1 +
 install/ui/details.js  |1 +
 install/ui/entity.js   |2 ++
 install/ui/policy.js   |   15 +++
 install/ui/serverconfig.js |   13 +++--
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index d3d6b124b431414ff04fad05b16dbb972b38c2b7..6ce8fea46caa57638273d53518ce0472df58ac2d 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -1206,6 +1206,7 @@ IPA.association_facet = function (spec) {
 };
 
 that.needs_update = function() {
+if (that._needs_update !== undefined) return that._needs_update;
 var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
 return that.pkey !== pkey;
 };
diff --git a/install/ui/details.js b/install/ui/details.js
index 15056204f72ef2095862c2c35d24cd47fbc819b3..93bb3e8a404bb24374e64bfeb824869f531a7f96 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -528,6 +528,7 @@ IPA.details_facet = function(spec) {
 };
 
 that.needs_update = function() {
+if (that._needs_update !== undefined) return that._needs_update;
 var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
 return pkey !== that.pkey;
 };
diff --git a/install/ui/entity.js b/install/ui/entity.js
index ace44c3c1fef43e8a8700038c5305391ae3106a4..526e2795d94512add214af785a8442e18192d171 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -44,6 +44,7 @@ IPA.facet = function (spec) {
 that.header = spec.header || IPA.facet_header({ facet: that });
 
 that.entity_name = spec.entity_name;
+that._needs_update = spec.needs_update;
 
 that.dialogs = $.ordered_map();
 
@@ -113,6 +114,7 @@ IPA.facet = function (spec) {
 };
 
 that.needs_update = function() {
+if (that._needs_update !== undefined) return that._needs_update;
 return true;
 };
 
diff --git a/install/ui/policy.js b/install/ui/policy.js
index 41432f743e2b894cb4a8d2a9b338bacc85b8c762..f773c4714bf1f62305d261dd42a8bc20195f8d9b 100644
--- a/install/ui/policy.js
+++ b/install/ui/policy.js
@@ -76,9 +76,16 @@ IPA.entity_factories.krbtpolicy =  function() {
 entity('krbtpolicy').
 details_facet({
 title: IPA.metadata.objects.krbtpolicy.label,
-sections:[{
-name: 'identity',
-fields:[ 'krbmaxrenewableage','krbmaxticketlife' ]
-}]}).
+sections: [
+{
+name: 'identity',
+fields: [
+'krbmaxrenewableage',
+'krbmaxticketlife'
+]
+}
+],
+needs_update: true
+}).
 build();
 };
diff --git a/install/ui/serverconfig.js b/install/ui/serverconfig.js
index 6dc2eaf6dec7ae49a69fe91ecb7779076534ab62..eec47d2f77647427f5a465f2bec1dd8648a8b506 100644
--- a/install/ui/serverconfig.js
+++ b/install/ui/serverconfig.js
@@ -32,12 +32,11 @@ IPA.entity_factories.config = function(){
 entity('config').
 details_facet({
 title: IPA.metadata.objects.config.label,
-sections:
-[
+sections: [
 {
 name: 'search',
 label: IPA.messages.objects.config.search,
-fields:[
+fields: [
 'ipasearchrecordslimit',
 'ipasearchtimelimit'
 ]
@@ -45,7 +44,7 @@ IPA.entity_factories.config = function(){
 {
 name: 'user',
 label: IPA.messages.objects.config.user,
-fields:[
+fields: [
 'ipausersearchfields',
 'ipadefaultemaildomain',
 {
@@ -71,7 +70,7 @@ IPA.entity_factories.config = function(){
 {
 name: 'group',
 label: IPA.messages.objects.config.group,
-fields:[
+fields: [
 'ipagroupsearchfields',
 {
 factory: 

Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-02 Thread Petr Vobornik

On 11/01/2011 11:31 PM, Endi Sukma Dewata wrote:

On 11/1/2011 7:37 AM, Petr Vobornik wrote:

1. The new clear() method is called during refresh(), so the facet with
the old data is still shown for a brief moment before it's cleared.



The clear() should be called before show(). However, if the pkey/filter
is unchanged (check using needs_update()) we just need to show() the
facet, no need to clear() and refresh() again. The above logic needs to
be fixed.


Changed.


The we will need to override the needs_update() for search and
association facets because the default one always returns true.


Done


On the second thought, this might not be sufficient to detect the
changes in the list page. Try changing an attribute in an entry, then go
back to the list page, the list page will not show the updated attribute
because the filter is not changed.

I think we should remove the needs_update() from the search facet so it
will always refresh, but we probably can keep it for association facet.
What do you think? Sorry about that.


Changed to refresh always. Clearing always or not clearing at all seems 
wrong. When the pkey doesn't change, only small portion of values 
can/will change, so it's probably not so wrong to show the previous 
list, but when the filter is changed the results will be probably much 
different and the clear is needed. What do you think? - Added 
needs_clear method which clears if the filter changes (basically renamed 
needs_update).



There are probably better solutions, but let's do this separately.


In future we can build a mechanism for subscribing to events from 
different facets and doing appropriate actions.


Something like:

var refresh_search_on_save = function(spec) {
var that = {};

that.register = function() {

that.entity = IPA.get_entity(spec.entity);
that.details_facet = that.entity.get_facet(spec.facet || 
'details');
that.search_facet = that.entity.get_facet(spec.search_facet || 
'search');


that.details_facet.on_save.attach(that.on_save, that);
};

that.on_save = function() {
that.search_facet.set_needs_refresh(true);
};

return that;
};

So the facets won't be dependent on each other.



5) Added ID generator, using in radio_widget, same reason as #4.


The get_id() method (might be better called get_next_id() or
generate_id()) doesn't really need to take a widget parameter. The
id_count should be unique enough. If you want, it can take an optional
prefix so the ID will be like 'prefix-id'. It will make it more
usable for other things not just widgets.


changed to get_next_id(prefix).





9. The facet header's clear() calls load() with empty data. The load()
will display the facet group label using facet's pkey. Since this is
called before refresh(), sometimes you'll see 'undefined' or the old
pkey. I think the code in entity.js:351-354 should check if the data is
empty it should clear the label.


Fixed


10. Instead of emptying button label in host.js:731-732, it's probably
better to reset it to its initial value:

var password_label = $('.button-label', that.set_password_button);
password_label.text(IPA.messages.objects.host.password_set_button);


Seems more proper to clean the label. If the label is set to 
...host.password_set_button it will always shows before load set OTP 
after load it can change to reset OTP which is wrong behavior.


--
Petr Vobornik
From b239957ae77de87bab163f3f43ca337d7f7bee33 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Mon, 24 Oct 2011 14:53:29 +0200
Subject: [PATCH] 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 d3b66132d5043b0dfe60b8847896e9f27f676059..d3d6b124b431414ff04fad05b16dbb972b38c2b7 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) {
 

Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-02 Thread Endi Sukma Dewata

On 11/2/2011 8:33 AM, Petr Vobornik wrote:

On the second thought, this might not be sufficient to detect the
changes in the list page. Try changing an attribute in an entry, then go
back to the list page, the list page will not show the updated attribute
because the filter is not changed.

I think we should remove the needs_update() from the search facet so it
will always refresh, but we probably can keep it for association facet.
What do you think? Sorry about that.


Changed to refresh always. Clearing always or not clearing at all seems
wrong. When the pkey doesn't change, only small portion of values
can/will change, so it's probably not so wrong to show the previous
list, but when the filter is changed the results will be probably much
different and the clear is needed. What do you think? - Added
needs_clear method which clears if the filter changes (basically renamed
needs_update).


OK. The search page feels more responsive this way. The term 
needs_clear() is a bit confusing because during facet.refresh() it also 
calls table.empty() which essentially the same as table.clear(). How 
about clear_before_show()? It's not important, we can do this later.



There are probably better solutions, but let's do this separately.


In future we can build a mechanism for subscribing to events from
different facets and doing appropriate actions.

Something like:

var refresh_search_on_save = function(spec) {
var that = {};

that.register = function() {

that.entity = IPA.get_entity(spec.entity);
that.details_facet = that.entity.get_facet(spec.facet || 'details');
that.search_facet = that.entity.get_facet(spec.search_facet || 'search');

that.details_facet.on_save.attach(that.on_save, that);
};

that.on_save = function() {
that.search_facet.set_needs_refresh(true);
};

return that;
};

So the facets won't be dependent on each other.


Yes, that would be better, but I'd put the registration somewhere inside 
the entity class (to be created). This is also going to force early 
creation of the facets as opposed to lazy loading.



9. The facet header's clear() calls load() with empty data. The load()
will display the facet group label using facet's pkey. Since this is
called before refresh(), sometimes you'll see 'undefined' or the old
pkey. I think the code in entity.js:351-354 should check if the data is
empty it should clear the label.


Fixed


I think displaying no label at all would be better than showing 
incomplete label (without primary key), but we can do this later.



10. Instead of emptying button label in host.js:731-732, it's probably
better to reset it to its initial value:

var password_label = $('.button-label', that.set_password_button);
password_label.text(IPA.messages.objects.host.password_set_button);


Seems more proper to clean the label. If the label is set to
...host.password_set_button it will always shows before load set OTP
after load it can change to reset OTP which is wrong behavior.


I see your point. It might be better to just hide the button, but we can 
do this later.


Question about this one:


4) Changed direct/indirect radio names in association facets - radios
form different facets were interfering.


Did you notice any problem with the old radio name? The name was 
supposed to be used locally by the facet itself so it should not 
interfere with radios in other facets, whereas ID is global so it needs 
to be unique.


Regardless, ACK and pushed to master.

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-02 Thread Petr Vobornik

On 11/02/2011 04:41 PM, Endi Sukma Dewata wrote:

On 11/2/2011 8:33 AM, Petr Vobornik wrote:

Question about this one:


4) Changed direct/indirect radio names in association facets - radios
form different facets were interfering.


Did you notice any problem with the old radio name? The name was
supposed to be used locally by the facet itself so it should not
interfere with radios in other facets, whereas ID is global so it needs
to be unique.


In sudo and hbac rule enable radio button.

Radios with same name are interfering on whole page. If you click at 
one, others gets unset. This wasn't an issue before because we have 
always reloaded the data. Radios in single facet wasn't interfering 
because they had different names. Gathering data wasn't a problem, 
because jquery selector was constraint to widget's container.



Regardless, ACK and pushed to master.


--
Petr Vobornik

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-01 Thread Petr Vobornik

On 10/31/2011 11:38 PM, Endi Sukma Dewata wrote:

On 10/27/2011 4:57 AM, Petr Vobornik wrote:

https://fedorahosted.org/freeipa/ticket/1459



Some issues:

1. The new clear() method is called during refresh(), so the facet with
the old data is still shown for a brief moment before it's cleared.



The clear() should be called before show(). However, if the pkey/filter
is unchanged (check using needs_update()) we just need to show() the
facet, no need to clear() and refresh() again. The above logic needs to
be fixed.


Changed.



The we will need to override the needs_update() for search and
association facets because the default one always returns true.


Done


2. The following code in association.js and search.js will call clear()
if there's no old pkey/filter, is this intentional? No old pkey/filter
means the page is just loaded, so it probably doesn't need clearing.

if (!old_pkey || old_pkey[0] !== pkey[0]) {
that.clear();
}

if (!old_filter || old_filter[0] !== filter[0]) {
that.clear();
}
It seems unnecessary. But probably it was intentional (don't remember) - 
IDRC if there is a widget - maybe keytab or certificate status, which 
has some default state worth cleaning. Anyway in current implementation 
this logic is part of need_update and it is a must. IMHO we should avoid 
implementing special need_cleaning method. Cleaning at first display 
doesn't do any harm and it is one less method to maintain in couple classes.




3) Fixed bad implementation of clear method in radio_widget.

4) Changed direct/indirect radio names in association facets - radios 
form different facets were interfering.


5) Added ID generator, using in radio_widget, same reason as #4.

6) Added clearing of header in details facet and association facets - 
refreshes of member counts were confusing.


7) Removed setting that.pkey in create method in details, association 
facet (it broke need_update, didn't found purpose).


8) Maybe we should add a refresh button to search facet. It doesn't 
reflect concurrent usage. Refresh by 2 changes of filter doesn't seem nice.



--
Petr Vobornik
From d99d152ea71f89459b4cdb2b60690cc771e1b8fc Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Mon, 24 Oct 2011 14:53:29 +0200
Subject: [PATCH] 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  |   19 +--
 install/ui/host.js|   12 +++
 install/ui/search.js  |   18 --
 install/ui/service.js |5 +++
 install/ui/user.js|5 +++
 install/ui/widget.js  |   80 +++--
 9 files changed, 164 insertions(+), 26 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index d3b66132d5043b0dfe60b8847896e9f27f676059..d3d6b124b431414ff04fad05b16dbb972b38c2b7 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 = $('input/', {
 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 = $('input/', {
 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() {

Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-11-01 Thread Endi Sukma Dewata

On 11/1/2011 7:37 AM, Petr Vobornik wrote:

1. The new clear() method is called during refresh(), so the facet with
the old data is still shown for a brief moment before it's cleared.



The clear() should be called before show(). However, if the pkey/filter
is unchanged (check using needs_update()) we just need to show() the
facet, no need to clear() and refresh() again. The above logic needs to
be fixed.


Changed.


The we will need to override the needs_update() for search and
association facets because the default one always returns true.


Done


On the second thought, this might not be sufficient to detect the 
changes in the list page. Try changing an attribute in an entry, then go 
back to the list page, the list page will not show the updated attribute 
because the filter is not changed.


I think we should remove the needs_update() from the search facet so it 
will always refresh, but we probably can keep it for association facet. 
What do you think? Sorry about that.


There are probably better solutions, but let's do this separately.


5) Added ID generator, using in radio_widget, same reason as #4.


The get_id() method (might be better called get_next_id() or 
generate_id()) doesn't really need to take a widget parameter. The 
id_count should be unique enough. If you want, it can take an optional 
prefix so the ID will be like 'prefix-id'. It will make it more 
usable for other things not just widgets.



8) Maybe we should add a refresh button to search facet. It doesn't
reflect concurrent usage. Refresh by 2 changes of filter doesn't seem nice.


You can reload the page too, but I agree we probably need a refresh 
button, and possibly for other facets too. I'll open a ticket.


9. The facet header's clear() calls load() with empty data. The load() 
will display the facet group label using facet's pkey. Since this is 
called before refresh(), sometimes you'll see 'undefined' or the old 
pkey. I think the code in entity.js:351-354 should check if the data is 
empty it should clear the label.


10. Instead of emptying button label in host.js:731-732, it's probably 
better to reset it to its initial value:


  var password_label = $('.button-label', that.set_password_button);
  password_label.text(IPA.messages.objects.host.password_set_button);

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


Re: [Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-10-31 Thread Endi Sukma Dewata

On 10/27/2011 4:57 AM, Petr Vobornik wrote:

https://fedorahosted.org/freeipa/ticket/1459

Changes:
* added clear method to widgets, section, search, details, association
facets
* clear method in facet is called only if key/filter was changed


Some issues:

1. The new clear() method is called during refresh(), so the facet with 
the old data is still shown for a brief moment before it's cleared.


Take a look at the following code in IPA.entity.display():

// same entity, same facet, and doesn't need updating = return
if (that == prev_entity
 that.facet == prev_facet
 !that.facet.needs_update()) {
return;
}

...

that.facet.show();
that.facet.header.select_tab();
that.facet.refresh();

The clear() should be called before show(). However, if the pkey/filter 
is unchanged (check using needs_update()) we just need to show() the 
facet, no need to clear() and refresh() again. The above logic needs to 
be fixed.


The we will need to override the needs_update() for search and 
association facets because the default one always returns true.


2. The following code in association.js and search.js will call clear() 
if there's no old pkey/filter, is this intentional? No old pkey/filter 
means the page is just loaded, so it probably doesn't need clearing.


if (!old_pkey || old_pkey[0] !== pkey[0]) {
that.clear();
}

if (!old_filter || old_filter[0] !== filter[0]) {
that.clear();
}

--
Endi S. Dewata

___
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel


[Freeipa-devel] [PATCH] 029 Page is cleared before it is visible

2011-10-27 Thread Petr Vobornik

https://fedorahosted.org/freeipa/ticket/1459

Changes:
 * added clear method to widgets, section, search, details, association 
facets

 * clear method in facet is called only if key/filter was changed
--
Petr Vobornik
From 22d6ba37f74ec40a8223082b8f6869ec9f1155a5 Mon Sep 17 00:00:00 2001
From: Petr Vobornik pvobo...@redhat.com
Date: Mon, 24 Oct 2011 14:53:29 +0200
Subject: [PATCH] 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 method in facet is called only if key/filter was changed
---
 install/ui/association.js |   11 ++
 install/ui/certificate.js |9 
 install/ui/details.js |   23 +
 install/ui/host.js|   12 +++
 install/ui/search.js  |   11 ++
 install/ui/service.js |5 
 install/ui/user.js|5 
 install/ui/widget.js  |   48 +
 8 files changed, 124 insertions(+), 0 deletions(-)

diff --git a/install/ui/association.js b/install/ui/association.js
index ebb6e421ff3b8538116471de240b1f972e08e6bf..f7e397c92fb97e0a3b1552f29bb3af9da6a55756 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -1198,9 +1198,20 @@ IPA.association_facet = function (spec) {
 
 command.on_error = that.on_error;
 
+var old_pkey = that.old_pkey;
+that.old_pkey = pkey;
+
+if (!old_pkey || old_pkey[0] !== pkey[0]) {
+that.clear();
+}
+
 command.execute();
 };
 
+that.clear = function() {
+that.table.clear();
+};
+
 /*initialization*/
 var adder_columns = spec.adder_columns || [];
 for (var i=0; iadder_columns.length; i++) {
diff --git a/install/ui/certificate.js b/install/ui/certificate.js
index 6136edaf0bbcedac890c8c8a6df3297d6802ccc9..70fc1ba3545a5339f873f47cc7656a0953fb50fd 100755
--- a/install/ui/certificate.js
+++ b/install/ui/certificate.js
@@ -725,6 +725,15 @@ IPA.cert.status_widget = function(spec) {
 }
 };
 
+that.clear = function() {
+that.status_valid.css('display', 'none');
+that.status_missing.css('display', 'none');
+that.status_revoked.css('display', 'none');
+that.revoke_button.css('display', 'none');
+that.restore_button.css('display', 'none');
+that.revocation_reason.text('');
+};
+
 function set_status(status, revocation_reason) {
 that.status_valid.css('display', status == IPA.cert.CERTIFICATE_STATUS_VALID ? 'inline' : 'none');
 that.status_missing.css('display', status == IPA.cert.CERTIFICATE_STATUS_MISSING ? 'inline' : 'none');
diff --git a/install/ui/details.js b/install/ui/details.js
index 5c03de0a32aed46aaebd36facddceaf56a853004..a863c18289c2df45aaecec0a68f464c5dc591bf8 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -201,6 +201,14 @@ IPA.details_section = function(spec) {
 }
 };
 
+that.clear = function() {
+var fields = that.fields.values;
+
+for (var i=0; i fields.length; i++) {
+fields[i].clear();
+}
+};
+
 init();
 
 // methods that should be invoked by subclasses
@@ -720,9 +728,24 @@ IPA.details_facet = function(spec) {
 that.pre_execute_hook(command);
 }
 
+var old_pkey = that.old_pkey;
+that.old_pkey = that.pkey;
+
+if (that.pkey !== old_pkey) {
+that.clear();
+}
+
 command.execute();
 };
 
+that.clear = function() {
+var sections = that.sections.values;
+
+for (var i=0; i sections.length; i++) {
+sections[i].clear();
+}
+};
+
 that.add_sections(spec.sections);
 
 that.details_facet_create_content = that.create_content;
diff --git a/install/ui/host.js b/install/ui/host.js
index 4c0ce6ed0e461a38a565c1450cd483098b0c2dc7..ba28ebcf8ce3f176fcab06616733ae07ef36c976 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -567,6 +567,11 @@ IPA.host_keytab_widget = function(spec) {
 set_status(value ? 'present' : 'missing');
 };
 
+that.clear = function() {
+that.present_span.css('display', 'none');
+that.missing_span.css('display', 'none');
+};
+
 function set_status(status) {
 that.present_span.css('display', status == 'present' ? 'inline' : 'none');
 that.missing_span.css('display', status == 'missing' ? 'inline' : 'none');
@@ -720,6 +725,13 @@ IPA.host_password_widget = function(spec) {
 set_status(value ? 'present' : 'missing');
 };
 
+that.clear = function() {
+that.missing_span.css('display', 'none');
+that.present_span.css('display', 'none');
+var password_label = $('.button-label', that.set_password_button);
+password_label.text('');
+};
+
 function set_status(status) {
 
 that.status = status;
diff