feat: open addmodal when dragging a file into the dashboard

This commit is contained in:
m4ximuel 2021-04-21 15:32:59 +09:00 committed by GitHub
parent 011a5bdcf5
commit 5807db5e99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -2,6 +2,7 @@
<v-dialog <v-dialog
v-model="dialog" v-model="dialog"
scrollable scrollable
:transition="dTransition"
:content-class="phoneLayout ? 'rounded-0' : 'rounded-form'" :content-class="phoneLayout ? 'rounded-0' : 'rounded-form'"
max-width="500px" max-width="500px"
:fullscreen="phoneLayout" :fullscreen="phoneLayout"
@ -201,9 +202,11 @@ import { FullScreenModal } from '@/mixins'
export default { export default {
name: 'AddModal', name: 'AddModal',
mixins: [Modal, FullScreenModal], mixins: [Modal, FullScreenModal],
props: ['initialMagnet'], props: ['initialMagnet', 'openSuddenly'],
data() { data() {
return { return {
dTransition: 'scale-transition',
hndlDialog: true,
showWrapDrag: false, showWrapDrag: false,
files: [], files: [],
category: null, category: null,
@ -253,6 +256,12 @@ export default {
this.$store.commit('FETCH_CATEGORIES') this.$store.commit('FETCH_CATEGORIES')
this.urls = this.initialMagnet this.urls = this.initialMagnet
this.setSettings() this.setSettings()
if (this.openSuddenly == true) {
this.dTransition = 'none'
}
},
mounted() {
this.dTransition = 'scale-transition'
}, },
methods: { methods: {
setSettings() { setSettings() {

View file

@ -1,7 +1,6 @@
<template> <template>
<div <div
class="px-1 px-sm-5 pt-4 background noselect" class="px-1 px-sm-5 pt-4 background noselect"
@dragenter.prevent="detectDragEnter()"
@click.self="resetSelected" @click.self="resetSelected"
> >
<v-row <v-row
@ -294,6 +293,7 @@ export default {
}, },
mounted() { mounted() {
document.addEventListener('keydown', this.handleKeyboardShortcut) document.addEventListener('keydown', this.handleKeyboardShortcut)
document.addEventListener('dragenter', this.detectDragEnter)
}, },
created() { created() {
this.$store.dispatch('INIT_INTERVALS') this.$store.dispatch('INIT_INTERVALS')
@ -302,6 +302,7 @@ export default {
beforeDestroy() { beforeDestroy() {
this.$store.commit('REMOVE_INTERVALS') this.$store.commit('REMOVE_INTERVALS')
document.removeEventListener('keydown', this.handleKeyboardShortcut) document.removeEventListener('keydown', this.handleKeyboardShortcut)
document.removeEventListener('dragenter', this.detectDragEnter)
}, },
methods: { methods: {
strTouchStart(e, data) { strTouchStart(e, data) {
@ -354,7 +355,7 @@ export default {
}, },
detectDragEnter() { detectDragEnter() {
if (this.selected_torrents.length == 0 && this.$store.state.modals.length < 1) { if (this.selected_torrents.length == 0 && this.$store.state.modals.length < 1) {
this.addModal('AddModal') this.createModal('AddModal', { openSuddenly: true })
} }
return true return true