summaryrefslogtreecommitdiffstats
path: root/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
diff options
context:
space:
mode:
authormkidd <michael.kidd@est.tech>2021-03-24 12:26:31 +0000
committermkidd <michael.kidd@est.tech>2021-03-25 16:14:07 +0000
commitaabae2a75c606a8f44fd5e0b38d840bf8cd767dc (patch)
treed9a4a1f0c6addb20cde96bb5edd6c60259bda868 /gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
parente13710d3bd6c6aa1c02ccc3ee9e1ecf8b77581c0 (diff)
Fix sonarqube code smells
Making changed regarding code smells. Some variables being declared twice while in scope. renaming some modelFileName in ApexFiles.js that is being declared while there is a constant with the same name. renamed some of the for loop control variables so that sonarqube doesnt see it as an issue Made changes based on reviews Issue-ID: POLICY-3095 Change-Id: If38934247a4e4ff9c48043feb3adde5505c46993 Signed-off-by: mkidd <michael.kidd@est.tech>
Diffstat (limited to 'gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js')
-rw-r--r--gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js30
1 files changed, 12 insertions, 18 deletions
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
index 116cfa4..97e1130 100644
--- a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
+++ b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexPolicyEditForm.js
@@ -1,7 +1,7 @@
/*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,7 +129,6 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
}
apexUtils_emptyElement(parent);
- var isedit = false;
var createEditOrView = "";
if (!operation) {
@@ -138,12 +137,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
createEditOrView = operation.toUpperCase();
}
- if (createEditOrView == "CREATE") {
- isedit = true;
- } else if (createEditOrView == "EDIT" || createEditOrView == "VIEW") {
- if (createEditOrView == "EDIT") {
- isedit = true;
- }
+ if (createEditOrView == "EDIT" || createEditOrView == "VIEW") {
if (!policy) {
console.warn("Invalid value (\"" + policy + "\") passed as a value for \"policy\" for PolicyForm form.");
@@ -306,7 +300,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
var firststateoptions = new Array();
var firststateselected = null;
if (policy != null && policy.state != null) {
- for (i = 0; i < policy.state.entry.length; i++) {
+ for (var i = 0; i < policy.state.entry.length; i++) {
if (policy.state.entry[i] != null && policy.state.entry[i].key != null) {
var statename = policy.state.entry[i].key;
firststateoptions.push({
@@ -341,7 +335,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
if (policy != null && policy.firstState != null && policy.firstState != "" && policy.state != null) {
for (i = 0; i < policy.state.entry.length; i++) {
if (policy.state.entry[i] != null && policy.state.entry[i].key != null) {
- var statename = policy.state.entry[i].key;
+ statename = policy.state.entry[i].key;
var state = policy.state.entry[i].value;
if (statename != null && statename == policy.firstState) {
triggerevent = {
@@ -438,7 +432,7 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
if (policy && policy.state) {
var states = policy.state.entry;
for ( var s in states) {
- var state = states[s];
+ state = states[s];
if (state.key == policy.firstState) {
states.splice(s, 1);
states.unshift(state);
@@ -447,8 +441,8 @@ function editPolicyForm_activate(parent, operation, policy, tasks, events, conte
}
for (i = 0; i < policy.state.entry.length; i++) {
var stateEntry = policy.state.entry[i];
- var statename = stateEntry.key;
- var state = stateEntry.value;
+ statename = stateEntry.key;
+ state = stateEntry.value;
var stateLI = editPolicyForm_addState(statename, state, createEditOrView, policy, tasks, events,
contextAlbums, contextItemSchemas);
statesUL.appendChild(stateLI);
@@ -565,7 +559,7 @@ function editPolicyForm_addNewState(statesUL, createEditOrView, policy, tasks, e
document.getElementById("editEventFormNewStateInput").value = "";
}
if (policy && policy.state) {
- for (i = 0; i < policy.state.entry.length; i++) {
+ for (var i = 0; i < policy.state.entry.length; i++) {
if (statename.toUpperCase() == policy.state.entry[i].key.toUpperCase()) {
alert("Policy " + policy.policyKey.name + ":" + policy.policyKey.version
+ " already contains a state called \"" + statename + "\".");
@@ -625,14 +619,14 @@ function editPolicyForm_updateTriggerEventOptions(events) {
}
}
} else {
- var triggerSelectDiv = document.getElementById("editEventFormSelectTrigger_dropdownList");
+ triggerSelectDiv = document.getElementById("editEventFormSelectTrigger_dropdownList");
triggerSelectDiv.innerHTML = "No Event Selected";
var periodicEventsCheckbox = $("#periodicEventsCheckbox");
if (periodicEventsCheckbox.is(":checked")) {
periodicEventsCheckbox.attr("checked", false);
}
if (createEditOrView == "CREATE") {
- var periodicCheckbox = document.getElementById("periodicEventsCheckbox");
+ periodicCheckbox = document.getElementById("periodicEventsCheckbox");
if (!periodicCheckbox.hasAttribute("disabled")) {
periodicCheckbox.disabled = true;
}
@@ -641,7 +635,7 @@ function editPolicyForm_updateTriggerEventOptions(events) {
if (stateevent) {
triggerSelectDiv.innerHTML = stateevent.displaytext;
if (stateevent.displaytext.indexOf("PeriodicEvent") == -1) {
- var periodicEventsCheckbox = $("#periodicEventsCheckbox");
+ periodicEventsCheckbox = $("#periodicEventsCheckbox");
if (periodicEventsCheckbox.is(":checked")) {
periodicEventsCheckbox.attr("checked", false);
}
@@ -741,7 +735,7 @@ function editPolicyForm_submitPressed() {
});
} else if (createEditOrView == "EDIT") {
var firstStatePeriodic = $("#periodicEventsCheckbox").is(":checked")
- var requestURL = window.restRootURL + "/Policy/Update?firstStatePeriodic=" + firstStatePeriodic;
+ requestURL = window.restRootURL + "/Policy/Update?firstStatePeriodic=" + firstStatePeriodic;
ajax_put(requestURL, jsonString, function(resultData) {
apexUtils_removeElement("editPolicyFormDiv");
policyTab_reset();