Skip to content

Commit fa7b08d

Browse files
authored
Merge pull request #6311 from LibreSign/backport/6309/stable32
[stable32] refactor: replace fileid by nodeid at filestore
2 parents 44559af + a409d17 commit fa7b08d

12 files changed

Lines changed: 134 additions & 140 deletions

File tree

src/Components/File/File.vue

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55
<template>
6-
<div v-if="currentFileId > 0" class="content-file" @click="openSidebar">
6+
<div v-if="currentNodeId > 0 && currentFile" class="content-file" @click="openSidebar">
77
<img v-if="previewUrl && backgroundFailed !== true"
88
ref="previewImg"
99
alt=""
@@ -15,10 +15,10 @@
1515
@load="backgroundFailed = false">
1616
<FileIcon v-else v-once :size="128" />
1717
<div class="enDot">
18-
<div :class="filesStore.files[currentFileId].statusText !== 'none' ? 'dot ' + statusToClass(filesStore.files[currentFileId].status) : '' " />
19-
<span>{{ filesStore.files[currentFileId].statusText !== 'none' ? filesStore.files[currentFileId].statusText : '' }}</span>
18+
<div :class="currentFile.statusText !== 'none' ? 'dot ' + statusToClass(currentFile.status) : '' " />
19+
<span>{{ currentFile.statusText }}</span>
2020
</div>
21-
<h1>{{ filesStore.files[currentFileId].name }}</h1>
21+
<h1>{{ currentFile.name }}</h1>
2222
</div>
2323
</template>
2424

