add data-id directly after upload/creation to the file list (bugfix for #1917)

This commit is contained in:
Björn Schießle 2012-10-08 17:28:56 +02:00
parent dc116b994d
commit 2923d24921
4 changed files with 16 additions and 5 deletions

View File

@ -20,7 +20,13 @@ if(strpos($foldername, '/')!==false) {
} }
if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) { if(OC_Files::newFile($dir, stripslashes($foldername), 'dir')) {
OCP\JSON::success(array("data" => array())); if ( $dir != '/') {
$path = $dir.'/'.$foldername;
} else {
$path = '/'.$foldername;
}
$id = OC_FileCache::getId($path);
OCP\JSON::success(array("data" => array('id'=>$id)));
exit(); exit();
} }

View File

@ -2,7 +2,7 @@
// Init owncloud // Init owncloud
error_log("upload!!!");
// Firefox and Konqueror tries to download application/json for me. --Arthur // Firefox and Konqueror tries to download application/json for me. --Arthur
OCP\JSON::setContentTypeHeader('text/plain'); OCP\JSON::setContentTypeHeader('text/plain');

View File

@ -116,11 +116,12 @@ var FileList={
$('#emptyfolder').hide(); $('#emptyfolder').hide();
$('.file_upload_filename').removeClass('highlight'); $('.file_upload_filename').removeClass('highlight');
}, },
loadingDone:function(name){ loadingDone:function(name, id){
var mime, tr=$('tr').filterAttr('data-file',name); var mime, tr=$('tr').filterAttr('data-file',name);
tr.data('loading',false); tr.data('loading',false);
mime=tr.data('mime'); mime=tr.data('mime');
tr.attr('data-mime',mime); tr.attr('data-mime',mime);
tr.attr('data-id', id);
getMimeIcon(mime,function(path){ getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')'); tr.find('td.filename').attr('style','background-image:url('+path+')');
}); });

View File

@ -347,7 +347,7 @@ $(document).ready(function() {
if(size==t('files','Pending')){ if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
} }
FileList.loadingDone(file.name); FileList.loadingDone(file.name, file.id);
} else { } else {
$('#notification').text(t('files', response.data.message)); $('#notification').text(t('files', response.data.message));
$('#notification').fadeIn(); $('#notification').fadeIn();
@ -377,7 +377,7 @@ $(document).ready(function() {
if(size==t('files','Pending')){ if(size==t('files','Pending')){
$('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size); $('tr').filterAttr('data-file',file.name).find('td.filesize').text(file.size);
} }
FileList.loadingDone(file.name); FileList.loadingDone(file.name, file.id);
} else { } else {
$('#notification').text(t('files', response.data.message)); $('#notification').text(t('files', response.data.message));
$('#notification').fadeIn(); $('#notification').fadeIn();
@ -519,6 +519,7 @@ $(document).ready(function() {
FileList.addFile(name,0,date,false,hidden); FileList.addFile(name,0,date,false,hidden);
var tr=$('tr').filterAttr('data-file',name); var tr=$('tr').filterAttr('data-file',name);
tr.data('mime','text/plain').data('id',result.data.id); tr.data('mime','text/plain').data('id',result.data.id);
tr.attr('data-id', result.data.id);
getMimeIcon('text/plain',function(path){ getMimeIcon('text/plain',function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')'); tr.find('td.filename').attr('style','background-image:url('+path+')');
}); });
@ -536,6 +537,8 @@ $(document).ready(function() {
if (result.status == 'success') { if (result.status == 'success') {
var date=new Date(); var date=new Date();
FileList.addDir(name,0,date,hidden); FileList.addDir(name,0,date,hidden);
var tr=$('tr').filterAttr('data-file',name);
tr.attr('data-id', result.data.id);
} else { } else {
OC.dialogs.alert(result.data.message, 'Error'); OC.dialogs.alert(result.data.message, 'Error');
} }
@ -572,6 +575,7 @@ $(document).ready(function() {
FileList.addFile(localName,size,date,false,hidden); FileList.addFile(localName,size,date,false,hidden);
var tr=$('tr').filterAttr('data-file',localName); var tr=$('tr').filterAttr('data-file',localName);
tr.data('mime',mime).data('id',id); tr.data('mime',mime).data('id',id);
tr.attr('data-id', id);
getMimeIcon(mime,function(path){ getMimeIcon(mime,function(path){
tr.find('td.filename').attr('style','background-image:url('+path+')'); tr.find('td.filename').attr('style','background-image:url('+path+')');
}); });