Browse Source

Make sure the conflict dialog is loaded before adding conflicts

tags/v8.2RC1
Vincent Petry 8 years ago
parent
commit
5dff9d88cb
2 changed files with 16 additions and 6 deletions
  1. 5
    2
      apps/files/js/file-upload.js
  2. 11
    4
      core/js/oc-dialogs.js

+ 5
- 2
apps/files/js/file-upload.js View File

return true; return true;
}); });
if (conflicts.length) { if (conflicts.length) {
_.each(conflicts, function(conflictData) {
OC.dialogs.fileexists(conflictData[1], conflictData[0], conflictData[1].files[0], OC.Upload);
// wait for template loading
OC.dialogs.fileexists(null, null, null, OC.Upload).done(function() {
_.each(conflicts, function(conflictData) {
OC.dialogs.fileexists(conflictData[1], conflictData[0], conflictData[1].files[0], OC.Upload);
});
}); });
} }



+ 11
- 4
core/js/oc-dialogs.js View File

* @param {object} original file with name, size and mtime * @param {object} original file with name, size and mtime
* @param {object} replacement file with name, size and mtime * @param {object} replacement file with name, size and mtime
* @param {object} controller with onCancel, onSkip, onReplace and onRename methods * @param {object} controller with onCancel, onSkip, onReplace and onRename methods
* @return {Promise} jquery promise that resolves after the dialog template was loaded
*/ */
fileexists:function(data, original, replacement, controller) { fileexists:function(data, original, replacement, controller) {
var self = this; var self = this;
var dialogDeferred = new $.Deferred();


var getCroppedPreview = function(file) { var getCroppedPreview = function(file) {
var deferred = new $.Deferred(); var deferred = new $.Deferred();


//recalculate dimensions //recalculate dimensions
$(window).trigger('resize'); $(window).trigger('resize');
dialogDeferred.resolve();
} else { } else {
//create dialog //create dialog
this._fileexistsshown = true; this._fileexistsshown = true;
}); });
$('body').append($dlg); $('body').append($dlg);


var $conflicts = $dlg.find('.conflicts');
addConflict($conflicts, original, replacement);
if (original && replacement) {
var $conflicts = $dlg.find('.conflicts');
addConflict($conflicts, original, replacement);
}


var buttonlist = [{ var buttonlist = [{
text: t('core', 'Cancel'), text: t('core', 'Cancel'),
}); });
$(dialogId).find('.conflicts').on('click', '.replacement input[type="checkbox"],.original:not(.readonly) 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
$(dialogId).find('.allexistingfiles + .count').text(''); $(dialogId).find('.allexistingfiles + .count').text('');
} }
}); });
dialogDeferred.resolve();
}) })
.fail(function() { .fail(function() {
dialogDeferred.reject();
alert(t('core', 'Error loading file exists template')); alert(t('core', 'Error loading file exists template'));
}); });
} }
//} //}
return dialogDeferred.promise();
}, },
_getFilePickerTemplate: function() { _getFilePickerTemplate: function() {
var defer = $.Deferred(); var defer = $.Deferred();

Loading…
Cancel
Save