Skip to content

Commit 910d2db

Browse files
authored
Merge pull request #6178 from LibreSign/feat/improve-signature-request-confirmation
feat: improve signature request confirmation
2 parents c914775 + 63cf7bc commit 910d2db

File tree

2 files changed

+56
-54
lines changed

2 files changed

+56
-54
lines changed

src/Components/Request/VisibleElements.vue

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
:variant="variantOfSaveButton"
4343
:wide="true"
4444
:class="{ disabled: signerSelected }"
45-
@click="isDraft ? save() : showConfirm = true">
46-
{{ isDraft ? t('libresign', 'Save') : t('libresign', 'Send') }}
45+
@click="save()">
46+
{{ t('libresign', 'Save') }}
4747
</NcButton>
4848

4949
<NcButton v-if="canSign"
@@ -61,31 +61,6 @@
6161
@pdf-editor:end-init="updateSigners"
6262
@pdf-editor:on-delete-signer="onDeleteSigner" />
6363
</div>
64-
<NcDialog v-if="showConfirm"
65-
:open.sync="showConfirm"
66-
:name="t('libresign', 'Confirm')"
67-
:no-close="loading"
68-
:message="t('libresign', 'Send signature request?')">
69-
<NcNoteCard v-if="errorConfirmRequest.length > 0"
70-
type="error">
71-
{{ errorConfirmRequest }}
72-
</NcNoteCard>
73-
<template #actions>
74-
<NcButton :disabled="loading"
75-
@click="showConfirm = false">
76-
{{ t('libresign', 'Cancel') }}
77-
</NcButton>
78-
<NcButton variant="primary"
79-
:disabled="loading"
80-
@click="request">
81-
<template #icon>
82-
<NcLoadingIcon v-if="loading" :size="20" name="Loading" />
83-
<Send v-else :size="20" />
84-
</template>
85-
{{ t('libresign', 'Send') }}
86-
</NcButton>
87-
</template>
88-
</NcDialog>
8964
</NcDialog>
9065
</template>
9166

