125125 </NcFormBox >
126126 <SigningProgress
127127 v-if =" showSigningProgress"
128- :status =" signingProgressStatus"
128+ :status =" signingProgressStatus ?? FILE_STATUS.SIGNING_IN_PROGRESS "
129129 :status-text =" signingProgressStatusText"
130- :progress =" signingProgress"
130+ :progress =" signingProgress ?? undefined "
131131 :is-loading =" hasLoading" />
132132 <NcFormBox v-if =" filesStore.canSign()" class =" action-form-box" >
133133 <NcButton
@@ -281,6 +281,7 @@ import axios from '@nextcloud/axios'
281281import { getCapabilities } from ' @nextcloud/capabilities'
282282import { showError , showSuccess } from ' @nextcloud/dialogs'
283283import { emit , subscribe , unsubscribe } from ' @nextcloud/event-bus'
284+ import type { Event as NextcloudEvent , EventHandler } from ' @nextcloud/event-bus'
284285import { loadState } from ' @nextcloud/initial-state'
285286import { generateOcsUrl , generateUrl } from ' @nextcloud/router'
286287
@@ -316,11 +317,29 @@ import { useSignStore } from '../../store/sign.js'
316317import { useUserConfigStore } from ' ../../store/userconfig.js'
317318import { startLongPolling } from ' ../../services/longPolling'
318319import { useSigningOrder } from ' ../../composables/useSigningOrder.js'
320+ import type { NextcloudCapabilities } from ' ../../types/capabilities'
319321
320322defineOptions ({
321323 name: ' RequestSignatureTab' ,
322324})
323325
326+ type SigningProgressData = {
327+ total: number
328+ signed: number
329+ files? : Array <{
330+ uuid: string
331+ name: string
332+ signedCount: number
333+ totalSigners: number
334+ isSigned: boolean
335+ }>
336+ signers? : Array <{
337+ id: string | number
338+ displayName: string
339+ signed: boolean
340+ }>
341+ }
342+
324343const props = withDefaults (defineProps <{
325344 useModal? : boolean
326345}>(), {
@@ -330,8 +349,11 @@ const props = withDefaults(defineProps<{
330349const filesStore = useFilesStore ()
331350const signStore = useSignStore ()
332351const sidebarStore = useSidebarStore ()
333- const userConfigStore = useUserConfigStore ()
352+ const userConfigStore = useUserConfigStore () as ReturnType <typeof useUserConfigStore > & {
353+ files_list_signer_identify_tab? : string
354+ }
334355const { normalizeSigningOrders, recalculateSigningOrders } = useSigningOrder ()
356+ const capabilities = getCapabilities () as NextcloudCapabilities
335357
336358const hasLoading = ref (false )
337359const signerToEdit = ref <Record <string , any >>({})
@@ -346,7 +368,7 @@ const preserveOrder = ref(false)
346368const showOrderDiagram = ref (false )
347369const showEnvelopeFilesDialog = ref (false )
348370const adminSignatureFlow = ref (loadState (' libresign' , ' signature_flow' , ' none' ))
349- const signingProgress = ref <number | null >(null )
371+ const signingProgress = ref <SigningProgressData | null >(null )
350372const signingProgressStatus = ref <number | null >(null )
351373const signingProgressStatusText = ref (' ' )
352374const stopPollingFunction = ref <null | (() => void )>(null )
@@ -386,6 +408,7 @@ const envelopeFilesCount = computed(() => filesStore.getFile()?.filesCount || 0)
386408const size = computed (() => window .matchMedia (' (max-width: 512px)' ).matches ? ' full' : ' normal' )
387409const modalTitle = computed (() => Object .keys (signerToEdit .value ).length > 0 ? t (' libresign' , ' Edit signer' ) : t (' libresign' , ' Add new signer' ))
388410const showSigningProgress = computed (() => signingProgressStatus .value === FILE_STATUS .SIGNING_IN_PROGRESS )
411+ const currentFile = computed (() => filesStore .getFile ())
389412
390413function isSignerSigned(signer : any ) {
391414 if (Array .isArray (signer ?.signed )) {
@@ -672,7 +695,7 @@ function getSvgIcon(name: string) {
672695}
673696
674697function isSignElementsAvailable() {
675- return getCapabilities ()? .libresign ?.config ?.[' sign-elements' ]?.[' is-available' ] === true
698+ return capabilities .libresign ?.config ?.[' sign-elements' ]?.[' is-available' ] === true
676699}
677700
678701function closeModal() {
@@ -875,7 +898,7 @@ async function save() {
875898 hasLoading .value = true
876899 try {
877900 await filesStore .saveOrUpdateSignatureRequest ({})
878- emit (' libresign:show-visible-elements' )
901+ emit (' libresign:show-visible-elements' , new CustomEvent ( ' libresign:show-visible-elements ' ) )
879902 } catch (error : any ) {
880903 if (error .response ?.data ?.ocs ?.data ?.message ) {
881904 showError (error .response .data .ocs .data .message )
@@ -980,7 +1003,11 @@ watch(() => filesStore.selectedFileId, (newFileId) => {
9801003 }
9811004}, { immediate: true })
9821005
983- watch (() => filesStore .currentFile ?.status , (newStatus ) => {
1006+ const handleEditSigner = ((event : NextcloudEvent ) => {
1007+ editSigner ((event as CustomEvent <any >).detail )
1008+ }) as EventHandler <NextcloudEvent >
1009+
1010+ watch (() => currentFile .value ?.status , (newStatus ) => {
9841011 if (newStatus === FILE_STATUS .SIGNING_IN_PROGRESS ) {
9851012 startSigningProgressPolling ()
9861013 } else if (stopPollingFunction .value ) {
@@ -989,14 +1016,14 @@ watch(() => filesStore.currentFile?.status, (newStatus) => {
9891016})
9901017
9911018onMounted (() => {
992- subscribe (' libresign:edit-signer' , editSigner )
1019+ subscribe (' libresign:edit-signer' , handleEditSigner )
9931020 filesStore .disableIdentifySigner ()
9941021 activeTab .value = userConfigStore .files_list_signer_identify_tab || ' '
9951022 syncPreserveOrderWithFile ()
9961023})
9971024
9981025onBeforeUnmount (() => {
999- unsubscribe (' libresign:edit-signer' )
1026+ unsubscribe (' libresign:edit-signer' , handleEditSigner )
10001027 if (stopPollingFunction .value ) {
10011028 stopSigningProgressPolling ()
10021029 }
0 commit comments