Skip to content

Commit fb977b5

Browse files
authored
Merge pull request #6306 from LibreSign/backport/6305/stable31
[stable31] feat: envelope sidebar improvements
2 parents e09cb34 + 3e9adfc commit fb977b5

2 files changed

Lines changed: 78 additions & 4 deletions

File tree

src/Components/RightSidebar/AppFilesTab.vue

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,73 @@ export default {
3030
},
3131
data() {
3232
return {
33-
file: {},
34-
signers: [],
35-
requested_by: {},
36-
requestDate: '',
33+
sidebarTitleObserver: null,
3734
}
3835
},
3936
methods: {
37+
checkAndLoadPendingEnvelope() {
38+
const pendingEnvelope = window.OCA?.Libresign?.pendingEnvelope
39+
if (pendingEnvelope?.id) {
40+
this.filesStore.addFile(pendingEnvelope)
41+
this.filesStore.selectFile(pendingEnvelope.id)
42+
delete window.OCA.Libresign.pendingEnvelope
43+
44+
this.$nextTick(() => {
45+
this.updateSidebarTitle(pendingEnvelope.name)
46+
})
47+
48+
return true
49+
}
50+
return false
51+
},
52+
53+
updateSidebarTitle(envelopeName) {
54+
if (!envelopeName) return
55+
56+
this.disconnectTitleObserver()
57+
58+
const titleElement = document.querySelector('.app-sidebar-header__mainname')
59+
60+
if (titleElement) {
61+
titleElement.textContent = envelopeName
62+
titleElement.setAttribute('title', envelopeName)
63+
64+
this.sidebarTitleObserver = new MutationObserver(() => {
65+
if (titleElement.textContent !== envelopeName) {
66+
titleElement.textContent = envelopeName
67+
titleElement.setAttribute('title', envelopeName)
68+
}
69+
})
70+
71+
this.sidebarTitleObserver.observe(titleElement, {
72+
childList: true,
73+
characterData: true,
74+
subtree: true
75+
})
76+
77+
setTimeout(() => this.disconnectTitleObserver(), 5000)
78+
}
79+
},
80+
81+
disconnectTitleObserver() {
82+
if (this.sidebarTitleObserver) {
83+
console.log('Disconnecting sidebar title observer')
84+
this.sidebarTitleObserver.disconnect()
85+
this.sidebarTitleObserver = null
86+
}
87+
},
88+
4089
async update(fileInfo) {
90+
if (this.checkAndLoadPendingEnvelope()) {
91+
return
92+
}
93+
94+
this.disconnectTitleObserver()
95+
96+
if (this.filesStore.selectedId === fileInfo.id) {
97+
return
98+
}
99+
41100
this.filesStore.addFile({
42101
nodeId: fileInfo.id,
43102
name: fileInfo.name,
@@ -46,6 +105,14 @@ export default {
46105
signers: [],
47106
})
48107
this.filesStore.selectFile(fileInfo.id)
108+
109+
this.$nextTick(() => {
110+
const titleElement = document.querySelector('.app-sidebar-header__mainname')
111+
if (titleElement) {
112+
titleElement.textContent = fileInfo.name
113+
titleElement.setAttribute('title', fileInfo.name)
114+
}
115+
})
49116
},
50117
},
51118
}

src/actions/openInLibreSignAction.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,16 @@ export const action = new FileAction({
7979
return new Array(nodes.length).fill(null)
8080
}
8181

82+
const rawDir = nodes[0].dirname ?? nodes[0].path.substring(0, nodes[0].path.lastIndexOf('/'))
83+
const normalizedDir = (rawDir && rawDir !== '/') ? rawDir.replace(/\/+$/, '') : ''
84+
const envelopePath = normalizedDir ? `${normalizedDir}/${envelopeName}` : `/${envelopeName}`
85+
8286
return axios.post(generateOcsUrl('/apps/libresign/api/v1/file'), {
8387
files: nodes.map(node => ({ fileId: node.fileid })),
8488
name: envelopeName,
89+
settings: {
90+
path: envelopePath,
91+
},
8592
}).then((response) => {
8693
const envelopeData = response.data?.ocs?.data
8794

0 commit comments

Comments
 (0)