2012-11-27 15:42:28 -04:00
|
|
|
var setVariablePickerJS = function(){
|
2013-01-07 17:11:55 -04:00
|
|
|
if (document.getElementById('_Var_Form_').addEventListener) // W3C DOM
|
|
|
|
|
document.getElementById('_Var_Form_').addEventListener('dblclick', function(){
|
2015-05-22 16:21:55 -04:00
|
|
|
if(this.value.substring(0,5) == 'gridt') {
|
|
|
|
|
try {
|
|
|
|
|
updateEditorContent(this.value.substring(5));
|
2015-05-27 12:49:47 -04:00
|
|
|
closePluginPopup();
|
2015-05-22 16:21:55 -04:00
|
|
|
} catch(err) {
|
|
|
|
|
closePluginPopup();
|
|
|
|
|
}
|
2012-11-28 17:43:19 -04:00
|
|
|
} else {
|
2015-05-22 16:21:55 -04:00
|
|
|
if (this.getAttribute('displayOption')=='event'){
|
|
|
|
|
e.insertFormVar(this.value.substring(2), this.value.substring(2), 'dyn' );
|
|
|
|
|
} else {
|
|
|
|
|
insertFormVar(document.getElementById('selectedField').value, this.value);
|
|
|
|
|
}
|
2012-11-28 17:43:19 -04:00
|
|
|
}
|
2013-01-07 17:11:55 -04:00
|
|
|
});
|
|
|
|
|
else if (document.getElementById('selectedField').attachEvent) { // IE DOM
|
|
|
|
|
var element = document.getElementById('_Var_Form_');
|
|
|
|
|
element.attachEvent("ondblclick", function(){
|
2015-05-22 16:21:55 -04:00
|
|
|
if(element.value.substring(0,5) == 'gridt') {
|
|
|
|
|
try {
|
|
|
|
|
updateEditorContent(element.value.substring(5));
|
2015-05-27 12:49:47 -04:00
|
|
|
closePluginPopup();
|
2015-05-22 16:21:55 -04:00
|
|
|
} catch(err) {
|
|
|
|
|
closePluginPopup();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (element.displayOption=='event'){
|
|
|
|
|
e.insertFormVar(element.value.substring(2), element.value.substring(2), 'dyn' );
|
|
|
|
|
} else {
|
|
|
|
|
insertFormVar(document.getElementById('selectedField').value, element.value);
|
|
|
|
|
}
|
2013-01-07 17:11:55 -04:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2012-12-07 19:28:59 +00:00
|
|
|
* Function getVariableList returns a list with all process variables
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string proUid process ID
|
|
|
|
|
* @param string queryText text searched
|
|
|
|
|
* @param string varType type of variables (System or Process)
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
var getVariableList = function (queryText, proUid, varType){
|
|
|
|
|
varType = varType.toLowerCase();
|
|
|
|
|
var responseData
|
|
|
|
|
var oRPC = new leimnud.module.rpc.xmlhttp({
|
|
|
|
|
url : "../processes/processes_Ajax",
|
|
|
|
|
async : false,
|
|
|
|
|
method: "POST",
|
|
|
|
|
args : "action=getVariableList&process="+proUid+"&queryText="+queryText+"&type="+varType
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
oRPC.make();
|
|
|
|
|
//alert(oRPC.xmlhttp.responseText);
|
|
|
|
|
responseData = eval ("(" +oRPC.xmlhttp.responseText+ ")");
|
|
|
|
|
|
|
|
|
|
return responseData;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-07 19:28:59 +00:00
|
|
|
/**
|
|
|
|
|
* Function getPrefix returns selected prefix
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string prefix
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2012-11-27 15:42:28 -04:00
|
|
|
var getPrefix = function (prefix) {
|
|
|
|
|
if(document.getElementById('prefix').value=='ID_TO_STRING')
|
|
|
|
|
prefix='@@';
|
|
|
|
|
else if(document.getElementById('prefix').value=='ID_TO_FLOAT')
|
|
|
|
|
prefix='@#';
|
|
|
|
|
else if(document.getElementById('prefix').value=='ID_TO_INTEGER')
|
|
|
|
|
prefix='@%';
|
|
|
|
|
else if(document.getElementById('prefix').value=='ID_TO_URL')
|
|
|
|
|
prefix='@?';
|
|
|
|
|
else if(document.getElementById('prefix').value=='ID_SQL_ESCAPE')
|
|
|
|
|
prefix='@$';
|
|
|
|
|
else if(document.getElementById('prefix').value=='ID_REPLACE_WITHOUT_CHANGES')
|
|
|
|
|
prefix='@=';
|
|
|
|
|
return prefix;
|
|
|
|
|
}
|
2012-11-23 15:23:44 -04:00
|
|
|
|
2012-12-07 19:28:59 +00:00
|
|
|
/**
|
|
|
|
|
* Function getPrefixInfo returns a prefix description
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string prefix
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
var getPrefixInfo = function (prefix){
|
|
|
|
|
var oRPC = new leimnud.module.rpc.xmlhttp({
|
|
|
|
|
url : "../processes/processes_Ajax",
|
|
|
|
|
async : false,
|
|
|
|
|
method: "POST",
|
|
|
|
|
args : "action=getVariablePrefix&prefix="+prefix
|
|
|
|
|
});
|
|
|
|
|
oRPC.make();
|
|
|
|
|
return oRPC.xmlhttp.responseText;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leimnud.event.add(document.getElementById('type_variables'), 'change', function(event) {
|
|
|
|
|
var prefix=getPrefix(document.getElementById('prefix').value);
|
|
|
|
|
generateListValues(prefix);
|
2012-11-26 12:18:03 -04:00
|
|
|
});
|
2012-11-23 15:23:44 -04:00
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
leimnud.event.add(document.getElementById('prefix'), 'change', function(event) {
|
|
|
|
|
var prefix=getPrefix(document.getElementById('prefix').value);
|
|
|
|
|
generateListValues(prefix);
|
|
|
|
|
});
|
2012-11-27 17:24:38 +00:00
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(event) {
|
2015-05-22 16:21:55 -04:00
|
|
|
var selectElement = document.getElementById('_Var_Form_');
|
|
|
|
|
if(selectElement.value.substring(0,5) == 'gridt') {
|
|
|
|
|
document.getElementById('selectedVariableLabel').textContent = selectElement.options[selectElement.selectedIndex].text;
|
|
|
|
|
} else {
|
|
|
|
|
document.getElementById('selectedVariableLabel').textContent = selectElement.value
|
|
|
|
|
}
|
2012-11-27 08:55:29 -04:00
|
|
|
});
|
|
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
leimnud.event.add(document.getElementById('search'), 'keypress', function(e) {
|
2012-11-23 19:01:17 +00:00
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
var prefix=getPrefix(document.getElementById('prefix').value);
|
|
|
|
|
var key = e.keyCode;
|
|
|
|
|
if(key == '13'){
|
|
|
|
|
generateListValues(prefix);
|
2012-11-23 19:01:17 +00:00
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
e.cancelBubble = true;
|
|
|
|
|
e.returnValue = false;
|
|
|
|
|
if (e.stopPropagation) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
}
|
2012-11-27 17:24:38 +00:00
|
|
|
}
|
2012-11-27 15:42:28 -04:00
|
|
|
});
|
2012-11-23 19:01:17 +00:00
|
|
|
|
2012-12-07 19:28:59 +00:00
|
|
|
/**
|
|
|
|
|
* Function generateListValues fills the dropdown with all variables according to filters
|
|
|
|
|
*
|
|
|
|
|
* @access public
|
|
|
|
|
* @param string prefix
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
|
2012-11-27 15:42:28 -04:00
|
|
|
function generateListValues (prefix){
|
|
|
|
|
var list = getVariableList(document.getElementById('search').value, document.getElementById('process').value, document.getElementById('type_variables').value);
|
|
|
|
|
var combo = document.getElementById("_Var_Form_");
|
|
|
|
|
var option = document.createElement('option');
|
2015-05-22 16:21:55 -04:00
|
|
|
var isBpmn = document.getElementById('isBpmn').value;
|
2012-11-27 15:42:28 -04:00
|
|
|
|
|
|
|
|
for(i=(combo.length-1); i>=0; i--)
|
2012-11-27 19:14:33 +00:00
|
|
|
{
|
2012-11-27 15:42:28 -04:00
|
|
|
aBorrar = combo.options[i];
|
|
|
|
|
aBorrar.parentNode.removeChild(aBorrar);
|
2012-11-27 17:24:38 +00:00
|
|
|
}
|
2012-11-27 15:42:28 -04:00
|
|
|
|
|
|
|
|
if(list.length>0){
|
|
|
|
|
for(i=0; i<list.length; i++)
|
|
|
|
|
{
|
2015-05-22 16:21:55 -04:00
|
|
|
var optionValue = prefix+list[i].sName;
|
|
|
|
|
if(isBpmn) {
|
2015-12-10 11:45:40 -04:00
|
|
|
if (list[i].sType === "hidden"){
|
|
|
|
|
list[i].sLabel = "hidden";
|
|
|
|
|
}
|
|
|
|
|
if(list[i].sLabel && list[i].sLabel.toLowerCase() == 'grid') {
|
2015-05-22 16:21:55 -04:00
|
|
|
var gridValue = 'gridt<table border=1 cellspacing=0><tr><th>Header_1</th></tr><tbody><!--@>'+list[i].sName+'--><tr><td>column_name1</td></tr><!--@<'+list[i].sName+'--></tbody></table>';
|
|
|
|
|
optionValue = gridValue;
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-11-27 15:42:28 -04:00
|
|
|
option = document.createElement("OPTION");
|
2015-05-22 16:21:55 -04:00
|
|
|
option.value = optionValue;
|
2012-11-27 15:42:28 -04:00
|
|
|
option.text = prefix+list[i].sName+' ('+list[i].sLabel+')';
|
|
|
|
|
combo.add(option);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
option = document.createElement("OPTION");
|
|
|
|
|
option.value = 0;
|
|
|
|
|
option.text = 'No results';
|
|
|
|
|
combo.add(option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-12-04 17:42:42 -04:00
|
|
|
// check wether the document has been already loaded or not,
|
|
|
|
|
// whatever the state is this condition ensures that the events are always loaded
|
2012-11-27 15:42:28 -04:00
|
|
|
if (document.readyState == 'complete'){
|
2012-12-04 17:42:42 -04:00
|
|
|
// if completed load the functions and events
|
2012-11-27 15:42:28 -04:00
|
|
|
setVariablePickerJS();
|
|
|
|
|
} else {
|
2012-12-04 17:42:42 -04:00
|
|
|
// if not set the function call in the body onload event
|
2012-11-27 15:42:28 -04:00
|
|
|
document.body.onload = setVariablePickerJS;
|
|
|
|
|
}
|
|
|
|
|
|