BUG-5437 New Feature 'Edit the file Name' in HOME -> DOCUMENTS.

I add a new function: UPDATE in 'engine/classes/model/AppFolder.php', and in 'engine/methods/appFolder/appFolderAjax.php' to save the new name of the file.
This commit is contained in:
jennylee
2012-11-29 16:35:20 -04:00
parent 1804224a12
commit fc54701386
3 changed files with 95 additions and 18 deletions

View File

@@ -24,7 +24,6 @@
*/
class AppFolder extends BaseAppFolder
{
/**
*
* @param string $folderName
@@ -86,6 +85,52 @@ class AppFolder extends BaseAppFolder
}
}
/**
* Update the application document registry
*
* @param array $aData
* @return string
*
*/
public function update ($aData)
{
$oConnection = Propel::getConnection( AppDocumentPeer::DATABASE_NAME );
try {
$oAppFolder = AppFolderPeer::retrieveByPK( $aData['FOLDER_UID'] );
if (! is_null( $oAppFolder )) {
$oAppFolder->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
if ($oAppFolder->validate()) {
$oConnection->begin();
if (isset( $aData['FOLDER_NAME'] )) {
$oAppFolder->setFolderName( $aData['FOLDER_NAME'] );
}
if (isset( $aData['FOLDER_UID'] )) {
$oAppFolder->setFolderUid( $aData['FOLDER_UID'] );
}
if (isset( $aData['FOLDER_UPDATE_DATE'] )) {
$oAppFolder->setFolderUpdateDate( $aData['FOLDER_UPDATE_DATE'] );
}
$iResult = $oAppFolder->save();
$oConnection->commit();
return $iResult;
} else {
$sMessage = '';
$aValidationFailures = $oAppFolder->getValidationFailures();
foreach ($aValidationFailures as $oValidationFailure) {
$sMessage .= $oValidationFailure->getMessage() . '<br />';
}
throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
}
} else {
throw (new Exception( 'This row doesn\'t exist!' ));
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
/**
*
* @param string $folderPath

View File

@@ -13,11 +13,42 @@ if (! function_exists ($_REQUEST ['action'])) {
die ();
}
$functionName = $_REQUEST ['action'];
$functionParams = isset ($_REQUEST ['params']) ? $_REQUEST ['params'] : array ();
if (($_REQUEST['action']) != 'rename') {
$functionName = $_REQUEST ['action'];
$functionParams = isset ($_REQUEST ['params']) ? $_REQUEST ['params'] : array ();
$functionName ($functionParams);
} else {
$functionName = 'renameFolder';
$functionParams = isset ($_REQUEST ['params']) ? $_REQUEST ['params'] : array ();
$oldname = $_REQUEST ['item'];
$newname = $_REQUEST ['newitemname'];
$uid = $_REQUEST ['selitems'];
$functionName ($oldname, $newname, $uid);
}
$functionName ($functionParams);
/////////////////////////////////////////////
function renameFolder($oldname, $newname, $uid)
{
$folder = new AppFolder();
//Clean Folder name (delete spaces...)
$newname = trim( $newname );
$fiels = array();
$fiels['FOLDER_UID'] = $uid[0];
$fiels['FOLDER_NAME'] = $newname;
$fiels['FOLDER_UPDATE_DATE'] = date('Y-m-d H:i:s');
$folder->update($fiels);
$msgLabel= G::LoadTranslation ('ID_EDIT_SUCCESSFULLY');
echo "{action: '', error:'error',message: '$msgLabel', success: 'success',folderUID: 'root'}";
}
/**
* delete folders and documents
* created by carlos pacha carlos@colosa.com, pckrlos@gmail.com

View File

@@ -73,6 +73,7 @@ streamFilefromPM=function(fileStream) {
};
var swHandleCallbackRootNodeLoad = 0;
var dirTreeEd;
function rootNodeCreate()
{
@@ -298,7 +299,6 @@ function openActionDialog( caller, action ) {
case 'edit':
case 'newFolder':
case 'moveAction':
case 'rename':
case 'search':
case 'uploadDocument':
requestParams = getRequestParams();
@@ -486,6 +486,9 @@ function openActionDialog( caller, action ) {
* messageText, false, true ); }else{ alert("sadasd"); }
*/
break;
case 'rename':
dirTreeEd.triggerEdit(Ext.getCmp('dirTreePanel').getSelectionModel().getSelectedNode());
break;
}
}
@@ -737,8 +740,8 @@ datastore = new Ext.data.Store({
url : "../appFolder/appFolderAjax.php",
directory : "/",
params : {
start : 0,
limit : 25,
start: 0,
limit: 100,
dir : this.directory,
node : this.directory,
option : "gridDocuments",
@@ -1082,11 +1085,11 @@ function filterDataStore(btn, e) {
}
// add a paging toolbar to the grid's footer
var gridbb = new Ext.PagingToolbar({
store : datastore,
pageSize : 25 ,
displayInfo : true,
// displayMsg : '% % %',
emptyMsg : TRANSLATIONS.ID_DISPLAY_EMPTY,
store: datastore,
pageSize: 100,
displayInfo: true,
displayMsg: _("ID_DISPLAY_TOTAL"),
emptyMsg: _("ID_DISPLAY_EMPTY"),
beforePageText : TRANSLATIONS.ID_PAGE,
// afterPageText : 'of %',
firstText : TRANSLATIONS.ID_FIRST,
@@ -1299,8 +1302,8 @@ function loadDir() {
// console.trace();
datastore.load({
params : {
start : 0,
limit : 25,
start: 0,
limit: 100,
dir : datastore.directory,
node : datastore.directory,
option : 'gridDocuments',
@@ -1441,7 +1444,7 @@ function dirContext(node, e) {
// Unselect all files in the grid
ext_itemgrid.getSelectionModel().clearSelections();
dirCtxMenu.items.get('dirCtxMenu_rename')[node.attributes.is_deletable ? 'disable': 'disable']();
dirCtxMenu.items.get('dirCtxMenu_rename')[node.attributes.is_deletable ? 'enable': 'disable']();
// dirCtxMenu.items.get('dirCtxMenu_remove')[node.attributes.is_deletable ? 'enable':'disable']();
dirCtxMenu.items.get('dirCtxMenu_remove')[permitodelete==1 && node.attributes.id!='root' ? 'show':'hide']();
@@ -1502,8 +1505,6 @@ var dirCtxMenu = new Ext.menu.Menu(
{
id : 'dirCtxMenu_rename',
iconCls: 'button_menu_ext ss_sprite ss_textfield_rename',// icon
// :
hidden: true, // '/images/documents/_fonts.png',
text : TRANSLATIONS.ID_RENAME,
handler : function() {
dirCtxMenu.hide();
@@ -1898,7 +1899,7 @@ var documentsTab = {
// create the editor for the directory
// tree
var dirTreeEd = new Ext.tree.TreeEditor(
dirTreeEd = new Ext.tree.TreeEditor(
dirTree,
{
allowBlank : false,