From a2cbc6a4ab4bd16c1601a7e95a48f0a171e50b26 Mon Sep 17 00:00:00 2001 From: xg353y Date: Tue, 14 May 2019 13:17:54 +0200 Subject: Fix targetResourceId issue Initialize targertResourceId options, before loading values from DB, otherwise the value shown in the UI will be blank. Issue-ID: CLAMP-382 Change-Id: Ie3fecab521272c5f5373161ed8070f9370fc219d Signed-off-by: xg353y --- .../designer/scripts/OperationalPolicyCtrl.js | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'src/main/resources') diff --git a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js index f5a93cb90..f474cf413 100644 --- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js +++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js @@ -190,11 +190,15 @@ app $("#formId" + formNum + " .policyProperties").find("#" + opPolicyPropValue.id).val( allPolicies['operational_policy']['policies'][opPolicyElemIndex][opPolicyPropValue.id]); }); + + // Initial TargetResourceId options + initTargetResourceIdOptions(allPolicies['operational_policy']['policies'][opPolicyElemIndex]['target']['type'], formNum); $.each($('.policyTarget').find('.form-control'), function(opPolicyTargetPropIndex, opPolicyTargetPropValue) { $("#formId" + formNum + " .policyTarget").find("#" + opPolicyTargetPropValue.id).val( allPolicies['operational_policy']['policies'][opPolicyElemIndex]['target'][opPolicyTargetPropValue.id]); }); + // update the current tab label $("#go_properties_tab" + formNum).text( allPolicies['operational_policy']['policies'][opPolicyElemIndex]['id']); @@ -216,30 +220,20 @@ app }); }); } - $scope.initTargetResourceId = function(event) { - var formNum = $(event.target).closest('.formId').attr('id').substring(6); - - var type = $(event.target).val(); + function initTargetResourceIdOptions (targetType, formNum) { var recipe = $("#formId" + formNum + "#recipe").val(); - $("#formId" + formNum + " #modelName").val(""); - $("#formId" + formNum + " #modelInvariantId").val(""); - $("#formId" + formNum + " #modelVersionId").val(""); - $("#formId" + formNum + " #modelVersion").val(""); - $("#formId" + formNum + " #modelCustomizationId").val(""); $("#formId" + formNum + " #resourceId").empty(); $("#formId" + formNum + " #resourceId").append($('').val("").html("-- choose an option --")); - if (type == "VM" || type == "" || type == "VNF") { - $("#formId" + formNum + " #metadata *").prop('disabled', true); - } + var resourceVnf = getResourceDetailsVfProperty(); - if (type == "VNF" && (null !== resourceVnf || undefined !== resourceVnf)) { + if (targetType == "VNF" && (null !== resourceVnf || undefined !== resourceVnf)) { for ( var prop in resourceVnf) { var name = resourceVnf[prop]["name"]; $("#formId" + formNum + " #resourceId").append($('').val(name).html(name)); } } var resourceVFModule = getResourceDetailsVfModuleProperty(); - if (type == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule)) { + if (targetType == "VFModule" && (null !== resourceVFModule || undefined !== resourceVFModule)) { if (recipe == 'VF Module Create' || recipe == 'VF Module Delete') { for ( var prop in resourceVFModule) { if (resourceVFModule[prop]["isBase"] == false) { @@ -253,13 +247,26 @@ app } } } + + function initTargetModelAttributes (formNum) { + $("#formId" + formNum + " #modelName").val(""); + $("#formId" + formNum + " #modelInvariantId").val(""); + $("#formId" + formNum + " #modelVersionId").val(""); + $("#formId" + formNum + " #modelVersion").val(""); + $("#formId" + formNum + " #modelCustomizationId").val(""); + } + + $scope.initTargetResourceId = function(event) { + var formNum = $(event.target).closest('.formId').attr('id').substring(6); + initTargetModelAttributes(formNum); + var type = $(event.target).val(); + initTargetResourceIdOptions(type, formNum); + } + $scope.changeTargetResourceId = function(event) { var formNum = $(event.target).closest('.formId').attr('id').substring(6); - $("#formId" + formNum +" #modelName").val(""); - $("#formId" + formNum +" #modelInvariantId").val(""); - $("#formId" + formNum +" #modelVersionId").val(""); - $("#formId" + formNum +" #modelVersion").val(""); - $("#formId" + formNum +" #modelCustomizationId").val(""); + initTargetModelAttributes(formNum); + var resourceVFModule = getResourceDetailsVfModuleProperty(); var type = $("#formId" + formNum +" #type").val(); var recipe = $("#formId" + formNum +" #recipe").val(); -- cgit 1.2.3-korg