summaryrefslogtreecommitdiffstats
path: root/apps/files/js
diff options
context:
space:
mode:
authorMorris Jobke <morris.jobke@gmail.com>2013-07-01 01:28:17 -0700
committerMorris Jobke <morris.jobke@gmail.com>2013-07-01 01:28:17 -0700
commitb19033b3533ce4726763aac6247aa156eb0a87d6 (patch)
treea07308e75b5f00c952a622bcbfecd267b6837f43 /apps/files/js
parent80a8b9c99581d6e2e20276e4c0273e50b67e4658 (diff)
parente0547a25ab9c5a3d9454611f72e00e3bc667e2d2 (diff)
downloadnextcloud-server-b19033b3533ce4726763aac6247aa156eb0a87d6.tar.gz
nextcloud-server-b19033b3533ce4726763aac6247aa156eb0a87d6.zip
Merge pull request #3223 from owncloud/fix-2820
if rename of file fails, the rename is undone in the view - fix 2820
Diffstat (limited to 'apps/files/js')
-rw-r--r--apps/files/js/filelist.js41
1 files changed, 36 insertions, 5 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js
index f4ca098eed1..c15fc21abf4 100644
--- a/apps/files/js/filelist.js
+++ b/apps/files/js/filelist.js
@@ -220,13 +220,44 @@ var FileList={
if (FileList.checkName(name, newname, false)) {
newname = name;
} else {
- $.get(OC.filePath('files','ajax','rename.php'), { dir : $('#dir').val(), newname: newname, file: name },function(result) {
- if (!result || result.status == 'error') {
- OC.dialogs.alert(result.data.message, 'Error moving file');
- newname = name;
+ // save background image, because it's replaced by a spinner while async request
+ var oldBackgroundImage = td.css('background-image');
+ // mark as loading
+ td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')');
+ $.ajax({
+ url: OC.filePath('files','ajax','rename.php'),
+ data: {
+ dir : $('#dir').val(),
+ newname: newname,
+ file: name
+ },
+ success: function(result) {
+ if (!result || result.status === 'error') {
+ OC.Notification.show(result.data.message);
+ newname = name;
+ // revert changes
+ tr.attr('data-file', newname);
+ var path = td.children('a.name').attr('href');
+ td.children('a.name').attr('href', path.replace(encodeURIComponent(name), encodeURIComponent(newname)));
+ if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') {
+ var basename=newname.substr(0,newname.lastIndexOf('.'));
+ } else {
+ var basename=newname;
+ }
+ td.find('a.name span.nametext').text(basename);
+ if (newname.indexOf('.') > 0 && tr.data('type') !== 'dir') {
+ if (td.find('a.name span.extension').length === 0 ) {
+ td.find('a.name span.nametext').append('<span class="extension"></span>');
+ }
+ td.find('a.name span.extension').text(newname.substr(newname.lastIndexOf('.')));
+ }
+ tr.find('.fileactions').effect('highlight', {}, 5000);
+ tr.effect('highlight', {}, 5000);
+ }
+ // remove loading mark and recover old image
+ td.css('background-image', oldBackgroundImage);
}
});
-
}
}
tr.data('renaming',false);