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

Former-commit-id: c06a6169603b32df1dbb1e3b31b3049235a7f743 [formerly 1c42799365eb0c5274729a68c8413a312da783bf] [formerly c0104b606e134e4f610c61d366f84f36283fce1d [formerly 9ffc6c3d89700c045fe4423dc6da8701495b4374]] Former-commit-id: 3d788cc061f35f17b0c2287d0ccd31766a14ac6c [formerly 26231ef89e7ec00bff76fa7f3e34c1b3eda56e58] Former-commit-id: d94ae5ce9f331f70146eae2cbcfd3f40acd39d57
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="closePrompts" 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',
|
|
computed: {
|
|
...mapGetters(['selectedCount']),
|
|
...mapState(['req', 'selected'])
|
|
},
|
|
methods: {
|
|
...mapMutations(['closePrompts']),
|
|
submit: function (event) {
|
|
this.closePrompts()
|
|
// 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>
|