Move file dialog - Testing

Former-commit-id: 24ec3ed37b
pull/726/head
fabioswartz 2017-01-03 22:21:53 +00:00
parent 2e3d0dc4bd
commit 15af52dae7
1 changed files with 22 additions and 15 deletions

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) {