Conflict between plugins

General discussion of Mantis.

Moderators: Developer, Contributor

Post Reply
sara.rossi
Posts: 9
Joined: 01 Feb 2023, 11:01

Conflict between plugins

Post by sara.rossi »

I have two plugins in my mantisbt that feature two javascript files.

I don't know why but when both are active they don't work simultaneously. Instead if one of the plugins is deactivated the other one is working correctly.



The first js :

var currentPage = null;
var map = new Map();
map.set("View Issue Details", "Close Issue");

$(document).ready(function () {
console.log('beginning of checkIssueField');
console.log(checkCurrentLocation(map));
if (checkCurrentLocation(map)) {
console.log('after if');
hideAssignedToField();
}
});

function checkCurrentLocation(targetPages) {
var closedStatusElement = $("td.bug-status:contains('Closed')");
if (closedStatusElement.length > 0) {
currentPage = targetPages.get("View Issue Details");
console.log('targetPages' + targetPages);

console.log('currentPage dentro a checkCurrentLocation' + currentPage);
return true;
}
return false;
}

function hideAssignedToField() {
console.log('4'+ currentPage);
if (currentPage === "Close Issue" && checkProject()) {
$("td.bug-assigned-to").html('<a href="link/to/user/none">none</a>');
}
}
function checkProject() {
// Recupera il valore del progetto dal tuo HTML o da una variabile globale, ad esempio:
var projectElement = $("td.bug-project");
var projectValue = projectElement.text().trim();

console.log('The project is ' + projectValue);

// // Aggiungi qui la tua logica specifica per verificare il progetto
// // Ad esempio, verifica se il progetto è uguale a "ATR" o "ACP"
if (projectValue === "ATR" || projectValue === "ACP") {
console.log('The project is ' + projectValue);
return true;
} else {
return false;
}
}



The second js script :

var currentPageCloseIssue = null;

var mapClose = new Map();
mapClose.set("Close Issue", "Close Issue");

$(document).ready(function () {

checkIssueCloseField(mapClose);

});

function checkCurrentCloseLocation(targetClosePages) {

var closeIssueElement = $("h4.widget-title.lighter:contains('Close Issue')");
if (closeIssueElement.length > 0) {

currentPageCloseIssue = targetClosePages.get("Close Issue");

return true;
}

return false;
}

function checkProject() {
// Verifica il progetto corrente

var projectElement = $("td.bug-project");
var projectValue = projectElement.text().trim();


if (projectValue === "ATR" || projectValue === "ACP") {
console.log('The project is ' + projectValue);
return true;
} else {
return false;
}
}
function checkCurrentLocation(targetPages) {
var closedStatusElement = $("td.bug-status:contains('Closed')");
if (closedStatusElement.length > 0) {
currentPage = targetPages.get("Close Issue");
return true;
}
return false;
}



function hideAssignedToField() {
console.log(' pre fourth close step');
if (currentPageCloseIssue === "Close Issue" && checkProject()) {
// Nascondi il campo "Assigned To" e i valori select "handler_id"
console.log('fourth close step');
$("th.category:contains('Assigned To')").hide();
$("select[name='handler_id']").hide();
}
}

function checkIssueCloseField(mapClose) {
console.log(' pre fourth close step');
console.log('questa mappa' + mapClose);
if (checkCurrentCloseLocation(mapClose)) {
//console.log(currentPage);
hideAssignedToField();
}
}
cas
Posts: 1622
Joined: 11 Mar 2006, 16:08
Contact:

Re: Conflict between plugins

Post by cas »

Perhaps due to the fgact that you use the same function names with different content?
Post Reply