mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
feature(dom) processFiles: add ask before overwriting
This commit is contained in:
parent
a3e44763df
commit
e36df63a0b
1 changed files with 26 additions and 9 deletions
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue