Moving working :)

This commit is contained in:
Henrique Dias 2017-06-29 14:25:59 +01:00
parent 1e7c4e6468
commit efc437c771
No known key found for this signature in database
GPG Key ID: 936F5EB68D786730
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) {
event.preventDefault()

View File

@ -4,7 +4,7 @@
<p>Choose new house for your file(s)/folder(s):</p>
<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>
<p>Currently navigating on: <code>{{ current }}</code>.</p>
@ -18,6 +18,7 @@
<script>
import page from '../page'
import webdav from '../webdav'
var $ = window.info
@ -55,11 +56,39 @@ export default {
$.showMove = false
},
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) {
console.log('Next')
let url = event.currentTarget.dataset.url
this.json(url)
.then((data) => {