@@ -509,81 +509,7 @@ export const useFilesStore = function(...args) {
509509 filesSorted ( ) {
510510 return this . ordered . map ( key => this . files [ key ] )
511511 } ,
512- async saveWithVisibleElements ( { visibleElements = [ ] , signers = null , uuid = null , fileId = null , signatureFlow = null } ) {
513- const file = this . getFile ( )
514-
515- let flowValue = signatureFlow || file . signatureFlow
516- if ( typeof flowValue === 'number' ) {
517- const flowMap = { 0 : 'none' , 1 : 'parallel' , 2 : 'ordered_numeric' }
518- flowValue = flowMap [ flowValue ] || 'parallel'
519- }
520-
521- const config = {
522- url : generateOcsUrl ( '/apps/libresign/api/v1/request-signature' ) ,
523- method : uuid || file . uuid ? 'patch' : 'post' ,
524- data : {
525- name : file ?. name ,
526- users : signers || file . signers || [ ] ,
527- visibleElements,
528- status : 0 ,
529- signatureFlow : flowValue ,
530- } ,
531- }
532-
533- if ( uuid || file . uuid ) {
534- config . data . uuid = uuid || file . uuid
535- } else if ( file . id ) {
536- config . data . file = { fileId : file . id }
537- } else if ( file . files ) {
538- config . data . files = file . files
539- } else if ( ! isNaN ( file . nodeId ) ) {
540- config . data . file = { nodeId : file . nodeId }
541- }
542-
543- if ( file . settings ) {
544- if ( config . data . file ) {
545- config . data . file . settings = file . settings
546- } else if ( config . data . files ) {
547- config . data . settings = file . settings
548- }
549- }
550-
551- const { data } = await axios ( config )
552- const responseFile = data ?. ocs ?. data
553-
554- if ( file . nodeType === 'envelope' && typeof file . nodeId === 'string' && responseFile . nodeId !== file . nodeId ) {
555- delete this . files [ file . nodeId ]
556- const index = this . ordered . indexOf ( file . nodeId )
557- if ( index !== - 1 ) {
558- this . ordered . splice ( index , 1 )
559- }
560- }
561-
562- if ( responseFile . nodeId ) {
563- const nodeId = responseFile . nodeId
564- const existingFile = this . files [ file . nodeId ] || this . files [ nodeId ]
565- if ( existingFile ?. settings ) {
566- responseFile . settings = { ...existingFile . settings , ...responseFile . settings }
567- }
568- set ( this . files , nodeId , responseFile )
569- this . addUniqueIdentifierToAllSigners ( this . files [ nodeId ] . signers )
570- if ( ! this . ordered . includes ( nodeId ) ) {
571- this . ordered . push ( nodeId )
572- }
573- if ( this . selectedNodeId === file . nodeId ) {
574- this . selectedNodeId = nodeId
575- }
576- } else {
577- this . addFile ( responseFile )
578- }
579- const eventName = ( ! uuid && ! file . uuid ) ? 'libresign:file:created' : 'libresign:file:updated'
580- emit ( eventName , {
581- path : responseFile . settings ?. path ,
582- nodeId : responseFile . nodeId ,
583- } )
584- return data . ocs . data
585- } ,
586- async updateSignatureRequest ( { visibleElements = [ ] , signers = null , uuid = null , fileId = null , status = 1 , signatureFlow = null } ) {
512+ async saveOrUpdateSignatureRequest ( { visibleElements = [ ] , signers = null , uuid = null , fileId = null , status = 0 , signatureFlow = null } = { } ) {
587513 const file = this . getFile ( )
588514
589515 let flowValue = signatureFlow || file . signatureFlow
@@ -621,6 +547,7 @@ export const useFilesStore = function(...args) {
621547 config . data . settings = file . settings
622548 }
623549 }
550+
624551 const { data } = await axios ( config )
625552 const responseFile = data ?. ocs ?. data
626553
0 commit comments