Moving working :)

Former-commit-id: bdf9418962bd0a7a97ee620be4e31b2794ae0bd4 [formerly 97d894f08335df5cdc067cb82ae582e16bbd78ad] [formerly 45421f1cce32aed206642da7ade436bcb3aaddcf [formerly efc437c771]]
Former-commit-id: e7fef34c75f43cbe8735236e1c797d93ec9b1024 [formerly 18ab632fa655d35753507a55d5e54f7db1df9166]
Former-commit-id: b10dd0d5a334d14052122bf5d4a41ed6f370ea5b
pull/726/head
Henrique Dias 2017-06-29 14:25:59 +01:00
parent dd87a70157
commit 090116caf5
2 changed files with 33 additions and 29 deletions

View File

@ -80,31 +80,6 @@ listing.addDoubleTapEvent = function () {
}) })
} }
listing.moveMakeItem = function (url, name) {
let node = document.createElement('li'),
count = 0
node.dataset.url = url
node.innerHTML = name
node.setAttribute('aria-selected', false)
node.addEventListener('dblclick', listing.moveDialogNext)
node.addEventListener('click', listing.selectMoveFolder)
node.addEventListener('touchstart', event => {
count++
setTimeout(() => {
count = 0
}, 300)
if (count > 1) {
listing.moveDialogNext(event)
}
})
return node
}
listing.moveSelected = function (event) { listing.moveSelected = function (event) {
event.preventDefault() event.preventDefault()

View File

@ -4,7 +4,7 @@
<p>Choose new house for your file(s)/folder(s):</p> <p>Choose new house for your file(s)/folder(s):</p>
<ul class="file-list"> <ul class="file-list">
<li @click="select" @dblclick="next" v-for="item in items" :data-url="item.url">{{ item.name }}</li> <li @click="select" @dblclick="next" :key="item.name" v-for="item in items" :data-url="item.url">{{ item.name }}</li>
</ul> </ul>
<p>Currently navigating on: <code>{{ current }}</code>.</p> <p>Currently navigating on: <code>{{ current }}</code>.</p>
@ -18,6 +18,7 @@
<script> <script>
import page from '../page' import page from '../page'
import webdav from '../webdav'
var $ = window.info var $ = window.info
@ -55,11 +56,39 @@ export default {
$.showMove = false $.showMove = false
}, },
move: function (event) { move: function (event) {
console.log('Move') event.preventDefault()
let el = event.currentTarget
let promises = []
let dest = this.current
// buttons.setLoading('move')
let selected = el.querySelector('li[aria-selected=true]')
if (selected !== null) {
dest = selected.dataset.url
}
for (let item of $.selected) {
let from = $.req.data.items[item].url
let to = dest + '/' + $.req.data.items[item].name
to = to.replace('//', '/')
promises.push(webdav.move(from, to))
}
$.showMove = false
Promise.all(promises)
.then(() => {
// buttons.setDone('move')
page.open(dest)
})
.catch(e => {
// buttons.setDone('move', false)
console.log(e)
})
}, },
next: function (event) { next: function (event) {
console.log('Next')
let url = event.currentTarget.dataset.url let url = event.currentTarget.dataset.url
this.json(url) this.json(url)
.then((data) => { .then((data) => {