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

Commit b02a741

Browse files
committed
ENH: Refs #0447. Implement Move action for (single) item/folder
1 parent 85e5a00 commit b02a741

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

core/controllers/BrowseController.php

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ public function movecopyAction()
6565
$select = $this->_getParam('selectElement');
6666
$share = $this->_getParam('share');
6767
$duplicate = $this->_getParam('duplicate');
68+
$move = $this->_getParam('move');
6869

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

90+
// Move folder(s)
8991
foreach($folders as $folder)
9092
{
9193
if(isset($moveSubmit))
@@ -118,19 +120,24 @@ public function movecopyAction()
118120
{
119121
$this->Item->duplicateItem($item, $this->userSession->Dao, $destinationFolder);
120122
}
121-
else //moveSubmit
123+
else //moveSubmit, Move item(s)
122124
{
123125
$from = $this->_getParam('from');
124-
$from = $this->Folder->load($from);
126+
$fromFolder = $this->Folder->load($from);
125127
if($destinationFolder == false)
126128
{
127129
throw new Zend_Exception("Unable to load destination");
128130
}
131+
if($fromFolder == false)
132+
{
133+
throw new Zend_Exception("Unable to load move from folder");
134+
}
129135
$this->Folder->addItem($destinationFolder, $item);
130136
$this->Item->copyParentPolicies($item, $destinationFolder);
131-
$this->Folder->removeItem($from, $item);
137+
$this->Folder->removeItem($fromFolder, $item);
132138
}
133139
}
140+
// Drag-and-drop actions
134141
if(isset($ajax))
135142
{
136143
$this->_helper->layout->disableLayout();
@@ -141,11 +148,11 @@ public function movecopyAction()
141148
$this->_redirect('/folder/'.$destinationFolder->getKey());
142149
}
143150

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

148-
if(isset($share) || isset($duplicate))
154+
// Used for moveCopyForm (movecopy.phtml)
155+
if(isset($share) || isset($duplicate) || isset($move))
149156
{
150157
$folderIds = $this->_getParam('folders');
151158
$itemIds = $this->_getParam('items');
@@ -168,16 +175,19 @@ public function movecopyAction()
168175
if(isset($share))
169176
{
170177
$this->view->shareEnabled = true;
171-
$this->view->duplicateEnabled = false;
172178
}
173-
else
179+
elseif(isset($duplicate))
174180
{
175181
$this->view->duplicateEnabled = true;
176-
$this->view->shareEnabled = false;
177182
}
178-
$this->view->selectEnabled = false;
183+
else // isset($move)
184+
{
185+
$this->view->moveEnabled = true;
186+
$from = $this->_getParam('from');
187+
$this->view->from = $from;
188+
}
179189
}
180-
else //isset($select)
190+
else // isset($select)
181191
{
182192
$this->view->selectEnabled = true;
183193
}

core/public/images/icons/move.png

718 Bytes
Loading

core/public/js/common/common.browser.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,16 @@ midas.editFolder = function (id) {
280280
showDialog(json.browse.edit, false);
281281
};
282282

283+
midas.moveFolder = function (id) {
284+
loadDialog("moveFolder"+id,"/browse/movecopy?move=true&folders="+id);
285+
showDialog(json.browse.move);
286+
}
287+
288+
midas.moveItem = function (itemId, fromFolderId) {
289+
loadDialog("moveItem"+itemId,"/browse/movecopy?move=true&items="+itemId+"&from="+fromFolderId);
290+
showDialog(json.browse.move);
291+
}
292+
283293
midas.parentOf = function (node) {
284294
var classNames = node[0].className.split(' ');
285295

@@ -319,6 +329,7 @@ midas.createAction = function (node) {
319329
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>';
320330
if(node.attr('deletable')!=undefined && node.attr('deletable')=='true') {
321331
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/edit.png"/> <a onclick="midas.editFolder('+element+');">'+json.browse.edit+'</a></li>';
332+
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/move.png"/> <a onclick="midas.moveFolder('+element+');">'+json.browse.move+'</a></li>';
322333
}
323334
}
324335
if(policy>=2) {
@@ -329,10 +340,13 @@ midas.createAction = function (node) {
329340
}
330341
}
331342
if(type == 'item') {
343+
var from = parentOf(node);
344+
var fromFolder = from.attr('element');
332345
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>';
333346
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>';
334347
if (policy>=2) {
335348
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>';
349+
html+='<li><img alt="" src="'+json.global.coreWebroot+'/public/images/icons/move.png"/> <a onclick="midas.moveItem(\''+ element + '\',\'' + fromFolder + '\');">'+json.browse.move+'</a></li>';
336350
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>';
337351
}
338352
}

core/views/browse/movecopy.phtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/b
5454
<br/> <br/>
5555
<form class="genericForm" id="moveCopyForm" type='post' action="<?php echo $this->webroot?>/browse/movecopy">
5656
<input type='hidden' name='elements' value='<?php echo $this->folderIds?>;<?php echo $this->itemIds?>' />
57+
<input type='hidden' name='from' value='<?php echo $this->from?>' />
5758
<input type='hidden' id="selectedDestinationHidden" name='destination' />
5859
Destination: <span id="selectedDestination" > <?php echo $this->t('Please select a folder.') ?> </span> <br/>
5960
<?php
@@ -74,7 +75,7 @@ echo '<script type="text/javascript" src="' . $this->coreWebroot . '/public/js/b
7475
<input type="submit" disabled name='shareElement' id='shareElement' value="<?php echo $this->t('Share')?>"/>
7576
<?php
7677
}
77-
else
78+
elseif($this->duplicateEnabled)
7879
{
7980
?>
8081
<input type="submit" disabled name='duplicateElement' id='duplicateElement' value="<?php echo $this->t('Duplicate')?>"/>

0 commit comments

Comments
 (0)