From 7df5fa7c869bf60f3de0fb0aedabbbbac443935d Mon Sep 17 00:00:00 2001 From: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> Date: Sat, 13 Dec 2025 16:13:33 -0300 Subject: [PATCH] feat: show 'Request signatures' button only for draft signers in appropriate order The 'Request signatures' button now appears conditionally based on signing flow: - Parallel flow: Shows when any signer has DRAFT status (status === 0) - Sequential flow: Shows only when current signing order has draft signers - Finds the lowest pending order among unsigned signers - Checks if that order contains any draft signers This prevents requesting signatures from signers who aren't in their turn yet in sequential signing, while maintaining flexibility in parallel signing. Refactored logic into smaller, focused methods: - hasAnyDraftSigner: Checks for any draft signer (parallel mode) - hasSequentialDraftSigners: Orchestrates sequential mode verification - getCurrentSigningOrder: Gets current order that should sign - hasOrderDraftSigners: Checks if specific order has draft signers Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com> --- .../RightSidebar/RequestSignatureTab.vue | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Components/RightSidebar/RequestSignatureTab.vue b/src/Components/RightSidebar/RequestSignatureTab.vue index 7e2b6d911d..996cc16561 100644 --- a/src/Components/RightSidebar/RequestSignatureTab.vue +++ b/src/Components/RightSidebar/RequestSignatureTab.vue @@ -311,7 +311,17 @@ export default { if (!this.filesStore.canSave()) { return false } - return this.hasSigners + return this.hasDraftSigners + }, + hasDraftSigners() { + const file = this.filesStore.getFile() + if (!file?.signers) { + return false + } + + return this.isOrderedNumeric + ? this.hasSequentialDraftSigners(file) + : this.hasAnyDraftSigner(file) }, hasSigners() { return this.filesStore.hasSigners(this.filesStore.getFile()) @@ -379,6 +389,27 @@ export default { return !hasPendingLowerOrder }, + hasAnyDraftSigner(file) { + return file.signers.some(signer => signer.status === 0) + }, + hasSequentialDraftSigners(file) { + const signersNotSigned = file.signers.filter(s => !s.signed) + if (signersNotSigned.length === 0) { + return false + } + + const currentOrder = this.getCurrentSigningOrder(signersNotSigned) + return this.hasOrderDraftSigners(file, currentOrder) + }, + getCurrentSigningOrder(signersNotSigned) { + return Math.min(...signersNotSigned.map(s => s.signingOrder || 1)) + }, + hasOrderDraftSigners(file, order) { + return file.signers.some(signer => { + const signerOrder = signer.signingOrder || 1 + return signerOrder === order && signer.status === 0 + }) + }, enabledMethods() { return this.methods.filter(method => method.enabled) },