feature(dom) processFiles: add ask before overwriting

This commit is contained in:
coderaiser 2015-04-24 05:22:47 -04:00
parent a3e44763df
commit e36df63a0b

View file

@ -1574,7 +1574,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*/
function processFiles(operation, data) {
var name, files, opFunc,
panel,
shouldAsk,
sameName,
ok,
RESTful = DOM.RESTful,
from = '',
@ -1582,11 +1585,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
names = [];
if (!data) {
data = {};
shouldAsk = true;
}
switch(operation) {
case 'copy':
opFunc = RESTful.cp;
@ -1596,22 +1594,41 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
break;
}
from = data.from || CurrentInfo.dirPath;
to = data.to || DOM.getNotCurrentDirPath();
names = data.names || Cmd.getSelectedNames();
if (data) {
from = data.from;
to = data.to;
names = data.names;
panel = CurrentInfo.panel;
} else {
from = CurrentInfo.dirPath;
to = DOM.getNotCurrentDirPath();
names = Cmd.getSelectedNames();
data = {};
shouldAsk = true;
panel = CurrentInfo.panelPassive;
}
if (!names.length)
names.push(DOM.getCurrentName());
name = names[0];
sameName = !!DOM.getCurrentByName(name, panel);
if (name === '..') {
Dialog.alert('No files selected!');
} else {
if (shouldAsk)
to = processMessage(to, operation, names);
if (from !== to && to) {
ok = from !== to && to;
if (ok && (shouldAsk && sameName))
ok = Dialog.confirm(Util.render('"{{ name }}" already exist. Overwrite?', {
name: name
}));
if (ok) {
Images.show.load('top');
files = {