Skip to content

Commit

Permalink
Improved navigation between execution and script page (small fix).
Browse files Browse the repository at this point in the history
  • Loading branch information
vertigo17 committed Mar 31, 2024
1 parent eb2c75e commit ccb8684
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 10 deletions.
29 changes: 29 additions & 0 deletions source/src/main/webapp/js/global/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -2206,6 +2206,35 @@ function GetURLParameters(sParam) {
return result;
}

/**
* Replace the parameter passed in the url Example : url?param=value&toto=tutu is replaced to url?param=newValue&toto=tutu
* @param {String} sParam parameter you want to replace value from
* @param {String} new Value of the sParam
* @returns {GetURLParameter.sParameterName} the value or defaultValue does not exist in URL or null if not found in URL and no default value specified.
*/
function ReplaceURLParameters(sParam, sValue) {
let sPageURL = window.location.search.substring(1);
let sURLVariables = sPageURL.split('&');
let result = "";
let replaced = false;

for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
result += sParameterName[0] + "=" + sValue;
replaced = true;
// result.push(decodeURIComponent(sParameterName[1]));
} else {
result += sParameterName[0] + "=" + sParameterName[1];
}
result += "&";
}
if (!replaced) {
result += sParam + "=" + sValue + "&";
}
return result.substring(0, result.length - 1);
}

/**
* Add an browser history entry only if different from the current one.
* @param {string} sUrl Url to insert in the history.
Expand Down
40 changes: 30 additions & 10 deletions source/src/main/webapp/js/pages/TestCaseScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,24 @@ $.when($.getScript("js/global/global.js")
if (tabactive !== null) {
$("a[name='" + tabactive + "']").click();
}

$("a[name='tabProperties']").on("shown.bs.tab", function (e) {
e.target; // newly activated tab
e.relatedTarget; // previous active tab
InsertURLInHistory("./TestCaseScript.jsp?" + ReplaceURLParameters("tabactive", "tabProperties"));

})
$("a[name='tabSteps']").on("shown.bs.tab", function (e) {
e.target; // newly activated tab
e.relatedTarget; // previous active tab
InsertURLInHistory("./TestCaseScript.jsp?" + ReplaceURLParameters("tabactive", "tabSteps"));
})
$("a[name='tabInheritedProperties']").on("shown.bs.tab", function (e) {
e.target; // newly activated tab
e.relatedTarget; // previous active tab
InsertURLInHistory("./TestCaseScript.jsp?" + ReplaceURLParameters("tabactive", "tabInheritedProperties"));
})

}
// close all Navbar menu
closeEveryNavbarMenu();
Expand Down Expand Up @@ -1418,7 +1436,7 @@ function duplicateStep(event) {
var step = steps[0];
step.description = "New Step";
var stepObj = new Step(step, steps, true);
console.info(stepObj);
// console.info(stepObj);
stepObj.draw();
steps.push(stepObj);
stepObj.html.trigger("click");
Expand Down Expand Up @@ -1889,9 +1907,11 @@ Step.prototype.show = function () {
$("#addActionBottomBtn").show();

const url = new URL(window.location);
url.hash = '#stepId=' + object.stepId;
window.history.pushState({}, '', url);
$("#seeLastExecUniq").parent().attr("href", "./TestCaseExecution.jsp?executionId=" + encodeURI(exeId) + window.location.hash + "-1");
// url.hash = '#stepId=' + object.stepId;
// console.info(ReplaceURLParameters("stepId", object.stepId));
InsertURLInHistory("./TestCaseScript.jsp?" + ReplaceURLParameters("stepId", object.stepId));
// window.history.pushState({}, '', url);
$("#seeLastExecUniq").parent().attr("href", "./TestCaseExecution.jsp?executionId=" + encodeURI(exeId) + "#stepId=" + object.stepId + "-1");

for (var i = 0; i < object.steps.length; i++) {
var step = object.steps[i];
Expand Down Expand Up @@ -3434,14 +3454,14 @@ var autocompleteAllFields, getTags, setTags, handlerToDeleteOnStepChange = [];
modifyAutocompleteSource($(this), null, data);
} catch (e) {
}
console.log("trigger settingsButton.");
// console.log("trigger settingsButton.");

$(this).trigger("settingsButton");
}

function modifyAutocomplete(e) {
console.log("modify feed autocomplete on input (generic).")
console.log("trigger settingsButton.");
// console.log("modify feed autocomplete on input (generic).")
// console.log("trigger settingsButton.");
$(this).trigger("settingsButton");
}

Expand Down Expand Up @@ -3472,7 +3492,7 @@ var autocompleteAllFields, getTags, setTags, handlerToDeleteOnStepChange = [];

// Adding Contextual buttons when 'settingsButton' event is triggered.
$(document).on('settingsButton', "div.crb-contextual-button input", function (e) {
console.log("start generate buttons.");
// console.log("start generate buttons.");
var doc = new Doc();
let currentAction = $(this).parents(".secondRow").find("[name='actionSelect']").val();
let htmlElement = $(this);
Expand Down Expand Up @@ -3676,11 +3696,11 @@ function setPlaceholderAction(action) {

function setPlaceholderCondition(conditionElement) {

console.log(conditionElement);
// console.log(conditionElement);
var user = getUser();
var placeHolders = conditionNewUIList[conditionElement.val()];

console.log(placeHolders);
// console.log(placeHolders);

if (typeof placeHolders === 'undefined') {
placeHolders = conditionNewUIList["always"];
Expand Down

0 comments on commit ccb8684

Please sign in to comment.