BUG 0000 PM tables ver 2. (performance improvements)
This commit is contained in:
@@ -330,6 +330,9 @@ class Form extends XmlForm
|
||||
$values["{$k}_label"] .= ($i != 0 ? '|': '') . $v->options[$value];
|
||||
} else {
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
if(trim($query) == '') {
|
||||
continue;
|
||||
}
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");//use default connection workflow if connection is not defined. Same as Dynaforms
|
||||
|
||||
@@ -361,6 +364,9 @@ class Form extends XmlForm
|
||||
$values["{$k}_label"] = $newValues["{$k}_label"] = $v->options[$newValues[$k]];
|
||||
} else {
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
if(trim($query) == '') {
|
||||
continue;
|
||||
}
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");
|
||||
$stmt = $con->prepareStatement($query);
|
||||
|
||||
@@ -37,6 +37,14 @@ class pmTables extends Controller
|
||||
|
||||
$this->setJSVar('_PLUGIN_SIMPLEREPORTS', $this->_getSimpleReportPluginDef());
|
||||
|
||||
if (isset($_SESSION['_cache_pmtables'])) {
|
||||
unset($_SESSION['_cache_pmtables']);
|
||||
}
|
||||
|
||||
if (isset($_SESSION['ADD_TAB_UID'])) {
|
||||
unset($_SESSION['ADD_TAB_UID']);
|
||||
}
|
||||
|
||||
//render content
|
||||
G::RenderPage('publish', 'extJs');
|
||||
}
|
||||
@@ -52,66 +60,21 @@ class pmTables extends Controller
|
||||
$table = false;
|
||||
$repTabPluginPermissions = false;
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables = new AdditionalTables();
|
||||
|
||||
if ($addTabUid !== false) { // if is a edit request
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
require_once 'classes/model/Fields.php';
|
||||
$tableFields = array();
|
||||
$fieldsList = array();
|
||||
|
||||
$table = $additionalTables->load($addTabUid, true);
|
||||
|
||||
// list the case fields
|
||||
foreach ($table['FIELDS'] as $i=>$field) {
|
||||
$table['FIELDS'][$i]['FLD_KEY'] = $field['FLD_KEY'] == '1' ? TRUE: FALSE;
|
||||
$table['FIELDS'][$i]['FLD_NULL'] = $field['FLD_NULL'] == '1' ? TRUE: FALSE;
|
||||
$table['FIELDS'][$i]['FLD_FILTER'] = $field['FLD_FILTER'] == '1' ? TRUE: FALSE;
|
||||
array_push($tableFields, $field['FLD_DYN_NAME']);
|
||||
}
|
||||
$_SESSION['ADD_TAB_UID'] = $addTabUid;
|
||||
|
||||
//list dynaform fields
|
||||
switch ($table['ADD_TAB_TYPE']) {
|
||||
case 'NORMAL':
|
||||
$fields = pmTablesProxy::_getDynafields($table['PRO_UID']);
|
||||
|
||||
foreach ($fields as $field) {
|
||||
//select to not assigned fields for available grid
|
||||
if (!in_array($field['name'], $tableFields)) {
|
||||
$fieldsList[] = array(
|
||||
'FIELD_UID' => $field['name'] . '-' . $field['type'],
|
||||
'FIELD_NAME' => $field['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
sort($fieldsList);
|
||||
$this->setJSVar('avFieldsList', $fieldsList);
|
||||
$repTabPluginPermissions = $this->_getSimpleReportPluginDef();
|
||||
$this->setJSVar('_plugin_permissions', $repTabPluginPermissions);
|
||||
break;
|
||||
|
||||
case 'GRID':
|
||||
list($gridName, $gridId) = explode('-', $table['ADD_TAB_GRID']);
|
||||
// $G_FORM = new Form($table['PRO_UID'] . '/' . $gridId, PATH_DYNAFORM, SYS_LANG, false);
|
||||
// $gridFields = $G_FORM->getVars(false);
|
||||
$fieldsList = array();
|
||||
$gridFields = pmTablesProxy::_getGridDynafields($table['PRO_UID'], $gridId);
|
||||
foreach ($gridFields as $gfield) {
|
||||
if (!in_array($gfield['name'], $tableFields)) {
|
||||
$fieldsList[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['type'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
sort($fieldsList);
|
||||
$this->setJSVar('avFieldsList', $fieldsList);
|
||||
$repTabPluginPermissions = $this->_getSimpleReportPluginDef();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
protected $className;
|
||||
protected $classPeerName;
|
||||
protected $dynUid;
|
||||
|
||||
/**
|
||||
* get pmtables list
|
||||
@@ -109,49 +110,68 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
$aFields['FIELDS'] = array();
|
||||
$aFields['PRO_UID'] = $httpData->PRO_UID;
|
||||
$dynFields = array();
|
||||
|
||||
if(isset($httpData->TYPE) && $httpData->TYPE == 'GRID') {
|
||||
$aProcessGridFields = Array();
|
||||
if (isset($httpData->GRID_UID)) {
|
||||
global $G_FORM;
|
||||
list($gridName, $gridId) = explode('-', $httpData->GRID_UID);
|
||||
$this->dynUid = $gridId;
|
||||
|
||||
$gridFields = $this->_getGridDynafields($httpData->PRO_UID, $gridId);
|
||||
|
||||
foreach ($gridFields as $gfield) {
|
||||
$aProcessGridFields[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['type'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
$httpData->textFilter = isset($httpData->textFilter) ? $httpData->textFilter : null;
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID'], 'grid', $httpData->start, $httpData->limit, $httpData->textFilter);
|
||||
}
|
||||
else {
|
||||
if (isset($_SESSION['_cache_pmtables'])) {
|
||||
unset($_SESSION['_cache_pmtables']);
|
||||
}
|
||||
} else {
|
||||
$gridFields = $this->_getGridFields($aFields['PRO_UID']);
|
||||
|
||||
foreach ($gridFields as $gfield) {
|
||||
$aProcessGridFields[] = array(
|
||||
$dynFields[] = array(
|
||||
'FIELD_UID' => $gfield['name'] . '-' . $gfield['xmlform'],
|
||||
'FIELD_NAME' => $gfield['name']
|
||||
);
|
||||
}
|
||||
}
|
||||
$resultList = $aProcessGridFields;
|
||||
|
||||
} else {
|
||||
$aProcessFields = Array();
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID']);
|
||||
|
||||
foreach ($dynFields as $dfield) {
|
||||
$aProcessFields[] = array(
|
||||
'FIELD_UID' => $dfield['name'] . '-' . $dfield['type'],
|
||||
'FIELD_NAME' => $dfield['name']
|
||||
);
|
||||
}
|
||||
$resultList = $aProcessFields;
|
||||
}
|
||||
else {
|
||||
$httpData->textFilter = isset($httpData->textFilter) ? $httpData->textFilter : null;
|
||||
$dynFields = $this->_getDynafields($aFields['PRO_UID'], 'xmlform', $httpData->start, $httpData->limit, $httpData->textFilter);
|
||||
}
|
||||
|
||||
sort($resultList);
|
||||
return $dynFields;
|
||||
}
|
||||
|
||||
return array('processFields'=>$resultList);
|
||||
public function updateAvDynafields($httpData)
|
||||
{
|
||||
$indexes = explode(',', $httpData->indexes);
|
||||
$fields = array();
|
||||
$httpData->isset = $httpData->isset=='true'? true: false;
|
||||
|
||||
if (isset($_SESSION['_cache_pmtables']) && $_SESSION['_cache_pmtables']['pro_uid']== $httpData->PRO_UID) {
|
||||
foreach ($indexes as $i) {
|
||||
if (is_numeric($i)) {
|
||||
if (isset($_SESSION['_cache_pmtables']['rows'][$i])) {
|
||||
$_SESSION['_cache_pmtables']['rows'][$i]['_isset'] = $httpData->isset;
|
||||
if ($httpData->isset) {
|
||||
$_SESSION['_cache_pmtables']['count']++;
|
||||
} else {
|
||||
$_SESSION['_cache_pmtables']['count']--;
|
||||
}
|
||||
|
||||
$fields[] = $_SESSION['_cache_pmtables']['rows'][$i]['FIELD_NAME'];
|
||||
}
|
||||
} else {
|
||||
|
||||
$index = $_SESSION['_cache_pmtables']['indexes'][$i];
|
||||
$_SESSION['_cache_pmtables']['rows'][$index]['_isset'] = $httpData->isset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -813,7 +833,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
* @param $proUid
|
||||
* @param $type [values:xmlform/grid]
|
||||
*/
|
||||
function _getDynafields($proUid, $type = 'xmlform')
|
||||
function _getDynafields2($proUid, $type = 'xmlform')
|
||||
{
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$fields = array();
|
||||
@@ -856,6 +876,122 @@ class pmTablesProxy extends HttpProxyController
|
||||
return $fields;
|
||||
}
|
||||
|
||||
function _getDynafields($proUid, $type = 'xmlform', $start=null, $limit=null, $filter=null)
|
||||
{
|
||||
$cache = 1;
|
||||
if (!isset($_SESSION['_cache_pmtables']) || (isset($_SESSION['_cache_pmtables']) && $_SESSION['_cache_pmtables']['pro_uid'] != $proUid)) {
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
$cache = 0;
|
||||
$fields = array();
|
||||
$fieldsNames = array();
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $proUid);
|
||||
$oCriteria->add(DynaformPeer::DYN_TYPE, $type);
|
||||
|
||||
|
||||
if (isset($this->dynUid)) {
|
||||
$oCriteria->add(DynaformPeer::DYN_UID, $this->dynUid);
|
||||
}
|
||||
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
$excludeFieldsList = array('title', 'subtitle', 'link', 'file', 'button', 'reset', 'submit',
|
||||
'listbox', 'checkgroup', 'grid', 'javascript');
|
||||
|
||||
$labelFieldsTypeList = array('dropdown', 'radiogroup');
|
||||
G::loadSystem('dynaformhandler');
|
||||
$index = 0;
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if (file_exists(PATH_DYNAFORM . PATH_SEP . $aRow['DYN_FILENAME'] . '.xml')) {
|
||||
$dynaformHandler = new dynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME']. '.xml');
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach($nodeFieldsList as $node) {
|
||||
$arrayNode = $dynaformHandler->getArray($node);
|
||||
$fieldName = $arrayNode['__nodeName__'];
|
||||
$fieldType = $arrayNode['type'];
|
||||
|
||||
if (!in_array($fieldType, $excludeFieldsList) && !in_array($fieldName, $fieldsNames)) {
|
||||
$fields[] = array(
|
||||
'FIELD_UID' => $fieldName . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName,
|
||||
'_index' => $index++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
|
||||
if (in_array($fieldType, $labelFieldsTypeList) && !in_array($fieldName . '_label', $fieldsNames)) {
|
||||
$fields[] = array(
|
||||
'FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,
|
||||
'FIELD_NAME' => $fieldName . '_label',
|
||||
'_index' => $index++,
|
||||
'_isset' => true
|
||||
);
|
||||
$fieldsNames[] = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
sort($fields);
|
||||
|
||||
// if is a editing
|
||||
$fieldsEdit = array();
|
||||
if (isset($_SESSION['ADD_TAB_UID'])) {
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$table = $additionalTables->load($_SESSION['ADD_TAB_UID'], true);
|
||||
|
||||
foreach ($table['FIELDS'] as $i=>$field) {
|
||||
array_push($fieldsEdit, $field['FLD_DYN_NAME']);
|
||||
}
|
||||
}//end editing
|
||||
|
||||
foreach($fields as $i => $field) {
|
||||
$fields[$i]['_index'] = $i;
|
||||
$indexes[$field['FIELD_NAME']] = $i;
|
||||
|
||||
if(in_array($field['FIELD_NAME'], $fieldsEdit)) {
|
||||
$fields[$i]['_isset'] = false;
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION['_cache_pmtables']['pro_uid'] = $proUid;
|
||||
$_SESSION['_cache_pmtables']['rows'] = $fields;
|
||||
$_SESSION['_cache_pmtables']['count'] = count($fields);
|
||||
$_SESSION['_cache_pmtables']['indexes'] = $indexes;
|
||||
} //end reload
|
||||
|
||||
$fields = array();
|
||||
$tmp = array();
|
||||
|
||||
foreach ($_SESSION['_cache_pmtables']['rows'] as $i => $row) {
|
||||
if (isset($filter) && $filter != '') {
|
||||
if ($row['_isset'] && stripos($row['FIELD_NAME'], $filter) !== false) {
|
||||
$tmp[] = $row;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ($row['_isset']) {
|
||||
$tmp[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields = array_slice($tmp, $start, $limit);
|
||||
|
||||
return array('cache'=>$cache, 'count'=>count($tmp), 'rows'=>$fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all dynaform grid fields from a process
|
||||
* @param $proUid
|
||||
@@ -895,27 +1031,38 @@ class pmTablesProxy extends HttpProxyController
|
||||
*/
|
||||
function _getGridFields($proUid)
|
||||
{
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
G::loadSystem('dynaformhandler');
|
||||
$aFields = array();
|
||||
$aFieldsNames = array();
|
||||
require_once 'classes/model/Dynaform.php';
|
||||
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->addSelectColumn(DynaformPeer::DYN_FILENAME);
|
||||
$oCriteria->add(DynaformPeer::PRO_UID, $proUid);
|
||||
$oCriteria->add(DynaformPeer::DYN_TYPE, 'xmlform');
|
||||
$oDataset = DynaformPeer::doSelectRS($oCriteria);
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
if ($G_FORM->type == 'xmlform') {
|
||||
foreach($G_FORM->fields as $k => $v) {
|
||||
if ($v->type == 'grid') {
|
||||
if (!in_array($k, $aFieldsNames)) {
|
||||
$aFields[] = array('name' => $k, 'xmlform' => str_replace($proUid . '/', '', $v->xmlGrid));
|
||||
$aFieldsNames[] = $k;
|
||||
}
|
||||
//$G_FORM = new Form($aRow['DYN_FILENAME'], PATH_DYNAFORM, SYS_LANG);
|
||||
$dynaformHandler = new dynaformHandler(PATH_DYNAFORM . $aRow['DYN_FILENAME']. '.xml');
|
||||
$nodeFieldsList = $dynaformHandler->getFields();
|
||||
|
||||
foreach($nodeFieldsList as $node) {
|
||||
$arrayNode = $dynaformHandler->getArray($node);
|
||||
$fieldName = $arrayNode['__nodeName__'];
|
||||
$fieldType = $arrayNode['type'];
|
||||
|
||||
if ($fieldType == 'grid') {
|
||||
|
||||
if (!in_array($fieldName, $aFieldsNames)) {
|
||||
$aFields[] = array('name' => $fieldName, 'xmlform' => str_replace($proUid . '/', '', $arrayNode['xmlgrid']));
|
||||
$aFieldsNames[] = $fieldName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aFields;
|
||||
|
||||
@@ -2,6 +2,7 @@ var PROCESSMAP_STEP_EDIT = false;
|
||||
var PROCESSMAP_USER_EDIT = false;
|
||||
|
||||
var processmapOutputsPanel;
|
||||
var _client = getClientWindowSize();
|
||||
|
||||
var processmap=function(){
|
||||
this.data={
|
||||
@@ -23,8 +24,8 @@ var processmap=function(){
|
||||
Hx = 460;
|
||||
|
||||
if(lanzado=='reportTables'){
|
||||
Wx = 800;
|
||||
Hx = 600;
|
||||
Wx = _client.width-20; //900;
|
||||
Hx = _client.height-15; //600;
|
||||
}
|
||||
|
||||
var bbk = {
|
||||
@@ -163,8 +164,8 @@ var processmap=function(){
|
||||
iframe.setAttribute('id','reportTablesIframe');
|
||||
iframe.src = '../pmTables?PRO_UID=' + this.options.uid;
|
||||
iframe.style.border='0px';
|
||||
iframe.style.width='786px';
|
||||
iframe.style.height='564px';
|
||||
iframe.style.width=_client.width-36;//'886px';
|
||||
iframe.style.height=_client.height-60;//'564px';
|
||||
panel.addContent(iframe);
|
||||
}.extend(this),
|
||||
dynaforms:function(){
|
||||
|
||||
@@ -16,9 +16,12 @@ var assignAllButton;
|
||||
var removeButton;
|
||||
var removeAllButton;
|
||||
var tmp1 = new Array();
|
||||
var pageSize = 50;
|
||||
var mainMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
|
||||
var bbarpaging;
|
||||
//main
|
||||
Ext.onReady(function(){
|
||||
|
||||
mainMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
|
||||
var fm = Ext.form;
|
||||
var fieldsCount = 0;
|
||||
|
||||
@@ -28,15 +31,31 @@ Ext.onReady(function(){
|
||||
url: '../pmTablesProxy/getDynafields'
|
||||
}),
|
||||
reader : new Ext.data.JsonReader( {
|
||||
root: 'processFields',
|
||||
fields : [{name : 'FIELD_UID'}, {name : 'FIELD_NAME'}]
|
||||
root: 'rows',
|
||||
totalProperty: 'count',
|
||||
fields : [
|
||||
{name : 'FIELD_UID'},
|
||||
{name : 'FIELD_NAME'},
|
||||
{name : '_index'},
|
||||
{name : '_isset'}
|
||||
]
|
||||
}),
|
||||
listeners: {
|
||||
load: function() {
|
||||
|
||||
Ext.getCmp('availableGrid').store.sort();
|
||||
storeA.setBaseParam('PRO_UID', (PRO_UID !== false? PRO_UID : Ext.getCmp('PROCESS').getValue()));
|
||||
mainMask.hide();
|
||||
assignedGrid._setTitle();
|
||||
}
|
||||
}
|
||||
},
|
||||
baseParams: {
|
||||
PRO_UID: ''
|
||||
},
|
||||
remoteSort: false
|
||||
});
|
||||
|
||||
storeA.setDefaultSort('FIELD_NAME', 'asc');
|
||||
|
||||
//column model for available fields grid
|
||||
cmodelA = new Ext.grid.ColumnModel({
|
||||
defaults: {
|
||||
@@ -49,6 +68,14 @@ Ext.onReady(function(){
|
||||
dataIndex: 'FIELD_UID',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
}, {
|
||||
dataIndex:'_index',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
}, {
|
||||
dataIndex:'_isset',
|
||||
hidden:true,
|
||||
hideable:false
|
||||
}, {
|
||||
header : _("ID_DYNAFORM_FIELDS"),
|
||||
dataIndex : 'FIELD_NAME',
|
||||
@@ -69,6 +96,43 @@ Ext.onReady(function(){
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
storePageSize = new Ext.data.SimpleStore({
|
||||
fields: ['size'],
|
||||
data: [['20'],['30'],['40'],['50'],['100']],
|
||||
autoLoad: true
|
||||
});
|
||||
|
||||
comboPageSize = new Ext.form.ComboBox({
|
||||
typeAhead : false,
|
||||
mode : 'local',
|
||||
triggerAction : 'all',
|
||||
store: storePageSize,
|
||||
valueField: 'size',
|
||||
displayField: 'size',
|
||||
width: 50,
|
||||
editable: false,
|
||||
listeners:{
|
||||
select: function(c,d,i){
|
||||
//UpdatePageConfig(d.data['size']);
|
||||
bbarpaging.pageSize = parseInt(d.data['size']);
|
||||
bbarpaging.moveFirst();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
comboPageSize.setValue(pageSize);
|
||||
|
||||
bbarpaging = new Ext.PagingToolbar({
|
||||
pageSize: pageSize,
|
||||
store: storeA,
|
||||
displayInfo: true,
|
||||
displayMsg: '{0} - {1} of {2}',
|
||||
emptyMsg: 'No records'/*,
|
||||
items: ['-',_('ID_PAGE_SIZE')+':',comboPageSize]*/
|
||||
});
|
||||
|
||||
//grid for table columns grid
|
||||
availableGrid = new Ext.grid.GridPanel({
|
||||
layout : 'fit',
|
||||
@@ -80,7 +144,7 @@ Ext.onReady(function(){
|
||||
autoWidth : true,
|
||||
stripeRows : true,
|
||||
height : 100,
|
||||
width : 200,
|
||||
width : '25%',
|
||||
stateful : true,
|
||||
stateId : 'grid',
|
||||
enableHdMenu : false,
|
||||
@@ -89,11 +153,50 @@ Ext.onReady(function(){
|
||||
cm : cmodelA,
|
||||
sm : smodelA,
|
||||
store : storeA,
|
||||
//loadMask: {message:'Loading...'},
|
||||
listeners : {
|
||||
rowdblclick: AssignFieldsAction
|
||||
}
|
||||
},
|
||||
tbar: [
|
||||
'->',
|
||||
{
|
||||
xtype: 'textfield',
|
||||
id: 'searchTxt',
|
||||
ctCls:'pm_search_text_field',
|
||||
allowBlank: true,
|
||||
width: 150,
|
||||
emptyText: _('ID_ENTER_SEARCH_TERM'),
|
||||
listeners: {
|
||||
specialkey: function(f,e){
|
||||
if (e.getKey() == e.ENTER) {
|
||||
filterAvFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'X',
|
||||
ctCls:'pm_search_x_button',
|
||||
handler: function(){
|
||||
Ext.getCmp('searchTxt').setValue('');
|
||||
filterAvFields();
|
||||
}
|
||||
}, {
|
||||
text: 'Filter',
|
||||
handler: function(){
|
||||
filterAvFields();
|
||||
}
|
||||
}
|
||||
],
|
||||
bbar: bbarpaging
|
||||
});
|
||||
|
||||
var filterAvFields = function() {
|
||||
//availableGrid.store.load({params: {textFilter: Ext.getCmp('searchTxt').getValue()}});
|
||||
//storeA.setParam('textFilter', Ext.getCmp('searchTxt').getValue());
|
||||
storeA.reload({params: {textFilter: Ext.getCmp('searchTxt').getValue(), start: bbarpaging.cursor, limit: pageSize}});
|
||||
}
|
||||
|
||||
//selecion model for table columns grid
|
||||
sm = new Ext.grid.RowSelectionModel({
|
||||
selectSingle: false,
|
||||
@@ -106,8 +209,9 @@ Ext.onReady(function(){
|
||||
break;
|
||||
case 1:
|
||||
var record = Ext.getCmp('assignedGrid').getSelectionModel().getSelected();
|
||||
Ext.getCmp('removeButton').enable();
|
||||
|
||||
if (record.data.field_dyn == '' && record.data.field_name != 'APP_UID' && record.data.field_name != 'APP_NUMBER' && record.data.field_name != 'ROW') {
|
||||
if (record.data.field_dyn != '' && record.data.field_name != 'APP_UID' && record.data.field_name != 'APP_NUMBER' && record.data.field_name != 'ROW') {
|
||||
Ext.getCmp('removeColumn').enable();
|
||||
}
|
||||
break;
|
||||
@@ -133,6 +237,14 @@ Ext.onReady(function(){
|
||||
dataIndex: 'uid',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
dataIndex: '_index',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
dataIndex: '_isset',
|
||||
hidden: true
|
||||
},
|
||||
{
|
||||
id: 'field_uid',
|
||||
dataIndex: 'field_uid',
|
||||
@@ -247,6 +359,8 @@ Ext.onReady(function(){
|
||||
store = new Ext.data.ArrayStore({
|
||||
fields: [
|
||||
{name: 'uid', type: 'string'},
|
||||
{name: '_index'},
|
||||
{name: '_isset'},
|
||||
{name: 'field_uid', type: 'string'},
|
||||
{name: 'field_key', type: 'string'},
|
||||
{name: 'field_name', type: 'string'},
|
||||
@@ -276,7 +390,7 @@ Ext.onReady(function(){
|
||||
|
||||
//table columns grid
|
||||
assignedGrid = new Ext.grid.GridPanel({
|
||||
//title: 'Columns',
|
||||
title: 'New Report Table',
|
||||
region : 'center',
|
||||
id : 'assignedGrid',
|
||||
ddGroup : 'availableGridDDGroup',
|
||||
@@ -286,6 +400,7 @@ Ext.onReady(function(){
|
||||
sm : sm,
|
||||
store : store,
|
||||
plugins : [editor, checkColumn],
|
||||
loadMask: {message:'Loading...'},
|
||||
tbar : [
|
||||
{
|
||||
icon: '/images/add-row-after.png',
|
||||
@@ -333,6 +448,9 @@ Ext.onReady(function(){
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
_setTitle: function() {
|
||||
this.setTitle('Report Table: ' + Ext.getCmp('REP_TAB_NAME').getValue() + ' ('+store.getCount()+' columns)');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -497,7 +615,7 @@ Ext.onReady(function(){
|
||||
gridsListStore = new Ext.data.Store({
|
||||
//autoLoad: true,
|
||||
proxy : new Ext.data.HttpProxy({
|
||||
url: '../pmTablesProxy/availableFieldsReportTables',
|
||||
url: '../pmTablesProxy/getDynafields',
|
||||
method : 'POST'
|
||||
}),
|
||||
baseParams : {
|
||||
@@ -505,7 +623,7 @@ Ext.onReady(function(){
|
||||
TYPE: 'GRID'
|
||||
},
|
||||
reader : new Ext.data.JsonReader( {
|
||||
root : 'processFields',
|
||||
//root : 'processFields',
|
||||
fields : [{name : 'FIELD_UID'}, {name : 'FIELD_NAME'}]
|
||||
}),
|
||||
listeners: {
|
||||
@@ -595,9 +713,11 @@ Ext.onReady(function(){
|
||||
comboDbConnections.getStore().reload({params:{PRO_UID : Ext.getCmp('PROCESS').getValue()}});
|
||||
|
||||
// loading available fields
|
||||
//if (TABLE.ADD_TAB_TYPE == 'NORMAL') {
|
||||
loadAvFieldsFromArray(avFieldsList);
|
||||
//}
|
||||
//loadAvFieldsFromArray(avFieldsList);
|
||||
if (TABLE.ADD_TAB_TYPE == 'GRID')
|
||||
loadFieldsGrids();
|
||||
else
|
||||
loadFieldNormal();
|
||||
|
||||
// loading table fields
|
||||
loadTableRowsFromArray(TABLE.FIELDS);
|
||||
@@ -662,7 +782,8 @@ Ext.onReady(function(){
|
||||
style:'text-transform: uppercase',
|
||||
listeners:{
|
||||
change: function(){
|
||||
this.setValue(this.getValue().toUpperCase())
|
||||
this.setValue(this.getValue().toUpperCase());
|
||||
assignedGrid._setTitle();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -746,7 +867,8 @@ Ext.onReady(function(){
|
||||
}
|
||||
|
||||
if (TABLE === false) {
|
||||
loadFieldNormal();
|
||||
if(TABLE.ADD_TAB_TYPE != 'GRID')
|
||||
loadFieldNormal();
|
||||
} //else if(typeof avFieldsList != 'undefined')
|
||||
//loadAvFieldsFromArray(avFieldsList);
|
||||
|
||||
@@ -845,6 +967,10 @@ function createReportTable()
|
||||
//add custon column for assignedGrid
|
||||
function addColumn()
|
||||
{
|
||||
if (!verifyTableLimit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
@@ -877,100 +1003,45 @@ function removeColumn()
|
||||
////ASSIGNBUTON FUNCTIONALITY
|
||||
AssignFieldsAction = function(){
|
||||
records = Ext.getCmp('availableGrid').getSelectionModel().getSelections();
|
||||
|
||||
for(i=0; i < records.length; i++){
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
field_uid : records[i].data['FIELD_UID'],
|
||||
field_dyn : records[i].data['FIELD_NAME'],
|
||||
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_type : meta.type,
|
||||
field_size : meta.size,
|
||||
field_key : 0,
|
||||
field_null : 1
|
||||
});
|
||||
|
||||
store.add(row);
|
||||
}
|
||||
|
||||
//remove from source grid
|
||||
Ext.each(records, Ext.getCmp('availableGrid').store.remove, Ext.getCmp('availableGrid').store);
|
||||
setReportFields(records);
|
||||
};
|
||||
|
||||
//RemoveButton Functionality
|
||||
RemoveFieldsAction = function(){
|
||||
|
||||
records = Ext.getCmp('assignedGrid').getSelectionModel().getSelections();
|
||||
var PMRow = availableGrid.getStore().recordType;
|
||||
for(i=0; i < records.length; i++){
|
||||
if (records[i].data['field_dyn'] != '' && records[i].data['field_name'] != 'APP_UID' && records[i].data['field_name'] != 'APP_NUMBER' && records[i].data['field_name'] != 'ROW') {
|
||||
var row = new PMRow({
|
||||
FIELD_UID : records[i].data['field_uid'],
|
||||
FIELD_NAME : records[i].data['field_dyn']
|
||||
});
|
||||
availableGrid.getStore().add(row);
|
||||
} else {
|
||||
records[i] = null;
|
||||
}
|
||||
}
|
||||
//remove from source grid
|
||||
Ext.each(records, Ext.getCmp('assignedGrid').store.remove, Ext.getCmp('assignedGrid').store);
|
||||
unsetReportFields(records);
|
||||
};
|
||||
|
||||
//AssignALLButton Functionality
|
||||
AssignAllFieldsAction = function(){
|
||||
var available = Ext.getCmp('availableGrid');
|
||||
var allRows = available.getStore();
|
||||
var arrAux = new Array();
|
||||
records = new Array()
|
||||
var avStore = Ext.getCmp('availableGrid').getStore();
|
||||
var records = new Array();
|
||||
|
||||
if (allRows.getCount() > 0){
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
for (i=0; i < allRows.getCount(); i++){
|
||||
records[i] = allRows.getAt(i);
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
field_uid : records[i].data['FIELD_UID'],
|
||||
field_dyn : records[i].data['FIELD_NAME'],
|
||||
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_type : meta.type,
|
||||
field_size : meta.size,
|
||||
field_key : 0,
|
||||
field_null : 1
|
||||
});
|
||||
|
||||
store.add(row);
|
||||
if (avStore.getCount() > 0){
|
||||
for (i=0; i < avStore.getCount(); i++){
|
||||
records[i] = avStore.getAt(i);
|
||||
}
|
||||
//remove from source grid
|
||||
Ext.each(records, Ext.getCmp('availableGrid').store.remove, Ext.getCmp('availableGrid').store);
|
||||
setReportFields(records);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
//RevomeALLButton Functionality
|
||||
RemoveAllFieldsAction = function(){
|
||||
|
||||
if (store.getCount() > 100) {
|
||||
PMExt.info('Notice', 'This action was disabled to prevent low performance on your browser. This is because there is more than 100 records on the columns definition grid. <br/><br/>Please perform this action with manual selection only.');
|
||||
return ;
|
||||
}
|
||||
|
||||
var allRows = Ext.getCmp('assignedGrid').getStore();
|
||||
var records = new Array();
|
||||
if (allRows.getCount() > 0) {
|
||||
var PMRow = availableGrid.getStore().recordType;
|
||||
for (var i=0; i < allRows.getCount(); i++){
|
||||
records[i] = allRows.getAt(i);
|
||||
if (records[i].data['field_dyn'] != '' && records[i].data['field_name'] != 'APP_UID' && records[i].data['field_name'] != 'APP_NUMBER' && records[i].data['field_name'] != 'ROW') {
|
||||
var row = new PMRow({
|
||||
FIELD_UID : records[i].data['field_uid'],
|
||||
FIELD_NAME : records[i].data['field_dyn']
|
||||
});
|
||||
availableGrid.getStore().add(row);
|
||||
} else {
|
||||
records[i] = null;
|
||||
}
|
||||
}
|
||||
//remove from source grid
|
||||
Ext.each(records, Ext.getCmp('assignedGrid').store.remove, Ext.getCmp('assignedGrid').store);
|
||||
unsetReportFields(records);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -980,7 +1051,9 @@ loadFieldNormal = function(){
|
||||
Ext.getCmp('availableGrid').store.load({
|
||||
params: {
|
||||
action: "getDynafields",
|
||||
PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue()
|
||||
PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue(),
|
||||
start: 0,
|
||||
limit: pageSize
|
||||
}
|
||||
});
|
||||
Ext.getCmp('assignedGrid').store.removeAll();
|
||||
@@ -995,7 +1068,9 @@ loadFieldsGrids = function(){
|
||||
action: "getDynafields",
|
||||
PRO_UID: PRO_UID !== false ? PRO_UID : Ext.getCmp('PROCESS').getValue(),
|
||||
TYPE: 'GRID',
|
||||
GRID_UID: Ext.getCmp('REP_TAB_GRID').getValue()
|
||||
GRID_UID: Ext.getCmp('REP_TAB_GRID').getValue(),
|
||||
start: 0,
|
||||
limit: pageSize
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1023,28 +1098,8 @@ var DDLoadFields = function(){
|
||||
var availableGridDropTarget = new Ext.dd.DropTarget(availableGridDropTargetEl, {
|
||||
ddGroup : 'availableGridDDGroup',
|
||||
notifyDrop : function(ddSource, e, data){
|
||||
|
||||
var records = ddSource.dragData.selections;
|
||||
var PMRow = availableGrid.getStore().recordType;
|
||||
|
||||
for (i=0; i < records.length; i++) {
|
||||
if (records[i].data['field_dyn'] != '') {
|
||||
var row = new PMRow({
|
||||
FIELD_UID: records[i].data['field_uid'],
|
||||
FIELD_NAME: records[i].data['field_dyn']
|
||||
});
|
||||
availableGrid.getStore().add(row);
|
||||
} else {
|
||||
if ( records[i].data['field_name'] == 'APP_UID'
|
||||
|| records[i].data['field_name'] == 'APP_NUMBER'
|
||||
|| records[i].data['field_name'] == 'ROW')
|
||||
{
|
||||
records[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ext.each(records, ddSource.grid.store.remove, ddSource.grid.store);
|
||||
unsetReportFields(records);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@@ -1054,37 +1109,104 @@ var DDLoadFields = function(){
|
||||
var assignedGridDropTarget = new Ext.dd.DropTarget(assignedGridDropTargetEl, {
|
||||
ddGroup : 'assignedGridDDGroup',
|
||||
notifyDrop : function(ddSource, e, data){
|
||||
|
||||
var records = ddSource.dragData.selections;
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
|
||||
//add on target grid
|
||||
for (i=0; i < records.length; i++){
|
||||
//arrAux[r] = records[r].data['FIELD_UID'];
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
field_uid : records[i].data['FIELD_UID'],
|
||||
field_dyn : records[i].data['FIELD_NAME'],
|
||||
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_type : meta.type,
|
||||
field_size : meta.size,
|
||||
field_key : 0,
|
||||
field_null : 1
|
||||
});
|
||||
|
||||
store.add(row);
|
||||
}
|
||||
//remove from source grid
|
||||
Ext.each(records, availableGrid.store.remove, availableGrid.store);
|
||||
|
||||
setReportFields(ddSource.dragData.selections)
|
||||
return true;
|
||||
}
|
||||
});
|
||||
//sw_func_groups = true;
|
||||
};
|
||||
|
||||
function setReportFields(records) {
|
||||
mainMask.show();
|
||||
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
var indexes = new Array();
|
||||
|
||||
for (i=0; i < records.length; i++) {
|
||||
if (!verifyTableLimit()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
|
||||
var row = new PMRow({
|
||||
uid : '',
|
||||
field_uid : records[i].data['FIELD_UID'],
|
||||
field_dyn : records[i].data['FIELD_NAME'],
|
||||
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
|
||||
field_type : meta.type,
|
||||
field_size : meta.size,
|
||||
field_key : 0,
|
||||
field_null : 1,
|
||||
_index : records[i].data['_index'] ? records[i].data['_index'] : records[i].data['FIELD_DYN']
|
||||
});
|
||||
|
||||
store.add(row);
|
||||
indexes.push(records[i].data['_index']);
|
||||
}
|
||||
|
||||
//remove from source grid
|
||||
Ext.each(records, availableGrid.store.remove, availableGrid.store);
|
||||
|
||||
//update on server
|
||||
Ext.Ajax.request({
|
||||
url: '../pmTablesProxy/updateAvDynafields',
|
||||
params: {
|
||||
PRO_UID : PRO_UID !== false? PRO_UID : Ext.getCmp('PROCESS').getValue(),
|
||||
indexes : indexes.join(','),
|
||||
isset : false
|
||||
},
|
||||
success: function(resp){
|
||||
result = Ext.util.JSON.decode(resp.responseText);
|
||||
availableGrid.store.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function unsetReportFields(records) {
|
||||
mainMask.show();
|
||||
|
||||
var PMRow = availableGrid.getStore().recordType;
|
||||
var indexes = new Array();
|
||||
|
||||
for (i=0; i < records.length; i++) {
|
||||
if (records[i].data['field_dyn'] != '') {
|
||||
var row = new PMRow({
|
||||
FIELD_UID: records[i].data['field_uid'],
|
||||
FIELD_NAME: records[i].data['field_dyn']
|
||||
});
|
||||
availableGrid.getStore().add(row);
|
||||
ix = records[i].data['_index'] != '' ? records[i].data['_index'] : records[i].data['field_dyn']
|
||||
indexes.push(ix);
|
||||
} else {
|
||||
if ( records[i].data['field_name'] == 'APP_UID'
|
||||
|| records[i].data['field_name'] == 'APP_NUMBER'
|
||||
|| records[i].data['field_name'] == 'ROW')
|
||||
{
|
||||
records[i] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ext.each(records, assignedGrid.store.remove, assignedGrid.store);
|
||||
|
||||
//update on server
|
||||
Ext.Ajax.request({
|
||||
url: '../pmTablesProxy/updateAvDynafields',
|
||||
params: {
|
||||
PRO_UID : PRO_UID !== false? PRO_UID : Ext.getCmp('PROCESS').getValue(),
|
||||
indexes : indexes.join(','),
|
||||
isset : true
|
||||
},
|
||||
success: function(resp){
|
||||
result = Ext.util.JSON.decode(resp.responseText);
|
||||
availableGrid.store.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function loadTableRowsFromArray(records)
|
||||
{
|
||||
var PMRow = assignedGrid.getStore().recordType;
|
||||
@@ -1101,7 +1223,8 @@ function loadTableRowsFromArray(records)
|
||||
field_size : records[i].FLD_SIZE,
|
||||
field_key : records[i].FLD_KEY,
|
||||
field_null : records[i].FLD_NULL,
|
||||
field_filter: records[i].FLD_FILTER == '1' ? true : false
|
||||
field_filter: records[i].FLD_FILTER == '1' ? true : false,
|
||||
_index : ''
|
||||
});
|
||||
|
||||
store.add(row);
|
||||
@@ -1183,3 +1306,15 @@ Ext.override(Ext.form.TextField, {
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function verifyTableLimit()
|
||||
{
|
||||
if( store.getCount() >= 255 ) {
|
||||
mainMask.hide();
|
||||
PMExt.info('Notice', 'The maximun limit of columns for a database table is 255, you already have them defined!');
|
||||
assignedGrid._setTitle();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user