aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 db127f7d2..7b13615a1 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 0f9b62ffe..806cfea9d 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");