aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorxg353y <xg353y@intl.att.com>2019-05-14 13:17:54 +0200
committerxg353y <xg353y@intl.att.com>2019-05-14 15:11:35 +0200
commita2cbc6a4ab4bd16c1601a7e95a48f0a171e50b26 (patch)
tree87bf0145f698fd93dc64d1b79cc9a86d74c4f985 /src/main
parent566e9e4b12042992d3b2be895477dc6e25e16922 (diff)
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 <xg353y@intl.att.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js45
1 files changed, 26 insertions, 19 deletions
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($('<option></option>').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($('<option></option>').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();