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

Former-commit-id: c821c066681092fa80300eefecd82394283112cd [formerly 31ee8568a88a7a3f53733c942ddc5d2a120662b6] [formerly fb943bcb74f7b85d390bf0610e6e5735ef1b6b74 [formerly 9e42f0f1ed8b717009dc26524cb7f2aa885ac448]] Former-commit-id: 142eda7f066e312d38f31b01c090a32005a94248 [formerly 2cee72b9263f86c146a43e6dfd32f6e6642f9f11] Former-commit-id: a8a4617e1ebbf3089880ab670a4f62402c44b637
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(() => {
|
|
this.$store.commit('setReload', true)
|
|
// buttons.setDone('delete')
|
|
})
|
|
.catch(error => {
|
|
console.log(error)
|
|
this.$store.commit('setReload', true)
|
|
// buttons.setDone('delete', false)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|