6262 </NcDialog >
6363 </div >
6464 </div >
65- <div v-else-if =" validationDocument" class =" infor-container" >
66- <component :is =" validationComponent"
67- :document =" validationDocument"
65+ <div v-else-if =" validationEnvelopeDocument || validationFileDocument" class =" infor-container" >
66+ <EnvelopeValidation
67+ v-if =" validationEnvelopeDocument"
68+ :document =" validationEnvelopeDocument"
69+ :legal-information =" legalInformation"
70+ :document-valid-message =" documentValidMessage"
71+ :is-after-signed =" isAfterSigned" />
72+ <FileValidation
73+ v-else-if =" validationFileDocument"
74+ :document =" validationFileDocument"
6875 :legal-information =" legalInformation"
6976 :document-valid-message =" documentValidMessage"
7077 :is-after-signed =" isAfterSigned" />
@@ -124,7 +131,13 @@ import { FILE_STATUS, SIGN_REQUEST_STATUS } from '../constants.js'
124131import logger from ' ../logger.js'
125132import { useSignStore } from ' ../store/sign.js'
126133import { useSidebarStore } from ' ../store/sidebar.js'
127- import type { ValidationViewChildFile , ValidationViewDocument , ValidationViewSigner } from ' ../types/index'
134+ import type {
135+ LoadedValidationEnvelopeDocument ,
136+ LoadedValidationFileDocument ,
137+ SignerDetailRecord ,
138+ ValidatedChildFileRecord ,
139+ ValidationFileRecord ,
140+ } from ' ../types/index'
128141
129142defineOptions ({
130143 name: ' Validation' ,
@@ -142,7 +155,7 @@ type RouterState = {
142155}
143156
144157type ToggleOpenState = Record <number , boolean >
145- type ValidationStatus = ValidationViewDocument [' status' ]
158+ type ValidationStatus = ValidationFileRecord [' status' ]
146159type ValidationStatusInfo = {
147160 id? : number
148161 label? : string
@@ -151,7 +164,7 @@ type ValidationModificationInfo = {
151164 status? : number
152165 valid? : boolean
153166}
154- type ValidationDisplaySigner = ValidationViewSigner & {
167+ type ValidationDisplaySigner = SignerDetailRecord & {
155168 signature_validation? : ValidationStatusInfo
156169 certificate_validation? : ValidationStatusInfo
157170 modification_validation? : ValidationModificationInfo
@@ -202,21 +215,21 @@ function toValidationStatus(value: unknown): ValidationStatus | null {
202215 return null
203216}
204217
205- function normalizeValidationSigner(signer : unknown ): ValidationViewSigner | null {
218+ function normalizeValidationSigner(signer : unknown ): SignerDetailRecord | null {
206219 if (! isRecord (signer )) {
207220 return null
208221 }
209- return { ... signer } as ValidationViewSigner
222+ return { ... signer } as SignerDetailRecord
210223}
211224
212- function normalizeValidationChildFile(file : unknown ): ValidationViewChildFile | null {
225+ function normalizeValidationChildFile(file : unknown ): ValidatedChildFileRecord | null {
213226 if (! isRecord (file )) {
214227 return null
215228 }
216- return { ... file } as ValidationViewChildFile
229+ return { ... file } as ValidatedChildFileRecord
217230}
218231
219- function normalizeValidationDocument(data : unknown ): ValidationViewDocument | null {
232+ function normalizeValidationDocument(data : unknown ): ValidationFileRecord | null {
220233 if (! isRecord (data )) {
221234 return null
222235 }
@@ -228,12 +241,12 @@ function normalizeValidationDocument(data: unknown): ValidationViewDocument | nu
228241 const files = Array .isArray (data .files )
229242 ? data .files
230243 .map (normalizeValidationChildFile )
231- .filter ((file ): file is ValidationViewChildFile => file !== null )
244+ .filter ((file ): file is ValidatedChildFileRecord => file !== null )
232245 : undefined
233246 const signers = Array .isArray (data .signers )
234247 ? data .signers
235248 .map (normalizeValidationSigner )
236- .filter ((signer ): signer is ValidationViewSigner => signer !== null )
249+ .filter ((signer ): signer is SignerDetailRecord => signer !== null )
237250 : undefined
238251 const nodeType = data .nodeType === ' envelope'
239252 ? ' envelope'
@@ -248,7 +261,7 @@ function normalizeValidationDocument(data: unknown): ValidationViewDocument | nu
248261 }
249262
250263 return {
251- ... (data as ValidationViewDocument ),
264+ ... (data as ValidationFileRecord ),
252265 uuid ,
253266 name ,
254267 nodeId ,
@@ -266,6 +279,14 @@ function getValidationErrorMessage(response: ValidationErrorResponse | undefined
266279 return fallback
267280}
268281
282+ function isLoadedValidationEnvelopeDocument(document : ValidationFileRecord | null ): document is LoadedValidationEnvelopeDocument {
283+ return document ?.nodeType === ' envelope'
284+ }
285+
286+ function isLoadedValidationFileDocument(document : ValidationFileRecord | null ): document is LoadedValidationFileDocument {
287+ return document ?.nodeType === ' file'
288+ }
289+
269290const signStore = useSignStore ()
270291const sidebarStore = useSidebarStore ()
271292const instance = getCurrentInstance ()
@@ -278,7 +299,7 @@ const logo = ref(logoGray)
278299const uuidToValidate = ref (route .value .params ?.uuid ?? ' ' )
279300const hasInfo = ref (false )
280301const loading = ref (false )
281- const document = ref <ValidationViewDocument | null >(null )
302+ const document = ref <ValidationFileRecord | null >(null )
282303const legalInformation = ref (loadState (' libresign' , ' legal_information' , ' ' ))
283304const clickedValidate = ref (false )
284305const getUUID = ref (false )
@@ -311,9 +332,9 @@ const isAfterSigned = computed(() => history.state?.isAfterSigned ?? shouldFireA
311332
312333const isEnvelope = computed (() => document .value ?.nodeType === ' envelope'
313334 || (Array .isArray (document .value ?.files ) && document .value .files .length > 0 ))
314-
315- const validationComponent = computed (() => (isEnvelope .value ? EnvelopeValidation : FileValidation ))
316335const validationDocument = computed (() => document .value )
336+ const validationEnvelopeDocument = computed <LoadedValidationEnvelopeDocument | null >(() => (isLoadedValidationEnvelopeDocument (document .value ) ? document .value : null ))
337+ const validationFileDocument = computed <LoadedValidationFileDocument | null >(() => (isLoadedValidationFileDocument (document .value ) ? document .value : null ))
317338
318339const canValidate = computed (() => {
319340 if (! uuidToValidate .value ) {
@@ -394,12 +415,10 @@ function dateFromSqlAnsi(date: string) {
394415 return Moment (Date .parse (date )).format (' LL LTS' )
395416}
396417
397- function toggleDetail(signer : ValidationViewSigner ) {
398- signer .opened = ! signer .opened
418+ function toggleDetail(_signer : SignerDetailRecord ) {
399419}
400420
401- function toggleFileDetail(file : ValidationViewChildFile ) {
402- file .opened = ! file .opened
421+ function toggleFileDetail(_file : ValidatedChildFileRecord ) {
403422}
404423
405424function getSignerStatus(status : string ) {
@@ -711,12 +730,6 @@ function handleValidationSuccess(data: unknown) {
711730 })
712731 }
713732 document .value = normalizedDocument
714- document .value .signers ?.forEach (signer => {
715- signer .opened = false
716- })
717- document .value .files ?.forEach (file => {
718- file .opened = false
719- })
720733 hasInfo .value = true
721734 const isSignedStatus = (status : unknown ) => Number (status ) === FILE_STATUS .SIGNED
722735 const isSignedDoc = isSignedStatus (document .value ?.status )
@@ -814,10 +827,6 @@ if (!uuidToValidate.value) {
814827 document .value = null
815828 hasInfo .value = false
816829 void validate (uuidToValidate .value )
817- } else if (hasInfo .value && document .value .signers ) {
818- document .value .signers .forEach (signer => {
819- signer .opened = false
820- })
821830 } else if (uuidToValidate .value .length > 0 ) {
822831 void validate (uuidToValidate .value )
823832 }
@@ -870,11 +879,12 @@ defineExpose({
870879 signRequestUuidForProgress ,
871880 isAfterSigned ,
872881 isEnvelope ,
873- validationComponent ,
874882 canValidate ,
875883 helperTextValidation ,
876884 size ,
877885 documentStatus ,
886+ validationEnvelopeDocument ,
887+ validationFileDocument ,
878888 validityStatusMap ,
879889 crlStatusMap ,
880890 upload ,
0 commit comments