progresses on sharing #192
Progresses on #192
Progresses on #192
Little API update
Build assets
Former-commit-id: 68e70132ea857eb65638c0496c030be1c181ed1c [formerly d67b74280b7f12c3e20de6abe31fcfc26e8f43ef] [formerly 8fe91e003c9616da23f0e673ad4bb89d792a41c8 [formerly 8684343605]]
Former-commit-id: 7d22ff468e580601d0c3e0921734b587b92484f8 [formerly 55f9d830636f9bbf15e0453d1ee7de6ee5d5191e]
Former-commit-id: ad411a5979521dda9ea9683d86e4c8ae7b3c9e6f
79 lines
2.2 KiB
Vue
79 lines
2.2 KiB
Vue
<template>
|
|
<div class="prompt">
|
|
<h3>{{ $t('prompts.deleteTitle') }}</h3>
|
|
<p v-show="req.kind !== 'listing'">{{ $t('prompts.deleteMessageSingle') }}</p>
|
|
<p v-show="req.kind === 'listing'">{{ $t('prompts.deleteMessageMultiple', { count: selectedCount}) }}</p>
|
|
<div>
|
|
<button @click="submit"
|
|
:aria-label="$t('buttons.delete')"
|
|
:title="$t('buttons.delete')">{{ $t('buttons.delete') }}</button>
|
|
<button class="cancel"
|
|
@click="$store.commit('closeHovers')"
|
|
:aria-label="$t('buttons.cancel')"
|
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {mapGetters, mapMutations, mapState} from 'vuex'
|
|
import { remove } 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 we are not on a listing, delete the current
|
|
// opened file.
|
|
if (this.req.kind !== 'listing') {
|
|
remove(this.$route.path)
|
|
.then(() => {
|
|
buttons.success('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
|
|
}
|
|
|
|
// Create the promises array and fill it with
|
|
// the delete request for every selected file.
|
|
let promises = []
|
|
|
|
for (let index of this.selected) {
|
|
promises.push(remove(this.req.items[index].url))
|
|
}
|
|
|
|
Promise.all(promises)
|
|
.then(() => {
|
|
buttons.success('delete')
|
|
this.$store.commit('setReload', true)
|
|
})
|
|
.catch(error => {
|
|
buttons.done('delete')
|
|
this.$store.commit('setReload', true)
|
|
this.$store.commit('showError', error)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|