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

Aline Manera alinefm at linux.vnet.ibm.com
Fri Sep 19 02:11:22 UTC 2014


On 09/16/2014 10:38 PM, Daniel Henrique Barboza wrote:
> 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();
> +

We need to do it a little bit different.
With this patch, if a pool has no free volume (that can be used to be 
attached to a VM) an empty combo box will be displayed.
We should disable the storage pools without free volumes or show a 
disable the volume combo box and add a message to it: "All volumes 
already in use"



>               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);




More information about the Kimchi-devel mailing list