Skip to content

Commit

Permalink
Conflict Pre Dialog added
Browse files Browse the repository at this point in the history
Signed-off-by: Sangramsinh Desai <sangramsinh.desai@t-systems.com>
  • Loading branch information
TSI-sangramdesai committed Sep 14, 2021
1 parent a994ef0 commit ff44f95
Show file tree
Hide file tree
Showing 5 changed files with 868 additions and 3 deletions.
53 changes: 50 additions & 3 deletions apps/files/js/file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ OC.FileUpload = function(uploader, data) {
OC.FileUpload.CONFLICT_MODE_DETECT = 0;
OC.FileUpload.CONFLICT_MODE_OVERWRITE = 1;
OC.FileUpload.CONFLICT_MODE_AUTORENAME = 2;
OC.conflictsData = null;

// IE11 polyfill
// TODO: nuke out of orbit as well as this legacy code
Expand Down Expand Up @@ -790,15 +791,17 @@ OC.Uploader.prototype = _.extend({
}
return true;
});
OC.conflictsData = conflicts;
if (conflicts.length) {
// wait for template loading
OC.dialogs.fileexists(null, null, null, this).done(function() {
_.each(conflicts, function(conflictData) {
OC.dialogs.fileexists(conflictData[1], conflictData[0], conflictData[1].getFile(), this);
OC.dialogs.fileexistsConflictPreDlg(null, null, null, this).done(function () {
_.each(conflicts, function (conflictData) {
OC.dialogs.fileexistsConflictPreDlg(conflictData[1], conflictData[0], conflictData[1].getFile(), this);
});
});
}


// upload non-conflicting files
// note: when reaching the server they might still meet conflicts
// if the folder was concurrently modified, these will get added
Expand Down Expand Up @@ -864,6 +867,50 @@ OC.Uploader.prototype = _.extend({
return ($tr.attr('data-mounttype') === 'shared-root' && $tr.attr('data-mime') !== 'httpd/unix-directory');
},

/** Custom Pre File conflict dialog*/

/**
* Bypass to nexcloud default confluct box
*/
moreDetails:function() {
var conflicts = OC.conflictsData;
var self = this;
this.cancelUploads();
if (conflicts.length) {
// wait for template loading
OC.dialogs.fileexists(null, null, null, this).done(function () {
_.each(conflicts, function (conflictData) {
OC.dialogs.fileexists(conflictData[1], conflictData[0], conflictData[1].getFile(), this);
});
});
}
},

/**
* callback for the conflicts dialog
* calls onSkip, onReplace or onAutorename for each conflict
* @param keepOriginal - boolean value. If true will keep original file
* @param keepOriginal - boolean value. If true will repleace file
*/
onContinueConflictPreDlg:function(keepOriginal, keepReplacement) {
var self = this;
//iterate over all conflicts
jQuery.each(OC.conflictsData, function (i, conflict) {
var conflictData = conflict[1]
if (keepOriginal && keepReplacement) {
// when both selected -> autorename
self.onAutorename(conflictData);
} else if (keepReplacement) {
// when only replacement selected -> overwrite
self.onReplace(conflictData);
} else {
// when only original selected -> skip
// when none selected -> skip
self.onSkip(conflictData);
}
});
},

/**
* Initialize the upload object
*
Expand Down
4 changes: 4 additions & 0 deletions apps/files/templates/fileexists-conflict-pre-dlg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div id="{dialog_name}" title="{title}" class="fileexists">
<span class="why">{what}</span><br/>
<span class="what">{why}</span><br/>
</div>
Loading

0 comments on commit ff44f95

Please # to comment.