mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #3922: Fix resize dialog, move code to capacity-inputs
The value were not filled correctly because a .change is needed after the .val call
This commit is contained in:
parent
9568051d38
commit
5c2d9ab59e
@ -6,6 +6,7 @@ define(function(require) {
|
||||
require('foundation.slider');
|
||||
var Locale = require('utils/locale');
|
||||
var Tips = require('utils/tips');
|
||||
var WizardFields = require('utils/wizard-fields');
|
||||
|
||||
/*
|
||||
TEMPLATES
|
||||
@ -19,7 +20,10 @@ define(function(require) {
|
||||
|
||||
return {
|
||||
'html': _html,
|
||||
'setup': _setup
|
||||
'setup': _setup,
|
||||
'fill': _fill,
|
||||
'retrieve': _retrieve,
|
||||
'retrieveResize': _retrieveResize
|
||||
};
|
||||
|
||||
/*
|
||||
@ -165,4 +169,56 @@ define(function(require) {
|
||||
|
||||
vcpu_slider.foundation('slider', 'set_value', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the capacity inputs
|
||||
* @param {Object} context JQuery selector
|
||||
* @param {Object} template VM or VMTemplate object
|
||||
*/
|
||||
function _fill(context, element) {
|
||||
var fields = $('[wizard_field]', context);
|
||||
|
||||
fields.each(function() {
|
||||
var field_name = $(this).attr('wizard_field');
|
||||
$(this).data("original_value", element.TEMPLATE[field_name]);
|
||||
});
|
||||
|
||||
WizardFields.fill(context, element.TEMPLATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the input values
|
||||
* @param {Object} context JQuery selector
|
||||
* @return {Object} If the input is not empty, returns:
|
||||
* - CPU
|
||||
* - MEMORY
|
||||
* - VCPU
|
||||
*/
|
||||
function _retrieve(context) {
|
||||
return WizardFields.retrieve(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the input values, but only if the value has changed from the
|
||||
* original set in fill()
|
||||
* @param {Object} context JQuery selector
|
||||
* @return {Object} If the input has changed, returns:
|
||||
* - CPU
|
||||
* - MEMORY
|
||||
* - VCPU
|
||||
*/
|
||||
function _retrieveResize(context) {
|
||||
var templateJSON = WizardFields.retrieve(context);
|
||||
|
||||
var fields = $('[wizard_field]', context);
|
||||
|
||||
fields.each(function() {
|
||||
var field_name = $(this).attr('wizard_field');
|
||||
if (templateJSON[field_name] == $(this).data("original_value")){
|
||||
delete templateJSON[field_name];
|
||||
}
|
||||
});
|
||||
|
||||
return templateJSON;
|
||||
}
|
||||
});
|
||||
|
@ -56,19 +56,7 @@ define(function(require) {
|
||||
Tips.setup(context);
|
||||
|
||||
$('#' + DIALOG_ID + 'Form', context).submit(function() {
|
||||
var templateJSON = WizardFields.retrieve(context);
|
||||
|
||||
if (templateJSON["CPU"] == that.element.TEMPLATE.CPU) {
|
||||
delete templateJSON["CPU"];
|
||||
};
|
||||
|
||||
if (templateJSON["MEMORY"] == that.element.TEMPLATE.MEMORY) {
|
||||
delete templateJSON["MEMORY"];
|
||||
};
|
||||
|
||||
if (templateJSON["VCPU"] == that.element.TEMPLATE.VCPU) {
|
||||
delete templateJSON["VCPU"];
|
||||
};
|
||||
var templateJSON = CapacityInputs.retrieveResize(context);
|
||||
|
||||
var enforce = $("#enforce", this).is(":checked");
|
||||
|
||||
@ -90,11 +78,7 @@ define(function(require) {
|
||||
function _onShow(context) {
|
||||
var that = this;
|
||||
$('#vm_id', context).text(that.element.ID);
|
||||
$('#CPU', context).val(that.element.TEMPLATE.CPU);
|
||||
$('#MEMORY_TMP', context).val(that.element.TEMPLATE.MEMORY);
|
||||
if (that.element.VCPU) {
|
||||
$('#VCPU', context).val(that.element.TEMPLATE.VCPU);
|
||||
}
|
||||
CapacityInputs.fill(context, that.element);
|
||||
|
||||
context.foundation('slider', 'reflow');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user