diff --git a/source/src/main/webapp/js/pages/TestCaseScript.js b/source/src/main/webapp/js/pages/TestCaseScript.js index c1ae7e98fd..bef2973631 100644 --- a/source/src/main/webapp/js/pages/TestCaseScript.js +++ b/source/src/main/webapp/js/pages/TestCaseScript.js @@ -20,17 +20,19 @@ var canUpdate = false; var allDelete = false; +var loadedPropertiesNumber = -1; var Tags = []; -$.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.js")).then(function () { - $(document).ready(function () { +$.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.js")).then(function() { + $(document).ready(function() { + loadedPropertiesNumber = -1; initModalDataLib(); - $("#nav-property").on('mouseenter', 'a', function (ev) { + $("#nav-property").on('mouseenter', 'a', function(ev) { try { $(this).find("button").show(); } catch (e) { } - }).on('mouseleave', 'a', function (ev) { + }).on('mouseleave', 'a', function(ev) { try { $(this).find("button").hide(); @@ -39,14 +41,14 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j }); $('#propName').trigger("change"); - $('#propName').change(function () { + $('#propName').change(function() { openModalAppServiceFromHere(); }); - $('#createApplicationObjectButton').click(function () { + $('#createApplicationObjectButton').click(function() { openModalApplicationObject(undefined, undefined, "ADD", "testCaseScript"); }); - $(window).bind('beforeunload', function () { + $(window).bind('beforeunload', function() { if (getModif()) { return true; // Display alert Message that a modification has // been done @@ -82,18 +84,18 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j fillTestAndTestCaseSelect(".testTestCase #test", "#testCaseSelect", test, testcase, false) - $("#testCaseSelect").bind("change", function (event) { + $("#testCaseSelect").bind("change", function(event) { window.location.href = "./TestCaseScript.jsp?test=" + test + "&testcase=" + $(this).val(); }); - $(".testTestCase #test").bind("change", function (event) { + $(".testTestCase #test").bind("change", function(event) { window.location.href = "./TestCaseScript.jsp?test=" + $(this).val(); }); if (test !== null && testcase !== null) { // Edit TestCase open the TestCase Modal - $("#editTcInfo").click(function () { + $("#editTcInfo").click(function() { openModalTestCase(test, testcase, "EDIT"); - $('#editTestCaseModal').on("hidden.bs.modal", function (e) { + $('#editTestCaseModal').on("hidden.bs.modal", function(e) { $('#editTestCaseModal').unbind("hidden.bs.modal"); var t = $('#editTestCaseModal').find("#test option:selected"); var tc = $('#editTestCaseModal').find("#testCase"); @@ -118,7 +120,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j url: "ReadTestCase", data: {test: test, testCase: testcase, withStep: true, system: getSys()}, dataType: "json", - success: function (data) { + success: function(data) { // manage error if (data.messageType !== undefined && data.messageType === "KO") { @@ -132,7 +134,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j loadTestCaseInfo(data.info); json = data.stepList; sortData(json); - data.inheritedProp.sort(function (a, b) { + data.inheritedProp.sort(function(a, b) { return compareStrings(a.property, b.property); }) createStepList(json, stepList, step, data.hasPermissionsUpdate, data.hasPermissionsStepLibrary); @@ -145,7 +147,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j 'identifier': true } var context = data - initTags(configs, context).then(function (tags) { + initTags(configs, context).then(function(tags) { autocompleteAllFields(configs, context, tags); }); @@ -165,16 +167,16 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j // Building full list of country from testcase. var myCountry = []; - $.each(testcaseinfo.countryList, function (index) { + $.each(testcaseinfo.countryList, function(index) { myCountry.push(index); }); - $("#manageProp").click(function () { + $("#manageProp").click(function() { editPropertiesModalClick(test, testcase, testcaseinfo, undefined, undefined, data.hasPermissionsUpdate); }); // Button Add Property insert a new Property - $("#addProperty").click(function () { + $("#addProperty").click(function() { if (myCountry.length <= 0) { showMessageMainPage("danger", doc.getDocLabel("page_testcasescript", "warning_nocountry"), false); @@ -221,7 +223,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j $('[data-toggle="tooltip"]').tooltip(); - $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { + $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) { initModification(); }); }, @@ -230,7 +232,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j $("#propertiesModal [name='buttonSave']").click(editPropertiesModalSaveHandler); - $("#addStep").click({stepList: stepList}, function (event) { + $("#addStep").click({stepList: stepList}, function(event) { // Store the current saveScript button status and disable it var saveScriptOldStatus = $("#saveScript").attr("disabled"); $("#saveScript").attr("disabled", true); @@ -241,21 +243,21 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j // Restore the saveScript button status $("#saveScript").attr("disabled", typeof saveScriptOldStatus !== typeof undefined && saveScriptOldStatus !== false); }); - $('#addStepModal').on('hidden.bs.modal', function () { + $('#addStepModal').on('hidden.bs.modal', function() { $("#importDetail").find("[name='importInfo']").removeData("stepInfo"); $("[name='importInfo']").empty(); $("#addStepModal #description").val(""); $("#useStep").prop("checked", false); $("#importDetail").hide(); $("#importDetail div.row").remove(); - $(".sub-sub-item.selected").each(function (idx, element) { + $(".sub-sub-item.selected").each(function(idx, element) { $(element).removeClass("selected"); $(element).find("[name='idx']").remove(); }); importInfoIdx = 0; }); - $("#deleteStep").click(function () { + $("#deleteStep").click(function() { var step = $("#stepList .active").data("item"); @@ -267,15 +269,15 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j } }); - $("#addAction").click(function () { + $("#addAction").click(function() { addActionAndFocus() }); // CONTEXT SAVE MENU $("#saveScript").click(saveScript); - $("#saveScriptAs").click(function () { + $("#saveScriptAs").click(function() { openModalTestCase(test, testcase, "DUPLICATE"); - $('#editTestCaseModal').on("hidden.bs.modal", function (e) { + $('#editTestCaseModal').on("hidden.bs.modal", function(e) { $('#editTestCaseModal').unbind("hidden.bs.modal"); var t = $('#editTestCaseModal').find("#test option:selected"); var tc = $('#editTestCaseModal').find("#testCase"); @@ -285,7 +287,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j } }); }); - $("#deleteTestCase").click(function () { + $("#deleteTestCase").click(function() { removeTestCaseClick(test, testcase); }); @@ -298,7 +300,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j url: "ReadTestCaseExecution", data: {test: test, testCase: testcase, system: getSys()}, dataType: "json", - success: function (data) { + success: function(data) { if (!jQuery.isEmptyObject(data.contentTable)) { $("#seeLastExecUniq").parent().attr("href", "./TestCaseExecution.jsp?executionId=" + data.contentTable.id); $("#seeLastExec").parent().attr("href", "./TestCaseExecutionList.jsp?test=" + test + "&testcase=" + testcase); @@ -306,7 +308,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j $("#rerunTestCase").parent().attr("href", "./RunTests.jsp?test=" + test + "&testcase=" + testcase + "&country=" + data.contentTable.country + "&environment=" + data.contentTable.env); $("#rerunFromQueue").attr("title", "Last Execution was " + data.contentTable.controlStatus + " in " + data.contentTable.env + " in " + data.contentTable.country + " on " + data.contentTable.end) if (data.contentTable.queueId > 0) { - $("#rerunFromQueue").click(function () { + $("#rerunFromQueue").click(function() { openModalTestCaseExecutionQueue(data.contentTable.queueId, "DUPLICATE"); }); } else { @@ -314,7 +316,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j } $("#rerunFromQueueandSee").attr("title", "Last Execution was " + data.contentTable.controlStatus + " in " + data.contentTable.env + " in " + data.contentTable.country + " on " + data.contentTable.end) if (data.contentTable.queueId > 0) { - $("#rerunFromQueueandSee").click(function () { + $("#rerunFromQueueandSee").click(function() { triggerTestCaseExecutionQueueandSeeFromTC(data.contentTable.queueId); }); } else { @@ -336,7 +338,7 @@ $.when($.getScript("js/global/global.js"), $.getScript("js/global/autocomplete.j var wrap = $(window); - wrap.on("scroll", function (e) { + wrap.on("scroll", function(e) { $(".affix").width($("#page-layout").width() - 3); // $(".affix-top").width($("#divPanelDefault").width()); }); @@ -454,7 +456,7 @@ function triggerTestCaseExecutionQueueandSeeFromTC(queueId) { actionState: "toQUEUED", actionSave: "save" }, - success: function (data) { + success: function(data) { if (getAlertType(data.messageType) === "success") { showMessageMainPage(getAlertType(data.messageType), data.message, false, 60000); var url = "./TestCaseExecution.jsp?executionQueueId=" + data.testCaseExecutionQueueList[0].id; @@ -478,7 +480,7 @@ function addAction(action) { } function addActionAndFocus(action) { - $.when(addAction(action)).then(function (action) { + $.when(addAction(action)).then(function(action) { listenEnterKeypressWhenFocusingOnDescription(); $($(action.html[0]).find(".description")[0]).focus(); }); @@ -552,6 +554,10 @@ function setAllSort() { function saveScript(property) { + if (!isPropertyListDisplayed()) { + return; + } + // Disable the save button to avoid double click. $("#saveScript").attr("disabled", true); @@ -584,7 +590,7 @@ function saveScript(property) { } } - var saveProp = function () { + var saveProp = function() { showLoaderInModal('#propertiesModal'); $.ajax({ url: "UpdateTestCaseWithDependencies", @@ -600,7 +606,7 @@ function saveScript(property) { stepArray: stepArr, propArr: propArr }), - success: function () { + success: function() { var stepHtml = $("#stepList li.active"); var stepData = stepHtml.data("item"); @@ -634,17 +640,17 @@ function saveScript(property) { if (propertyWithoutCountry) { - showModalConfirmation(function () { + showModalConfirmation(function() { $('#confirmationModal').modal('hide'); saveProp(); - }, function () { + }, function() { $("#saveScript").attr("disabled", false); }, doc.getDocLabel("page_global", "btn_savetableconfig"), doc.getDocLabel("page_testcasescript", "warning_no_country"), "", "", "", ""); } else if (propertyWithoutName) { - showModalConfirmation(function () { + showModalConfirmation(function() { $('#confirmationModal').modal('hide'); saveProp(); - }, function () { + }, function() { $("#saveScript").attr("disabled", false); }, doc.getDocLabel("page_global", "btn_savetableconfig"), doc.getDocLabel("page_testcasescript", "warning_one_empty_prop"), "", "", "", ""); } else { @@ -653,11 +659,27 @@ function saveScript(property) { } +function isPropertyListDisplayed() { + + var displayedPropertiesNumber = document.getElementById('propList').getElementsByTagName('li').length; + console.log("-------VERIF AVANT SAUVEGARDE----------"); + console.log("nb propriétés chargée depuis bdd : " + loadedPropertiesNumber); + console.log("nb propriétés affichées : " + displayedPropertiesNumber); + console.log("displayedPropertiesNumber < loadedPropertiesNumber ? : " + displayedPropertiesNumber < loadedPropertiesNumber); + if (loadedPropertiesNumber === -1 || displayedPropertiesNumber < loadedPropertiesNumber) { + console.log("/!\\ ERREUR ARRET SAUVERGARDE :/!\\"); + return false; + } + console.log("controle OK"); + return true; + +} + function deleteFnct(property) { var linkToProperty = null; // go though every link and look for the right one - $("#propListWrapper li a").each(function () { + $("#propListWrapper li a").each(function() { if ($(this).text() === property) linkToProperty = $(this).parent(); }); @@ -696,10 +718,10 @@ function drawPropertyList(property, index, isSecondary) { // block;color: #636e72;">secondary } - deleteBtn.click(function (ev) { + deleteBtn.click(function(ev) { if (allDelete !== true) { - $("div.list-group-item").each(function () { + $("div.list-group-item").each(function() { if ($(this).find("#propName").val() === property) { if (!$(this).hasClass("list-group-item-danger")) { $(this).find("button.add-btn.btn-danger").trigger("click"); @@ -707,7 +729,7 @@ function drawPropertyList(property, index, isSecondary) { } }) } else { - $("div.list-group-item").each(function () { + $("div.list-group-item").each(function() { if ($(this).find("#propName").val() === property) { $(this).find("button.add-btn.btn-danger").trigger("click"); } @@ -786,17 +808,17 @@ function drawProperty(property, testcaseinfo, canUpdate, index) { var retryPeriod = $("
").append($("").text(doc.getDocLabel("testcasecountryproperties", "RetryPeriod"))).append(retryPeriodInput); var rank = $("").append($("").text(doc.getDocLabel("testcasecountryproperties", "Rank"))).append(rankInput); - var selectAllBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-check")).click(function () { + var selectAllBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-check")).click(function() { country.find("input[type='checkbox']").prop('checked', true).trigger("change"); }); selectAllBtn.attr("disabled", !canUpdate); - var selectNoneBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-unchecked")).click(function () { + var selectNoneBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-unchecked")).click(function() { country.find("input[type='checkbox']").prop('checked', false).trigger("change"); }); selectNoneBtn.attr("disabled", !canUpdate); var btnRow = $("").css("margin-top", "5px").css("margin-bottom", "5px").append(selectAllBtn).append(selectNoneBtn); - deleteBtn.click(function () { + deleteBtn.click(function() { // trigger when any deleteBtn is clicked var stopAllDelete = false; var stopNothing = false; @@ -816,7 +838,7 @@ function drawProperty(property, testcaseinfo, canUpdate, index) { } } - $(table).find("div.list-group-item").each(function () { + $(table).find("div.list-group-item").each(function() { if ($(this).find("#propName").val() === property.property) { if ($(this).hasClass("list-group-item-danger")) { if (stopAllDelete !== true) { @@ -838,7 +860,7 @@ function drawProperty(property, testcaseinfo, canUpdate, index) { } }) - $("#propListWrapper li a").each(function () { + $("#propListWrapper li a").each(function() { if ($(this).text() === property.property) linkToProperty = $(this).parent(); }); @@ -865,7 +887,7 @@ function drawProperty(property, testcaseinfo, canUpdate, index) { } }); - moreBtn.click(function () { + moreBtn.click(function() { if ($(this).find("span").hasClass("glyphicon-chevron-down")) { $(this).find("span").removeClass("glyphicon-chevron-down"); $(this).find("span").addClass("glyphicon-chevron-up"); @@ -876,56 +898,56 @@ function drawProperty(property, testcaseinfo, canUpdate, index) { $(this).parent().parent().find(".row:not([name='masterProp'])").toggle(); }); - propertyInput.change(function () { + propertyInput.change(function() { property.property = $(this).val(); }); - descriptionInput.change(function () { + descriptionInput.change(function() { property.description = $(this).val(); }); - selectType.change(function () { + selectType.change(function() { property.type = $(this).val(); setPlaceholderProperty($(this).parents(".property"), property); }); - selectDB.change(function () { + selectDB.change(function() { property.database = $(this).val(); }); - valueInput.change(function () { + valueInput.change(function() { property.value1 = $(this).val(); }); - value2Input.change(function () { + value2Input.change(function() { property.value2 = $(this).val(); }); - lengthInput.change(function () { + lengthInput.change(function() { property.length = $(this).val(); }); - rowLimitInput.change(function () { + rowLimitInput.change(function() { property.rowLimit = $(this).val(); }); - cacheExpireInput.change(function () { + cacheExpireInput.change(function() { property.cacheExpire = parseInt($(this).val()); }); - selectNature.change(function () { + selectNature.change(function() { property.nature = $(this).val(); }); - retryNbInput.change(function () { + retryNbInput.change(function() { property.retryNb = $(this).val(); }); - retryPeriodInput.change(function () { + retryPeriodInput.change(function() { property.retryPeriod = $(this).val(); }); - rankInput.change(function () { + rankInput.change(function() { property.rank = $(this).val(); }); @@ -1022,15 +1044,15 @@ function drawInheritedProperty(propList) { var rank = $("").append($("").text(doc.getDocLabel("testcasecountryproperties", "Rank"))).append(rankInput); - var selectAllBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-check")).click(function () { + var selectAllBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-check")).click(function() { country.find("input[type='checkbox']").prop('checked', true); }); - var selectNoneBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-unchecked")).click(function () { + var selectNoneBtn = $("").addClass("btn btn-default btn-sm").append($("").addClass("glyphicon glyphicon-unchecked")).click(function() { country.find("input[type='checkbox']").prop('checked', false); }); var btnRow = $("").css("margin-top", "5px").css("margin-bottom", "5px").append(selectAllBtn).append(selectNoneBtn); - moreBtn.click(function () { + moreBtn.click(function() { if ($(this).find("span").hasClass("glyphicon-chevron-down")) { $(this).find("span").removeClass("glyphicon-chevron-down"); $(this).find("span").addClass("glyphicon-chevron-up"); @@ -1083,7 +1105,7 @@ function drawInheritedProperty(propList) { function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, canUpdate) { - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { var array = []; var secondaryPropertiesArray = []; @@ -1094,9 +1116,9 @@ function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, ca url: "GetPropertiesForTestCase", data: {test: test, testcase: testcase}, async: true, - success: function (data) { + success: function(data) { - data.sort(function (a, b) { + data.sort(function(a, b) { return compareStrings(a.property, b.property); }) @@ -1121,6 +1143,7 @@ function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, ca propertyList.push(property.property); } } + loadedPropertiesNumber = propertyList.length; localStorage.setItem("properties", JSON.stringify(propertyList)); localStorage.setItem("secondaryProperties", JSON.stringify(propertyList)); sortProperties("#propTable"); @@ -1128,10 +1151,10 @@ function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, ca var scope = undefined; if (propertyToFocus != undefined && propertyToFocus != null) { - $("#propTable #propName").each(function (i) { + $("#propTable #propName").each(function(i) { if ($(this).val() == propertyToFocus) { scope = this; - $("#propertiesModal").on("shown.bs.modal", function (e) { + $("#propertiesModal").on("shown.bs.modal", function(e) { $(scope).focus(); $(scope).click(); }); @@ -1150,7 +1173,7 @@ function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, ca drawPropertyList(secondaryPropertyListUnique[index], index, true); } - array.sort(function (a, b) { + array.sort(function(a, b) { return compareStrings(a, b); }) @@ -1166,7 +1189,7 @@ function loadPropertiesAndDraw(test, testcase, testcaseinfo, propertyToFocus, ca function sortProperties(identifier) { var container = $(identifier); var list = container.children(".property"); - list.sort(function (a, b) { + list.sort(function(a, b) { var aProp = $(a).find("#masterProp").data("property").property.toLowerCase(), bProp = $(b).find("#masterProp").data("property").property.toLowerCase(); @@ -1187,7 +1210,7 @@ function sortProperties(identifier) { function sortSecondaryProperties(identifier) { var container = $(identifier); var list = container.children(".secondaryProperty"); - list.sort(function (a, b) { + list.sort(function(a, b) { var aProp = $(a).find("#masterProp").data("property").property.toLowerCase(), bProp = $(b).find("#masterProp").data("property").property.toLowerCase(); @@ -1208,7 +1231,7 @@ function getTestCaseCountry(countryList, countryToCheck, isDisabled) { var cpt = 0; var div = $("").addClass("checkbox"); - $.each(countryList, function (index) { + $.each(countryList, function(index) { var country; if (typeof index === "number") { @@ -1224,7 +1247,7 @@ function getTestCaseCountry(countryList, countryToCheck, isDisabled) { if (isDisabled) { input.prop("disabled", "disabled"); } else { - input.change(function () { + input.change(function() { var country = $(this).prop("name"); var checked = $(this).prop("checked"); var index = countryToCheck.indexOf(country); @@ -1337,11 +1360,11 @@ function addStep(event) { $("#addStepModal").modal('show'); // Setting the focus on the Description of the step. - $('#addStepModal').on('shown.bs.modal', function () { + $('#addStepModal').on('shown.bs.modal', function() { $('#description').focus(); }) - $("#addStepConfirm").unbind("click").click(function (event) { + $("#addStepConfirm").unbind("click").click(function(event) { setModif(true); @@ -1357,7 +1380,7 @@ function addStep(event) { } else { // added a library step - $("[name='importInfo']").each(function (idx, importInfo) { + $("[name='importInfo']").each(function(idx, importInfo) { var step = initStep(); if ($(importInfo).data("stepInfo")) { @@ -1369,7 +1392,7 @@ function addStep(event) { url: "ReadTestCaseStep", data: {test: useStep.test, testcase: useStep.testCase, step: useStep.step}, async: false, - success: function (data) { + success: function(data) { step.actionList = data.tcsActionList; for (var index = 0; index < data.tcsActionControlList.length; index++) { @@ -1430,12 +1453,12 @@ function createStepList(data, stepList, stepIndex, canUpdate, hasPermissionsStep /** Modification Status * */ var getModif, setModif, initModification; -(function () { +(function() { var isModif = false; - getModif = function () { + getModif = function() { return isModif; }; - setModif = function (val) { + setModif = function(val) { isModif = val; if (isModif === true && $("#saveScript").hasClass("btn-default")) { $("#saveScript").removeClass("btn-default").addClass("btn-primary"); @@ -1444,8 +1467,8 @@ var getModif, setModif, initModification; } }; - initModification = function () { - $(".panel-body input, .panel-body select, .panel-body textarea").change(function () { + initModification = function() { + $(".panel-body input, .panel-body select, .panel-body textarea").change(function() { setModif(true); }) }; @@ -1464,7 +1487,7 @@ function loadLibraryStep(search) { url: "GetStepInLibrary", data: {system: getUser().defaultSystem}, async: true, - success: function (data) { + success: function(data) { var test = {}; for (var index = 0; index < data.testCaseStepList.length; index++) { @@ -1502,17 +1525,17 @@ function loadLibraryStep(search) { $('#lib').find("div").toggleClass('in'); } - $('#addStepModal > .list-group-item').unbind("click").on('click', function () { + $('#addStepModal > .list-group-item').unbind("click").on('click', function() { $('.glyphicon', this) .toggleClass('glyphicon-chevron-right') .toggleClass('glyphicon-chevron-down'); }); - $("#addStepModal #search").unbind("input").on("input", function (e) { + $("#addStepModal #search").unbind("input").on("input", function(e) { var search = $(this).val(); // Clear any previously set timer before setting a fresh one window.clearTimeout($(this).data("timeout")); - $(this).data("timeout", setTimeout(function () { + $(this).data("timeout", setTimeout(function() { loadLibraryStep(search); }, 500)); }); @@ -1523,12 +1546,12 @@ function loadLibraryStep(search) { } function loadApplicationObject(application) { - return new Promise(function (resolve, reject) { + return new Promise(function(resolve, reject) { var array = []; $.ajax({ url: "ReadApplicationObject?application=" + application, dataType: "json", - success: function (data) { + success: function(data) { for (var i = 0; i < data.contentTable.length; i++) { array.push(data.contentTable[i]); } @@ -1542,7 +1565,7 @@ function showStepUsesLibraryInConfirmationModal(object) { var doc = new Doc(); $("#confirmationModal [name='buttonConfirm']").text("OK"); $("#confirmationModal [name='buttonDismiss']").hide(); - $("#confirmationModal").on("hidden.bs.modal", function () { + $("#confirmationModal").on("hidden.bs.modal", function() { $("#confirmationModal [name='buttonConfirm']").text(doc.getDocLabel("page_global", "buttonConfirm")); $("#confirmationModal [name='buttonDismiss']").show(); $("#confirmationModal").unbind("hidden.bs.modal"); @@ -1557,7 +1580,7 @@ function showStepUsesLibraryInConfirmationModal(object) { step: object.step, getUses: true }, - success: function (data) { + success: function(data) { var content = ""; for (var i = 0; i < data.step.length; i++) { content += "" + data.step[i].test + " - " + data.step[i].testCase + " - " + data.step[i].sort + " - " + data.step[i].description + "Type : ' + data[$(htmlElement).val()].type + '
'); let secondRow = $('Value : ' + data[$(htmlElement).val()].value + '
'); $("#modalProperty").find("h5").text("test"); @@ -2907,7 +2930,7 @@ var autocompleteAllFields, getTags, setTags, handlerToDeleteOnStepChange = []; '); if (data[name]) { let property = name - viewEntry.find("button").on("click", function () { + viewEntry.find("button").on("click", function() { let firstRow = $('Type : ' + data[property].type + '
'); let secondRow = $('Value : ' + data[property].value + '
'); $("#modalProperty").find("#firstRowProperty").find("p").remove(); @@ -2926,7 +2949,7 @@ var autocompleteAllFields, getTags, setTags, handlerToDeleteOnStepChange = []; } }) - $(document).on('input', ".content div.fieldRow input:not('.description')", function (e) { + $(document).on('input', ".content div.fieldRow input:not('.description')", function(e) { let data = loadGuiProperties() if ($(this).parent().parent().find("select").val() === "callService") { let url = "ReadAppService?service=" + $(this).val() + "&limit=15"; @@ -2956,7 +2979,7 @@ function deleteTestCaseHandlerClick() { var test = $('#confirmationModal').find('#hiddenField1').prop("value"); var testCase = $('#confirmationModal').find('#hiddenField2').prop("value"); var jqxhr = $.post("DeleteTestCase", {test: test, testCase: testCase}, "json"); - $.when(jqxhr).then(function (data) { + $.when(jqxhr).then(function(data) { var messageType = getAlertType(data.messageType); if (messageType === "success") { window.location = "./TestCaseScript.jsp?test=" + test; @@ -2968,15 +2991,15 @@ function deleteTestCaseHandlerClick() { }).fail(handleErrorAjaxAfterTimeout); } -editPropertiesModalClick = function (test, testcase, info, propertyToAdd, propertyToFocus, canUpdate) { +editPropertiesModalClick = function(test, testcase, info, propertyToAdd, propertyToFocus, canUpdate) { // $("#propTable").empty(); - loadPropertiesAndDraw(test, testcase, info, propertyToFocus, canUpdate).then(function () { + loadPropertiesAndDraw(test, testcase, info, propertyToFocus, canUpdate).then(function() { autocompleteAllFields(); }); if (propertyToAdd !== undefined && propertyToAdd !== null) { // Building full list of country from testcase. var myCountry = []; - $.each(info.countryList, function (index) { + $.each(info.countryList, function(index) { myCountry.push(index); }); @@ -3019,7 +3042,7 @@ function editPropertiesModalSaveHandler() { } propArr.push($(properties[i]).data("property")); } - var saveProp = function () { + var saveProp = function() { showLoaderInModal('#propertiesModal'); $.ajax({ url: "UpdateTestCaseProperties", @@ -3032,7 +3055,7 @@ function editPropertiesModalSaveHandler() { informationTestCase: GetURLParameter("testcase"), propArr: JSON.stringify(propArr) }, - success: function (data) { + success: function(data) { var Tags = getTags(); var array = []; @@ -3061,7 +3084,7 @@ function editPropertiesModalSaveHandler() { }; if (propertyWithoutCountry) { - showModalConfirmation(function () { + showModalConfirmation(function() { $('#confirmationModal').modal('hide'); saveProp(); }, undefined, undefined, doc.getDocLabel("page_global", "btn_savetableconfig"), doc.getDocLabel("page_testcasescript", "warning_no_country"), "", "", "", ""); @@ -3161,7 +3184,7 @@ function setPlaceholderAction(actionElement) { var user = getUser(); var placeHolders = placeHoldersList[user.language]; - $(actionElement).find('select#actionSelect option:selected').each(function (i, e) { + $(actionElement).find('select#actionSelect option:selected').each(function(i, e) { for (var i = 0; i < placeHolders.length; i++) { if (placeHolders[i].type === e.value) { if (placeHolders[i].object !== null) { @@ -3236,7 +3259,7 @@ function setPlaceholderCondition(conditionElement) { if ($(conditionElement).find('select#conditionSelect option:selected').length) { - $(conditionElement).find('select#conditionSelect option:selected').each(function (i, e) { + $(conditionElement).find('select#conditionSelect option:selected').each(function(i, e) { for (var i = 0; i < placeHolders.length; i++) { if (placeHolders[i].type === e.value) { if (placeHolders[i].object !== null) { @@ -3261,7 +3284,7 @@ function setPlaceholderCondition(conditionElement) { } }); } else if ($(conditionElement).children().find('select#stepConditionOper option:selected').length) { - $(conditionElement).children().find('select#stepConditionOper option:selected').each(function (i, e) { + $(conditionElement).children().find('select#stepConditionOper option:selected').each(function(i, e) { for (var i = 0; i < placeHolders.length; i++) { if (placeHolders[i].type === e.value) { if (placeHolders[i].object !== null) { @@ -3286,7 +3309,7 @@ function setPlaceholderCondition(conditionElement) { } }); } else if ($(conditionElement).find('select#controlConditionSelect option:selected').length) { - $(conditionElement).find('select#controlConditionSelect option:selected').each(function (i, e) { + $(conditionElement).find('select#controlConditionSelect option:selected').each(function(i, e) { for (var i = 0; i < placeHolders.length; i++) { if (placeHolders[i].type === e.value) { if (placeHolders[i].object !== null) { @@ -3656,7 +3679,7 @@ function setPlaceholderControl(controlElement) { var user = getUser(); var placeHolders = placeHoldersList[user.language]; - $(controlElement).find('select#controlSelect option:selected').each(function (i, e) { + $(controlElement).find('select#controlSelect option:selected').each(function(i, e) { for (var i = 0; i < placeHolders.length; i++) { if (placeHolders[i].type === e.value) { @@ -4166,7 +4189,7 @@ function setPlaceholderProperty(propertyElement, property) { var user = getUser(); var placeHolders = placeHoldersList[user.language]; - $(propertyElement).find('select[name="propertyType"] option:selected').each(function (i, e) { + $(propertyElement).find('select[name="propertyType"] option:selected').each(function(i, e) { function initChange() { @@ -4184,7 +4207,7 @@ function setPlaceholderProperty(propertyElement, property) { }, async: true, method: "GET", - success: function (data) { + success: function(data) { if (data.messageType === "OK") { // Feed the data to the screen and manage // authorities. @@ -4199,7 +4222,7 @@ function setPlaceholderProperty(propertyElement, property) { displayDataLibList(editor.container.id, undefined, data) $("#" + editor.container.id).parent().find("button").attr('onclick', 'openModalDataLib(\'' + editor.container.id + "\','" + $("#" + editor.container.id).parent().find("select").val() + "\','EDIT'," + "'" + escaped + "')"); - $("#" + editor.container.id).parent().find("select").unbind("change").change(function () { + $("#" + editor.container.id).parent().find("select").unbind("change").change(function() { $("#" + editor.container.id).parent().find("button").attr('onclick', 'openModalDataLib(\'' + editor.container.id + "\','" + $("#" + editor.container.id).parent().find("select").val() + "\','EDIT'," + "'" + escaped + "')"); }) @@ -4330,10 +4353,10 @@ function CompleterForAllDataLib() { var staticWordCompleter = { - getCompletions: function (editor, session, pos, prefix, callback) { + getCompletions: function(editor, session, pos, prefix, callback) { var escaped = encodeURIComponent(editor.getValue()) - $.getJSON("ReadTestDataLib?name=" + escaped + "&limit=15&like=Y", function (wordList) { - callback(null, wordList.contentTable.map(function (ea) { + $.getJSON("ReadTestDataLib?name=" + escaped + "&limit=15&like=Y", function(wordList) { + callback(null, wordList.contentTable.map(function(ea) { return {name: ea.name, value: ea.name, meta: "DataLib"} })); }) @@ -4354,7 +4377,7 @@ function configureAceEditor(editor, mode, property) { var commandNameForAutoCompletePopup = "cerberusPopup"; var commandNameForIssueDetection = "cerberusIssueDetection"; // event listenner - editor.commands.on("afterExec", function (e) { + editor.commands.on("afterExec", function(e) { var langTools = ace.require('ace/ext/language_tools'); @@ -4363,7 +4386,7 @@ function configureAceEditor(editor, mode, property) { if (property.type === "getFromDataLib") { CompleterForAllDataLib(); - $("pre").off("input").on("input", function (e) { + $("pre").off("input").on("input", function(e) { editor.execCommand("startAutocomplete") }) editor.setOptions({maxLines: 15, enableBasicAutocompletion: true, enableLiveAutocompletion: false}); @@ -4459,7 +4482,7 @@ function addCommandForCustomAutoCompletePopup(editor, allKeyword, commandName) { editor.commands.addCommand({ name: commandName, - exec: function () { + exec: function() { var cursorPositionY = editor.getCursorPosition().row; var editorValueAtTheLine = editor.session.getLine(cursorPositionY); // value on the line the cursor is currently in @@ -4608,7 +4631,7 @@ function changeAceCompletionList(keywordList, label, editor) { var langTools = ace.require("ace/ext/language_tools"); langTools.setCompleters([]);// clear the autocompleter list var completer = { - getCompletions: function (editor, session, pos, prefix, callback) { + getCompletions: function(editor, session, pos, prefix, callback) { var completions = []; for (var i in keywordList) { completions.push({name: "default_name", value: keywordList[i], meta: label}); @@ -4627,7 +4650,7 @@ function addCommandToDetectKeywordIssue(editor, allKeyword, commandName) { editor.commands.addCommand({ name: commandName, - exec: function () { + exec: function() { var numberOfLine = editor.session.getLength(); var annotationObjectList = []; // var warningKeywordList =[]; @@ -4735,7 +4758,7 @@ function createGuterCellListenner(editor) { for (var i = 0; i < cellList.length; i++) { cellList[i].setAttribute("style", "cursor: pointer"); - cellList[i].onclick = function () { + cellList[i].onclick = function() { var lineClickedId = this.innerHTML - 1;// start at 1 var annotationObjectList = editor.getSession().getAnnotations(); @@ -4770,13 +4793,13 @@ function addPropertyWithAce(keywordValue) { url: "ReadTestCase", data: {test: test, testCase: testcase, withStep: true}, dataType: "json", - success: function (data) { + success: function(data) { testcaseinfo = data.info; loadTestCaseInfo(data.info); var myCountry = []; - $.each(testcaseinfo.countryList, function (index) { + $.each(testcaseinfo.countryList, function(index) { myCountry.push(index); }); // Store the current saveScript button status and disable it @@ -4821,7 +4844,7 @@ function addObjectWithAce(keywordValue) { url: "ReadTestCase", data: {test: test, testCase: testcase, withStep: true}, dataType: "json", - success: function (data) { + success: function(data) { // Store the current saveScript button status and disable it var saveScriptOldStatus = $("#saveScript").attr("disabled"); $("#saveScript").attr("disabled", true);