Former-commit-id: c14972384cc8afad28d49388b0b4545669e20b7d [formerly 0af2e5f9aff2aac576044ca9590045f656fbffda] [formerly 02248a86b7063e1c9d6779c3574a848708ff86f2 [formerly efaa8439a9dbbf9b829cf9fc32ca789c2a16df7d]] Former-commit-id: 4ce0a81ea04b56cef11d62107d692502e266a16e [formerly 2c46db9398c267351c10f06c089ed08dc3625232] Former-commit-id: 1c93a0643217ab69668600b41e2d8263266d7e23
71 lines
1.8 KiB
Vue
71 lines
1.8 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="closeHovers" class="cancel">Cancel</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapGetters, mapMutations, mapState} from 'vuex'
|
|
import api from '@/utils/api'
|
|
import url from '@/utils/url'
|
|
import buttons from '@/utils/buttons'
|
|
|
|
export default {
|
|
name: 'delete',
|
|
computed: {
|
|
...mapGetters(['selectedCount']),
|
|
...mapState(['req', 'selected'])
|
|
},
|
|
methods: {
|
|
...mapMutations(['closeHovers']),
|
|
submit: function (event) {
|
|
this.closeHovers()
|
|
buttons.loading('delete')
|
|
|
|
if (this.req.kind !== 'listing') {
|
|
api.delete(this.$route.path)
|
|
.then(() => {
|
|
buttons.done('delete')
|
|
this.$router.push({path: url.removeLastDir(this.$route.path) + '/'})
|
|
})
|
|
.catch(error => {
|
|
buttons.done('delete')
|
|
this.$store.commit('showError', 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(() => {
|
|
this.$store.commit('setReload', true)
|
|
buttons.done('delete')
|
|
})
|
|
.catch(error => {
|
|
console.log(error)
|
|
this.$store.commit('setReload', true)
|
|
buttons.done('delete')
|
|
this.$store.commit('showError', error)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|