diff options
author | Björn Schießle <schiessle@owncloud.com> | 2014-05-21 06:27:07 -0400 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2014-05-21 06:27:07 -0400 |
commit | 88d26aac7bded0267a7af4ba26a7534a73851e55 (patch) | |
tree | 6b92e314b42d8082206e1ecfd995b7adace0eace /apps/files/js | |
parent | 319942bccb0f08abd694219b1c7bcf1e71d589c4 (diff) | |
parent | 5a0281add84b0754404c9fa617c4f527fcef04dc (diff) | |
download | nextcloud-server-88d26aac7bded0267a7af4ba26a7534a73851e55.tar.gz nextcloud-server-88d26aac7bded0267a7af4ba26a7534a73851e55.zip |
Merge pull request #8612 from owncloud/share-updateshareiconsafterrename
[master] Fixed issues with renaming
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/filelist.js | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 38766e2b801..3dcd9dd3eaa 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1184,10 +1184,22 @@ event.preventDefault(); try { var newName = input.val(); + input.tipsy('hide'); + form.remove(); + if (newName !== oldname) { checkInput(); - // mark as loading + // mark as loading (temp element) td.css('background-image', 'url('+ OC.imagePath('core', 'loading.gif') + ')'); + tr.attr('data-file', newName); + var basename = newName; + if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { + basename = newName.substr(0, newName.lastIndexOf('.')); + } + td.find('a.name span.nametext').text(basename); + td.children('a.name').show(); + tr.find('.fileactions, .action').addClass('hidden'); + $.ajax({ url: OC.filePath('files','ajax','rename.php'), data: { @@ -1207,30 +1219,17 @@ // reinsert row self.files.splice(tr.index(), 1); tr.remove(); - self.add(fileInfo); + self.add(fileInfo, {updateSummary: false}); + self.$fileList.trigger($.Event('fileActionsReady')); } }); + } else { + // add back the old file info when cancelled + self.files.splice(tr.index(), 1); + tr.remove(); + self.add(oldFileInfo, {updateSummary: false}); + self.$fileList.trigger($.Event('fileActionsReady')); } - input.tipsy('hide'); - tr.data('renaming',false); - tr.attr('data-file', newName); - var path = td.children('a.name').attr('href'); - // FIXME this will fail if the path contains the filename. - td.children('a.name').attr('href', path.replace(encodeURIComponent(oldname), encodeURIComponent(newName))); - var basename = newName; - if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { - basename = newName.substr(0, newName.lastIndexOf('.')); - } - td.find('a.name span.nametext').text(basename); - if (newName.indexOf('.') > 0 && tr.data('type') !== 'dir') { - if ( ! td.find('a.name span.extension').exists() ) { - td.find('a.name span.nametext').append('<span class="extension"></span>'); - } - td.find('a.name span.extension').text(newName.substr(newName.lastIndexOf('.'))); - } - form.remove(); - self.fileActions.display( tr.find('td.filename'), true); - td.children('a.name').show(); } catch (error) { input.attr('title', error); input.tipsy({gravity: 'w', trigger: 'manual'}); |