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; i<adder_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 --git a/install/ui/search.js b/install/ui/search.js
index 83b91051c2a5e2cb87e83b61a281dd827f7dfe0c..3df556374bf09305b359be0c8e8345f24293c5da 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -283,9 +283,20 @@ IPA.search_facet = function(spec) {
             on_error: that.on_error
         });
 
+        var old_filter = that.old_filter;
+        that.old_filter = filter;
+
+        if (!old_filter || old_filter[0] !== filter[0]) {
+            that.clear();
+        }
+
         command.execute();
     };
 
+    that.clear = function() {
+        that.table.clear();
+    };
+
     // methods that should be invoked by subclasses
     that.search_facet_create_content = that.create_content;
 
diff --git a/install/ui/service.js b/install/ui/service.js
index 0ac2b6bec131786ca3f0c80122e9d8483a9c8f6c..50b7963b0c6da57db9b7fe14c593e191861fd80c 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -301,6 +301,11 @@ IPA.service_provisioning_status_widget = function (spec) {
         set_status(krblastpwdchange ? 'valid' : 'missing');
     };
 
+    that.clear = function() {
+        that.status_valid.css('display', 'none');
+        that.status_missing.css('display', 'none');
+    };
+
     function set_status(status) {
         that.status_valid.css('display', status == 'valid' ? 'inline' : 'none');
         that.status_missing.css('display', status == 'missing' ? 'inline' : 'none');
diff --git a/install/ui/user.js b/install/ui/user.js
index bfda51d84b7e34bed5f429fcdd83e0b1ea6b4e43..e97bb04a1c503d47498bbf9205c873491d69c768 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -244,6 +244,11 @@ IPA.user_status_widget = function(spec) {
         }
     };
 
+    that.clear = function() {
+        that.link_span.css('display', 'none');
+        that.status_span.text('');
+    };
+
     that.show_activation_dialog = function() {
 
         var action = that.status_link.attr('href');
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 3dd9b619ff866d88bed36fd0ded4d8eb184080f9..1d6ef3092ada328fec2ca70f527fcdcc6d4eb53b 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -390,6 +390,9 @@ IPA.widget = function(spec) {
         error_link.css('display', 'none');
     };
 
+    that.clear = function() {
+    };
+
     that.set_enabled = function() {
     };
 
@@ -505,6 +508,11 @@ IPA.text_widget = function(spec) {
         }
     };
 
+    that.clear = function() {
+        that.input.val('');
+        that.display_control.text('');
+    };
+
     // methods that should be invoked by subclasses
     that.text_load = that.load;
 
@@ -769,6 +777,10 @@ IPA.multivalued_text_widget = function(spec) {
         that.set_dirty(false, index);
     };
 
+    that.clear = function() {
+        that.remove_rows();
+    };
+
     that.update = function(index) {
 
         var value;
@@ -871,6 +883,10 @@ IPA.checkbox_widget = function (spec) {
         return false;
     };
 
+    that.clear = function() {
+        that.input.attr('checked', false);
+    };
+
     that.checkbox_save = that.save;
     that.checkbox_load = that.load;
 
@@ -958,6 +974,10 @@ IPA.checkboxes_widget = function (spec) {
         }
     };
 
+    that.clear = function() {
+        $('input[name="'+that.name+'"]').attr('checked', false);
+    };
+
     // methods that should be invoked by subclasses
     that.checkboxes_update = that.update;
 
@@ -1045,6 +1065,10 @@ IPA.radio_widget = function(spec) {
         return false;
     };
 
+    that.clear = function() {
+        that.input.attr('checked', false);
+    };
+
     // methods that should be invoked by subclasses
     that.radio_create = that.create;
     that.radio_save = that.save;
@@ -1117,6 +1141,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;
@@ -1179,6 +1207,10 @@ IPA.textarea_widget = function (spec) {
         that.input.val(value);
     };
 
+    that.clear = function() {
+        that.input.val('');
+    };
+
     return that;
 };
 
@@ -1652,6 +1684,12 @@ IPA.table_widget = function (spec) {
         }
     };
 
+    that.clear = function() {
+        that.empty();
+        that.summary.text('');
+    };
+
+    //column initialization
     if (spec.columns) {
         for (var i=0; i<spec.columns; i++) {
             that.create_column(spec.columns[i]);
@@ -1906,6 +1944,11 @@ IPA.combobox_widget = function(spec) {
         that.list.empty();
     };
 
+    that.clear = function() {
+        that.input.val('');
+        that.remove_options();
+    };
+
     return that;
 };
 
@@ -2021,6 +2064,11 @@ IPA.entity_link_widget = function(spec) {
         }).execute();
     };
 
+    that.clear = function() {
+        that.nonlink.text('');
+        that.link.text('');
+    };
+
 
     return that;
 };
-- 
1.7.6.4

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

Reply via email to