2017-06-29 13:16:08 +00:00
|
|
|
<template>
|
|
|
|
<div class="prompt">
|
2017-08-01 19:49:56 +00:00
|
|
|
<h3>{{ $t('prompts.move') }}</h3>
|
|
|
|
<p>{{ $t('prompts.moveMessage') }}</p>
|
2017-06-29 13:16:08 +00:00
|
|
|
|
2017-07-26 14:55:39 +00:00
|
|
|
<file-list @update:selected="val => dest = val"></file-list>
|
2017-06-29 13:16:08 +00:00
|
|
|
|
|
|
|
<div>
|
2017-08-01 19:49:56 +00:00
|
|
|
<button class="ok" @click="move">{{ $t('buttons.move') }}</button>
|
|
|
|
<button class="cancel"
|
|
|
|
@click="$store.commit('closeHovers')"
|
|
|
|
:aria-label="$t('buttons.cancel')"
|
|
|
|
:title="$t('buttons.cancel')">{{ $t('buttons.cancel') }}</button>
|
2017-06-29 13:16:08 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2017-06-30 16:49:05 +00:00
|
|
|
import { mapState } from 'vuex'
|
2017-07-26 14:55:39 +00:00
|
|
|
import FileList from './FileList'
|
2017-07-03 14:19:17 +00:00
|
|
|
import api from '@/utils/api'
|
2017-07-04 17:08:42 +00:00
|
|
|
import buttons from '@/utils/buttons'
|
2017-06-29 13:16:08 +00:00
|
|
|
|
|
|
|
export default {
|
2017-07-03 16:15:47 +00:00
|
|
|
name: 'move',
|
2017-07-26 14:55:39 +00:00
|
|
|
components: { FileList },
|
2017-06-29 13:16:08 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
2017-07-08 10:12:43 +00:00
|
|
|
current: window.location.pathname,
|
2017-07-26 14:55:39 +00:00
|
|
|
dest: null
|
2017-06-29 13:16:08 +00:00
|
|
|
}
|
|
|
|
},
|
2017-07-26 14:55:39 +00:00
|
|
|
computed: mapState(['req', 'selected']),
|
2017-06-29 13:16:08 +00:00
|
|
|
methods: {
|
|
|
|
move: function (event) {
|
2017-06-29 13:25:59 +00:00
|
|
|
event.preventDefault()
|
2017-07-04 17:04:00 +00:00
|
|
|
buttons.loading('move')
|
2017-07-26 14:55:39 +00:00
|
|
|
let items = []
|
2017-06-29 13:25:59 +00:00
|
|
|
|
2017-07-08 10:12:43 +00:00
|
|
|
// Create a new promise for each file.
|
2017-06-30 16:49:05 +00:00
|
|
|
for (let item of this.selected) {
|
2017-07-26 14:55:39 +00:00
|
|
|
items.push({
|
|
|
|
from: this.req.items[item].url,
|
|
|
|
to: this.dest + encodeURIComponent(this.req.items[item].name)
|
|
|
|
})
|
2017-06-29 13:25:59 +00:00
|
|
|
}
|
|
|
|
|
2017-07-08 10:12:43 +00:00
|
|
|
// Execute the promises.
|
2017-07-26 14:55:39 +00:00
|
|
|
api.move(items)
|
2017-06-29 13:25:59 +00:00
|
|
|
.then(() => {
|
2017-07-04 17:04:00 +00:00
|
|
|
buttons.done('move')
|
2017-07-26 14:55:39 +00:00
|
|
|
this.$router.push({ path: this.dest })
|
2017-06-29 13:25:59 +00:00
|
|
|
})
|
2017-07-06 13:40:06 +00:00
|
|
|
.catch(error => {
|
2017-07-04 17:08:42 +00:00
|
|
|
buttons.done('move')
|
2017-07-06 13:40:06 +00:00
|
|
|
this.$store.commit('showError', error)
|
2017-06-29 13:25:59 +00:00
|
|
|
})
|
2017-06-29 13:16:08 +00:00
|
|
|
|
2017-07-26 14:55:39 +00:00
|
|
|
event.preventDefault()
|
2017-06-29 13:16:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|