Skip to content

Commit efaa03d

Browse files
fix: read envelope child signature requirements in sign view
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 9bf85d6 commit efaa03d

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

src/views/SignPDF/_partials/Sign.vue

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,14 @@ import { SigningRequirementValidator } from '../../../services/SigningRequiremen
199199
import { SignFlowHandler } from '../../../services/SignFlowHandler'
200200
import {
201201
normalizeDocumentForVisibleElements,
202-
normalizeFileForVisibleElements,
203202
} from '../../../services/signingDocumentAdapter'
204203
import { FILE_STATUS } from '../../../constants.js'
205-
import { getFileSigners, getVisibleElementsFromDocument, idsMatch, isCurrentUserSigner } from '../../../services/visibleElementsService'
204+
import {
205+
getCurrentUserSignRequestIds,
206+
hasVisibleElementsForCurrentUser,
207+
getVisibleElementsFromDocument,
208+
idsMatch,
209+
} from '../../../services/visibleElementsService'
206210
207211
type OpenApiAccountMe = operations['account-me']['responses'][200]['content']['application/json']['ocs']['data']
208212
type LibreSignAccountMe = Omit<OpenApiAccountMe, 'settings'> & {
@@ -322,7 +326,6 @@ type SignatureProfile = LibreSignUserElement
322326
323327
type SignDocument = NonNullable<ReturnType<typeof useSignStore>['document']>
324328
type SignDocumentFile = NonNullable<SignDocument['files']>[number]
325-
type SignDocumentSigner = NonNullable<SignDocument['signers']>[number]
326329
327330
type SignResult = {
328331
status: 'signingInProgress' | 'signed' | 'unknown'
@@ -419,24 +422,10 @@ let requirementValidator: SigningRequirementValidator | null = null
419422
let actionHandler: SignFlowHandler | null = null
420423
const currentDocument = computed<SignDocument>(() => signStore.document)
421424
const visibleElementsDocument = computed(() => normalizeDocumentForVisibleElements(currentDocument.value))
425+
const currentUserSignRequestIds = computed(() => new Set(getCurrentUserSignRequestIds(visibleElementsDocument.value)))
422426
423427
const elements = computed(() => {
424-
const document = currentDocument.value
425-
const signer = document?.signers?.find((row: SignDocumentSigner) => row.me)
426-
427-
const signRequestIds = new Set<number>()
428-
if (signer?.signRequestId !== undefined) {
429-
signRequestIds.add(signer.signRequestId)
430-
}
431-
432-
if (Array.isArray(document?.files)) {
433-
document.files
434-
.map(normalizeFileForVisibleElements)
435-
.flatMap((file) => getFileSigners(file))
436-
.filter((row): row is ReturnType<typeof getFileSigners>[number] & { me: true; signRequestId: number } => isCurrentUserSigner(row) && row.signRequestId !== undefined)
437-
.forEach((row) => signRequestIds.add(row.signRequestId))
438-
}
439-
428+
const signRequestIds = currentUserSignRequestIds.value
440429
if (signRequestIds.size === 0) {
441430
return []
442431
}
@@ -458,13 +447,7 @@ const needCreateSignature = computed(() => {
458447
if (!canCreateSignature.value || hasSignatures.value) {
459448
return false
460449
}
461-
const document = currentDocument.value
462-
const signer = document?.signers?.find((row: SignDocumentSigner) => row.me)
463-
if (signer?.signRequestId === undefined) {
464-
return false
465-
}
466-
const visibleElements = visibleElementsDocument.value.visibleElements || []
467-
return visibleElements.some((row) => row.signRequestId === signer.signRequestId)
450+
return hasVisibleElementsForCurrentUser(visibleElementsDocument.value)
468451
})
469452
const needIdentificationDocuments = computed(() => identificationDocumentStore.showDocumentsComponent())
470453
const canCreateSignature = computed(() => {

0 commit comments

Comments
 (0)