Merge pull request #2034 from owncloud/fix_bug47
Fix #47 - Duplicate files create a (2) when multiples are uploaded
This commit is contained in:
commit
0488968443
|
@ -246,14 +246,17 @@ var FileList={
|
||||||
},
|
},
|
||||||
checkName:function(oldName, newName, isNewFile) {
|
checkName:function(oldName, newName, isNewFile) {
|
||||||
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
if (isNewFile || $('tr').filterAttr('data-file', newName).length > 0) {
|
||||||
$('#notification').data('oldName', oldName);
|
var html;
|
||||||
$('#notification').data('newName', newName);
|
if(isNewFile){
|
||||||
$('#notification').data('isNewFile', isNewFile);
|
html = t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span> <span class="cancel">'+t('files', 'cancel')+'</span>';
|
||||||
if (isNewFile) {
|
}else{
|
||||||
OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="suggest">'+t('files', 'suggest name')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
html = t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>';
|
||||||
} else {
|
|
||||||
OC.Notification.showHtml(t('files', '{new_name} already exists', {new_name: escapeHTML(newName)})+'<span class="replace">'+t('files', 'replace')+'</span><span class="cancel">'+t('files', 'cancel')+'</span>');
|
|
||||||
}
|
}
|
||||||
|
html = $('<span>' + html + '</span>');
|
||||||
|
html.attr('data-oldName', oldName);
|
||||||
|
html.attr('data-newName', newName);
|
||||||
|
html.attr('data-isNewFile', isNewFile);
|
||||||
|
OC.Notification.showHtml(html);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -291,9 +294,7 @@ var FileList={
|
||||||
FileList.lastAction = function() {
|
FileList.lastAction = function() {
|
||||||
FileList.finishReplace();
|
FileList.finishReplace();
|
||||||
};
|
};
|
||||||
if (isNewFile) {
|
if (!isNewFile) {
|
||||||
OC.Notification.showHtml(t('files', 'replaced {new_name}', {new_name: newName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
|
||||||
} else {
|
|
||||||
OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
OC.Notification.showHtml(t('files', 'replaced {new_name} with {old_name}', {new_name: newName}, {old_name: oldName})+'<span class="undo">'+t('files', 'undo')+'</span>');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -376,19 +377,19 @@ $(document).ready(function(){
|
||||||
FileList.lastAction = null;
|
FileList.lastAction = null;
|
||||||
OC.Notification.hide();
|
OC.Notification.hide();
|
||||||
});
|
});
|
||||||
$('#notification').on('click', '.replace', function() {
|
$('#notification:first-child').on('click', '.replace', function() {
|
||||||
OC.Notification.hide(function() {
|
OC.Notification.hide(function() {
|
||||||
FileList.replace($('#notification').data('oldName'), $('#notification').data('newName'), $('#notification').data('isNewFile'));
|
FileList.replace($('#notification > span').attr('data-oldName'), $('#notification > span').attr('data-newName'), $('#notification > span').attr('data-isNewFile'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#notification').on('click', '.suggest', function() {
|
$('#notification:first-child').on('click', '.suggest', function() {
|
||||||
$('tr').filterAttr('data-file', $('#notification').data('oldName')).show();
|
$('tr').filterAttr('data-file', $('#notification > span').attr('data-oldName')).show();
|
||||||
OC.Notification.hide();
|
OC.Notification.hide();
|
||||||
});
|
});
|
||||||
$('#notification').on('click', '.cancel', function() {
|
$('#notification:first-child').on('click', '.cancel', function() {
|
||||||
if ($('#notification').data('isNewFile')) {
|
if ($('#notification > span').attr('data-isNewFile')) {
|
||||||
FileList.deleteCanceled = false;
|
FileList.deleteCanceled = false;
|
||||||
FileList.deleteFiles = [$('#notification').data('oldName')];
|
FileList.deleteFiles = [$('#notification > span').attr('data-oldName')];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FileList.useUndo=(window.onbeforeunload)?true:false;
|
FileList.useUndo=(window.onbeforeunload)?true:false;
|
||||||
|
|
|
@ -317,12 +317,12 @@ OC.addStyle.loaded=[];
|
||||||
OC.addScript.loaded=[];
|
OC.addScript.loaded=[];
|
||||||
|
|
||||||
OC.Notification={
|
OC.Notification={
|
||||||
|
queuedNotifications: [],
|
||||||
getDefaultNotificationFunction: null,
|
getDefaultNotificationFunction: null,
|
||||||
setDefault: function(callback) {
|
setDefault: function(callback) {
|
||||||
OC.Notification.getDefaultNotificationFunction = callback;
|
OC.Notification.getDefaultNotificationFunction = callback;
|
||||||
},
|
},
|
||||||
hide: function(callback) {
|
hide: function(callback) {
|
||||||
$("#notification").text('');
|
|
||||||
$('#notification').fadeOut('400', function(){
|
$('#notification').fadeOut('400', function(){
|
||||||
if (OC.Notification.isHidden()) {
|
if (OC.Notification.isHidden()) {
|
||||||
if (OC.Notification.getDefaultNotificationFunction) {
|
if (OC.Notification.getDefaultNotificationFunction) {
|
||||||
|
@ -332,19 +332,28 @@ OC.Notification={
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback.call();
|
callback.call();
|
||||||
}
|
}
|
||||||
|
$('#notification').empty();
|
||||||
|
if(OC.Notification.queuedNotifications.length > 0){
|
||||||
|
OC.Notification.showHtml(OC.Notification.queuedNotifications[0]);
|
||||||
|
OC.Notification.queuedNotifications.shift();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showHtml: function(html) {
|
showHtml: function(html) {
|
||||||
var notification = $('#notification');
|
if(($('#notification').filter('span.undo').length == 1) || OC.Notification.isHidden()){
|
||||||
notification.hide();
|
$('#notification').html(html);
|
||||||
notification.html(html);
|
$('#notification').fadeIn().css("display","inline");
|
||||||
notification.fadeIn().css("display","inline");
|
}else{
|
||||||
|
OC.Notification.queuedNotifications.push(html);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
show: function(text) {
|
show: function(text) {
|
||||||
var notification = $('#notification');
|
if(($('#notification').filter('span.undo').length == 1) || OC.Notification.isHidden()){
|
||||||
notification.hide();
|
$('#notification').html(html);
|
||||||
notification.text(text);
|
$('#notification').fadeIn().css("display","inline");
|
||||||
notification.fadeIn().css("display","inline");
|
}else{
|
||||||
|
OC.Notification.queuedNotifications.push($(text).html());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isHidden: function() {
|
isHidden: function() {
|
||||||
return ($("#notification").text() === '');
|
return ($("#notification").text() === '');
|
||||||
|
|
Loading…
Reference in New Issue