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

Currently adding or deleting sudo options will refresh the entire page. It's not a problem but the code could be optimized to refresh only the sudo options table

--
Petr Vobornik
From 05bfd5e1fa5126ee581273d1adfcf995da4d4dcd Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Fri, 26 Aug 2011 18:36:54 +0200
Subject: [PATCH] Modifying sudo options refreshes the whole page

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

Currently adding or deleting sudo options will refresh the entire page. It's not a problem but the code could be optimized to refresh only the sudo options table
---
 install/ui/sudo.js   |   36 ++++++++++++++++++++++++++++--------
 install/ui/widget.js |   10 +++++-----
 2 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/install/ui/sudo.js b/install/ui/sudo.js
index 8d33550c0d7c25bc8f882084cb8a04662a54ebd7..4b0a2e12350dda47c6ee918a595609e57ebcd7bb 100644
--- a/install/ui/sudo.js
+++ b/install/ui/sudo.js
@@ -574,12 +574,12 @@ IPA.sudo.options_section = function(spec) {
                 options: {
                     ipasudoopt: value
                 },
-                on_success: function() {
-                    that.facet.refresh();
+                on_success: function(data) {
+                    that.load(data.result.result);
                     dialog.close();
                 },
-                on_error: function() {
-                    that.facet.refresh();
+                on_error: function(data) {
+                    that.update();
                     dialog.close();
                 }
             });
@@ -618,12 +618,19 @@ IPA.sudo.options_section = function(spec) {
         dialog.execute = function() {
 
             var batch = IPA.batch_command({
-                on_success: function() {
-                    that.facet.refresh();
+                on_success: function(data) {
+                    //last successful result of batch results contains valid data
+                    var result = data.result.results[data.result.results.length - 1].result;
+                    if(result) {
+                        that.load(result);
+                    } else {
+                        that.update();
+                    }
+
                     dialog.close();
                 },
-                on_error: function() {
-                    that.facet.refresh();
+                on_error: function(data) {
+                    that.update();
                     dialog.close();
                 }
             });
@@ -646,6 +653,19 @@ IPA.sudo.options_section = function(spec) {
         dialog.open(that.container);
     };
 
+    that.update = function() {
+        var command = IPA.command({
+            entity: that.facet.entity.name,
+            method: 'show',
+            args: that.facet.get_primary_key(true),
+            on_success: function(data) {
+                that.load(data.result.result);
+            }
+        });
+
+        command.execute();
+    };
+
     /*initialization*/
     setup_table();
 
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 62af6c16d10aac65e51191f2da955b8f1ebb3bed..83cb4dcb23c6a296739bf7e8604ef3f7a6a5b3e7 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -1471,11 +1471,11 @@ IPA.table_widget = function (spec) {
         that.empty();
 
         that.values = result[that.name];
-        if (!that.values) return;
-
-        for (var i=0; i<that.values.length; i++) {
-            var record = that.get_record(result, i);
-            that.add_record(record);
+        if (that.values) {
+            for (var i=0; i<that.values.length; i++) {
+                var record = that.get_record(result, i);
+                that.add_record(record);
+            }
         }
         that.unselect_all();
     };
-- 
1.7.6

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

Reply via email to