Skip to content

Commit 77c5613

Browse files
committed
feat: add conditional buttons for draft and pending signers
- Show 'Request signature' button for draft status (status === 0) - Show 'Send reminder' button for pending status (status === 1) - Implement requestSignatureForSigner method to update signer status - Use signRequestId instead of identify for signer identification
1 parent 0eb36db commit 77c5613

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@
3232
</template>
3333
{{ t('libresign', 'Delete') }}
3434
</NcActionButton>
35-
<NcActionButton v-if="filesStore.canRequestSign && !signer.signed && signer.signRequestId && !signer.me"
35+
<NcActionButton v-if="filesStore.canRequestSign && !signer.signed && signer.signRequestId && !signer.me && signer.status === 0"
36+
:close-after-click="true"
37+
@click="requestSignatureForSigner(signer)">
38+
<template #icon>
39+
<Send :size="20" />
40+
</template>
41+
{{ t('libresign', 'Request signature') }}
42+
</NcActionButton>
43+
<NcActionButton v-if="filesStore.canRequestSign && !signer.signed && signer.signRequestId && !signer.me && signer.status === 1"
3644
icon="icon-comment"
3745
:close-after-click="true"
3846
@click="sendNotify(signer)">
@@ -415,6 +423,31 @@ export default {
415423
})
416424
417425
},
426+
async requestSignatureForSigner(signer) {
427+
this.hasLoading = true
428+
try {
429+
const file = this.filesStore.getFile()
430+
const signers = file.signers.map(s => {
431+
if (s.signRequestId === signer.signRequestId) {
432+
return { ...s, status: 1 }
433+
}
434+
return s
435+
})
436+
await this.filesStore.updateSignatureRequest({
437+
visibleElements: [],
438+
signers,
439+
status: 1,
440+
})
441+
showSuccess(t('libresign', 'Signature requested'))
442+
} catch (error) {
443+
if (error.response?.data?.ocs?.data?.message) {
444+
showError(error.response.data.ocs.data.message)
445+
} else if (error.response?.data?.ocs?.data?.errors) {
446+
error.response.data.ocs.data.errors.forEach(error => showError(error.message))
447+
}
448+
}
449+
this.hasLoading = false
450+
},
418451
async sign() {
419452
const uuid = this.filesStore.getFile().signers
420453
.reduce((accumulator, signer) => {
@@ -448,7 +481,7 @@ export default {
448481
async request() {
449482
this.hasLoading = true
450483
try {
451-
const response = await this.filesStore.requestSignaturesWithVisibleElements({ visibleElements: [] })
484+
const response = await this.filesStore.updateSignatureRequest({ visibleElements: [], status: 1 })
452485
showSuccess(t('libresign', response.message))
453486
} catch (error) {
454487
if (error.response?.data?.ocs?.data?.message) {

0 commit comments

Comments
 (0)