Skip to content

Commit 943774f

Browse files
fix: handle numeric signature flow values in frontend
Convert numeric flow values (0=none, 1=parallel, 2=ordered_numeric) to string equivalents in Signer, Signers, and files store. Signed-off-by: Vitor Mattos <[email protected]>
1 parent f5535e4 commit 943774f

3 files changed

Lines changed: 36 additions & 6 deletions

File tree

src/Components/Signers/Signer.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ export default {
9696
computed: {
9797
signatureFlow() {
9898
const file = this.filesStore.getFile()
99-
return file?.signatureFlow ?? 'parallel'
99+
let flow = file?.signatureFlow ?? 'parallel'
100+
101+
if (typeof flow === 'number') {
102+
const flowMap = { 0: 'none', 1: 'parallel', 2: 'ordered_numeric' }
103+
flow = flowMap[flow] || 'parallel'
104+
}
105+
106+
return flow
100107
},
101108
signer() {
102109
const file = this.filesStore.getFile()

src/Components/Signers/Signers.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ export default {
8383
},
8484
isOrderedNumeric() {
8585
const file = this.filesStore.getFile()
86-
return file?.signatureFlow === 'ordered_numeric'
86+
let flow = file?.signatureFlow
87+
88+
if (typeof flow === 'number') {
89+
const flowMap = { 0: 'none', 1: 'parallel', 2: 'ordered_numeric' }
90+
flow = flowMap[flow]
91+
}
92+
93+
return flow === 'ordered_numeric'
8794
},
8895
canReorder() {
8996
return this.filesStore.canSave() && this.signers.length > 1

src/store/files.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,15 @@ export const useFilesStore = function(...args) {
381381
filesSorted() {
382382
return this.ordered.map(key => this.files[key])
383383
},
384-
async saveWithVisibleElements({ visibleElements = [], signers = null, uuid = null, nodeId = null }) {
384+
async saveWithVisibleElements({ visibleElements = [], signers = null, uuid = null, nodeId = null, signatureFlow = null }) {
385385
const file = this.getFile()
386+
387+
let flowValue = signatureFlow || file.signatureFlow
388+
if (typeof flowValue === 'number') {
389+
const flowMap = { 0: 'none', 1: 'parallel', 2: 'ordered_numeric' }
390+
flowValue = flowMap[flowValue] || 'parallel'
391+
}
392+
386393
const config = {
387394
url: generateOcsUrl('/apps/libresign/api/v1/request-signature'),
388395
method: uuid || file.uuid ? 'patch' : 'post',
@@ -391,10 +398,12 @@ export const useFilesStore = function(...args) {
391398
users: signers || file.signers,
392399
visibleElements,
393400
status: 0,
401+
signatureFlow: flowValue,
394402
},
395403
}
396404

397-
if (uuid || file.uuid) {
405+
406+
if (uuid || file.uuid) {
398407
config.data.uuid = uuid || file.uuid
399408
} else {
400409
config.data.file = {
@@ -406,8 +415,15 @@ export const useFilesStore = function(...args) {
406415
this.addFile(data.ocs.data.data)
407416
return data.ocs.data
408417
},
409-
async updateSignatureRequest({ visibleElements = [], signers = null, uuid = null, nodeId = null, status = 1 }) {
418+
async updateSignatureRequest({ visibleElements = [], signers = null, uuid = null, nodeId = null, status = 1, signatureFlow = null }) {
410419
const file = this.getFile()
420+
421+
let flowValue = signatureFlow || file.signatureFlow
422+
if (typeof flowValue === 'number') {
423+
const flowMap = { 0: 'none', 1: 'parallel', 2: 'ordered_numeric' }
424+
flowValue = flowMap[flowValue] || 'parallel'
425+
}
426+
411427
const config = {
412428
url: generateOcsUrl('/apps/libresign/api/v1/request-signature'),
413429
method: uuid || file.uuid ? 'patch' : 'post',
@@ -416,6 +432,7 @@ export const useFilesStore = function(...args) {
416432
users: signers || file.signers,
417433
visibleElements,
418434
status,
435+
signatureFlow: flowValue,
419436
},
420437
}
421438

@@ -426,7 +443,6 @@ export const useFilesStore = function(...args) {
426443
fileId: nodeId || this.selectedNodeId,
427444
}
428445
}
429-
430446
const { data } = await axios(config)
431447
this.addFile(data.ocs.data.data)
432448
return data.ocs.data

0 commit comments

Comments
 (0)