Skip to content

Commit ecfe60b

Browse files
fix(signpdf): hide PDF only for PDF loading errors
Keep PdfEditor visible for generic/signing errors and only hide it when the error was produced by PDF/envelope loading. Tag load-time errors with scope=pdfLoad and gate PdfEditor rendering using that scope. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 7c821b6 commit ecfe60b

1 file changed

Lines changed: 20 additions & 9 deletions

File tree

src/views/SignPDF/SignPDF.vue

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<TopBar
88
v-if="!isMobile"
99
:sidebar-toggle="true" />
10-
<PdfEditor v-if="mounted && !signStore.errors.length && pdfBlobs.length > 0"
10+
<PdfEditor v-if="mounted && !hasPdfLoadError && pdfBlobs.length > 0"
1111
ref="pdfEditor"
1212
width="100%"
1313
height="100%"
@@ -71,7 +71,7 @@ import type { SignerDetailRecord, SignerSummaryRecord, VisibleElementRecord } fr
7171
7272
type ServiceVisibleElement = VisibleElementRecord
7373
74-
type SignError = { title?: string; message?: string }
74+
type SignError = { title?: string; message?: string; scope?: string }
7575
type SignDocumentStatus = number | string
7676
type SignDocumentVisibleElement = {
7777
elementId?: number
@@ -230,6 +230,17 @@ const pdfFileName = computed(() => {
230230
return `${doc.name}.${extension}`
231231
})
232232
233+
const PDF_LOAD_ERROR_SCOPE = 'pdfLoad'
234+
235+
const hasPdfLoadError = computed(() => signStore.errors.some((error) => error.scope === PDF_LOAD_ERROR_SCOPE))
236+
237+
function setPdfLoadErrors(errors: SignError[]) {
238+
signStore.errors = errors.map((error) => ({
239+
...error,
240+
scope: PDF_LOAD_ERROR_SCOPE,
241+
}))
242+
}
243+
233244
function getRouteUuid() {
234245
const uuid = getRoute().params.uuid
235246
return Array.isArray(uuid) ? uuid[0] : uuid
@@ -318,9 +329,9 @@ async function handleInitialStatePdfs(urls: string[]) {
318329
sidebarStore.hideSidebar()
319330
const firstErrorMessage = data.errors?.[0]?.message
320331
if (firstErrorMessage && firstErrorMessage.length > 0) {
321-
signStore.errors = data.errors ?? []
332+
setPdfLoadErrors(data.errors ?? [])
322333
} else {
323-
signStore.errors = [{ message: t('libresign', 'File not found') }]
334+
setPdfLoadErrors([{ message: t('libresign', 'File not found') }])
324335
}
325336
return
326337
}
@@ -336,7 +347,7 @@ async function loadPdfsFromStore() {
336347
const doc = signStore.document
337348
338349
if (!doc || !doc.nodeId) {
339-
signStore.errors = [{ message: t('libresign', 'Document not found') }]
350+
setPdfLoadErrors([{ message: t('libresign', 'Document not found') }])
340351
return
341352
}
342353
@@ -351,7 +362,7 @@ async function loadPdfsFromStore() {
351362
if (fileUrl) {
352363
await getCompatMethod('handleInitialStatePdfs')([fileUrl])
353364
} else {
354-
signStore.errors = [{ message: t('libresign', 'Document URL not found') }]
365+
setPdfLoadErrors([{ message: t('libresign', 'Document URL not found') }])
355366
}
356367
}
357368
@@ -365,7 +376,7 @@ async function loadEnvelopePdfs(parentFileId: number | string) {
365376
}
366377
367378
if (!normalizedEnvelopeFiles.length) {
368-
signStore.errors = [{ message: t('libresign', 'Failed to load envelope files') }]
379+
setPdfLoadErrors([{ message: t('libresign', 'Failed to load envelope files') }])
369380
return
370381
}
371382
@@ -378,14 +389,14 @@ async function loadEnvelopePdfs(parentFileId: number | string) {
378389
.map((file) => getFileUrl(file))
379390
.filter((url): url is string => Boolean(url))
380391
if (!urls.length) {
381-
signStore.errors = [{ message: t('libresign', 'Failed to load envelope files') }]
392+
setPdfLoadErrors([{ message: t('libresign', 'Failed to load envelope files') }])
382393
return
383394
}
384395
385396
fileNames.value = normalizedEnvelopeFiles.map((file) => `${file.name}.${(file.metadata as SignDocumentMetadata | undefined)?.extension || 'pdf'}`)
386397
await getCompatMethod('handleInitialStatePdfs')(urls)
387398
} catch {
388-
signStore.errors = [{ message: t('libresign', 'Failed to load envelope files') }]
399+
setPdfLoadErrors([{ message: t('libresign', 'Failed to load envelope files') }])
389400
}
390401
}
391402

0 commit comments

Comments
 (0)