Skip to content

Commit 370cdda

Browse files
fix: align frontend with file ids
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 9762242 commit 370cdda

File tree

12 files changed

+185
-114
lines changed

12 files changed

+185
-114
lines changed

src/Components/File/File.vue

Lines changed: 16 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="currentNodeId > 0 && currentFile" class="content-file" @click="openSidebar">
6+
<div v-if="currentFileId > 0 && currentFile" class="content-file" @click="openSidebar">
77
<img v-if="previewUrl && backgroundFailed !== true"
88
ref="previewImg"
99
alt=""
@@ -28,22 +28,20 @@ import FileIcon from 'vue-material-design-icons/File.vue'
2828
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
2929
3030
import { useFilesStore } from '../../store/files.js'
31+
import { useSidebarStore } from '../../store/sidebar.js'
3132
3233
export default {
3334
name: 'File',
3435
components: {
3536
FileIcon,
3637
},
37-
props: {
38-
nodeId: {
39-
type: Number,
40-
default: 0,
41-
required: false,
42-
},
43-
},
4438
setup() {
4539
const filesStore = useFilesStore()
46-
return { filesStore }
40+
const sidebarStore = useSidebarStore()
41+
return {
42+
filesStore,
43+
sidebarStore,
44+
}
4745
},
4846
data() {
4947
return {
@@ -53,14 +51,11 @@ export default {
5351
}
5452
},
5553
computed: {
56-
currentNodeId() {
57-
if (this.nodeId) {
58-
return this.nodeId
59-
}
60-
return this.filesStore.selectedNodeId
54+
currentFileId() {
55+
return this.filesStore.selectedFileId
6156
},
6257
currentFile() {
63-
return this.filesStore.files[this.currentNodeId]
58+
return this.filesStore.files[this.currentFileId]
6459
},
6560
previewUrl() {
6661
if (this.backgroundFailed === true) {
@@ -76,6 +71,10 @@ export default {
7671
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/{nodeId}', {
7772
nodeId: this.currentFile.nodeId,
7873
})
74+
} else if (this.currentFile.id) {
75+
previewUrl = generateOcsUrl('/apps/libresign/api/v1/file/thumbnail/file_id/{fileId}', {
76+
fileId: this.currentFile.id,
77+
})
7978
} else {
8079
previewUrl = window.location.origin + generateUrl('/core/preview?fileId={fileid}', {
8180
fileid: this.currentFile.id,
@@ -96,7 +95,8 @@ export default {
9695
},
9796
methods: {
9897
openSidebar() {
99-
this.filesStore.selectFile(this.currentNodeId)
98+
this.filesStore.selectFile(this.currentFileId)
99+
this.sidebarStore.activeRequestSignatureTab()
100100
},
101101
statusToClass(status) {
102102
switch (Number(status)) {

src/Components/Request/RequestPicker.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ import UploadProgress from '../UploadProgress.vue'
122122
123123
import { useActionsMenuStore } from '../../store/actionsmenu.js'
124124
import { useFilesStore } from '../../store/files.js'
125+
import { useSidebarStore } from '../../store/sidebar.js'
125126
126127
export default {
127128
name: 'RequestPicker',
@@ -150,9 +151,11 @@ export default {
150151
setup() {
151152
const actionsMenuStore = useActionsMenuStore()
152153
const filesStore = useFilesStore()
154+
const sidebarStore = useSidebarStore()
153155
return {
154156
actionsMenuStore,
155157
filesStore,
158+
sidebarStore,
156159
}
157160
},
158161
data() {
@@ -278,6 +281,7 @@ export default {
278281
})
279282
.then((nodeId) => {
280283
this.filesStore.selectFile(nodeId)
284+
this.sidebarStore.activeRequestSignatureTab()
281285
})
282286
.catch((error) => {
283287
if (error.code === 'ERR_CANCELED') {
@@ -338,6 +342,7 @@ export default {
338342
})
339343
.then((nodeId) => {
340344
this.filesStore.selectFile(nodeId)
345+
this.sidebarStore.activeRequestSignatureTab()
341346
this.closeModalUploadFromUrl()
342347
})
343348
.catch(({ response }) => {
@@ -373,6 +378,7 @@ export default {
373378
})
374379
.then((nodeId) => {
375380
this.filesStore.selectFile(nodeId)
381+
this.sidebarStore.activeRequestSignatureTab()
376382
})
377383
.catch(({ response }) => {
378384
showError(response?.data?.ocs?.data?.message || this.t('libresign', 'Upload failed'))
@@ -395,6 +401,7 @@ export default {
395401
})
396402
.then((nodeId) => {
397403
this.filesStore.selectFile(nodeId)
404+
this.sidebarStore.activeRequestSignatureTab()
398405
})
399406
.catch(({ response }) => {
400407
showError(response.data.ocs.data.message)

src/Components/RightSidebar/AppFilesTab.vue

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { generateRemoteUrl } from '@nextcloud/router'
2121
import RequestSignatureTab from '../RightSidebar/RequestSignatureTab.vue'
2222
2323
import { useFilesStore } from '../../store/files.js'
24+
import { useSidebarStore } from '../../store/sidebar.js'
2425
2526
export default {
2627
name: 'AppFilesTab',
@@ -29,7 +30,11 @@ export default {
2930
},
3031
setup() {
3132
const filesStore = useFilesStore()
32-
return { filesStore }
33+
const sidebarStore = useSidebarStore()
34+
return {
35+
filesStore,
36+
sidebarStore,
37+
}
3338
},
3439
data() {
3540
return {
@@ -60,6 +65,7 @@ export default {
6065
6166
await this.filesStore.addFile(pendingEnvelope)
6267
this.filesStore.selectFile(pendingEnvelope.nodeId)
68+
this.sidebarStore.activeRequestSignatureTab()
6369
delete window.OCA.Libresign.pendingEnvelope
6470
6571
this.$nextTick(() => {
@@ -99,7 +105,6 @@ export default {
99105
100106
disconnectTitleObserver() {
101107
if (this.sidebarTitleObserver) {
102-
console.log('Disconnecting sidebar title observer')
103108
this.sidebarTitleObserver.disconnect()
104109
this.sidebarTitleObserver = null
105110
}
@@ -112,7 +117,15 @@ export default {
112117
113118
this.disconnectTitleObserver()
114119
115-
if (this.filesStore.selectedNodeId === fileInfo.id) {
120+
const fileId = await this.filesStore.selectFileByNodeId(fileInfo.id)
121+
if (fileId) {
122+
this.$nextTick(() => {
123+
const titleElement = document.querySelector('.app-sidebar-header__mainname')
124+
if (titleElement) {
125+
titleElement.textContent = fileInfo.name
126+
titleElement.setAttribute('title', fileInfo.name)
127+
}
128+
})
116129
return
117130
}
118131
@@ -123,7 +136,8 @@ export default {
123136
.replace(/\/\/$/, '/'),
124137
signers: [],
125138
})
126-
this.filesStore.selectFile(fileInfo.id)
139+
this.filesStore.selectFile(-fileInfo.id)
140+
this.sidebarStore.activeRequestSignatureTab()
127141
128142
this.$nextTick(() => {
129143
const titleElement = document.querySelector('.app-sidebar-header__mainname')
@@ -146,7 +160,7 @@ export default {
146160
emit(`files:node:${eventType}`, resultToNode(result.data))
147161
},
148162
149-
async handleLibreSignFileChangeWithNodeId(nodeId, eventType) {
163+
async handleLibreSignFileChangeAtCurretntFolder() {
150164
const client = getClient()
151165
const propfindPayload = getDefaultPropfind()
152166
const rootPath = getRootPath()
@@ -169,7 +183,7 @@ export default {
169183
if (path) {
170184
await this.handleLibreSignFileChangeWithPath(path, eventType)
171185
} else if (nodeId) {
172-
await this.handleLibreSignFileChangeWithNodeId(nodeId, eventType)
186+
await this.handleLibreSignFileChangeAtCurretntFolder()
173187
}
174188
},
175189

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ export default {
375375
showEnvelopeFilesDialog: false,
376376
infoIcon: svgInfo,
377377
adminSignatureFlow: '',
378-
lastSyncedNodeId: null,
378+
lastSyncedFileId: null,
379+
debouncedSave: null,
380+
debouncedTabChange: null,
379381
}
380382
},
381383
computed: {
@@ -594,11 +596,11 @@ export default {
594596
signers(signers) {
595597
this.init(signers)
596598
},
597-
'filesStore.selectedNodeId': {
598-
handler(newNodeId, oldNodeId) {
599-
if (newNodeId && newNodeId !== this.lastSyncedNodeId) {
599+
'filesStore.selectedFileId': {
600+
handler(newFileId, oldFileId) {
601+
if (newFileId && newFileId !== this.lastSyncedFileId) {
600602
this.syncPreserveOrderWithFile()
601-
this.lastSyncedNodeId = newNodeId
603+
this.lastSyncedFileId = newFileId
602604
}
603605
},
604606
immediate: true,
@@ -618,7 +620,7 @@ export default {
618620
unsubscribe('libresign:edit-signer')
619621
},
620622
created() {
621-
this.$set(this, 'methods', loadState('libresign', 'identify_methods'))
623+
this.$set(this, 'methods', loadState('libresign', 'identify_methods', []))
622624
this.$set(this, 'document', loadState('libresign', 'file_info', {}))
623625
624626
this.debouncedSave = debounce(async () => {
@@ -683,7 +685,7 @@ export default {
683685
684686
const flow = file.signatureFlow
685687
686-
this.lastSyncedNodeId = this.filesStore.selectedNodeId
688+
this.lastSyncedFileId = this.filesStore.selectedFileId
687689
688690
if ((flow === 'ordered_numeric' || flow === 2) && !this.isAdminFlowForced) {
689691
this.preserveOrder = true

0 commit comments

Comments
 (0)