WYSIWYG EDITOR Variable Picker

WYSIWYG EDITOR variable picker changes
This commit is contained in:
norahmollo
2012-11-27 17:24:38 +00:00
parent 2f1ded16f5
commit 892a48eba0
2 changed files with 68 additions and 34 deletions

89
workflow/engine/js/controls/variablePicker.js Normal file → Executable file
View File

@@ -1,3 +1,10 @@
//function onLoad(){
// generateListValues(document.getElementById('prefix').value);
//}
//window.onload=function(){
//generateListValues(document.getElementById('prefix').value);
//};
var getValue = function (list) { var getValue = function (list) {
insertFormVar(document.getElementById('selectedField').value,list.value); insertFormVar(document.getElementById('selectedField').value,list.value);
} }
@@ -19,6 +26,22 @@ var getVariableList = function (queryText, proUid, varType){
return responseData; return responseData;
} }
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;
}
var getPrefixInfo = function (prefix){ var getPrefixInfo = function (prefix){
var oRPC = new leimnud.module.rpc.xmlhttp({ var oRPC = new leimnud.module.rpc.xmlhttp({
url : "../processes/processes_Ajax", url : "../processes/processes_Ajax",
@@ -31,11 +54,13 @@ var getPrefixInfo = function (prefix){
} }
leimnud.event.add(document.getElementById('type_variables'), 'change', function(event) { leimnud.event.add(document.getElementById('type_variables'), 'change', function(event) {
generateListValues(); var prefix=getPrefix(document.getElementById('prefix').value);
generateListValues(prefix);
}); });
leimnud.event.add(document.getElementById('prefix'), 'change', function(event) { leimnud.event.add(document.getElementById('prefix'), 'change', function(event) {
document.getElementById('desc_prefix').textContent = getPrefixInfo(document.getElementById('prefix').value); var prefix=getPrefix(document.getElementById('prefix').value);
generateListValues(prefix);
}); });
leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(event) { leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(event) {
@@ -43,38 +68,38 @@ leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(even
}); });
leimnud.event.add(document.getElementById('search'), 'keypress', function(e) { leimnud.event.add(document.getElementById('search'), 'keypress', function(e) {
var key = e.keyCode;
if(key == '13'){ var prefix=getPrefix(document.getElementById('prefix').value);
// elements that will be part of a function var key = e.keyCode;
var list = getVariableList(document.getElementById('search').value, document.getElementById("process").value, document.getElementById('type_variables').value); if(key == '13'){
for (var i=0; i< list.length; i++){ generateListValues(prefix);
console.log(list[i].sName);
} e.cancelBubble = true;
e.cancelBubble = true; e.returnValue = false;
e.returnValue = false; if (e.stopPropagation) {
if (e.stopPropagation) { e.stopPropagation();
e.stopPropagation(); e.preventDefault();
e.preventDefault(); }
} }
//return false;
}
}); });
var generateListValues = function(){ function generateListValues (prefix){
var list = getVariableList('', document.getElementById("process").value, document.getElementById('type_variables').value); var list = getVariableList(document.getElementById('search').value, document.getElementById('process').value, document.getElementById('type_variables').value);
var combo = document.getElementById("_Var_Form_"); var combo = document.getElementById("_Var_Form_");
var option = document.createElement('option'); var option = document.createElement('option');
for (m=combo.options.length-1;m>=0;m--){ for (m=combo.options.length-1;m>=0;m--){
combo.options[m]=null combo.options[m]=null
}
for (var i=0; i< list.length; i++){
console.log(list[i].sValue);
var combo = document.getElementById("_Var_Form_");
var option = document.createElement('option');
combo.options.add(option, 0);
combo.options[0].value = list[i].sName;
combo.options[0].text ='@@'+list[i].sName+' ('+list[i].sLabel+')';
} }
if(list.length>0){
for (var i=0; i< list.length; i++){
combo.options.add(option, 0);
combo.options[0].value = list[i].sName;
combo.options[0].text = prefix+list[i].sName+' ('+list[i].sLabel+')';
}
} else {
combo.options.add(option, 0);
combo.options[0].value = '0';
combo.options[0].text = 'No results';
}
} }

View File

@@ -21,7 +21,7 @@
* For more information, contact Colosa Inc, 2566 Le Jeune Rd., * For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/ */
$html = '<form action="uploader.php?'.$_SERVER["QUERY_STRING"].'&q=upload" method="post" enctype="multipart/form-data" onsubmit="">'; $html = '<form action="uploader.php?'.$_SERVER["QUERY_STRING"].'&q=upload" onLoad="onLoad()" method="post" enctype="multipart/form-data" onsubmit="">';
$html .= '<div id="d_variables">'; $html .= '<div id="d_variables">';
@@ -62,12 +62,21 @@ $html .= '</td>';
$html .= '<td width="25%">'; $html .= '<td width="25%">';
//$html .= '<select name="prefix" id="prefix" onChange="Seleccionar(this);">'; //$html .= '<select name="prefix" id="prefix" onChange="Seleccionar(this);">';
$html .= '<select name="prefix" id="prefix">'; $html .= '<select name="prefix" id="prefix">';
$html .= '<option value="ID_TO_FLOAT">@#</option>';
$html .= '<option value="ID_TO_STRING">@@</option>'; $html .= '<option value="ID_TO_STRING">@@</option>';
$html .= '<option value="ID_TO_FLOAT">@#</option>';
$html .= '<option value="ID_TO_INTEGER">@%</option>'; $html .= '<option value="ID_TO_INTEGER">@%</option>';
$html .= '<option value="ID_TO_URL">@?</option>'; $html .= '<option value="ID_TO_URL">@?</option>';
$html .= '<option value="ID_SQL_ESCAPE">@$</option>'; $html .= '<option value="ID_SQL_ESCAPE">@$</option>';
$html .= '<option value="ID_REPLACE_WITHOUT_CHANGES">@=</option>'; $html .= '<option value="ID_REPLACE_WITHOUT_CHANGES">@=</option>';
/*
$html .= '<option value="@@">@@</option>';
$html .= '<option value="@#">@#</option>';
$html .= '<option value="@%">@%</option>';
$html .= '<option value="@?">@?</option>';
$html .= '<option value="@$">@$</option>';
$html .= '<option value="@=">@=</option>';
*/
$html .= '</select> &nbsp;&nbsp;&nbsp;&nbsp;'; $html .= '</select> &nbsp;&nbsp;&nbsp;&nbsp;';
$html .= '</td>'; $html .= '</td>';