BUG 0000 PMTables improving data edit UI
- data row editor improved, how for each type the field editor is diamic for date, numeric, and text - hard coded labels completed
This commit is contained in:
@@ -409,7 +409,6 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
if (count($row) > 0) {
|
||||
eval('$con = Propel::getConnection('.$this->classPeerName.'::DATABASE_NAME);');
|
||||
$con->begin();
|
||||
$obj->fromArray($row, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
if ($obj->validate()) {
|
||||
@@ -423,6 +422,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
}
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($obj->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "\n";
|
||||
}
|
||||
@@ -460,6 +460,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
$oAdditionalTables = new AdditionalTables();
|
||||
$table = $oAdditionalTables->load($httpData->id, true);
|
||||
$primaryKeys = $oAdditionalTables->getPrimaryKeys('keys');
|
||||
$this->className = $table['ADD_TAB_CLASS_NAME'];
|
||||
$this->classPeerName = $this->className . 'Peer';
|
||||
$sPath = PATH_DB . SYS_SYS . PATH_SEP . 'classes' . PATH_SEP;
|
||||
@@ -474,15 +475,17 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
if (is_array($rows)) {
|
||||
foreach($rows as $row) {
|
||||
$result = $this->_dataUpdate($row);
|
||||
$row = (array) $row;
|
||||
$result = $this->_dataUpdate($row, $primaryKeys);
|
||||
}
|
||||
}
|
||||
else { //then is object
|
||||
$result = $this->_dataUpdate($rows);
|
||||
$row = (array) $rows;
|
||||
$result = $this->_dataUpdate($row, $primaryKeys);
|
||||
}
|
||||
|
||||
$this->success = $result;
|
||||
$this->message = $result ? 'Updated Successfully' : 'Error Updating record';
|
||||
$this->message = $result ? G::loadTranslation('ID_UPDATED_SUCCESSFULLY') : G::loadTranslation('ID_UPDATE_FAILED');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -505,7 +508,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
require_once $sPath . $this->className . '.php';
|
||||
|
||||
$this->success = $this->_dataDestroy($httpData->rows);
|
||||
$this->message = $this->success ? 'Deleted Successfully' : 'Error Deleting record';
|
||||
$this->message = $this->success ? G::loadTranslation('ID_DELETED_SUCCESSFULLY') : G::loadTranslation('ID_DELETE_FAILED');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -564,7 +567,7 @@ class pmTablesProxy extends HttpProxyController
|
||||
$this->message = $sErrorMessages;
|
||||
} else {
|
||||
$this->success = true;
|
||||
$this->message = 'File Imported "'.$filename.'" Successfully';
|
||||
$this->message = G::loadTranslation('ID_FILE_IMPORTED_SUCCESSFULLY', array($filename));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1035,11 +1038,11 @@ class pmTablesProxy extends HttpProxyController
|
||||
* Update data from a addTable record
|
||||
* @param $row
|
||||
*/
|
||||
function _dataUpdate($row)
|
||||
function _dataUpdate($row, $primaryKeys)
|
||||
{
|
||||
$keys = G::decrypt($row->__index__, 'pmtable');
|
||||
$keys = G::decrypt($row['__index__'], 'pmtable');
|
||||
$keys = explode('-', $keys);
|
||||
unset($row->__index__);
|
||||
unset($row['__index__']);
|
||||
|
||||
$params = array();
|
||||
|
||||
@@ -1052,16 +1055,31 @@ class pmTablesProxy extends HttpProxyController
|
||||
|
||||
if (is_object($obj)) {
|
||||
foreach ($row as $key => $value) {
|
||||
// validation, don't modify primary keys
|
||||
if (in_array($key, $primaryKeys)) {
|
||||
throw new Exception(G::loadTranslation('ID_DONT_MODIFY_PK_VALUE', array($key)));
|
||||
}
|
||||
$action = 'set' . AdditionalTables::getPHPName($key);
|
||||
$obj->$action($value);
|
||||
}
|
||||
$obj->save();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
$this->success = false;
|
||||
$this->message = 'Update Failed';
|
||||
if ($r = $obj->validate()) {
|
||||
$obj->save();
|
||||
$result = true;
|
||||
}
|
||||
else {
|
||||
$msg = '';
|
||||
foreach($obj->getValidationFailures() as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "\n";
|
||||
}
|
||||
throw new Exception($msg);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,17 +82,51 @@ Ext.onReady(function(){
|
||||
_fields.push({name: _idProperty});
|
||||
|
||||
for (i=0;i<tableDef.FIELDS.length; i++) {
|
||||
switch (tableDef.FIELDS[i].FLD_TYPE) {
|
||||
case 'DATE':
|
||||
columnRenderer = function (value) {
|
||||
if (!value.dateFormat)
|
||||
return value;
|
||||
else
|
||||
return value.dateFormat('Y-m-d');
|
||||
}
|
||||
columnAlign = 'left';
|
||||
columnEditor = {
|
||||
xtype : 'datefield',
|
||||
format : 'Y-m-d',
|
||||
allowBlank : true
|
||||
};
|
||||
break;
|
||||
|
||||
case 'INTEGER': case 'INT': case 'FLOAT': case 'DOUBLE' :
|
||||
columnRenderer = {};
|
||||
columnAlign = 'right';
|
||||
columnEditor = {
|
||||
xtype : 'numberfield',
|
||||
format : 'Y-m-d',
|
||||
allowBlank : true
|
||||
};
|
||||
break;
|
||||
|
||||
default:
|
||||
columnRenderer = {};
|
||||
columnAlign = 'left';
|
||||
columnEditor = {
|
||||
xtype : 'textfield',
|
||||
allowBlank : true
|
||||
};
|
||||
}
|
||||
|
||||
column = {
|
||||
id : tableDef.FIELDS[i].FLD_NAME,
|
||||
header : tableDef.FIELDS[i].FLD_DESCRIPTION,
|
||||
dataIndex : tableDef.FIELDS[i].FLD_NAME,
|
||||
width : 40
|
||||
width : 40,
|
||||
align : columnAlign,
|
||||
renderer : columnRenderer
|
||||
};
|
||||
if (tableDef.FIELDS[i].FLD_AUTO_INCREMENT != 1) {
|
||||
column.editor = {
|
||||
xtype : 'textfield',
|
||||
allowBlank : true
|
||||
}
|
||||
column.editor = columnEditor
|
||||
}
|
||||
else {
|
||||
column.editor = {
|
||||
@@ -156,15 +190,14 @@ Ext.onReady(function(){
|
||||
|
||||
// all exception events
|
||||
Ext.data.DataProxy.addListener('exception', function(proxy, type, action, options, res) {
|
||||
try{
|
||||
response = Ext.util.JSON.decode(res.responseText);
|
||||
|
||||
if(response.message != 'nothing to do') {
|
||||
PMExt.notify(_('ID_ERROR'), response.msg);
|
||||
if (res.raw.success) {
|
||||
if(res.raw.message != 'nothing to do') {
|
||||
PMExt.notify(_('ID_INFO'), response.raw.message);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
PMExt.notify(_('ID_ERROR'), res.responseText);
|
||||
}
|
||||
else {
|
||||
PMExt.error(_('ID_ERROR'), res.raw.message);
|
||||
infoGrid.store.reload();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user