Move file dialog - Testing

This commit is contained in:
fabioswartz 2017-01-03 22:21:53 +00:00
parent eb79371421
commit 24ec3ed37b

View File

@ -301,6 +301,11 @@ function loadNextFolder(event) {
prompt.querySelector("ul").innerHTML = ""; prompt.querySelector("ul").innerHTML = "";
prompt.querySelector('code').innerHTML = event.target.dataset.url; prompt.querySelector('code').innerHTML = event.target.dataset.url;
if(JSON.parse(request.response) == null) {
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
return;
}
for(let f of JSON.parse(request.response)) { for(let f of JSON.parse(request.response)) {
if(f.IsDir === true) { if(f.IsDir === true) {
dirs++; dirs++;
@ -327,23 +332,25 @@ function loadNextFolder(event) {
function moveSelected(event) { function moveSelected(event) {
event.preventDefault(); event.preventDefault();
// TODO: this only works for ONE file. What if there are more files selected? let promises = [];
// TODO: use webdav.rename buttons.setLoading("move");
/* let request = new XMLHttpRequest(), for(let file of selectedItems) {
oldLink = toWebDavURL(window.location.pathname), let fileElement = document.getElementById(file),
newLink = toWebDavURL(event.srcElement.querySelector("li[aria-selected=true]").innerHTML + "/"); destFolder = event.target.querySelector("p code").innerHTML;
if(event.srcElement.querySelector("li[aria-selected=true]") != null) destFolder = event.srcElement.querySelector("li[aria-selected=true]").innerHTML;
promises.push(webdav.move(fileElement.dataset.url, "/" + destFolder + "/" + fileElement.querySelector(".name").innerHTML));
}
request.open("MOVE", oldLink); Promise.all(promises)
request.setRequestHeader("Destination", newLink); .then(() => {
request.send(); closePrompt(event);
request.onreadystatechange = function () { buttons.setDone("move");
if(request.readyState == 4) { listing.reload();
if(request.status == 200 || request.status == 204) { })
window.reload(); .catch(e => {
} console.log(e);
} })
} */
} }
function moveEvent(event) { function moveEvent(event) {