mirror of
https://github.com/filebrowser/filebrowser.git
synced 2025-05-08 19:22:57 +00:00

Former-commit-id: 9f1f09311813203910d5b323ba80712553ee2741 [formerly 0be00be1de305d786affc6bf0886aed9b20fbc51] [formerly 04597463117e94830b24b87faaaccf3d35284427 [formerly 3f2dc3f1c56a7a636a836d36b94c052f55f32d93]] Former-commit-id: 8d26cc1d96faed73c7974ea7e5e78bf268af3ad9 [formerly a083ac8f68c90a636843c3565bd349657c0ec383] Former-commit-id: ef10f3b3c388d65ceac40785b45dbac190a6cc99
83 lines
2.1 KiB
Vue
83 lines
2.1 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>Delete files</h3>
|
|
<p v-show="req.kind !== 'listing'">Are you sure you want to delete this file/folder?</p>
|
|
<p v-show="req.kind === 'listing'">Are you sure you want to delete {{ selectedCount }} file(s)?</p>
|
|
<div>
|
|
<button @click="submit" autofocus>Delete</button>
|
|
<button @click="showDelete(false)" class="cancel">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapGetters, mapMutations, mapState} from 'vuex'
|
|
import webdav from '../utils/webdav'
|
|
import page from '../utils/page'
|
|
|
|
export default {
|
|
name: 'delete-prompt',
|
|
computed: {
|
|
...mapGetters(['selectedCount']),
|
|
...mapState(['req', 'selected'])
|
|
},
|
|
methods: {
|
|
...mapMutations(['showDelete']),
|
|
submit: function (event) {
|
|
this.showDelete(false)
|
|
// buttons.setLoading('delete')
|
|
|
|
if (this.req.kind !== 'listing') {
|
|
webdav.trash(window.location.pathname)
|
|
.then(() => {
|
|
// buttons.setDone('delete')
|
|
page.open(page.removeLastDir(window.location.pathname))
|
|
})
|
|
.catch(error => {
|
|
// buttons.setDone('delete', false)
|
|
console.log(error)
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
if (this.selectedCount === 0) {
|
|
// This shouldn't happen...
|
|
return
|
|
}
|
|
|
|
if (this.selectedCount === 1) {
|
|
webdav.trash(this.req.data.items[this.selected[0]].url)
|
|
.then(() => {
|
|
// buttons.setDone('delete')
|
|
page.reload()
|
|
})
|
|
.catch(error => {
|
|
// buttons.setDone('delete', false)
|
|
console.log(error)
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
// More than one item!
|
|
let promises = []
|
|
|
|
for (let index of this.selected) {
|
|
promises.push(webdav.trash(this.req.data.items[index].url))
|
|
}
|
|
|
|
Promise.all(promises)
|
|
.then(() => {
|
|
page.reload()
|
|
// buttons.setDone('delete')
|
|
})
|
|
.catch(error => {
|
|
console.log(error)
|
|
// buttons.setDone('delete', false)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|