On 09/23/2014 09:55 PM, Aline Manera wrote:
Almost there =)
See below:
On 09/23/2014 06:23 AM, Wen Wang wrote:
> From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
>
> V2 -> V3:
> Make the value of "Disk(GB)" inputbox consistent with user input. If
> choosing iSCSI or SCSI, inputbox is disabled and value of "Disk(GB)" is
> refreshed with the system. If changing back, the value stays the same
> with user last input.
>
> V1 -> V2:
> Considering iSCSI and SCSI situation that we need to have the input box
> disabled when choosing iSCSI and SCSI for storage pool and enable when
> choosing others.
>
> This patch fix the bug that value of "Disk(GB)" input box is changing
> with the item of "Storage Pool" in "Templates" -->
"Actions" --> "Edit"
> -->"Edit Templates" dialogue. This might be comfusing to user when
> changing the "Storage Pool", "Disk(GB)" is changed with it
without even
> notice. This might confuse the users and is not necessary. Solved by
> removing the change.
>
> Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
> ---
> ui/js/src/kimchi.template_edit_main.js | 12 +++++-------
> 1 files changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/ui/js/src/kimchi.template_edit_main.js
> b/ui/js/src/kimchi.template_edit_main.js
> index cb43091..d2bbe23 100644
> --- a/ui/js/src/kimchi.template_edit_main.js
> +++ b/ui/js/src/kimchi.template_edit_main.js
> @@ -40,6 +40,7 @@ kimchi.template_edit_main = function() {
> }
> var disks = template.disks;
> $('input[name="disks"]').val(disks[0].size);
> + kimchi.templateDiskSize = $('input[name="disks"]').val();
I suggest to do not user kimchi.<variable> the kimchi variable is used
when the value needs to be used by the whole application.
In this case, templateDiskSize is only used there in
kimchi.template_edit_main() function so I suggest to make a variable
local to this function.
ACK
> if (disks[0].volume) {
> var spool_value = $('#form-template-edit
> [name="storagepool"]').val();
> $('input[name="storagepool"]',
> templateEditForm).val(spool_value + '/' + disks[0].volume);
> @@ -128,19 +129,16 @@ kimchi.template_edit_main = function() {
> $('input[name="disks"]',
> templateEditForm).attr('disabled','disabled');
> return false;
> }, function (err) {
> + $('input[name="disks"]',
> templateEditForm).val(kimchi.templateDiskSize);
> kimchi.message.error(err.responseJSON.reason);
> });
> } else {
> - if (origPool == storagepool) {
> - // Previous disk size value
> - $('input[name="disks"]',
> templateEditForm).val(origDisks[0].size);
> - } else {
> - // Default disk size value
> - $('input[name="disks"]',
templateEditForm).val(10);
> - }
> $('input[name="disks"]',
> templateEditForm).removeAttr('disabled');
You also need to set the right value in the else statement.
In 'else' the pool is not iSCSI or SCSI so you need to set the input
box to the previous value on input box
$('input[name="disks"]',
templateEditForm).val(kimchi.templateDiskSize);
Good catch, I will have it changed
in V4
> }
> });
> + $('input[name="disks"]', templateEditForm).keyup(function() {
> + kimchi.templateDiskSize = $('input[name="disks"]',
> templateEditForm).val();
> + });
>
> $('#tmpl-edit-button-save').on('click', function() {
> var editableFields = [ 'name', 'cpus', 'memory',
> 'storagepool', 'disks', 'graphics'];
--
=======================================================
Best Regards
Wang Wen