Skip to content

Commit

Permalink
B #5578: Fix user inputs on service form (#1593)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio Betanzos committed Nov 19, 2021
1 parent 71b92d8 commit 20e45c5
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
Expand Up @@ -289,26 +289,32 @@ define(function(require) {
});
extra_info.merge_template.custom_attrs_values = $.extend({}, optionalCustomAttrs, extra_info.merge_template.custom_attrs_values);
}
if(that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles){
if (that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles) {
var charters = "";
var scheduleActionsList = ScheduleActions.retrieve(context, true)

$.each(scheduleActionsList, function(_,sched_action){
charters += TemplateUtils.templateToString(sched_action);
});

$.each(that.service_template_json.DOCUMENT.TEMPLATE.BODY.roles, function(index, role){
var temp_role = {};
$.extend( temp_role, role);
vm_template_contents = TemplateUtils.stringToTemplate(role.vm_template_contents);
var div_id = "user_input_role_"+index;
var tmp_json = {};
$.extend( tmp_json, WizardFields.retrieve($("#"+div_id, context)) );
$.each(tmp_json, function(key, value){
if (Array.isArray(value)){
delete vm_template_contents[key];
vm_template_contents[key] = value.join(",");
var temp_role = $.extend({}, role);
var temp_inputs = $.extend({}, WizardFields.retrieve($("#user_input_role_"+index, context)));
var vm_template_contents = TemplateUtils.stringToTemplate(role.vm_template_contents);

$.each(temp_inputs, function(inputName, inputValue) {
if (Array.isArray(inputValue)) {
delete temp_inputs[inputName];
temp_inputs[inputName] = inputValue.join(",");
}

// removes duplicated inputs in context
delete vm_template_contents[inputName];
});

temp_role.user_inputs_values = temp_inputs;
temp_role.vm_template_contents = TemplateUtils.templateToString(vm_template_contents);

var stringCustomValues = TemplateUtils.templateToString(customAttrsValues);
if (stringCustomValues) {
(temp_role.vm_template_contents)
Expand Down
24 changes: 17 additions & 7 deletions src/sunstone/public/app/tabs/provision-tab.js
Expand Up @@ -1572,20 +1572,30 @@ define(function(require) {
var extra_info = ServiceUtils.getExtraInfo(context, Config.isFeatureEnabled("show_vnet_instantiate_flow"));

$(".provision_create_flow_role", context).each(function(){
var user_inputs_values = WizardFields.retrieve($(".provision_custom_attributes_selector", $(this)));

var role_template = $(this).data("opennebula");

var cardinality = WizardFields.retrieve( $(".provision_cardinality_selector", $(this)) )["cardinality"];
var temp_inputs = WizardFields.retrieve($(".provision_custom_attributes_selector", $(this)));
var vm_template_contents = TemplateUtils.stringToTemplate(role_template.vm_template_contents);

$.each(temp_inputs, function(inputName, inputValue) {
if (Array.isArray(inputValue)) {
delete temp_inputs[inputName];
temp_inputs[inputName] = inputValue.join(",");
}

// removes duplicated inputs in context
delete vm_template_contents[inputName];
});

extra_info.merge_template.roles.push($.extend(role_template, {
"cardinality": cardinality,
"user_inputs_values": user_inputs_values
cardinality: cardinality,
user_inputs_values: temp_inputs,
vm_template_contents: TemplateUtils.templateToString(vm_template_contents),
}));
});

if (flow_name){
extra_info["merge_template"]["name"] = flow_name;
if (flow_name) {
extra_info.merge_template.name = flow_name;
}

Sunstone.runAction("Provision.Flow.instantiate", template_id, extra_info);
Expand Down

0 comments on commit 20e45c5

Please sign in to comment.