Merge pull request #24 from scub-france/bug-doc-upload
Fix evetn listening redirection on doc upload
This commit is contained in:
commit
c3e96b62cd
3 changed files with 13 additions and 3 deletions
Binary file not shown.
|
|
@ -27,6 +27,8 @@ import { ref } from 'vue'
|
|||
import { useDocumentStore } from '../store'
|
||||
import { useI18n } from '../../../shared/i18n'
|
||||
|
||||
const emit = defineEmits<{ uploaded: [docId: string] }>()
|
||||
|
||||
const store = useDocumentStore()
|
||||
const { t } = useI18n()
|
||||
const fileInput = ref<HTMLInputElement | null>(null)
|
||||
|
|
@ -39,7 +41,10 @@ function openFilePicker() {
|
|||
async function onFileSelect(e: Event) {
|
||||
const target = e.target as HTMLInputElement
|
||||
const file = target.files?.[0]
|
||||
if (file) await store.upload(file)
|
||||
if (file) {
|
||||
const doc = await store.upload(file)
|
||||
if (doc) emit('uploaded', doc.id)
|
||||
}
|
||||
target.value = ''
|
||||
}
|
||||
|
||||
|
|
@ -47,7 +52,8 @@ async function onDrop(e: DragEvent) {
|
|||
dragging.value = false
|
||||
const file = e.dataTransfer?.files?.[0]
|
||||
if (file && file.type === 'application/pdf') {
|
||||
await store.upload(file)
|
||||
const doc = await store.upload(file)
|
||||
if (doc) emit('uploaded', doc.id)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<!-- Quick upload -->
|
||||
<div class="home-upload">
|
||||
<DocumentUpload />
|
||||
<DocumentUpload @uploaded="onUploaded" />
|
||||
</div>
|
||||
|
||||
<!-- Stats -->
|
||||
|
|
@ -71,6 +71,10 @@ const docCount = computed(() => documentStore.documents.length)
|
|||
const analysisCount = computed(() => historyStore.analyses.length)
|
||||
const recentDocs = computed(() => documentStore.documents.slice(0, 5))
|
||||
|
||||
function onUploaded() {
|
||||
router.push('/studio')
|
||||
}
|
||||
|
||||
function openInStudio(doc: Document) {
|
||||
documentStore.select(doc.id)
|
||||
router.push('/studio')
|
||||
|
|
|
|||
Loading…
Reference in a new issue