summaryrefslogtreecommitdiffstats
path: root/src/main/resources
diff options
context:
space:
mode:
authorSébastien Determe <sebastien.determe@intl.att.com>2019-06-05 09:55:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-06-05 09:55:31 +0000
commit70e4a3fc5be81abaae4d1b9bd17a2e8134e5862e (patch)
tree8b965cfa0b80c96524b0b17d5540d4bf31b60253 /src/main/resources
parent4aa3b770b9bb0d0cda545eb9bcd7aa70f478e8fb (diff)
parent3f4cbda9ef295a42fe2fe16b7bd7995fac8e174e (diff)
Merge "Validate ids"
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html7
-rw-r--r--src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js27
2 files changed, 22 insertions, 12 deletions
diff --git a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
index db127f7d..7b13615a 100644
--- a/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
+++ b/src/main/resources/META-INF/resources/designer/partials/portfolios/operational_policy_window.html
@@ -165,12 +165,12 @@ label {
<form class="policyProperties" class="form-horizontal"
style="border: 2px dotted gray;"
title="Operational Policy Properties">
-
<div class="form-group clearfix">
<label class="col-sm-4 control-label" for="id">ID</label>
<div class="col-sm-8">
- <input type="text" class="form-control" name="id" id="id"
+ <input type="text" class="form-control" name="id" id="id" ng-model="duplicated" ng-init="duplicated = false"
ng-keyup="updateTabLabel($event)" />
+ <span >ID must be unique</span>
</div>
</div>
<div class="form-group clearfix">
@@ -247,6 +247,7 @@ label {
ng-options="policy for policy in policy_ids track by policy">
<option value="">-- choose an option --</option>
</select>
+
</div>
</div>
<div class="form-group clearfix">
@@ -481,7 +482,7 @@ label {
</div>
<div attribute-test="policywindowpropertiesf" class="modal-footer">
- <button id="savePropsBtn" class="btn btn-primary">Close</button>
+ <button id="savePropsBtn" class="btn btn-primary" ng-disabled="duplicated">Close</button>
<button ng-click="close(true)" id="close_button"
class="btn btn-primary">Cancel</button>
</div>
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 0f9b62ff..806cfea9 100644
--- a/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
+++ b/src/main/resources/META-INF/resources/designer/scripts/OperationalPolicyCtrl.js
@@ -39,6 +39,8 @@ app
$scope.number = 0;
$scope.clname = "";
$scope.guard_ids = [];
+ $scope.duplicated = false;
+
function getAllFormId() {
return Array.from(document.getElementsByClassName("formId"));
@@ -400,15 +402,22 @@ app
$($("#formId" + formNum + " #actor")[1]).val($(event.target).val());
}
// When we change the name of a policy
- $scope.updateTabLabel = function(event) {
-
- // update policy id structure
- var formNum = $(event.target).closest('.formId').attr('id').substring(6);
- $scope.policy_ids.splice($scope.policy_ids.indexOf($("#formId" + formNum + " #id").val()), 1);
- $scope.policy_ids.push($(event.target).val());
- // Update the tab now
- $("#go_properties_tab" + formNum).text($(event.target).val());
- }
+ $scope.updateTabLabel = function (event) {
+
+ // update policy id structure
+ var formNum = $(event.target).closest('.formId').attr('id').substring(6);
+ var policyId = $(event.target).val();
+ if ($scope.policy_ids.includes(policyId)) {
+ console.log("Duplicated ID, cannot proceed");
+ $scope.duplicated = true;
+ } else {
+ $scope.duplicated = false;
+ $scope.policy_ids.splice($scope.policy_ids.indexOf($("#formId" + formNum + " #id").val()), 1);
+ $scope.policy_ids.push($(event.target).val());
+ // Update the tab now
+ $("#go_properties_tab" + formNum).text($(event.target).val());
+ }
+ };
$scope.close = function() {
console.log("close");