rename _assets to assets
Former-commit-id: 3bb6cc662da9e9255bd61fef42430c271002fd49 [formerly eaf1785c4f85522e4eb66d00a6ae9dd9ecc4fcb4] [formerly addd3ffe1396e6df84cdc3e8787d57ffb2be3dc6 [formerly 800693ad49e76c880230eb8cd1bc4a95e8c39fff]] Former-commit-id: 6c24d30f26529457202f470620a0ea1d31772b13 [formerly 384d2af17fe100b9db91462eb41337f9dff855f4] Former-commit-id: 94f4933e12f97ee7468c884f041612498e07ba32
This commit is contained in:
71
assets/src/components/prompts/Delete.vue
Normal file
71
assets/src/components/prompts/Delete.vue
Normal file
@@ -0,0 +1,71 @@
|
||||
<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')
|
||||
// TODO: show error in prompt
|
||||
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.done('delete')
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
this.$store.commit('setReload', true)
|
||||
buttons.done('delete')
|
||||
// TODO: show error in prompt
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user