Version 3.0.0 first version compatible with GLPi 9.1.1
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
|
||||
var oldHandler ;
|
||||
var submitButton ;
|
||||
function onClickContinue( obj ) {
|
||||
var submitButton;
|
||||
var caseIFrame;
|
||||
|
||||
function onClickContinue(obj) {
|
||||
//debugger;
|
||||
// call old handler
|
||||
if (obj != undefined && oldHandler)
|
||||
oldHandler(obj.target);
|
||||
submitButton.click() ;
|
||||
// hide the iFrame
|
||||
caseIFrame.style.visibility = 'hidden';
|
||||
|
||||
// call new handler
|
||||
submitButton.click();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,11 +46,11 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
var buttonContinue = contentDocument.getElementById('form[btnGLPISendRequest]');
|
||||
var txtAreaUseRequestSumUp = contentDocument.getElementById('form[UserRequestSumUp]');
|
||||
var linkList = contentDocument.getElementsByTagName('a');
|
||||
if (txtAreaUseRequestSumUp != undefined) { // !bAreaUseRequestSumUp &&
|
||||
//bAreaUseRequestSumUp = true; // to prevent multiple adds
|
||||
Ext.select("textarea[name='content']").elements[0].value = txtAreaUseRequestSumUp.value;
|
||||
if (txtAreaUseRequestSumUp != undefined) {
|
||||
//debugger;
|
||||
$("textarea[name='content']")[0].value = txtAreaUseRequestSumUp.value;
|
||||
} else
|
||||
Ext.select("textarea[name='content']").elements[0].value = '_';
|
||||
$("textarea[name='content']")[0].value = '_';
|
||||
|
||||
if (!bButtonContinue && buttonContinue != undefined && linkList != undefined && linkList.length > 0) {
|
||||
bButtonContinue = true; //window.clearInterval(caseTimer); // to be sure that it will be done only one time
|
||||
@@ -61,13 +68,13 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
buttonContinue.onclick = onClickContinue;
|
||||
|
||||
|
||||
submitButton = Ext.select("input[name='add'][type=submit]").elements[0];
|
||||
submitButton = $("input[name='add'][type=submit]")[0];
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_action' value='routecase'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_caseid' value='" + caseId + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_delindex' value='" + delIndex + "'/>");
|
||||
submitButton.insertAdjacentHTML('beforebegin', "<input type='hidden' name='processmaker_casenum' value='" + caseNumber + "'/>");
|
||||
|
||||
Ext.select("input[name='name'][type=text]").elements[0].value = processName;
|
||||
$("input[name='name'][type=text]")[0].value = processName;
|
||||
|
||||
}
|
||||
|
||||
@@ -75,7 +82,7 @@ function onLoadFrame( evt, caseId, delIndex, caseNumber, processName ) {
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var locElt = contentDocument.getElementsByTagName("form")[0];
|
||||
var newHeight = (locElt.clientHeight < 100 ? 100 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
|
||||
var newHeight = (locElt.clientHeight < 300 ? 300 : locElt.clientHeight) + locElt.offsetParent.offsetTop + 10 ;
|
||||
caseIFrame.height = newHeight;
|
||||
redimIFrame = true;
|
||||
}
|
||||
|
||||
87
js/cases.js
87
js/cases.js
@@ -29,14 +29,14 @@ function showMask(elt) {
|
||||
};
|
||||
|
||||
|
||||
function onTaskFrameLoad(delIndex) {
|
||||
function onTaskFrameLoad(event, delIndex, hideClaimButton, csrf) {
|
||||
//alert("Loaded frame " + delIndex);
|
||||
var taskFrameId = "caseiframe-" + delIndex;
|
||||
var taskFrameId = event.target.id; //"caseiframe-" + delIndex;
|
||||
var bShowHideNextStep = false ; // not done yet!
|
||||
var bHideClaimCancelButton = false; // To manage 'Claim' button
|
||||
var taskFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
|
||||
//debugger;
|
||||
var taskFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
var locContentDocument;
|
||||
@@ -63,9 +63,17 @@ function onTaskFrameLoad(delIndex) {
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
|
||||
// add an element that will be the csrf data code for the POST
|
||||
//debugger;
|
||||
var csrfElt = document.createElement("input");
|
||||
csrfElt.setAttribute("type", "hidden");
|
||||
csrfElt.setAttribute("name", "_glpi_csrf_token") ;
|
||||
csrfElt.setAttribute("value", csrf) ;
|
||||
node.appendChild(csrfElt);
|
||||
|
||||
// try to add showMask function to submit event
|
||||
//locElt.addEventListener( 'click', showMask ); // it is not good if a validation error occurs
|
||||
node.addEventListener('submit', showMask, true);
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask, true);
|
||||
} else {
|
||||
// then hide the button itself
|
||||
locElt.style.display = 'none';
|
||||
@@ -78,16 +86,22 @@ function onTaskFrameLoad(delIndex) {
|
||||
var cancelButton = locContentDocument.getElementById('form[BTN_CANCEL]');
|
||||
if (cancelButton != undefined && !bHideClaimCancelButton) {
|
||||
cancelButton.style.display = 'none';
|
||||
// hides claim button if asked for
|
||||
if (hideClaimButton) {
|
||||
claimButton = locContentDocument.getElementById('form[BTN_CATCH]');
|
||||
claimButton.style.display = 'none';
|
||||
}
|
||||
// to manage Claim
|
||||
var formList = locContentDocument.getElementsByTagName('form');
|
||||
var node = formList[0]; // must have one element in list: in a dynaform there is one and only one HTML form
|
||||
var action = node.action.split('?');
|
||||
node.action = GLPI_HTTP_CASE_FORM + '?' + action[1] + '&DEL_INDEX=' + delIndex;
|
||||
bHideClaimCancelButton = true;
|
||||
node.addEventListener('submit', showMask);
|
||||
// TODO
|
||||
//node.addEventListener('submit', showMask);
|
||||
}
|
||||
|
||||
// to force immediat reload of GLPI item form
|
||||
// to force immediate reload of GLPI item form
|
||||
var forcedReload = locContentDocument.getElementById('GLPI_FORCE_RELOAD');
|
||||
if (forcedReload != undefined && !GLPI_DURING_RELOAD) {
|
||||
//showMask();
|
||||
@@ -96,12 +110,19 @@ function onTaskFrameLoad(delIndex) {
|
||||
GLPI_RELOAD_PARENT.location.reload();
|
||||
}
|
||||
|
||||
// try to redim caseIFrame
|
||||
// try to redim caseIFrame
|
||||
if (!redimIFrame) {
|
||||
var newHeight;
|
||||
var locElt = locContentDocument.getElementsByTagName("table")[0];
|
||||
var newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
|
||||
if (locElt && locElt.offsetParent)
|
||||
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
|
||||
else {
|
||||
locElt = locContentDocument.getElementsByTagName("form")[0];
|
||||
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetTop ;
|
||||
}
|
||||
//locElt.clientHeight = newHeight; // don't know if this is neccessary!!! --> bugs on IE8
|
||||
tabs.getItem('task-' + delIndex).setHeight(newHeight);
|
||||
//NOT NEEDED WITH jQuery: var elts = $('#processmakertabpanel').tabs();//.getItem('task-' + delIndex).setHeight(newHeight);
|
||||
//debugger;
|
||||
taskFrame.height = newHeight ;
|
||||
redimIFrame = true;
|
||||
}
|
||||
@@ -141,11 +162,14 @@ function clearClass(lociFrame) {
|
||||
}, 10);
|
||||
}
|
||||
|
||||
function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
|
||||
var otherFrameId = frameName; //tabPanelName ; //+ 'Frame';
|
||||
function onOtherFrameLoad(tabPanelName, frameName, eltTagName, isMap3) {
|
||||
var otherFrameId = frameName;
|
||||
var otherFrameTimerCounter = 0;
|
||||
var redimIFrame = false;
|
||||
//debugger;
|
||||
if (isMap3 == undefined)
|
||||
isMap3 = false;
|
||||
|
||||
var otherFrameTimer = window.setInterval(function () {
|
||||
try {
|
||||
|
||||
@@ -161,17 +185,38 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
|
||||
// try to redim otherFrame
|
||||
// and tabPanel
|
||||
if (!redimIFrame) {
|
||||
var locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
|
||||
var locElt;
|
||||
// isMap3 == true
|
||||
// map is bpmn
|
||||
// must look at div with special CSS class name to get newHeight and should change offset and size of parent div
|
||||
if (!isMap3) {
|
||||
if (tabPanelName == 'caseMap') {
|
||||
// locElt = locContentDocument.querySelectorAll('div.panel_content___processmaker')[0];
|
||||
locElt = locContentDocument.querySelectorAll('div.panel_containerWindow___processmaker')[0];
|
||||
locElt2 = locContentDocument.getElementById('pm_target');
|
||||
locElt2.style.height = locElt.clientHeight + 'px';
|
||||
} else {
|
||||
locElt = locContentDocument.getElementsByTagName(eltTagName)[0];
|
||||
}
|
||||
} else {
|
||||
locElt = locContentDocument.querySelectorAll('div.pmui-pmpool')[0];
|
||||
}
|
||||
if (locElt != undefined) {
|
||||
var newHeight ;
|
||||
var newHeight;
|
||||
if (isMap3) {
|
||||
locElt.offsetParent.style.top = 0;
|
||||
locElt.offsetParent.style.width = locElt.offsetWidth + locElt.offsetLeft + 'px';
|
||||
locElt.offsetParent.style.height = locElt.offsetHeight + locElt.offsetTop + 'px';
|
||||
}
|
||||
|
||||
if (locElt.offsetParent)
|
||||
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) + locElt.offsetParent.offsetTop ;
|
||||
newHeight = (locElt.offsetHeight < 400 ? 400 : locElt.offsetHeight) + locElt.offsetParent.offsetTop ;
|
||||
else
|
||||
newHeight = (locElt.clientHeight < 400 ? 400 : locElt.clientHeight) ;
|
||||
if (locElt.scrollHeight && locElt.scrollHeight > newHeight )
|
||||
newHeight = locElt.scrollHeight ;
|
||||
tabs.getItem(tabPanelName).setHeight(newHeight);
|
||||
otherFrame.height = newHeight;
|
||||
newHeight = (locElt.offsetHeight < 400 ? 400 : locElt.offsetHeight) ;
|
||||
if (locElt.scrollHeight && locElt.scrollHeight > newHeight)
|
||||
newHeight = locElt.scrollHeight;
|
||||
//NOT NEEDED WITH jQuery: tabs.getItem(tabPanelName).setHeight(newHeight);
|
||||
otherFrame.height = newHeight ;
|
||||
redimIFrame = true;
|
||||
}
|
||||
}
|
||||
@@ -190,3 +235,5 @@ function onOtherFrameLoad(tabPanelName, frameName, eltTagName) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,52 +12,29 @@ if (!defined('GLPI_ROOT')) {
|
||||
die("Can not access directly to this file");
|
||||
}
|
||||
|
||||
echo "Ext.onReady(function () {
|
||||
echo "$(function () {
|
||||
|
||||
function showMask(){Ext.getBody().moveTo( 0, 0); var myMask = new Ext.LoadMask(Ext.getBody(), {removeMask:false}); myMask.show();};
|
||||
/*function showMask(){Ext.getBody().moveTo( 0, 0); var myMask = new Ext.LoadMask(Ext.getBody(), {removeMask:false}); myMask.show();};*/
|
||||
|
||||
// look if name='helpdeskform' is present. If yes replace the form.location
|
||||
var ahrefTI = '".$CFG_GLPI["root_doc"]."/plugins/processmaker/front/tracking.injector.php';
|
||||
var formLink = Ext.select(\"form[name='helpdeskform']\").elements[0];
|
||||
var formLink = $(\"form[name='helpdeskform']\")[0];
|
||||
if (formLink != undefined) {
|
||||
formLink.action = ahrefTI;
|
||||
}
|
||||
var ticketType = Ext.select(\"select[name='type']\").elements[0];
|
||||
/*
|
||||
var ticketType = $(\"select[name='type']\")$[0];
|
||||
if (ticketType != undefined) {
|
||||
ticketType.addEventListener( 'change', showMask );
|
||||
}
|
||||
var ticketCat = Ext.select(\"select[name='itilcategories_id']\").elements[0];
|
||||
var ticketCat = $(\"select[name='itilcategories_id']\")[0];
|
||||
if (ticketCat!= undefined) {
|
||||
ticketCat.addEventListener( 'change', showMask );
|
||||
}
|
||||
|
||||
*/
|
||||
});
|
||||
|
||||
"; // end of echo
|
||||
|
||||
|
||||
//Ext.onReady(function () {
|
||||
// var ahref = "../plugins/processmaker/front/processmaker.helpdesk.form.php";
|
||||
// var markup = '';
|
||||
// // look for menu id = menu2 to insert a new menu
|
||||
// var createTicketMenu = Ext.get('menu2');
|
||||
// if (createTicketMenu != undefined) {
|
||||
// markup = '<li id="menu2"><a href="' + ahref + '" class="itemP" title="Create User ticket">Create User ticket</a></li>';
|
||||
// Ext.DomHelper.insertAfter(createTicketMenu, markup)
|
||||
// }
|
||||
|
||||
// // look for 'Create a ticket' in order to insert a link <a>
|
||||
// var ticketLink = Ext.select('table.tab_cadrehov tbody tr th a').elements[0];
|
||||
// if (ticketLink != undefined) {
|
||||
// var img = Ext.select('table.tab_cadrehov tbody tr th a img').elements[0];
|
||||
// // add a link to the user management screen
|
||||
// markup = ' <a href="' + ahref + '">User Management Ticket<img src="' + img.attributes["src"].value + '"></a>';
|
||||
// Ext.DomHelper.insertAfter(ticketLink, markup)
|
||||
// //window.clearInterval(ticketTimer)
|
||||
// }
|
||||
|
||||
|
||||
|
||||
//});
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user