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

Commit a4f6985

Browse files
committed
ENH: refs #223. Fixed the scenario that item is droppred to its current folder.
1 parent 86f59d7 commit a4f6985

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

core/public/js/community/community.manage.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,19 @@ function initDragAndDrop()
145145
{
146146
elements=';'+$(ui.draggable).parents("tr").attr('element');
147147
}
148-
var from;
148+
var from_ojbect;
149149
var classNames=$(ui.draggable).parents("tr").attr('class').split(' ');
150150
for(key in classNames) {
151151
if(classNames[key].match('child-of-')) {
152-
from= $("#" + classNames[key].substring(9)).attr('element');
152+
from_obj = "#" + classNames[key].substring(9);
153153
}
154154
}
155155
var destination_obj=this;
156-
$.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:from,ajax:true},
157-
function(data) {
156+
157+
// do nothing if drop item(s) to its current folder
158+
if ($(this).attr('id') != $(from_obj).attr('id')){
159+
$.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:$(from_obj).attr('element'),ajax:true},
160+
function(data) {
158161

159162
jsonResponse = jQuery.parseJSON(data);
160163
if(jsonResponse==null)
@@ -166,14 +169,15 @@ function initDragAndDrop()
166169
{
167170
createNotive(jsonResponse[1],1500);
168171
$($(ui.draggable).parents("tr")).appendBranchTo(destination_obj);
169-
$(destination_obj).reload();
172+
$(from_obj).reload();
173+
$(destination_obj).reload();
170174
}
171175
else
172176
{
173177
createNotive(jsonResponse[1],4000);
174178
}
175-
});
176-
179+
});
180+
}
177181
},
178182
hoverClass: "accept",
179183
over: function(e, ui) {

core/public/js/user/user.manage.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
var disableElementSize=true;
23

34
$(document).ready(function() {
@@ -90,16 +91,19 @@ function initDragAndDrop()
9091
{
9192
elements=';'+$(ui.draggable).parents("tr").attr('element');
9293
}
93-
var from;
94+
var from_obj;
9495
var classNames=$(ui.draggable).parents("tr").attr('class').split(' ');
9596
for(key in classNames) {
9697
if(classNames[key].match('child-of-')) {
97-
from= $("#" + classNames[key].substring(9)).attr('element');
98+
from_obj = "#" + classNames[key].substring(9);
9899
}
99100
}
100101
var destination_obj=this;
101-
$.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:from,ajax:true},
102-
function(data) {
102+
103+
// do nothing if drop item(s) to its current folder
104+
if ($(this).attr('id') != $(from_obj).attr('id')){
105+
$.post(json.global.webroot+'/browse/movecopy', {moveElement: true, elements: elements , destination:$(this).attr('element'),from:$(from_obj).attr('element'),ajax:true},
106+
function(data) {
103107

104108
jsonResponse = jQuery.parseJSON(data);
105109
if(jsonResponse==null)
@@ -111,13 +115,15 @@ function initDragAndDrop()
111115
{
112116
createNotive(jsonResponse[1],1500);
113117
$($(ui.draggable).parents("tr")).appendBranchTo(destination_obj);
118+
$(from_obj).reload();
114119
$(destination_obj).reload();
115120
}
116121
else
117122
{
118123
createNotive(jsonResponse[1],4000);
119124
}
120-
});
125+
});
126+
}
121127

122128
},
123129
hoverClass: "accept",

0 commit comments

Comments
 (0)