2222 }"
2323 :aria-label =" action.title"
2424 :title =" action.title"
25- @click =" onActionClick(action)" >
25+ @click.stop =" onActionClick(action)" >
2626 <template #icon >
2727 <NcLoadingIcon v-if =" loading === action.id" :size =" 18" />
2828 <NcIconSvgWrapper v-else :svg =" action.iconSvgInline" />
@@ -94,6 +94,13 @@ defineOptions({
9494
9595type SourceFile = FileEntrySource & {
9696 signUuid? : string | null
97+ settings? : {
98+ signerFileUuid? : string | null
99+ }
100+ signers? : Array <{
101+ me? : boolean
102+ sign_uuid? : string | null
103+ }>
97104}
98105
99106type MenuAction = {
@@ -146,6 +153,16 @@ function registerAction(action: MenuAction) {
146153 enabledMenuActions .value = [... enabledMenuActions .value , action ]
147154}
148155
156+ function getSignRouteUuid(file : SourceFile | null | undefined ) {
157+ const signer = file ?.signers ?.find ((row ) => row ?.me ) || file ?.signers ?.[0 ]
158+ const fromSettings = typeof file ?.settings ?.signerFileUuid === ' string' && file .settings .signerFileUuid .length > 0
159+ ? file .settings .signerFileUuid
160+ : null
161+
162+ return [file ?.signUuid , signer ?.sign_uuid , fromSettings , props .source .signUuid ]
163+ .find ((value ): value is string => typeof value === ' string' && value .length > 0 ) || ' '
164+ }
165+
149166function visibleIf(action : Pick <MenuAction , ' id' >) {
150167 let visible = false
151168 if (action .id === ' request-signature' ) {
@@ -169,29 +186,29 @@ function visibleIf(action: Pick<MenuAction, 'id'>) {
169186
170187async function onActionClick(action : Pick <MenuAction , ' id' >) {
171188 openedMenu .value = false
172- sidebarStore .hideSidebar ()
173189 if (action .id === ' details' || action .id === ' request-signature' ) {
174190 filesStore .selectFile (props .source .id )
175191 sidebarStore .activeRequestSignatureTab ()
176192 } else if (action .id === ' sign' ) {
177- const detailedFile = await filesStore .fetchFileDetail ({ fileId: props .source .id , force: true })
178- const signUuid = detailedFile ?. signUuid || props . source . signUuid || ' '
193+ const detailedFile = await filesStore .fetchFileDetail ({ fileId: props .source .id , force: true }) as SourceFile | undefined
194+ const signUuid = getSignRouteUuid ( detailedFile )
179195 if (! signUuid || ! detailedFile ) {
180196 return
181197 }
198+ filesStore .selectFile (props .source .id )
182199 signStore .setFileToSign (detailedFile )
183- router .push ({
200+ await router .push ({
184201 name: ' SignPDF' ,
185202 params: {
186203 uuid: signUuid ,
187204 },
188205 })
189- filesStore .selectFile (props .source .id )
190- sidebarStore .activeRequestSignatureTab ()
206+ sidebarStore .activeSignTab ()
191207 } else if (action .id === ' validate' ) {
192208 if (! props .source .uuid ) {
193209 return
194210 }
211+ sidebarStore .hideSidebar ()
195212 router .push ({
196213 name: ' ValidationFile' ,
197214 params: {
0 commit comments