@@ -35,7 +35,7 @@ export default {
3535
FileIcon,
3636
},
3737
props: {
38-
fileId: {
38+
nodeId: {
3939
type: Number,
4040
default: 0,
4141
required: false,
@@ -53,30 +53,32 @@ export default {
5353
}
5454
},
5555
computed: {
56-
currentFileId() {
57-
if (this.fileId) {
58-
return this.fileId
56+
currentNodeId() {
57+
if (this.nodeId) {
58+
return this.nodeId
5959
}
60-
return this.filesStore.selectedId
60+
return this.filesStore.selectedNodeId
61+
},
62+
currentFile() {
63+
return this.filesStore.files[this.currentNodeId]
6164
},
6265
previewUrl() {
6366
if (this.backgroundFailed === true) {
6467
return null
6568
}
6669
67-
const file = this.filesStore.files[this.currentFileId]
68-
if (!file) {
70+
if (!this.currentFile) {
6971
return null
7072
}
7173
7274
let previewUrl = ''
73-
if (file.nodeId) {
75+
if (this.currentFile.nodeId) {
7476
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', {
75-
nodeId: file.nodeId,
77+
nodeId: this.currentFile.nodeId,
7678
})
7779
} else {
7880
previewUrl = window.location.origin + generateUrl('/core/preview?fileId={fileid}', {
79-
fileid: this.currentFileId,
81+
fileid: this.currentFile.id,
8082
})
8183
}
8284
@@ -89,12 +91,12 @@ export default {
8991
9092
// Handle cropping
9193
url.searchParams.set('a', this.cropPreviews === true ? '0' : '1')
92-
return url
94+
return url.toString()
9395
},
9496
},
9597
methods: {
9698
openSidebar() {
97-
this.filesStore.selectFile(this.currentFileId)
99+
this.filesStore.selectFile(this.currentNodeId)
98100
},
99101
statusToClass(status) {
100102
switch (Number(status)) {

src/Components/Request/RequestPicker.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ export default {
312312
url: this.pdfUrl,
313313
},
314314
})
315-
.then((fileId) => {
316-
this.filesStore.selectFile(fileId)
315+
.then((nodeId) => {
316+
this.filesStore.selectFile(nodeId)
317317
this.closeModalUploadFromUrl()
318318
})
319319
.catch(({ response }) => {
@@ -347,8 +347,8 @@ export default {
347347
files: filesPayload,
348348
name: envelopeName.trim(),
349349
})
350-
.then((fileId) => {
351-
this.filesStore.selectFile(fileId)
350+
.then((nodeId) => {
351+
this.filesStore.selectFile(nodeId)
352352
})
353353
.catch(({ response }) => {
354354
showError(response?.data?.ocs?.data?.message || this.t('libresign', 'Upload failed'))
@@ -369,8 +369,8 @@ export default {
369369
},
370370
name: path.match(/([^/]*?)(?:\.[^.]*)?$/)[1] ?? '',
371371
})
372-
.then((fileId) => {
373-
this.filesStore.selectFile(fileId)
372+
.then((nodeId) => {
373+
this.filesStore.selectFile(nodeId)
374374
})
375375
.catch(({ response }) => {
376376
showError(response.data.ocs.data.message)

src/Components/RightSidebar/AppFilesTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default {
9393
9494
this.disconnectTitleObserver()
9595
96-
if (this.filesStore.selectedId === fileInfo.id) {
96+
if (this.filesStore.selectedNodeId === fileInfo.id) {
9797
return
9898
}
9999

src/Components/RightSidebar/EnvelopeFilesList.vue

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,6 @@ export default {
206206
envelope() {
207207
return this.filesStore.getFile()
208208
},
209-
envelopeUuid() {
210-
return this.envelope.uuid
211-
},
212-
envelopeId() {
213-
return this.envelope.id
214-
},
215209
canDelete() {
216210
return this.envelope?.status === SIGN_STATUS.DRAFT && this.files.length >= 1
217211
},
@@ -276,7 +270,7 @@ export default {
276270
},
277271
methods: {
278272
async loadFiles(page = 1) {
279-
if (!this.envelopeId) {
273+
if (!this.envelope?.id) {
280274
return
281275
}
282276
@@ -291,7 +285,7 @@ export default {
291285
const params = new URLSearchParams({
292286
page: page,
293287
length: 50,
294-
parentFileId: this.envelopeId,
288+
parentFileId: this.envelope.id,
295289
})
296290
297291
await axios.get(`${url}?${params.toString()}`)
@@ -368,7 +362,7 @@ export default {
368362
source: fileUrl,
369363
basename: file.name,
370364
mime: 'application/pdf',
371-
fileid: file.nodeId,
365+
fileid: file.id,
372366
}
373367
OCA.Viewer.open({
374368
fileInfo,
@@ -410,7 +404,7 @@ export default {
410404
this.hasLoading = true
411405
const fileIds = [...this.selectedFiles]
412406
413-
const result = await this.filesStore.removeFilesFromEnvelope(this.envelopeId, fileIds)
407+
const result = await this.filesStore.removeFilesFromEnvelope(fileIds)
414408
415409
if (result.success) {
416410
// Remover arquivos da lista local
@@ -453,7 +447,7 @@ export default {
453447
const abortController = new AbortController()
454448
this.uploadAbortController = abortController
455449
456-
const result = await this.filesStore.addFilesToEnvelope(this.envelopeUuid, formData, {
450+
const result = await this.filesStore.addFilesToEnvelope(this.envelope.uuid, formData, {
457451
signal: abortController.signal,
458452
onUploadProgress: (progressEvent) => {
459453
if (progressEvent.total) {
@@ -467,9 +461,6 @@ export default {
467461
this.showSuccess(this.t('libresign', result.message))
468462
this.files.push(...result.files)
469463
this.totalFiles = result.filesCount
470-
if (this.envelopeId && this.filesStore.files[this.envelopeId]) {
471-
this.filesStore.files[this.envelopeId].filesCount = result.filesCount
472-
}
473464
} else {
474465
if (result.message !== 'Upload cancelled') {
475466
this.showError(this.t('libresign', result.message))
@@ -558,7 +549,7 @@ export default {
558549
async confirmDelete(file) {
559550
this.hasLoading = true
560551
561-
const result = await this.filesStore.removeFilesFromEnvelope(this.envelopeId, file.id)
552+
const result = await this.filesStore.removeFilesFromEnvelope([file.id])
562553
563554
if (result.success) {
564555
this.showSuccess(this.t('libresign', result.message))

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ export default {
375375
showEnvelopeFilesDialog: false,
376376
infoIcon: svgInfo,
377377
adminSignatureFlow: '',
378-
lastSyncedFileId: null,
378+
lastSyncedNodeId: null,
379379
}
380380
},
381381
computed: {
@@ -594,11 +594,11 @@ export default {
594594
signers(signers) {
595595
this.init(signers)
596596
},
597-
'filesStore.selectedId': {
598-
handler(newFileId, oldFileId) {
599-
if (newFileId && newFileId !== this.lastSyncedFileId) {
597+
'filesStore.selectedNodeId': {
598+
handler(newNodeId, oldNodeId) {
599+
if (newNodeId && newNodeId !== this.lastSyncedNodeId) {
600600
this.syncPreserveOrderWithFile()
601-
this.lastSyncedFileId = newFileId
601+
this.lastSyncedNodeId = newNodeId
602602
}
603603
},
604604
immediate: true,
@@ -684,7 +684,7 @@ export default {
684684
685685
const flow = file.signatureFlow
686686
687-
this.lastSyncedFileId = this.filesStore.selectedId
687+
this.lastSyncedNodeId = this.filesStore.selectedNodeId
688688
689689
if ((flow === 'ordered_numeric' || flow === 2) && !this.isAdminFlowForced) {
690690
this.preserveOrder = true
@@ -845,7 +845,7 @@ export default {
845845
},
846846
async sendNotify(signer) {
847847
const body = {
848-
fileId: this.filesStore.selectedId,
848+
fileId: this.filesStore.getFile().id,
849849
signRequestId: signer.signRequestId,
850850
}
851851

0 commit comments

Comments
 (0)