[Kimchi-devel] [PATCH] guest_storage_add.main.js: fixing Storage Volume select

Daniel Henrique Barboza danielhb at linux.vnet.ibm.com
Wed Sep 17 01:38:42 UTC 2014


The select menu of Storage Volume didn't behave properly in the
case where a storage pool with no eligible volumes is selected
after a storage pool with valid volumes. The previous values
remained in the select menu.

Signed-off-by: Daniel Henrique Barboza <danielhb at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.guest_storage_add.main.js | 7 ++++++-
 ui/js/widgets/select-menu.js               | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ui/js/src/kimchi.guest_storage_add.main.js b/ui/js/src/kimchi.guest_storage_add.main.js
index a8c5acb..59b82e8 100644
--- a/ui/js/src/kimchi.guest_storage_add.main.js
+++ b/ui/js/src/kimchi.guest_storage_add.main.js
@@ -75,7 +75,12 @@ kimchi.guest_storage_add_main = function() {
     poolTextbox.change(function() {
         var options = [];
         kimchi.listStorageVolumes($(this).val(), function(result) {
+            if(typeof $('#guest-disk').selectMenu() !== "undefined") {
+                $('#guest-disk').selectMenu("destroy");
+                $(volTextbox).val("").change();
+            }
             $('#guest-disk').selectMenu();
+
             if (result.length) {
                 $.each(result, function(index, value) {
                     // Only unused volume can be attached
@@ -89,9 +94,9 @@ kimchi.guest_storage_add_main = function() {
                 if (options.length) {
                     $(volTextbox).val(options[0].value);
                     $(volTextbox).change();
+                    $('#guest-disk').selectMenu("setData", options);
                 }
             }
-            $('#guest-disk').selectMenu("setData", options);
         });
     });
 
diff --git a/ui/js/widgets/select-menu.js b/ui/js/widgets/select-menu.js
index ad53200..2b681b9 100644
--- a/ui/js/widgets/select-menu.js
+++ b/ui/js/widgets/select-menu.js
@@ -75,6 +75,7 @@
             this.selectDiv.removeClass('btn dropdown popable');
             this.target.removeClass('input');
             this.label.removeClass('input');
+            this.label.text('');
             this.listControl.removeClass('select-list');
             this.listControl.parent().removeClass('popover');
             $.Widget.prototype.destroy.call(this);
-- 
1.8.3.1




More information about the Kimchi-devel mailing list