diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php
index 03085e35f..6b91b099b 100644
--- a/workflow/engine/controllers/pmTablesProxy.php
+++ b/workflow/engine/controllers/pmTablesProxy.php
@@ -334,7 +334,7 @@ class pmTablesProxy extends HttpProxyController
public function delete($httpData)
{
G::LoadClass('reportTables');
- $rows = G::json_decode($httpData->rows);
+ $rows = G::json_decode(stripslashes($httpData->rows));
$rp = new reportTables();
$at = new AdditionalTables();
@@ -403,7 +403,7 @@ class pmTablesProxy extends HttpProxyController
*/
public function dataCreate($httpData)
{
- $rows = G::json_decode($httpData->rows);
+ $rows = G::json_decode(stripslashes($httpData->rows));
require_once 'classes/model/AdditionalTables.php';
$oAdditionalTables = new AdditionalTables();
@@ -495,7 +495,7 @@ class pmTablesProxy extends HttpProxyController
require_once $sPath . $this->className . '.php';
- $rows = G::json_decode($httpData->rows);
+ $rows = G::json_decode(stripslashes($httpData->rows));
if (is_array($rows)) {
foreach($rows as $row) {
@@ -791,8 +791,8 @@ class pmTablesProxy extends HttpProxyController
{
require_once 'classes/model/AdditionalTables.php';
- $tablesToExport = json_decode(stripslashes($httpData->rows));
-
+ $tablesToExport = G::json_decode(stripslashes($httpData->rows));
+
try{
G::LoadCLass('net');
$net = new NET(G::getIpAddress());
diff --git a/workflow/engine/templates/pmTables/data.js b/workflow/engine/templates/pmTables/data.js
index 108ab4965..519f5b12a 100644
--- a/workflow/engine/templates/pmTables/data.js
+++ b/workflow/engine/templates/pmTables/data.js
@@ -291,13 +291,13 @@ NewPMTableRow = function(){
}
var row = new PMRow(new props);
- length = infoGrid.getStore().data.length;
+ len = infoGrid.getStore().data.length;
editor.stopEditing();
- store.insert(length, row);
+ store.insert(len, row);
infoGrid.getView().refresh();
- infoGrid.getSelectionModel().selectRow(length);
- editor.startEditing(length);
+ infoGrid.getSelectionModel().selectRow(len);
+ editor.startEditing(len);
};
//Load PM Table Edition Row Form
diff --git a/workflow/engine/templates/pmTables/edit.js b/workflow/engine/templates/pmTables/edit.js
index 15538e3e6..b82f312b9 100644
--- a/workflow/engine/templates/pmTables/edit.js
+++ b/workflow/engine/templates/pmTables/edit.js
@@ -280,10 +280,12 @@ Ext.onReady(function(){
},
afteredit: function(roweditor, rowIndex) {
row = assignedGrid.getSelectionModel().getSelected();
+ //if a column was set as PK so can't be null
if (row.get('field_key') == true) {
row.data.field_null = false;
- row.commit();
+
}
+ row.commit();
}
});
@@ -616,44 +618,50 @@ function createReportTable()
//validate columns count
if(allRows.getCount() == 0) {
- PMExt.error(_('ID_ERROR'), 'Set columns for this Report Table please.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT7'));
return false;
}
+ var fieldsNames = new Array();
- for (var r=0; r < allRows.getCount(); r++) {
- row = allRows.getAt(r);
+ for (var i = 0; i < allRows.getCount(); i++) {
+ row = allRows.getAt(i);
+
+ if (in_array(row.data['field_name'], fieldsNames)) {
+ PMExt.error(_('ID_ERROR'),_('ID_PMTABLES_ALERT1') + ' ' + row.data['field_name']+'');
+ return false;
+ }
// validate that fieldname is not empty
if(row.data['field_name'].trim() == '') {
- PMExt.error(_('ID_ERROR'), 'Field Name for all columns is required.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT2'));
return false;
}
if(row.data['field_label'].trim() == '') {
- PMExt.error(_('ID_ERROR'), 'Field Label for all columns is required.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT3'));
return false;
}
if (row.data['field_type'] == '') {
- PMExt.error(_('ID_ERROR'), 'Set a field type for '+row.data['field_name']+' please.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT4') + ' '+row.data['field_name']+'');
return false;
}
// validate field size for varchar & int column types
if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') {
- PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT5')+' '+row.data['field_name']+' ('+row.data['field_type']+').');
return false;
}
if (row.data['field_key']) {
hasSomePrimaryKey = true;
}
-
+ fieldsNames.push(row.data['field_name']);
columns.push(row.data);
}
if (!hasSomePrimaryKey) {
- PMExt.error(_('ID_ERROR'), 'You need set one column at least as Primary Key.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT6'));
return;
}
@@ -912,3 +920,11 @@ function loadTableRowsFromArray(records)
store.add(row);
}
}
+
+
+function in_array(needle, haystack) {
+ for(var i in haystack) {
+ if(haystack[i] == needle) return true;
+ }
+ return false;
+}
\ No newline at end of file
diff --git a/workflow/engine/templates/pmTables/editReport.js b/workflow/engine/templates/pmTables/editReport.js
index 29914497a..c0941226c 100644
--- a/workflow/engine/templates/pmTables/editReport.js
+++ b/workflow/engine/templates/pmTables/editReport.js
@@ -892,27 +892,33 @@ function createReportTable()
//validate columns count
if(allRows.getCount() == 0) {
- PMExt.error(_('ID_ERROR'), 'Set columns for this Report Table please.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT7'));
return false;
}
+ var fieldsNames = new Array();
for (var r=0; r < allRows.getCount(); r++) {
row = allRows.getAt(r);
+ if (in_array(row.data['field_name'], fieldsNames)) {
+ PMExt.error(_('ID_ERROR'),_('ID_PMTABLES_ALERT1') + ' ' + row.data['field_name']+'');
+ return false;
+ }
+
// validate that fieldname is not empty
if(row.data['field_name'].trim() == '') {
- PMExt.error(_('ID_ERROR'), 'Field Name for "'+row.data['field_dyn']+'" is required.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT2'));
return false;
}
if(row.data['field_label'].trim() == '') {
- PMExt.error(_('ID_ERROR'), 'Field Label for all columns is required.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT3'));
return false;
}
// validate field size for varchar & int column types
if ((row.data['field_type'] == 'VARCHAR' || row.data['field_type'] == 'INT') && row.data['field_size'] == '') {
- PMExt.error(_('ID_ERROR'), 'Set a field size for '+row.data['field_name']+' ('+row.data['field_type']+') please.');
+ PMExt.error(_('ID_ERROR'), _('ID_PMTABLES_ALERT5')+' '+row.data['field_name']+' ('+row.data['field_type']+').');
return false;
}
@@ -1305,4 +1311,11 @@ function verifyTableLimit()
return false;
}
return true;
+}
+
+function in_array(needle, haystack) {
+ for(var i in haystack) {
+ if(haystack[i] == needle) return true;
+ }
+ return false;
}
\ No newline at end of file