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

Commit 7c41569

Browse files
author
Charles Marion
committed
ENH: Added "remove item" and fixed remove folder
1 parent 6a2e74f commit 7c41569

File tree

5 files changed

+107
-5
lines changed

5 files changed

+107
-5
lines changed

core/AppController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public function preDispatch()
125125
'manage'=>$this->t('Manage'),
126126
'edit'=>$this->t('Edit'),
127127
'delete'=>$this->t('Delete'),
128+
'removeItem'=>$this->t('Remove Item from Folder'),
128129
'deleteMessage'=>$this->t('Do you really want to delete the folder'),
130+
'removeMessage'=>$this->t('Do you really want to remove the item'),
129131
'share'=>$this->t('Sharing settings'),
130132
'rename'=>$this->t('Rename'),
131133
'move'=>$this->t('Move'),

core/controllers/FolderController.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,42 @@ public function deleteAction()
116116
$this->Folder->delete($folder);
117117
$folderInfo=$folder->_toArray();
118118
echo JsonComponent::encode(array(true,$this->t('Changes saved'),$folderInfo));
119-
}// end createfolderAction
119+
}// end deleteAction
120+
121+
/** remove an item from a folder (dialog,ajax only)*/
122+
public function removeitemAction()
123+
{
124+
$this->_helper->layout->disableLayout();
125+
$this->_helper->viewRenderer->setNoRender();
126+
$folder_id=$this->_getParam('folderId');
127+
$item_id=$this->_getParam('itemId');
128+
$folder=$this->Folder->load($folder_id);
129+
$item=$this->Item->load($item_id);
130+
$header="";
131+
if(!isset($folder_id))
132+
{
133+
throw new Zend_Exception("Please set the folderId.");
134+
}
135+
if(!isset($item_id))
136+
{
137+
throw new Zend_Exception("Please set the folderId.");
138+
}
139+
elseif($folder===false)
140+
{
141+
throw new Zend_Exception("The folder doesn t exist.");
142+
}
143+
elseif($item===false)
144+
{
145+
throw new Zend_Exception("The item doesn t exist.");
146+
}
147+
elseif(!$this->Folder->policyCheck($folder, $this->userSession->Dao, MIDAS_POLICY_WRITE))
148+
{
149+
throw new Zend_Exception("Permissions error.");
150+
}
151+
152+
$this->Folder->removeItem($folder,$item);
153+
echo JsonComponent::encode(array(true,$this->t('Changes saved')));
154+
}// end deleteAction
120155

121156
/** create a folder (dialog,ajax only)*/
122157
public function createfolderAction()

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

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@
111111
{
112112
createNotive(jsonResponse[1],1500);
113113
node.each(function(){
114-
childrenOf($(this)).remove();
114+
var children = childrenOf($(this));
115+
if(children!=undefined)
116+
{
117+
children.remove();
118+
}
115119
});
116120
node.remove();
117121
$( "div.MainDialog" ).dialog('close');
@@ -128,6 +132,60 @@
128132
$( "div.MainDialog" ).dialog('close');
129133
});
130134

135+
}
136+
function removeItem(id)
137+
{
138+
var html='';
139+
html+=json.browse['removeMessage'];
140+
html+='<br/>';
141+
html+='<br/>';
142+
html+='<br/>';
143+
html+='<input style="margin-left:140px;" class="globalButton deleteFolderYes" element="'+id+'" type="button" value="'+json.global.Yes+'"/>';
144+
html+='<input style="margin-left:50px;" class="globalButton deleteFolderNo" type="button" value="'+json.global.No+'"/>';
145+
146+
showDialogWithContent(json.browse['delete'],html,false);
147+
148+
$('input.deleteFolderYes').unbind('click').click(function()
149+
{
150+
var node=$('table.treeTable tr[element='+id+']');
151+
var parent;
152+
//get parent
153+
var classNames = node.attr('class').split(' ');
154+
for(key in classNames) {
155+
if(classNames[key].match("child-of-")) {
156+
parent = $("#" + classNames[key].substring(9));
157+
}
158+
}
159+
$.post(json.global.webroot+'/folder/removeitem', {folderId: parent.attr('element'), itemId: id},
160+
function(data) {
161+
jsonResponse = jQuery.parseJSON(data);
162+
if(jsonResponse==null)
163+
{
164+
createNotive('Error',4000);
165+
return;
166+
}
167+
if(jsonResponse[0])
168+
{
169+
createNotive(jsonResponse[1],1500);
170+
node.remove();
171+
$( "div.MainDialog" ).dialog('close');
172+
parent.find('span.elementCount').remove();
173+
parent.find('span.elementSize').after("<img class='folderLoading' element='{"+parent.attr('element')+"}' alt='' src='"+json.global.coreWebroot+"/public/images/icons/loading.gif'/>");
174+
parent.find('span.elementSize').remove();
175+
getElementsSize();
176+
}
177+
else
178+
{
179+
createNotive(jsonResponse[1],4000);
180+
}
181+
});
182+
183+
});
184+
$('input.deleteFolderNo').unbind('click').click(function()
185+
{
186+
$( "div.MainDialog" ).dialog('close');
187+
});
188+
131189
}
132190

133191
function createAction(node)
@@ -164,6 +222,7 @@
164222
if(policy>=1)
165223
{
166224
html+='<li><a type="item" element="'+element+'" class="sharingLink">'+json.browse.share+'</a></li>';
225+
html+='<li><a onclick="removeItem('+element+');">'+json.browse['removeItem']+'</a></li>';
167226
}
168227
}
169228
$('div.viewAction ul').html(html);

core/public/js/layout/jquery.treeTable.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070

7171
function initializeAjax(node,first)
7272
{
73+
if(node==undefined)
74+
{
75+
return ;
76+
}
7377
var folders='';
7478
var children;
7579
if(first)
@@ -469,8 +473,8 @@
469473
arrayElement=jQuery.parseJSON(data);
470474
$.each(arrayElement, function(index, value) {
471475
var img=$('img.folderLoading[element='+value.id+']');
472-
img.after(value.size);
473-
img.parents('tr').find('td:first span:last').append(' ('+value.count+')');
476+
img.after('<span class="elementSize">'+value.size+'</span>');
477+
img.parents('tr').find('td:first span:last').append('<span style="padding-left:0px;" class="elementCount">'+' ('+value.count+')'+'</span>');
474478
img.remove();
475479
});
476480
});

core/translation/fr-main.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Download;T
9292
Delete Feed;Effacer cette actualit�
9393
Do you really want to delete the feed;Voulez-vous vraiment supprimer l'actualit�
9494
Do you really want to delete the folder;Voulez-vous vraiment supprimer le r�pertoire
95+
Do you really want to remove the item;Voulez-vous vraiment retirer le document
9596
Yes;Oui
9697
No;Non
9798
Plugins;Plugins
@@ -199,4 +200,5 @@ can read;peut voir
199200
Add a permission to ...;Ajouter une autorisation � ...
200201
Owned by me;M'appartenant
201202
Shared to me;Partag�s avec moi
202-
Shared to Members;Partag�s aux Membres
203+
Shared to Members;Partag�s aux Membres
204+
Remove Item from Folder;Enlever le document du r�pertoire

0 commit comments

Comments
 (0)