From b58e72cdb27d46188675484c73d2783102f7d050 Mon Sep 17 00:00:00 2001 From: Michael Gapczynski Date: Mon, 23 Jul 2012 22:35:34 -0400 Subject: Alert user of errors when creating new files or folders --- apps/files/js/files.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'apps') diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 86c5185bf72..8d52b742c1b 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -462,14 +462,18 @@ $(document).ready(function() { $.post( OC.filePath('files','ajax','newfile.php'), {dir:$('#dir').val(),filename:name,content:" \n"}, - function(data){ - var date=new Date(); - FileList.addFile(name,0,date); - var tr=$('tr').filterAttr('data-file',name); - tr.data('mime','text/plain'); - getMimeIcon('text/plain',function(path){ - tr.find('td.filename').attr('style','background-image:url('+path+')'); - }); + function(result){ + if (result.status == 'success') { + var date=new Date(); + FileList.addFile(name,0,date); + var tr=$('tr').filterAttr('data-file',name); + tr.data('mime','text/plain'); + getMimeIcon('text/plain',function(path){ + tr.find('td.filename').attr('style','background-image:url('+path+')'); + }); + } else { + OC.dialogs.alert(result.data.message, 'Error'); + } } ); break; @@ -477,9 +481,13 @@ $(document).ready(function() { $.post( OC.filePath('files','ajax','newfolder.php'), {dir:$('#dir').val(),foldername:name}, - function(data){ - var date=new Date(); - FileList.addDir(name,0,date); + function(result){ + if (result.status == 'success') { + var date=new Date(); + FileList.addDir(name,0,date); + } else { + OC.dialogs.alert(result.data.message, 'Error'); + } } ); break; @@ -510,7 +518,7 @@ $(document).ready(function() { tr.find('td.filename').attr('style','background-image:url('+path+')'); }); }else{ - + OC.dialogs.alert(result.data.message, 'Error'); } } ); -- cgit v1.2.3