Files
filebrowser/assets/src/components/buttons/Download.vue
T
Henrique Dias 946ce2df5a Comment download
Former-commit-id: f1c430bf94bbf67ee3fe42c15df9805e8d7f3eb3 [formerly f4e34a00f33e607bcd7b752f8eec1bb6e79678cc] [formerly 8ba9cd9133ef9a566d691704a6ebe03c3c56cd72 [formerly 063cd4f5ed]]
Former-commit-id: 0b036c023d5f9929c34cb4be078bb493dd476547 [formerly 909ba7a88cbd83b9bd0be5c0813f2c5a91bcf62d]
Former-commit-id: add67bf286544c7c7d60d63861b05df82efa073f
2017-07-08 11:15:23 +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) {
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>