Another update to the grids wizard feature

This commit is contained in:
Gustavo Cruz
2012-12-05 18:07:10 -04:00
parent b936900f2a
commit d45c6bbd73
8 changed files with 109 additions and 139 deletions

View File

@@ -33,10 +33,10 @@
// with the path of the uploaded file
function pmGrids(field_name, url, type, win) {
//tinyMCE.activeEditor.anyVariable='path/to/ProcessMaker'
var strPluginPath = tinyMCE.activeEditor.plugins.pmGrids.getPluginURL(); // get the path to the uploader plugin
var strScriptURL = strPluginPath + "/pmGrids.html";
tinyMCE.activeEditor.windowManager.open({ // open the plugin popup
var strPluginPath = tinyMCE.activeEditor.plugins.pmGrids.getPluginURL(); // get the path to the uploader plugin
var strScriptURL = strPluginPath + "/pmGrids.html";
tinyMCE.activeEditor.windowManager.open({ // open the plugin popup
file : strScriptURL,
title : 'ProcessMaker Grid Wizard',
width : '600px',

View File

@@ -33,7 +33,7 @@
// with the path of the uploaded file
function pmGrids(field_name, url, type, win) {
//tinyMCE.activeEditor.anyVariable='path/to/ProcessMaker'
var strPluginPath = tinyMCE.activeEditor.plugins.pmGrids.getPluginURL(); // get the path to the uploader plugin
var strPluginPath = tinyMCE.activeEditor.plugins.pmGrids.getPluginURL(); // get the path to the uploader plugin
var strScriptURL = strPluginPath + "/pmGrids.html";
tinyMCE.activeEditor.windowManager.open({ // open the plugin popup
@@ -62,5 +62,6 @@ function closePluginPopup(){
function updateEditorContent(serializedHTML){
tinyMCE.activeEditor.execCommand('mceInsertContent', false, serializedHTML);
closePluginPopup();
}

View File

@@ -19,26 +19,26 @@ and open the template in the editor.
left: 45%;
margin-left: -70px;
}
#container {
.container {
display: table;
}
#row {
.row {
display: table-row;
}
#left, #right, #middle, .gridCell {
.left, .right, .middle, .gridCell {
display: table-cell;
}
</style>
</head>
<body>
<div id="container">
<div id="row">
<div id="left">
<div class="container">
<div class="row">
<div class="left">
Chose a grid
</div>
<div id="middle">
<div class="middle">
<div id="gridDropdown">
<select id="gridList">
@@ -46,11 +46,11 @@ and open the template in the editor.
</div>
</div>
</div>
<div id="row">
<div id="left">
<div class="row">
<div class="left">
Prefix
</div>
<div id="middle">
<div class="middle">
<div id="prefixDropdown">
<select name="prefixList" id="prefixList">
<option value="@#">@#</option>
@@ -59,36 +59,25 @@ and open the template in the editor.
</div>
</div>
</div>
<div id="row">
<div id="left">
</div>
<div id="middle">
<div id="borderCheckBox">
<input type="checkbox"> Border
</div>
<div class="row">
<div class="middle">
<input type="checkbox" id="borderCheckbox"> Border
</div>
</div>
<div id="row">
<div id="left">
</div>
<div id="middle">
<div id="headersCheckBox">
<input type="checkbox"> Headers
</div>
<div class="row">
<div class="middle">
<input type="checkbox" id="headersCheckbox"> Headers
</div>
</div>
</div>
<center>
<table id="listContainer" border="1" cellspacing="0" cellpadding="3">
</table>
<div id="container">
<div id="row">
<div id="left">
<div class="container">
<div class="row">
<div class="left">
</div>
<div id="middle">
<div class="middle">
<button id="addButton" style="width: 100px">
Add
</button>
@@ -96,10 +85,9 @@ and open the template in the editor.
Cancel
</button>
</div>
<div id="right">
<div class="right">
</div>
</div>
</div>
</center>
</body>
</html>

View File

@@ -1,64 +1,40 @@
$(document).ready(function () {
$(document).ready(function () {
var getGridList = function(){
var responseData
responseData = '[{"id":"grid_01","name":"grid_01"},{"id":"grid_02","name":"grid_02"}]';
/*$.ajax({
url : "/processes/processes_Ajax",
// responseData = '[{"id":"grid_01","name":"grid_01"},{"id":"grid_02","name":"grid_02"}]';
var url = tinyMCE.activeEditor.domainURL+"processes/processes_Ajax";
responseData = $.ajax({
url : url,
type: "POST",
data: {action : 'getDynagridList', PRO_UID: tinyMCE.activeEditor.processID},
dataType: "html",
success: function (data) {
$.each(data, function(index, element) {
$('#listContainer').append($('<div class="gridCell">', {
text: element.name
}));
});
},
failure: function(){
// responseData = '[{"id":"1","name":"grid_01"},{"id":"2","name":"grid_02"}]';
}
});*/
responseData = eval ("(" +responseData+ ")");
data: {action : 'getGridList', PRO_UID: tinyMCE.activeEditor.processID},
async: false,
dataType: "json"
}).responseText;
responseData = eval("(" +responseData+ ")");
return responseData;
}
var getGridFieldList = function (gridUid){
var responseData
if (gridUid=='1'||gridUid==1){
responseData = eval ('([{"id":"1","name":"field01"},{"id":"2","name":"field02"}])');
} else {
responseData = eval ('([{"id":"3","name":"field03"},{"id":"4","name":"field04"}])');
}
/*$.ajax({
url: "/processes/processes_Ajax",
var getGridFieldList = function(gridUid){
var responseData = $.ajax({
url : tinyMCE.activeEditor.domainURL+"processes/processes_Ajax",
type: "POST",
data: {action : 'getGridFieldList', PRO_UID: tinyMCE.activeEditor.processID, DYN_UID: gridUid},
data: {action : 'getVariableGrid', PRO_UID: tinyMCE.activeEditor.processID, DYN_UID: gridUid},
dataType: "json",
success: function (data) {
$.each(responseData, function(index, element) {
$('#listContainer').append($('<div class="gridCell">', {
text: element.name
}));
});
}
});*/
async:false
}).responseText;
responseData = eval("("+responseData+")");
$('#listContainer').html('');
var divHeader = '<tr>';
var divCell = '<tr>';
$.each(responseData, function(index, element){
divHeader += "<td><input type='checkbox' class='headerField' name='headerField' value='"+element.name+"'/><input type='text' style='width:100px;' name='dynafield' class='dynaField' value='"+element.name+"' id='"+element.name+"'></td>";
divCell += "<td align='center'><input type='hidden' id='field_"+element.name+"' value='"+element.name+"'>"+element.name+"</td>";
divHeader += "<td><input type='checkbox' class='headerField' name='headerField' value='"+element+"'/><input type='text' style='width:80px;' name='dynafield' class='dynaField' value='"+element+"' id='"+element+"'></td>";
divCell += "<td align='center'><input type='hidden' id='field_"+element+"' value='"+element+"'>"+element+"</td>";
});
divHeader += "</tr>";
divCell += "</tr>";
$('#listContainer').append(divHeader+divCell);
}
divHeader += '</tr>';
divCell += '</tr>';
$('#listContainer').append(divHeader+divCell);
};
var generateListValues = function(){
var list = getGridList();
@@ -66,16 +42,16 @@
var option = document.createElement('option');
for(i=(combo.length-1); i>=0; i--)
{
var aDelete = combo.options[i];
aDelete.parentNode.removeChild(aDelete);
var aDelete = combo.options[i];
aDelete.parentNode.removeChild(aDelete);
}
if(list.length>0){
for(i=0; i<list.length; i++)
{
option = document.createElement("OPTION");
option.value = list[i].id;
option.text = list[i].name;
option.value = list[i].sXmlForm;
option.text = list[i].sName;
combo.add(option);
}
} else {
@@ -101,11 +77,12 @@
});
headerCode += "</tr>";
fieldCode += "</tr>";
gridCode += fieldCode+"<!--@<"+gridName+"-->";
if ($("#headersCheckbox").attr("checked")!="checked"){
headerCode = '';
}
gridCode += headerCode+fieldCode+"<!--@<"+gridName+"-->";
tableCode += gridCode+"</table>"
updateEditorContent (tableCode);
closePluginPopup();
}
$('#gridList').change(function(){

View File

@@ -3,6 +3,7 @@
**/
(function(){
tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce";
var strPluginURL;
tinymce.create('tinymce.plugins.pmVariablePickerPlugin', {
init: function(ed, url)
@@ -69,7 +70,7 @@ function pmVariablePicker(field_name, url, type, win) {
// This function will get called when the uploader is done uploading the file and ready to update
// calling dialog and close the upload popup
// strReturnURL should be the string with the path to the uploaded file
function closePluginPopup(){
function closePluginPopup(){
tinyMCEPopup.close(); // close popup window
}

View File

@@ -76,8 +76,8 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
*/
public function attachEvents ($element)
{
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
$editorDefinition = 'tinyMCE.baseURL = "/js/tinymce/jscripts/tiny_mce"; ';
$editorDefinition .= 'var domainURL = "/sys'.SYS_SYS.'/'.SYS_LANG.'/'.SYS_SKIN.'/"';
switch ($this->editorType){
case 'EMAIL_TEMPLATE':
@@ -95,11 +95,13 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
theme_advanced_buttons1 : "pmSimpleUploader,|,pmVariablePicker,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,|,cut,copy,paste,|,bullist,numlist,|,outdent,indent,blockquote",
theme_advanced_buttons2 : "tablecontrols,|,undo,redo,|,link,unlink,image,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,sub,sup,|,ltr,rtl,|,code",
oninit: function (){
tinyMCE.activeEditor.processID =formProcessID;
tinyMCE.activeEditor.processID = formProcessID;
tinyMCE.activeEditor.domainURL = domainURL;
},
onchange_callback: function(inst) {
if(inst.isDirty()) {
inst.save();
inst.save();
}
return true;
},
@@ -126,8 +128,9 @@ class XmlForm_Field_WYSIWYG_EDITOR extends XmlForm_Field
verify_html : false,
theme_advanced_buttons1 : "pmSimpleUploader,|,pmVariablePicker,|,pmGrids,|,bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,|,fontselect,fontsizeselect,|,cut,copy,paste,|,bullist,numlist,|,outdent,indent,blockquote",
theme_advanced_buttons2 : "tablecontrols,|,undo,redo,|,link,unlink,image,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,sub,sup,|,ltr,rtl,|,code",
oninit: function (){
tinyMCE.activeEditor.processID=formProcessID;
oninit: function () {
tinyMCE.activeEditor.processID = formProcessID;
tinyMCE.activeEditor.domainURL = domainURL;
},
onchange_callback: function(inst) {
if(inst.isDirty()) {

View File

@@ -457,46 +457,46 @@ function getGridsVars ($sProcessUID)
return $aFields;
}
/*
function getVarsGrid ()
function getVarsGrid ()
{
$aFields = array ();
$aFieldsNames = array ();
require_once 'classes/model/Dynaform.php';
$aFields = array ();
$aFieldsNames = array ();
require_once 'classes/model/Dynaform.php';
$aFields = new Dynaform();
//$aFields->getDynaformFields( $caseId );
$aFields->getDynaformFields( '45855056550a69a8cbeed24036053462' );
G::pr($aFields);
return $aFields;
return $aFields;
}
*/
function getVarsGrid ($proUid, $dynUid)
function getVarsGrid ($proUid, $dynUid)
{
G::LoadClass( 'dynaformhandler' );
G::LoadClass( 'AppSolr' );
G::LoadClass( 'AppSolr' );
$dynaformFields = array ();
$dynaformFields = array ();
if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) {
$dyn = new dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dynaformFields[] = $dyn->getFields();
}
if (is_file( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'.$dynUid. '.xml' ) && filesize( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/'. $proUid .'/'. $dynUid .'.xml' ) > 0) {
$dyn = new dynaFormHandler( PATH_DATA . '/sites/'. SYS_SYS .'/xmlForms/' .$proUid. '/' . $dynUid .'.xml' );
$dynaformFields[] = $dyn->getFields();
}
$dynaformFieldTypes = array ();
foreach ($dynaformFields as $aDynFormFields) {
foreach ($aDynFormFields as $field) {
foreach ($dynaformFields as $aDynFormFields) {
foreach ($aDynFormFields as $field) {
if ($field->getAttribute( 'validate' ) == 'Int') {
$dynaformFieldTypes[$field->nodeName] = 'Int';
} elseif ($field->getAttribute( 'validate' ) == 'Real') {
$dynaformFieldTypes[$field->nodeName] = 'Real';
} else {
$dynaformFieldTypes[$field->nodeName] = $field->getAttribute( 'type' );
}
}
if ($field->getAttribute( 'validate' ) == 'Int') {
$dynaformFieldTypes[$field->nodeName] = 'Int';
} elseif ($field->getAttribute( 'validate' ) == 'Real') {
$dynaformFieldTypes[$field->nodeName] = 'Real';
} else {
$dynaformFieldTypes[$field->nodeName] = $field->getAttribute( 'type' );
}
}
}
return $dynaformFieldTypes;
}

View File

@@ -553,34 +553,34 @@ try {
echo G::LoadTranslation($_REQUEST['prefix']);
break;
case 'getGridList':
G::LoadClass('xmlfield_InputPM');
$proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
$aFields = getGridsVars( $proUid );
case 'getGridList':
G::LoadClass('xmlfield_InputPM');
$proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
$aVariables = array();
foreach ($aFields as $key => $value){
$aFields = getGridsVars( $proUid );
$aVariables = array();
foreach ($aFields as $key => $value){
$aVariables[] = $aFields[$key];
}
echo Bootstrap::json_encode( $aVariables );
}
echo Bootstrap::json_encode( $aVariables );
break;
case 'getVariableGrid':
G::LoadClass('xmlfield_InputPM');
case 'getVariableGrid':
G::LoadClass('xmlfield_InputPM');
$proUid= isset( $_REQUEST['PRO_UID'] )?$_REQUEST['PRO_UID']:'';
$dynUid= isset( $_REQUEST['DYN_UID'] )?$_REQUEST['DYN_UID']:'';
$aFields = getVarsGrid($proUid, $dynUid);
$aFields = getVarsGrid($proUid, $dynUid);
$aVariables = array();
foreach ($aFields as $key => $value) {
$aVariables[] = $key;
}
echo Bootstrap::json_encode( $aVariables );
}
echo Bootstrap::json_encode( $aVariables );
break;
/*
case 'saveFile':