Skip to content

Commit 2da4eaa

Browse files
committed
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 <[email protected]>
1 parent 25e6961 commit 2da4eaa

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,17 @@ export default {
311311
if (!this.filesStore.canSave()) {
312312
return false
313313
}
314-
return this.hasSigners
314+
return this.hasDraftSigners
315+
},
316+
hasDraftSigners() {
317+
const file = this.filesStore.getFile()
318+
if (!file?.signers) {
319+
return false
320+
}
321+
322+
return this.isOrderedNumeric
323+
? this.hasSequentialDraftSigners(file)
324+
: this.hasAnyDraftSigner(file)
315325
},
316326
hasSigners() {
317327
return this.filesStore.hasSigners(this.filesStore.getFile())
@@ -379,6 +389,27 @@ export default {
379389
380390
return !hasPendingLowerOrder
381391
},
392+
hasAnyDraftSigner(file) {
393+
return file.signers.some(signer => signer.status === 0)
394+
},
395+
hasSequentialDraftSigners(file) {
396+
const signersNotSigned = file.signers.filter(s => !s.signed)
397+
if (signersNotSigned.length === 0) {
398+
return false
399+
}
400+
401+
const currentOrder = this.getCurrentSigningOrder(signersNotSigned)
402+
return this.hasOrderDraftSigners(file, currentOrder)
403+
},
404+
getCurrentSigningOrder(signersNotSigned) {
405+
return Math.min(...signersNotSigned.map(s => s.signingOrder || 1))
406+
},
407+
hasOrderDraftSigners(file, order) {
408+
return file.signers.some(signer => {
409+
const signerOrder = signer.signingOrder || 1
410+
return signerOrder === order && signer.status === 0
411+
})
412+
},
382413
enabledMethods() {
383414
return this.methods.filter(method => method.enabled)
384415
},

0 commit comments

Comments
 (0)