Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
ENH: Refs #0447. Implement Move action for (single) item/folder
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhengZ committed Jan 23, 2012
1 parent 85e5a00 commit b02a741
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
32 changes: 21 additions & 11 deletions core/controllers/BrowseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public function movecopyAction()
$select = $this->_getParam('selectElement');
$share = $this->_getParam('share');
$duplicate = $this->_getParam('duplicate');
$move = $this->_getParam('move');

// used for drag-and-drop actions
// used for movecopyAction
if(isset($moveSubmit) || isset($shareSubmit) || isset($duplicateSubmit))
{
$elements = explode(';', $this->_getParam('elements'));
Expand All @@ -86,6 +87,7 @@ public function movecopyAction()
throw new Zend_Exception("Unable to load destination");
}

// Move folder(s)
foreach($folders as $folder)
{
if(isset($moveSubmit))
Expand Down Expand Up @@ -118,19 +120,24 @@ public function movecopyAction()
{
$this->Item->duplicateItem($item, $this->userSession->Dao, $destinationFolder);
}
else //moveSubmit
else //moveSubmit, Move item(s)
{
$from = $this->_getParam('from');
$from = $this->Folder->load($from);
$fromFolder = $this->Folder->load($from);
if($destinationFolder == false)
{
throw new Zend_Exception("Unable to load destination");
}
if($fromFolder == false)
{
throw new Zend_Exception("Unable to load move from folder");
}
$this->Folder->addItem($destinationFolder, $item);
$this->Item->copyParentPolicies($item, $destinationFolder);
$this->Folder->removeItem($from, $item);
$this->Folder->removeItem($fromFolder, $item);
}
}
// Drag-and-drop actions
if(isset($ajax))
{
$this->_helper->layout->disableLayout();
Expand All @@ -141,11 +148,11 @@ public function movecopyAction()
$this->_redirect('/folder/'.$destinationFolder->getKey());
}

// Used for movecopy dialog
$this->requireAjaxRequest();
$this->_helper->layout->disableLayout();

if(isset($share) || isset($duplicate))
// Used for moveCopyForm (movecopy.phtml)
if(isset($share) || isset($duplicate) || isset($move))
{
$folderIds = $this->_getParam('folders');
$itemIds = $this->_getParam('items');
Expand All @@ -168,16 +175,19 @@ public function movecopyAction()
if(isset($share))
{
$this->view->shareEnabled = true;
$this->view->duplicateEnabled = false;
}
else
elseif(isset($duplicate))
{
$this->view->duplicateEnabled = true;
$this->view->shareEnabled = false;
}
$this->view->selectEnabled = false;
else // isset($move)
{
$this->view->moveEnabled = true;
$from = $this->_getParam('from');
$this->view->from = $from;
}
}
else //isset($select)
else // isset($select)
{
$this->view->selectEnabled = true;
}
Expand Down
Binary file added core/public/images/icons/move.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions core/public/js/common/common.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ midas.editFolder = function (id) {
showDialog(json.browse.edit, false);
};

midas.moveFolder = function (id) {
loadDialog("moveFolder"+id,"/browse/movecopy?move=true&folders="+id);
showDialog(json.browse.move);
}

midas.moveItem = function (itemId, fromFolderId) {
loadDialog("moveItem"+itemId,"/browse/movecopy?move=true&items="+itemId+"&from="+fromFolderId);
showDialog(json.browse.move);
}

midas.parentOf = function (node) {
var classNames = node[0].className.split(' ');

Expand Down Expand Up @@ -319,6 +329,7 @@ midas.createAction = function (node) {
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/upload.png"/> <a rel="'+json.global.webroot+'/upload/simpleupload/?parent='+element+'" class="uploadInFolder">'+json.browse.uploadIn+'</a></li>';
if(node.attr('deletable')!=undefined && node.attr('deletable')=='true') {
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/edit.png"/> <a onclick="midas.editFolder('+element+');">'+json.browse.edit+'</a></li>';
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/move.png"/> <a onclick="midas.moveFolder('+element+');">'+json.browse.move+'</a></li>';
}
}
if(policy>=2) {
Expand All @@ -329,10 +340,13 @@ midas.createAction = function (node) {
}
}
if(type == 'item') {
var from = parentOf(node);
var fromFolder = from.attr('element');
html += '<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/view.png"/> <a href="'+json.global.webroot+'/item/'+element+'">'+json.browse.view+'</a></li>';
html += '<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/download.png"/> <a href="'+json.global.webroot+'/download?items='+element+'">'+json.browse.downloadLatest+'</a></li>';
if (policy>=2) {
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/lock.png"/> <a type="item" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/move.png"/> <a onclick="midas.moveItem(\''+ element + '\',\'' + fromFolder + '\');">'+json.browse.move+'</a></li>';
html+='<li class="removeItemLi"><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/close.png"/> <a onclick="midas.removeItem('+element+');">'+json.browse['removeItem']+'</a></li>';
}
}
Expand Down
3 changes: 2 additions & 1 deletion core/views/browse/movecopy.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/b
<br/> <br/>
<form class="genericForm" id="moveCopyForm" type='post' action="<?php echo $this->webroot?>/browse/movecopy">
<input type='hidden' name='elements' value='<?php echo $this->folderIds?>;<?php echo $this->itemIds?>' />
<input type='hidden' name='from' value='<?php echo $this->from?>' />
<input type='hidden' id="selectedDestinationHidden" name='destination' />
Destination: <span id="selectedDestination" > <?php echo $this->t('Please select a folder.') ?> </span> <br/>
<?php
Expand All @@ -74,7 +75,7 @@ echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/b
<input type="submit" disabled name='shareElement' id='shareElement' value="<?php echo $this->t('Share')?>"/>
<?php
}
else
elseif($this->duplicateEnabled)
{
?>
<input type="submit" disabled name='duplicateElement' id='duplicateElement' value="<?php echo $this->t('Duplicate')?>"/>
Expand Down

0 comments on commit b02a741

Please sign in to comment.