Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/Components/File/File.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div v-if="currentFileId > 0" class="content-file" @click="openSidebar">
<div v-if="currentNodeId > 0 && currentFile" class="content-file" @click="openSidebar">
<img v-if="previewUrl && backgroundFailed !== true"
ref="previewImg"
alt=""
Expand All @@ -15,10 +15,10 @@
@load="backgroundFailed = false">
<FileIcon v-else v-once :size="128" />
<div class="enDot">
<div :class="filesStore.files[currentFileId].statusText !== 'none' ? 'dot ' + statusToClass(filesStore.files[currentFileId].status) : '' " />
<span>{{ filesStore.files[currentFileId].statusText !== 'none' ? filesStore.files[currentFileId].statusText : '' }}</span>
<div :class="currentFile.statusText !== 'none' ? 'dot ' + statusToClass(currentFile.status) : '' " />
<span>{{ currentFile.statusText }}</span>
</div>
<h1>{{ filesStore.files[currentFileId].name }}</h1>
<h1>{{ currentFile.name }}</h1>
</div>
</template>

Expand All @@ -35,7 +35,7 @@ export default {
FileIcon,
},
props: {
fileId: {
nodeId: {
type: Number,
default: 0,
required: false,
Expand All @@ -53,30 +53,32 @@ export default {
}
},
computed: {
currentFileId() {
if (this.fileId) {
return this.fileId
currentNodeId() {
if (this.nodeId) {
return this.nodeId
}
return this.filesStore.selectedId
return this.filesStore.selectedNodeId
},
currentFile() {
return this.filesStore.files[this.currentNodeId]
},
previewUrl() {
if (this.backgroundFailed === true) {
return null
}

const file = this.filesStore.files[this.currentFileId]
if (!file) {
if (!this.currentFile) {
return null
}

let previewUrl = ''
if (file.nodeId) {
if (this.currentFile.nodeId) {
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', {
nodeId: file.nodeId,
nodeId: this.currentFile.nodeId,
})
} else {
previewUrl = window.location.origin + generateUrl('/core/preview?fileId={fileid}', {
fileid: this.currentFileId,
fileid: this.currentFile.id,
})
}

Expand All @@ -89,12 +91,12 @@ export default {

// Handle cropping
url.searchParams.set('a', this.cropPreviews === true ? '0' : '1')
return url
return url.toString()
},
},
methods: {
openSidebar() {
this.filesStore.selectFile(this.currentFileId)
this.filesStore.selectFile(this.currentNodeId)
},
statusToClass(status) {
switch (Number(status)) {
Expand Down
12 changes: 6 additions & 6 deletions src/Components/Request/RequestPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ export default {
url: this.pdfUrl,
},
})
.then((fileId) => {
this.filesStore.selectFile(fileId)
.then((nodeId) => {
this.filesStore.selectFile(nodeId)
this.closeModalUploadFromUrl()
})
.catch(({ response }) => {
Expand Down Expand Up @@ -347,8 +347,8 @@ export default {
files: filesPayload,
name: envelopeName.trim(),
})
.then((fileId) => {
this.filesStore.selectFile(fileId)
.then((nodeId) => {
this.filesStore.selectFile(nodeId)
})
.catch(({ response }) => {
showError(response?.data?.ocs?.data?.message || this.t('libresign', 'Upload failed'))
Expand All @@ -369,8 +369,8 @@ export default {
},
name: path.match(/([^/]*?)(?:\.[^.]*)?$/)[1] ?? '',
})
.then((fileId) => {
this.filesStore.selectFile(fileId)
.then((nodeId) => {
this.filesStore.selectFile(nodeId)
})
.catch(({ response }) => {
showError(response.data.ocs.data.message)
Expand Down
2 changes: 1 addition & 1 deletion src/Components/RightSidebar/AppFilesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {

this.disconnectTitleObserver()

if (this.filesStore.selectedId === fileInfo.id) {
if (this.filesStore.selectedNodeId === fileInfo.id) {
return
}

Expand Down
21 changes: 6 additions & 15 deletions src/Components/RightSidebar/EnvelopeFilesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,6 @@ export default {
envelope() {
return this.filesStore.getFile()
},
envelopeUuid() {
return this.envelope.uuid
},
envelopeId() {
return this.envelope.id
},
canDelete() {
return this.envelope?.status === SIGN_STATUS.DRAFT && this.files.length >= 1
},
Expand Down Expand Up @@ -276,7 +270,7 @@ export default {
},
methods: {
async loadFiles(page = 1) {
if (!this.envelopeId) {
if (!this.envelope?.id) {
return
}

Expand All @@ -291,7 +285,7 @@ export default {
const params = new URLSearchParams({
page: page,
length: 50,
parentFileId: this.envelopeId,
parentFileId: this.envelope.id,
})

await axios.get(`${url}?${params.toString()}`)
Expand Down Expand Up @@ -368,7 +362,7 @@ export default {
source: fileUrl,
basename: file.name,
mime: 'application/pdf',
fileid: file.nodeId,
fileid: file.id,
}
OCA.Viewer.open({
fileInfo,
Expand Down Expand Up @@ -410,7 +404,7 @@ export default {
this.hasLoading = true
const fileIds = [...this.selectedFiles]

const result = await this.filesStore.removeFilesFromEnvelope(this.envelopeId, fileIds)
const result = await this.filesStore.removeFilesFromEnvelope(fileIds)

if (result.success) {
// Remover arquivos da lista local
Expand Down Expand Up @@ -453,7 +447,7 @@ export default {
const abortController = new AbortController()
this.uploadAbortController = abortController

const result = await this.filesStore.addFilesToEnvelope(this.envelopeUuid, formData, {
const result = await this.filesStore.addFilesToEnvelope(this.envelope.uuid, formData, {
signal: abortController.signal,
onUploadProgress: (progressEvent) => {
if (progressEvent.total) {
Expand All @@ -467,9 +461,6 @@ export default {
this.showSuccess(this.t('libresign', result.message))
this.files.push(...result.files)
this.totalFiles = result.filesCount
if (this.envelopeId && this.filesStore.files[this.envelopeId]) {
this.filesStore.files[this.envelopeId].filesCount = result.filesCount
}
} else {
if (result.message !== 'Upload cancelled') {
this.showError(this.t('libresign', result.message))
Expand Down Expand Up @@ -558,7 +549,7 @@ export default {
async confirmDelete(file) {
this.hasLoading = true

const result = await this.filesStore.removeFilesFromEnvelope(this.envelopeId, file.id)
const result = await this.filesStore.removeFilesFromEnvelope([file.id])

if (result.success) {
this.showSuccess(this.t('libresign', result.message))
Expand Down
14 changes: 7 additions & 7 deletions src/Components/RightSidebar/RequestSignatureTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default {
showEnvelopeFilesDialog: false,
infoIcon: svgInfo,
adminSignatureFlow: '',
lastSyncedFileId: null,
lastSyncedNodeId: null,
}
},
computed: {
Expand Down Expand Up @@ -594,11 +594,11 @@ export default {
signers(signers) {
this.init(signers)
},
'filesStore.selectedId': {
handler(newFileId, oldFileId) {
if (newFileId && newFileId !== this.lastSyncedFileId) {
'filesStore.selectedNodeId': {
handler(newNodeId, oldNodeId) {
if (newNodeId && newNodeId !== this.lastSyncedNodeId) {
this.syncPreserveOrderWithFile()
this.lastSyncedFileId = newFileId
this.lastSyncedNodeId = newNodeId
}
},
immediate: true,
Expand Down Expand Up @@ -684,7 +684,7 @@ export default {

const flow = file.signatureFlow

this.lastSyncedFileId = this.filesStore.selectedId
this.lastSyncedNodeId = this.filesStore.selectedNodeId

if ((flow === 'ordered_numeric' || flow === 2) && !this.isAdminFlowForced) {
this.preserveOrder = true
Expand Down Expand Up @@ -845,7 +845,7 @@ export default {
},
async sendNotify(signer) {
const body = {
fileId: this.filesStore.selectedId,
fileId: this.filesStore.getFile().id,
signRequestId: signer.signRequestId,
}

Expand Down
Loading
Loading