show readonly message in file conflict dialog, make it always selected
This commit is contained in:
parent
85176ec072
commit
c615b3527f
|
@ -117,6 +117,12 @@ if (strpos($dir, '..') === false) {
|
||||||
$fileCount = count($files['name']);
|
$fileCount = count($files['name']);
|
||||||
for ($i = 0; $i < $fileCount; $i++) {
|
for ($i = 0; $i < $fileCount; $i++) {
|
||||||
|
|
||||||
|
if (isset($_POST['resolution'])) {
|
||||||
|
$resolution = $_POST['resolution'];
|
||||||
|
} else {
|
||||||
|
$resolution = null;
|
||||||
|
}
|
||||||
|
|
||||||
// target directory for when uploading folders
|
// target directory for when uploading folders
|
||||||
$relativePath = '';
|
$relativePath = '';
|
||||||
if(!empty($_POST['file_directory'])) {
|
if(!empty($_POST['file_directory'])) {
|
||||||
|
@ -124,7 +130,7 @@ if (strpos($dir, '..') === false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
|
// $path needs to be normalized - this failed within drag'n'drop upload to a sub-folder
|
||||||
if (isset($_POST['resolution']) && $_POST['resolution']==='autorename') {
|
if ($resolution === 'autorename') {
|
||||||
// append a number in brackets like 'filename (2).ext'
|
// append a number in brackets like 'filename (2).ext'
|
||||||
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir . $relativePath), $files['name'][$i]);
|
$target = OCP\Files::buildNotExistingFileName(stripslashes($dir . $relativePath), $files['name'][$i]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -141,9 +147,12 @@ if (strpos($dir, '..') === false) {
|
||||||
}
|
}
|
||||||
$returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
|
$returnedDir = \OC\Files\Filesystem::normalizePath($returnedDir);
|
||||||
|
|
||||||
if ( ! \OC\Files\Filesystem::file_exists($target)
|
|
||||||
|| (isset($_POST['resolution']) && $_POST['resolution']==='replace')
|
$exists = \OC\Files\Filesystem::file_exists($target);
|
||||||
) {
|
if ($exists) {
|
||||||
|
$updatable = \OC\Files\Filesystem::isUpdatable($target);
|
||||||
|
}
|
||||||
|
if ( ! $exists || ($updatable && $resolution === 'replace' ) ) {
|
||||||
// upload and overwrite file
|
// upload and overwrite file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -181,8 +190,11 @@ if (strpos($dir, '..') === false) {
|
||||||
$error = $l->t('Upload failed. Could not get file info.');
|
$error = $l->t('Upload failed. Could not get file info.');
|
||||||
} else {
|
} else {
|
||||||
$data = \OCA\Files\Helper::formatFileInfo($meta);
|
$data = \OCA\Files\Helper::formatFileInfo($meta);
|
||||||
$data['permissions'] = $data['permissions'] & $allowedPermissions;
|
if ($updatable) {
|
||||||
$data['status'] = 'existserror';
|
$data['status'] = 'existserror';
|
||||||
|
} else {
|
||||||
|
$data['status'] = 'readonly';
|
||||||
|
}
|
||||||
$data['originalname'] = $files['tmp_name'][$i];
|
$data['originalname'] = $files['tmp_name'][$i];
|
||||||
$data['uploadMaxFilesize'] = $maxUploadFileSize;
|
$data['uploadMaxFilesize'] = $maxUploadFileSize;
|
||||||
$data['maxHumanFilesize'] = $maxHumanFileSize;
|
$data['maxHumanFilesize'] = $maxHumanFileSize;
|
||||||
|
|
|
@ -64,6 +64,28 @@
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.oc-dialog .fileexists {
|
||||||
|
-webkit-touch-callout: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-khtml-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.oc-dialog .fileexists .conflict .filename,
|
||||||
|
.oc-dialog .fileexists .conflict .mtime,
|
||||||
|
.oc-dialog .fileexists .conflict .size {
|
||||||
|
-webkit-touch-callout: initial;
|
||||||
|
-webkit-user-select: initial;
|
||||||
|
-khtml-user-select: initial;
|
||||||
|
-moz-user-select: initial;
|
||||||
|
-ms-user-select: initial;
|
||||||
|
user-select: initial;
|
||||||
|
}
|
||||||
|
.oc-dialog .fileexists .conflict .message {
|
||||||
|
color: #e9322d;
|
||||||
|
}
|
||||||
.oc-dialog .fileexists table {
|
.oc-dialog .fileexists table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,7 +175,14 @@ OC.Upload = {
|
||||||
* @param {function} callbacks.onCancel
|
* @param {function} callbacks.onCancel
|
||||||
*/
|
*/
|
||||||
checkExistingFiles: function (selection, callbacks) {
|
checkExistingFiles: function (selection, callbacks) {
|
||||||
|
/*
|
||||||
|
$.each(selection.uploads, function(i, upload) {
|
||||||
|
var $row = OCA.Files.App.fileList.findFileEl(upload.files[0].name);
|
||||||
|
if ($row) {
|
||||||
// TODO check filelist before uploading and show dialog on conflicts, use callbacks
|
// TODO check filelist before uploading and show dialog on conflicts, use callbacks
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
callbacks.onNoConflicts(selection);
|
callbacks.onNoConflicts(selection);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -417,11 +424,15 @@ OC.Upload = {
|
||||||
data.textStatus = 'servererror';
|
data.textStatus = 'servererror';
|
||||||
data.errorThrown = t('files', 'Could not get result from server.');
|
data.errorThrown = t('files', 'Could not get result from server.');
|
||||||
fu._trigger('fail', e, data);
|
fu._trigger('fail', e, data);
|
||||||
|
} else if (result[0].status === 'readonly') {
|
||||||
|
var original = result[0];
|
||||||
|
var replacement = data.files[0];
|
||||||
|
OC.dialogs.fileexists(data, original, replacement, OC.Upload);
|
||||||
} else if (result[0].status === 'existserror') {
|
} else if (result[0].status === 'existserror') {
|
||||||
//show "file already exists" dialog
|
//show "file already exists" dialog
|
||||||
var original = result[0];
|
var original = result[0];
|
||||||
var replacement = data.files[0];
|
var replacement = data.files[0];
|
||||||
OC.dialogs.fileexists(data, original, replacement, OC.Upload, fu);
|
OC.dialogs.fileexists(data, original, replacement, OC.Upload);
|
||||||
} else if (result[0].status !== 'success') {
|
} else if (result[0].status !== 'success') {
|
||||||
//delete data.jqXHR;
|
//delete data.jqXHR;
|
||||||
data.textStatus = 'servererror';
|
data.textStatus = 'servererror';
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<span class="svg icon"></span>
|
<span class="svg icon"></span>
|
||||||
<div class="mtime"></div>
|
<div class="mtime"></div>
|
||||||
<div class="size"></div>
|
<div class="size"></div>
|
||||||
|
<div class="message"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -363,56 +363,69 @@ var OCdialogs = {
|
||||||
return canvas.toDataURL("image/png", 0.7);
|
return canvas.toDataURL("image/png", 0.7);
|
||||||
};
|
};
|
||||||
|
|
||||||
var addConflict = function(conflicts, original, replacement) {
|
var addConflict = function($conflicts, original, replacement) {
|
||||||
|
|
||||||
var conflict = conflicts.find('.template').clone().removeClass('template').addClass('conflict');
|
var $conflict = $conflicts.find('.template').clone().removeClass('template').addClass('conflict');
|
||||||
|
var $originalDiv = $conflict.find('.original');
|
||||||
|
var $replacementDiv = $conflict.find('.replacement');
|
||||||
|
|
||||||
conflict.data('data',data);
|
$conflict.data('data',data);
|
||||||
|
|
||||||
conflict.find('.filename').text(original.name);
|
$conflict.find('.filename').text(original.name);
|
||||||
conflict.find('.original .size').text(humanFileSize(original.size));
|
$originalDiv.find('.size').text(humanFileSize(original.size));
|
||||||
conflict.find('.original .mtime').text(formatDate(original.mtime));
|
$originalDiv.find('.mtime').text(formatDate(original.mtime));
|
||||||
// ie sucks
|
// ie sucks
|
||||||
if (replacement.size && replacement.lastModifiedDate) {
|
if (replacement.size && replacement.lastModifiedDate) {
|
||||||
conflict.find('.replacement .size').text(humanFileSize(replacement.size));
|
$replacementDiv.find('.size').text(humanFileSize(replacement.size));
|
||||||
conflict.find('.replacement .mtime').text(formatDate(replacement.lastModifiedDate));
|
$replacementDiv.find('.mtime').text(formatDate(replacement.lastModifiedDate));
|
||||||
}
|
}
|
||||||
var path = original.directory + '/' +original.name;
|
var path = original.directory + '/' +original.name;
|
||||||
Files.lazyLoadPreview(path, original.mimetype, function(previewpath){
|
Files.lazyLoadPreview(path, original.mimetype, function(previewpath){
|
||||||
conflict.find('.original .icon').css('background-image','url('+previewpath+')');
|
$originalDiv.find('.icon').css('background-image','url('+previewpath+')');
|
||||||
}, 96, 96, original.etag);
|
}, 96, 96, original.etag);
|
||||||
getCroppedPreview(replacement).then(
|
getCroppedPreview(replacement).then(
|
||||||
function(path){
|
function(path){
|
||||||
conflict.find('.replacement .icon').css('background-image','url(' + path + ')');
|
$replacementDiv.find('.icon').css('background-image','url(' + path + ')');
|
||||||
}, function(){
|
}, function(){
|
||||||
Files.getMimeIcon(replacement.type,function(path){
|
Files.getMimeIcon(replacement.type,function(path){
|
||||||
conflict.find('.replacement .icon').css('background-image','url(' + path + ')');
|
$replacementDiv.find('.icon').css('background-image','url(' + path + ')');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
conflicts.append(conflict);
|
$conflicts.append($conflict);
|
||||||
|
|
||||||
//set more recent mtime bold
|
//set more recent mtime bold
|
||||||
// ie sucks
|
// ie sucks
|
||||||
if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() > original.mtime) {
|
if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() > original.mtime) {
|
||||||
conflict.find('.replacement .mtime').css('font-weight', 'bold');
|
$replacementDiv.find('.mtime').css('font-weight', 'bold');
|
||||||
} else if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() < original.mtime) {
|
} else if (replacement.lastModifiedDate && replacement.lastModifiedDate.getTime() < original.mtime) {
|
||||||
conflict.find('.original .mtime').css('font-weight', 'bold');
|
$originalDiv.find('.mtime').css('font-weight', 'bold');
|
||||||
} else {
|
} else {
|
||||||
//TODO add to same mtime collection?
|
//TODO add to same mtime collection?
|
||||||
}
|
}
|
||||||
|
|
||||||
// set bigger size bold
|
// set bigger size bold
|
||||||
if (replacement.size && replacement.size > original.size) {
|
if (replacement.size && replacement.size > original.size) {
|
||||||
conflict.find('.replacement .size').css('font-weight', 'bold');
|
$replacementDiv.find('.size').css('font-weight', 'bold');
|
||||||
} else if (replacement.size && replacement.size < original.size) {
|
} else if (replacement.size && replacement.size < original.size) {
|
||||||
conflict.find('.original .size').css('font-weight', 'bold');
|
$originalDiv.find('.size').css('font-weight', 'bold');
|
||||||
} else {
|
} else {
|
||||||
//TODO add to same size collection?
|
//TODO add to same size collection?
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO show skip action for files with same size and mtime in bottom row
|
//TODO show skip action for files with same size and mtime in bottom row
|
||||||
|
|
||||||
|
// always keep readonly files
|
||||||
|
|
||||||
|
if (original.status === 'readonly') {
|
||||||
|
$originalDiv
|
||||||
|
.addClass('readonly')
|
||||||
|
.find('input[type="checkbox"]')
|
||||||
|
.prop('checked', true)
|
||||||
|
.prop('disabled', true);
|
||||||
|
$originalDiv.find('.message')
|
||||||
|
.text(t('core','read-only'))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
//var selection = controller.getSelection(data.originalFiles);
|
//var selection = controller.getSelection(data.originalFiles);
|
||||||
//if (selection.defaultAction) {
|
//if (selection.defaultAction) {
|
||||||
|
@ -423,8 +436,8 @@ var OCdialogs = {
|
||||||
if (this._fileexistsshown) {
|
if (this._fileexistsshown) {
|
||||||
// add conflict
|
// add conflict
|
||||||
|
|
||||||
var conflicts = $(dialogId+ ' .conflicts');
|
var $conflicts = $(dialogId+ ' .conflicts');
|
||||||
addConflict(conflicts, original, replacement);
|
addConflict($conflicts, original, replacement);
|
||||||
|
|
||||||
var count = $(dialogId+ ' .conflict').length;
|
var count = $(dialogId+ ' .conflict').length;
|
||||||
var title = n('core',
|
var title = n('core',
|
||||||
|
@ -456,8 +469,8 @@ var OCdialogs = {
|
||||||
});
|
});
|
||||||
$('body').append($dlg);
|
$('body').append($dlg);
|
||||||
|
|
||||||
var conflicts = $($dlg).find('.conflicts');
|
var $conflicts = $dlg.find('.conflicts');
|
||||||
addConflict(conflicts, original, replacement);
|
addConflict($conflicts, original, replacement);
|
||||||
|
|
||||||
var buttonlist = [{
|
var buttonlist = [{
|
||||||
text: t('core', 'Cancel'),
|
text: t('core', 'Cancel'),
|
||||||
|
@ -496,20 +509,20 @@ var OCdialogs = {
|
||||||
|
|
||||||
//add checkbox toggling actions
|
//add checkbox toggling actions
|
||||||
$(dialogId).find('.allnewfiles').on('click', function() {
|
$(dialogId).find('.allnewfiles').on('click', function() {
|
||||||
var checkboxes = $(dialogId).find('.conflict .replacement input[type="checkbox"]');
|
var $checkboxes = $(dialogId).find('.conflict .replacement input[type="checkbox"]');
|
||||||
checkboxes.prop('checked', $(this).prop('checked'));
|
$checkboxes.prop('checked', $(this).prop('checked'));
|
||||||
});
|
});
|
||||||
$(dialogId).find('.allexistingfiles').on('click', function() {
|
$(dialogId).find('.allexistingfiles').on('click', function() {
|
||||||
var checkboxes = $(dialogId).find('.conflict .original input[type="checkbox"]');
|
var $checkboxes = $(dialogId).find('.conflict .original:not(.readonly) input[type="checkbox"]');
|
||||||
checkboxes.prop('checked', $(this).prop('checked'));
|
$checkboxes.prop('checked', $(this).prop('checked'));
|
||||||
});
|
});
|
||||||
$(dialogId).find('.conflicts').on('click', '.replacement,.original', function() {
|
$(dialogId).find('.conflicts').on('click', '.replacement,.original:not(.readonly)', function() {
|
||||||
var checkbox = $(this).find('input[type="checkbox"]');
|
var $checkbox = $(this).find('input[type="checkbox"]');
|
||||||
checkbox.prop('checked', !checkbox.prop('checked'));
|
$checkbox.prop('checked', !$checkbox.prop('checked'));
|
||||||
});
|
});
|
||||||
$(dialogId).find('.conflicts').on('click', 'input[type="checkbox"]', function() {
|
$(dialogId).find('.conflicts').on('click', '.replacement input[type="checkbox"],.original:not(.readonly) input[type="checkbox"]', function() {
|
||||||
var checkbox = $(this);
|
var $checkbox = $(this);
|
||||||
checkbox.prop('checked', !checkbox.prop('checked'));
|
$checkbox.prop('checked', !checkbox.prop('checked'));
|
||||||
});
|
});
|
||||||
|
|
||||||
//update counters
|
//update counters
|
||||||
|
|
Loading…
Reference in New Issue