2017-06-29 08:11:46 +00:00
|
|
|
<template>
|
2017-06-30 15:04:01 +00:00
|
|
|
<button @click="download" aria-label="Download" title="Download" class="action">
|
|
|
|
<i class="material-icons">file_download</i>
|
|
|
|
<span>Download</span>
|
|
|
|
<span v-if="selectedCount > 0" class="counter">{{ selectedCount }}</span>
|
|
|
|
</button>
|
2017-06-29 08:11:46 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-06-30 15:04:01 +00:00
|
|
|
import {mapGetters, mapState} from 'vuex'
|
2017-07-03 20:33:21 +00:00
|
|
|
import api from '@/utils/api'
|
2017-06-29 08:11:46 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'download-button',
|
2017-06-30 15:04:01 +00:00
|
|
|
computed: {
|
2017-07-03 20:33:21 +00:00
|
|
|
...mapState(['req', 'selected']),
|
2017-06-30 15:04:01 +00:00
|
|
|
...mapGetters(['selectedCount'])
|
|
|
|
},
|
2017-06-29 08:11:46 +00:00
|
|
|
methods: {
|
|
|
|
download: function (event) {
|
2017-06-30 15:04:01 +00:00
|
|
|
if (this.req.kind !== 'listing') {
|
2017-07-03 20:33:21 +00:00
|
|
|
api.download(null, this.$route.path)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.selectedCount === 1) {
|
|
|
|
api.download(null, this.req.items[this.selected[0]].url)
|
2017-06-29 08:11:46 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-03 19:44:01 +00:00
|
|
|
this.$store.commit('showPrompt', 'download')
|
2017-06-29 08:11:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|