diff options
author | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-05 11:01:00 +0200 |
---|---|---|
committer | Wojciech Sliwka <wojciech.sliwka@nokia.com> | 2019-06-05 11:01:00 +0200 |
commit | 3f4cbda9ef295a42fe2fe16b7bd7995fac8e174e (patch) | |
tree | ea7325a2ff31a083d59f1df745a9436aa162aef7 /src/main/resources | |
parent | 18fa819e455e1314b21a5b4f5e6ef0e1b0588c9e (diff) |
Validate ids
Disable close button when policy id is duplicated
Issue-ID: CLAMP-403
Signed-off-by: Wojciech Sliwka <wojciech.sliwka@nokia.com>
Change-Id: I47dee2e27ce4f7a5e2083a541458a04da8cf7bee
Diffstat (limited to 'src/main/resources')
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"); |