From 8dd2b641da8f7b7ed5616d0f00d4c53f60a27106 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 27 Nov 2012 15:42:28 -0400 Subject: [PATCH] Changes to the variable picker feature before revision meeting with the CTO --- .../pmVariablePicker/editor_plugin_src.js | 15 +- workflow/engine/js/controls/variablePicker.js | 204 +++++++++--------- workflow/engine/methods/controls/varsAjax.php | 13 +- .../xmlform/processes/processes_FileEdit.xml | 2 +- 4 files changed, 124 insertions(+), 110 deletions(-) diff --git a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js index 27126648a..932696556 100755 --- a/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js +++ b/gulliver/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js @@ -44,12 +44,12 @@ function pmVariablePicker(field_name, url, type, win) { strUploaderURL = strUploaderURL + "&type=" + type + "&d=" + strUploadPath + "&subs=" + strSubstitutePath; } tinyMCE.activeEditor.windowManager.open({ // open the plugin popup - //file : strUploaderURL, - file : strPluginPath + '/VariablePicker.html', + file : '/sysworkflow/en/classic/controls/varsAjax?displayOption=tinyMCE&sSymbol=@@', title : 'Upload Variable', - width : '600px', - height : '150px', - resizable : "yes", + width : '400px', + height : '350px', + resizable : "yes", + overflow : false, inline : 1, // This parameter only has an effect if you use the inlinepopups plugin! close_previous : "no" }, { @@ -68,4 +68,9 @@ function closePluginPopup(){ function updateEditorContent(serializedHTML){ tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML); +} + +function insertFormVar(fieldName,serializedHTML){ + tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML); + closePluginPopup(); } \ No newline at end of file diff --git a/workflow/engine/js/controls/variablePicker.js b/workflow/engine/js/controls/variablePicker.js index afdb1263a..c3c2fe47f 100755 --- a/workflow/engine/js/controls/variablePicker.js +++ b/workflow/engine/js/controls/variablePicker.js @@ -1,111 +1,113 @@ -//function onLoad(){ - // generateListValues(document.getElementById('prefix').value); -//} -//window.onload=function(){ - //generateListValues(document.getElementById('prefix').value); -//}; - -var getValue = function (list) { - insertFormVar(document.getElementById('selectedField').value,list.value); -} - -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 +var setVariablePickerJS = function(){ + + document.getElementById('_Var_Form_').addEventListener('dblclick', function(){ + insertFormVar(document.getElementById('selectedField').value, this.value); }); - - oRPC.make(); - //alert(oRPC.xmlhttp.responseText); - responseData = eval ("(" +oRPC.xmlhttp.responseText+ ")"); - - 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 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 + }); -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; -} + oRPC.make(); + //alert(oRPC.xmlhttp.responseText); + responseData = eval ("(" +oRPC.xmlhttp.responseText+ ")"); -leimnud.event.add(document.getElementById('type_variables'), 'change', function(event) { - var prefix=getPrefix(document.getElementById('prefix').value); - generateListValues(prefix); -}); + return responseData; + } -leimnud.event.add(document.getElementById('prefix'), 'change', function(event) { - var prefix=getPrefix(document.getElementById('prefix').value); - generateListValues(prefix); -}); + 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; + } -leimnud.event.add(document.getElementById('_Var_Form_'), 'change', function(event) { - document.getElementById('selectedVariableLabel').textContent = document.getElementById('_Var_Form_').value -}); + 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('search'), 'keypress', function(e) { - - var prefix=getPrefix(document.getElementById('prefix').value); - var key = e.keyCode; - if(key == '13'){ + leimnud.event.add(document.getElementById('type_variables'), 'change', function(event) { + var prefix=getPrefix(document.getElementById('prefix').value); generateListValues(prefix); - - e.cancelBubble = true; - e.returnValue = false; - if (e.stopPropagation) { - e.stopPropagation(); - e.preventDefault(); - } - } -}); + }); -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'); - - for(i=(combo.length-1); i>=0; i--) - { - aBorrar = combo.options[i]; - aBorrar.parentNode.removeChild(aBorrar); - } - - if(list.length>0){ - for(i=0; i=0; i--) + { + aBorrar = combo.options[i]; + aBorrar.parentNode.removeChild(aBorrar); + } + + if(list.length>0){ + for(i=0; i'; -$html .= ''; foreach ($aFields as $aField) { - $html .= ''; + $html .= ''; } $aRows[0] = Array ('fieldname' => 'char','variable' => 'char','type' => 'type','label' => 'char'); @@ -134,13 +134,20 @@ $html .= ''; $html .= ''; +$display = 'raw'; $G_PUBLISH = new Publisher(); $oHeadPublisher = & headPublisher::getSingleton(); $oHeadPublisher->addScriptFile('/jscore/controls/variablePicker.js'); +if($_REQUEST['displayOption']=='tinyMCE'){ + $display = 'blank'; + $oHeadPublisher->addScriptFile('/js/tinymce/jscripts/tiny_mce/tiny_mce_popup.js'); + $oHeadPublisher->addScriptFile('/js/tinymce/jscripts/tiny_mce/plugins/pmVariablePicker/editor_plugin_src.js'); +} + echo $html; -G::RenderPage( 'publish', 'raw' ); +G::RenderPage( 'publish', $display ); /* $alll = '