Henrique Dias 0a29515e3a Fix download single folder
Former-commit-id: 6a33652b05f7ce5561253888997a2e48d3375730 [formerly cc08258ac6555353e6a5354b980370de6bd6f72c] [formerly a33e4246bca6444b99aed5cc1d7d4168613b3cf6 [formerly 34a3fec044d8e18bfdd5533ef3e30f685822811e]]
Former-commit-id: 71b1d7e3f84da16d32ab69efaa103bb6f811b3eb [formerly 7d7db781a856cee5942f9c67240fc25416cb4a35]
Former-commit-id: 2abca1999fa05fcc1449b993e02ae1ed76a4ff73
2017-07-19 08:30:08 +01:00

40 lines
1.1 KiB
Vue

<template>
<button @click="download" aria-label="Download" title="Download" id="download-button" class="action">
<i class="material-icons">file_download</i>
<span>Download</span>
<span v-if="selectedCount > 0" class="counter">{{ selectedCount }}</span>
</button>
</template>
<script>
import {mapGetters, mapState} from 'vuex'
import api from '@/utils/api'
export default {
name: 'download-button',
computed: {
...mapState(['req', 'selected']),
...mapGetters(['selectedCount'])
},
methods: {
download: function (event) {
// If we are not on a listing, download the current file.
if (this.req.kind !== 'listing') {
api.download(null, this.$route.path)
return
}
// If we are on a listing and there is one element selected,
// download it.
if (this.selectedCount === 1 && !this.req.items[this.selected[0]].isDir) {
api.download(null, this.req.items[this.selected[0]].url)
return
}
// Otherwise show the prompt to choose the formt of the download.
this.$store.commit('showHover', 'download')
}
}
}
</script>