Former-commit-id: 682c7d56814a3c9a35fcf55b540e470b5c66d890 [formerly a603a591938ec8edbe3f703772f86ba978ff92de] [formerly 6d1a11fdeb5d3a00c202e125a0873b263a3787cf [formerly 12c466d2aafbd07bea83352c03d0ad19347dbea3]] Former-commit-id: 4f43bbf0b4f91a9528cdf881f4abbdfc098b82cd [formerly 7fc1e010ac54107ff03762ad729ed54beccca02c] Former-commit-id: 4d464034e98aefbdce39d142a30bf34aa3fd2d2e
69 lines
1.7 KiB
Vue
69 lines
1.7 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 api from '@/utils/api'
|
|
import url from '@/utils/url'
|
|
|
|
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') {
|
|
api.delete(this.$route.path)
|
|
.then(() => {
|
|
// buttons.setDone('delete')
|
|
this.$router.push({path: url.removeLastDir(this.$route.path) + '/'})
|
|
})
|
|
.catch(error => {
|
|
// buttons.setDone('delete', false)
|
|
console.log(error)
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
if (this.selectedCount === 0) {
|
|
// This shouldn't happen...
|
|
return
|
|
}
|
|
|
|
let promises = []
|
|
|
|
for (let index of this.selected) {
|
|
promises.push(api.delete(this.req.items[index].url))
|
|
}
|
|
|
|
Promise.all(promises)
|
|
.then(() => {
|
|
// page.reload()
|
|
// buttons.setDone('delete')
|
|
})
|
|
.catch(error => {
|
|
console.log(error)
|
|
// page.reload()
|
|
// buttons.setDone('delete', false)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|