@@ -102,8 +77,6 @@ import NcDialog from '@nextcloud/vue/components/NcDialog'
10277
import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
10378
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
10479
105-
import Send from 'vue-material-design-icons/Send.vue'
106-
10780
import Chip from '../Chip.vue'
10881
import PdfEditor from '../PdfEditor/PdfEditor.vue'
10982
import Signer from '../Signers/Signer.vue'
@@ -121,7 +94,6 @@ export default {
12194
NcButton,
12295
NcLoadingIcon,
12396
PdfEditor,
124-
Send,
12597
},
12698
setup() {
12799
const filesStore = useFilesStore()
@@ -131,9 +103,7 @@ export default {
131103
return {
132104
canRequestSign: loadState('libresign', 'can_request_sign', false),
133105
modal: false,
134-
showConfirm: false,
135106
loading: false,
136-
errorConfirmRequest: '',
137107
signerSelected: null,
138108
width: getCapabilities().libresign.config['sign-elements']['full-signature-width'],
139109
height: getCapabilities().libresign.config['sign-elements']['full-signature-height'],
@@ -204,7 +174,6 @@ export default {
204174
this.filesStore.loading = true
205175
},
206176
closeModal() {
207-
this.errorConfirmRequest = ''
208177
this.modal = false
209178
this.filesStore.loading = false
210179
},
@@ -306,26 +275,6 @@ export default {
306275
return false
307276
}
308277
},
309-
async request() {
310-
this.loading = true
311-
this.errorConfirmRequest = ''
312-
const visibleElements = this.buildVisibleElements()
313-
314-
try {
315-
const response = await this.filesStore.updateSignatureRequest({ visibleElements, status: 1 })
316-
this.filesStore.addFile(response.data)
317-
this.showConfirm = false
318-
showSuccess(t('libresign', response.message))
319-
this.closeModal()
320-
emit('libresign:visible-elements-saved')
321-
this.loading = false
322-
return true
323-
} catch (error) {
324-
this.errorConfirmRequest = error.response?.data?.ocs?.data?.message || t('libresign', 'An error occurred')
325-
this.loading = false
326-
return false
327-
}
328-
},
329278
buildVisibleElements() {
330279
const visibleElements = []
331280
const scale = this.$refs.pdfEditor.$refs.vuePdfEditor.scale || 1

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,44 @@
134134
</NcAppSidebarTab>
135135
</NcAppSidebar>
136136
</NcDialog>
137+
<NcDialog v-if="showConfirmRequest"
138+
:name="t('libresign', 'Confirm')"
139+
:message="t('libresign', 'Send signature request?')"
140+
@closing="showConfirmRequest = false">
141+
<template #actions>
142+
<NcButton @click="showConfirmRequest = false">
143+
{{ t('libresign', 'Cancel') }}
144+
</NcButton>
145+
<NcButton variant="primary"
146+
:disabled="hasLoading"
147+
@click="confirmRequest">
148+
<template #icon>
149+
<NcLoadingIcon v-if="hasLoading" :size="20" />
150+
<Send v-else :size="20" />
151+
</template>
152+
{{ t('libresign', 'Send') }}
153+
</NcButton>
154+
</template>
155+
</NcDialog>
156+
<NcDialog v-if="showConfirmRequestSigner"
157+
:name="t('libresign', 'Confirm')"
158+
:message="t('libresign', 'Send signature request?')"
159+
@closing="showConfirmRequestSigner = false; selectedSigner = null">
160+
<template #actions>
161+
<NcButton @click="showConfirmRequestSigner = false; selectedSigner = null">
162+
{{ t('libresign', 'Cancel') }}
163+
</NcButton>
164+
<NcButton variant="primary"
165+
:disabled="hasLoading"
166+
@click="confirmRequestSigner">
167+
<template #icon>
168+
<NcLoadingIcon v-if="hasLoading" :size="20" />
169+
<Send v-else :size="20" />
170+
</template>
171+
{{ t('libresign', 'Send') }}
172+
</NcButton>
173+
</template>
174+
</NcDialog>
137175
</div>
138176
</template>
139177
<script>
@@ -241,6 +279,9 @@ export default {
241279
document: {},
242280
hasInfo: false,
243281
methods: [],
282+
showConfirmRequest: false,
283+
showConfirmRequestSigner: false,
284+
selectedSigner: null,
244285
}
245286
},
246287
computed: {
@@ -518,11 +559,17 @@ export default {
518559
519560
},
520561
async requestSignatureForSigner(signer) {
562+
this.selectedSigner = signer
563+
this.showConfirmRequestSigner = true
564+
},
565+
async confirmRequestSigner() {
566+
if (!this.selectedSigner) return
567+
521568
this.hasLoading = true
522569
try {
523570
const file = this.filesStore.getFile()
524571
const signers = file.signers.map(s => {
525-
if (s.signRequestId === signer.signRequestId) {
572+
if (s.signRequestId === this.selectedSigner.signRequestId) {
526573
return { ...s, status: 1 }
527574
}
528575
return s
@@ -532,6 +579,8 @@ export default {
532579
signers,
533580
})
534581
showSuccess(t('libresign', 'Signature requested'))
582+
this.showConfirmRequestSigner = false
583+
this.selectedSigner = null
535584
} catch (error) {
536585
if (error.response?.data?.ocs?.data?.message) {
537586
showError(error.response.data.ocs.data.message)
@@ -572,10 +621,14 @@ export default {
572621
this.hasLoading = false
573622
},
574623
async request() {
624+
this.showConfirmRequest = true
625+
},
626+
async confirmRequest() {
575627
this.hasLoading = true
576628
try {
577629
const response = await this.filesStore.updateSignatureRequest({ visibleElements: [], status: 1 })
578630
showSuccess(t('libresign', response.message))
631+
this.showConfirmRequest = false
579632
} catch (error) {
580633
if (error.response?.data?.ocs?.data?.message) {
581634
showError(error.response.data.ocs.data.message)

0 commit comments

Comments
 (0)