|
12 | 12 | <Signers event="libresign:edit-signer" |
13 | 13 | @signing-order-changed="debouncedSave"> |
14 | 14 | <template #actions="{signer, closeActions}"> |
15 | | - <NcActionInput v-if="isOrderedNumeric && totalSigners > 1 && filesStore.canSave() && !signer.signed" |
| 15 | + <NcActionInput v-if="canEditSigningOrder(signer)" |
16 | 16 | :label="t('libresign', 'Signing order')" |
17 | 17 | type="number" |
18 | 18 | :value="signer.signingOrder || 1" |
|
23 | 23 | <OrderNumericAscending :size="20" /> |
24 | 24 | </template> |
25 | 25 | </NcActionInput> |
26 | | - <NcActionButton v-if="filesStore.canSave() && !signer.signed" |
| 26 | + <NcActionButton v-if="canDelete(signer)" |
27 | 27 | aria-label="Delete" |
28 | 28 | :close-after-click="true" |
29 | 29 | @click="filesStore.deleteSigner(signer)"> |
|
32 | 32 | </template> |
33 | 33 | {{ t('libresign', 'Delete') }} |
34 | 34 | </NcActionButton> |
35 | | - <NcActionButton v-if="filesStore.canRequestSign && !signer.signed && signer.signRequestId && !signer.me" |
| 35 | + <NcActionButton v-if="canRequestSignature(signer)" |
| 36 | + :close-after-click="true" |
| 37 | + @click="requestSignatureForSigner(signer)"> |
| 38 | + <template #icon> |
| 39 | + <Send :size="20" /> |
| 40 | + </template> |
| 41 | + {{ t('libresign', 'Request signature') }} |
| 42 | + </NcActionButton> |
| 43 | + <NcActionButton v-if="canSendReminder(signer)" |
36 | 44 | icon="icon-comment" |
37 | 45 | :close-after-click="true" |
38 | 46 | @click="sendNotify(signer)"> |
@@ -240,6 +248,37 @@ export default { |
240 | 248 | isOrderedNumeric() { |
241 | 249 | return this.signatureFlow === 'ordered_numeric' |
242 | 250 | }, |
| 251 | + canEditSigningOrder() { |
| 252 | + return (signer) => { |
| 253 | + return this.isOrderedNumeric |
| 254 | + && this.totalSigners > 1 |
| 255 | + && this.filesStore.canSave() |
| 256 | + && !signer.signed |
| 257 | + } |
| 258 | + }, |
| 259 | + canDelete() { |
| 260 | + return (signer) => { |
| 261 | + return this.filesStore.canSave() && !signer.signed |
| 262 | + } |
| 263 | + }, |
| 264 | + canRequestSignature() { |
| 265 | + return (signer) => { |
| 266 | + return this.filesStore.canRequestSign |
| 267 | + && !signer.signed |
| 268 | + && signer.signRequestId |
| 269 | + && !signer.me |
| 270 | + && signer.status === 0 |
| 271 | + } |
| 272 | + }, |
| 273 | + canSendReminder() { |
| 274 | + return (signer) => { |
| 275 | + return this.filesStore.canRequestSign |
| 276 | + && !signer.signed |
| 277 | + && signer.signRequestId |
| 278 | + && !signer.me |
| 279 | + && signer.status === 1 |
| 280 | + } |
| 281 | + }, |
243 | 282 | showSaveButton() { |
244 | 283 | if (!this.filesStore.canSave()) { |
245 | 284 | return false |
@@ -415,6 +454,31 @@ export default { |
415 | 454 | }) |
416 | 455 |
|
417 | 456 | }, |
| 457 | + async requestSignatureForSigner(signer) { |
| 458 | + this.hasLoading = true |
| 459 | + try { |
| 460 | + const file = this.filesStore.getFile() |
| 461 | + const signers = file.signers.map(s => { |
| 462 | + if (s.signRequestId === signer.signRequestId) { |
| 463 | + return { ...s, status: 1 } |
| 464 | + } |
| 465 | + return s |
| 466 | + }) |
| 467 | + await this.filesStore.updateSignatureRequest({ |
| 468 | + visibleElements: [], |
| 469 | + signers, |
| 470 | + status: 1, |
| 471 | + }) |
| 472 | + showSuccess(t('libresign', 'Signature requested')) |
| 473 | + } catch (error) { |
| 474 | + if (error.response?.data?.ocs?.data?.message) { |
| 475 | + showError(error.response.data.ocs.data.message) |
| 476 | + } else if (error.response?.data?.ocs?.data?.errors) { |
| 477 | + error.response.data.ocs.data.errors.forEach(error => showError(error.message)) |
| 478 | + } |
| 479 | + } |
| 480 | + this.hasLoading = false |
| 481 | + }, |
418 | 482 | async sign() { |
419 | 483 | const uuid = this.filesStore.getFile().signers |
420 | 484 | .reduce((accumulator, signer) => { |
@@ -448,7 +512,7 @@ export default { |
448 | 512 | async request() { |
449 | 513 | this.hasLoading = true |
450 | 514 | try { |
451 | | - const response = await this.filesStore.requestSignaturesWithVisibleElements({ visibleElements: [] }) |
| 515 | + const response = await this.filesStore.updateSignatureRequest({ visibleElements: [], status: 1 }) |
452 | 516 | showSuccess(t('libresign', response.message)) |
453 | 517 | } catch (error) { |
454 | 518 | if (error.response?.data?.ocs?.data?.message) { |
|
0 commit comments