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:
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
class AppFolder extends BaseAppFolder
|
class AppFolder extends BaseAppFolder
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $folderName
|
* @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
|
* @param string $folderPath
|
||||||
|
|||||||
@@ -13,11 +13,42 @@ if (! function_exists ($_REQUEST ['action'])) {
|
|||||||
die ();
|
die ();
|
||||||
}
|
}
|
||||||
|
|
||||||
$functionName = $_REQUEST ['action'];
|
if (($_REQUEST['action']) != 'rename') {
|
||||||
$functionParams = isset ($_REQUEST ['params']) ? $_REQUEST ['params'] : array ();
|
$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
|
* delete folders and documents
|
||||||
* created by carlos pacha carlos@colosa.com, pckrlos@gmail.com
|
* created by carlos pacha carlos@colosa.com, pckrlos@gmail.com
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ streamFilefromPM=function(fileStream) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var swHandleCallbackRootNodeLoad = 0;
|
var swHandleCallbackRootNodeLoad = 0;
|
||||||
|
var dirTreeEd;
|
||||||
|
|
||||||
function rootNodeCreate()
|
function rootNodeCreate()
|
||||||
{
|
{
|
||||||
@@ -298,7 +299,6 @@ function openActionDialog( caller, action ) {
|
|||||||
case 'edit':
|
case 'edit':
|
||||||
case 'newFolder':
|
case 'newFolder':
|
||||||
case 'moveAction':
|
case 'moveAction':
|
||||||
case 'rename':
|
|
||||||
case 'search':
|
case 'search':
|
||||||
case 'uploadDocument':
|
case 'uploadDocument':
|
||||||
requestParams = getRequestParams();
|
requestParams = getRequestParams();
|
||||||
@@ -486,6 +486,9 @@ function openActionDialog( caller, action ) {
|
|||||||
* messageText, false, true ); }else{ alert("sadasd"); }
|
* messageText, false, true ); }else{ alert("sadasd"); }
|
||||||
*/
|
*/
|
||||||
break;
|
break;
|
||||||
|
case 'rename':
|
||||||
|
dirTreeEd.triggerEdit(Ext.getCmp('dirTreePanel').getSelectionModel().getSelectedNode());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -737,8 +740,8 @@ datastore = new Ext.data.Store({
|
|||||||
url : "../appFolder/appFolderAjax.php",
|
url : "../appFolder/appFolderAjax.php",
|
||||||
directory : "/",
|
directory : "/",
|
||||||
params : {
|
params : {
|
||||||
start : 0,
|
start: 0,
|
||||||
limit : 25,
|
limit: 100,
|
||||||
dir : this.directory,
|
dir : this.directory,
|
||||||
node : this.directory,
|
node : this.directory,
|
||||||
option : "gridDocuments",
|
option : "gridDocuments",
|
||||||
@@ -1082,11 +1085,11 @@ function filterDataStore(btn, e) {
|
|||||||
}
|
}
|
||||||
// add a paging toolbar to the grid's footer
|
// add a paging toolbar to the grid's footer
|
||||||
var gridbb = new Ext.PagingToolbar({
|
var gridbb = new Ext.PagingToolbar({
|
||||||
store : datastore,
|
store: datastore,
|
||||||
pageSize : 25 ,
|
pageSize: 100,
|
||||||
displayInfo : true,
|
displayInfo: true,
|
||||||
// displayMsg : '% % %',
|
displayMsg: _("ID_DISPLAY_TOTAL"),
|
||||||
emptyMsg : TRANSLATIONS.ID_DISPLAY_EMPTY,
|
emptyMsg: _("ID_DISPLAY_EMPTY"),
|
||||||
beforePageText : TRANSLATIONS.ID_PAGE,
|
beforePageText : TRANSLATIONS.ID_PAGE,
|
||||||
// afterPageText : 'of %',
|
// afterPageText : 'of %',
|
||||||
firstText : TRANSLATIONS.ID_FIRST,
|
firstText : TRANSLATIONS.ID_FIRST,
|
||||||
@@ -1299,8 +1302,8 @@ function loadDir() {
|
|||||||
// console.trace();
|
// console.trace();
|
||||||
datastore.load({
|
datastore.load({
|
||||||
params : {
|
params : {
|
||||||
start : 0,
|
start: 0,
|
||||||
limit : 25,
|
limit: 100,
|
||||||
dir : datastore.directory,
|
dir : datastore.directory,
|
||||||
node : datastore.directory,
|
node : datastore.directory,
|
||||||
option : 'gridDocuments',
|
option : 'gridDocuments',
|
||||||
@@ -1441,7 +1444,7 @@ function dirContext(node, e) {
|
|||||||
// Unselect all files in the grid
|
// Unselect all files in the grid
|
||||||
ext_itemgrid.getSelectionModel().clearSelections();
|
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')[node.attributes.is_deletable ? 'enable':'disable']();
|
||||||
dirCtxMenu.items.get('dirCtxMenu_remove')[permitodelete==1 && node.attributes.id!='root' ? 'show':'hide']();
|
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',
|
id : 'dirCtxMenu_rename',
|
||||||
iconCls: 'button_menu_ext ss_sprite ss_textfield_rename',// icon
|
iconCls: 'button_menu_ext ss_sprite ss_textfield_rename',// icon
|
||||||
// :
|
|
||||||
hidden: true, // '/images/documents/_fonts.png',
|
|
||||||
text : TRANSLATIONS.ID_RENAME,
|
text : TRANSLATIONS.ID_RENAME,
|
||||||
handler : function() {
|
handler : function() {
|
||||||
dirCtxMenu.hide();
|
dirCtxMenu.hide();
|
||||||
@@ -1898,7 +1899,7 @@ var documentsTab = {
|
|||||||
|
|
||||||
// create the editor for the directory
|
// create the editor for the directory
|
||||||
// tree
|
// tree
|
||||||
var dirTreeEd = new Ext.tree.TreeEditor(
|
dirTreeEd = new Ext.tree.TreeEditor(
|
||||||
dirTree,
|
dirTree,
|
||||||
{
|
{
|
||||||
allowBlank : false,
|
allowBlank : false,
|
||||||
|
|||||||
Reference in New Issue
Block a user