Skip to content

Commit 42c025b

Browse files
authored
Merge pull request #6225 from LibreSign/feat/disabled-identify-methods-handling
feat: disabled identify methods handling
2 parents 9a9ca2b + 4e34ff0 commit 42c025b

3 files changed

Lines changed: 122 additions & 13 deletions

File tree

src/Components/Request/IdentifySigner.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616
<strong>{{ identifyMethodLabel }}:</strong> {{ signer.id }}
1717
</NcNoteCard>
1818

19-
<NcTextField v-if="signerSelected"
19+
<NcNoteCard v-if="disabled" type="warning" class="disabled-warning">
20+
{{ t('libresign', 'This signer cannot be used because the identification method "{method}" has been disabled by the administrator.', { method: identifyMethodLabel }) }}
21+
</NcNoteCard>
22+
23+
<NcTextField v-if="signerSelected && !disabled"
2024
v-model="displayName"
2125
aria-describedby="name-input"
2226
autocapitalize="none"
@@ -27,7 +31,7 @@
2731
:helper-text="nameHelperText"
2832
@update:value="onNameChange" />
2933

30-
<div v-if="signerSelected && showCustomMessage" class="description-wrapper">
34+
<div v-if="signerSelected && showCustomMessage && !disabled" class="description-wrapper">
3135
<NcCheckboxRadioSwitch v-model:checked="enableCustomMessage"
3236
type="switch"
3337
@update:checked="onToggleCustomMessage">
@@ -43,7 +47,7 @@
4347
resize="none" />
4448
</div>
4549

46-
<div class="identifySigner__footer">
50+
<div v-if="!disabled" class="identifySigner__footer">
4751
<div class="button-group">
4852
<NcButton @click="filesStore.disableIdentifySigner()">
4953
{{ t('libresign', 'Cancel') }}
@@ -119,6 +123,10 @@ export default {
119123
type: Array,
120124
default: () => [],
121125
},
126+
disabled: {
127+
type: Boolean,
128+
default: false,
129+
},
122130
},
123131
setup() {
124132
const filesStore = useFilesStore()
@@ -253,6 +261,11 @@ export default {
253261
width: 96%;
254262
margin: 0 auto;
255263
264+
.disabled-warning {
265+
margin-top: 12px;
266+
width: 100%;
267+
}
268+
256269
#account-or-email {
257270
width: 100%;
258271
}

src/Components/RightSidebar/RequestSignatureTab.vue

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<NcNoteCard v-if="showDocMdpWarning" type="warning">
88
{{ t('libresign', 'This document has been certified with no changes allowed. You cannot add more signers to this document.') }}
99
</NcNoteCard>
10+
<NcNoteCard v-if="hasSignersWithDisabledMethods" type="warning">
11+
{{ t('libresign', 'Some signers use identification methods that have been disabled. Please remove or update them before requesting signatures.') }}
12+
</NcNoteCard>
1013
<NcButton v-if="filesStore.canAddSigner()"
1114
:variant="hasSigners ? 'secondary' : 'primary'"
1215
@click="addSigner">
@@ -132,11 +135,7 @@
132135
:size="size"
133136
:name="modalTitle"
134137
@closing="filesStore.disableIdentifySigner()">
135-
<NcNoteCard v-if="isSignerMethodDisabled" type="warning">
136-
{{ t('libresign', 'The identification method "{method}" used by this signer has been disabled by the system administrator.', { method: disabledMethodName }) }}
137-
</NcNoteCard>
138-
<NcAppSidebar v-else
139-
:name="modalTitle"
138+
<NcAppSidebar :name="modalTitle"
140139
:active="activeTab"
141140
@update:active="onTabChange">
142141
<NcAppSidebarTab v-for="method in enabledMethods"
@@ -150,7 +149,8 @@
150149
<IdentifySigner :signer-to-edit="signerToEdit"
151150
:placeholder="method.friendly_name"
152151
:method="method.name"
153-
:methods="methods" />
152+
:methods="methods"
153+
:disabled="isSignerMethodDisabled" />
154154
</NcAppSidebarTab>
155155
</NcAppSidebar>
156156
</NcDialog>
@@ -348,6 +348,10 @@ export default {
348348
return false
349349
}
350350
351+
if (!this.canSignerActInOrder(signer)) {
352+
return false
353+
}
354+
351355
return !!method
352356
}
353357
},
@@ -377,6 +381,24 @@ export default {
377381
return this.canSignerActInOrder(signer)
378382
}
379383
},
384+
hasSignersWithDisabledMethods() {
385+
const file = this.filesStore.getFile()
386+
if (!file?.signers) {
387+
return false
388+
}
389+
390+
return file.signers.some(signer => {
391+
if (signer.signed) {
392+
return false
393+
}
394+
const method = signer.identifyMethods?.[0]?.method
395+
if (!method) {
396+
return false
397+
}
398+
const methodConfig = this.methods.find(m => m.name === method)
399+
return !methodConfig?.enabled
400+
})
401+
},
380402
showSaveButton() {
381403
if (!this.filesStore.canSave()) {
382404
return false
@@ -392,12 +414,19 @@ export default {
392414
return false
393415
}
394416
417+
if (this.hasSignersWithDisabledMethods) {
418+
return false
419+
}
420+
395421
return true
396422
},
397423
showRequestButton() {
398424
if (!this.filesStore.canSave()) {
399425
return false
400426
}
427+
if (this.hasSignersWithDisabledMethods) {
428+
return false
429+
}
401430
return this.hasDraftSigners
402431
},
403432
hasDraftSigners() {
@@ -429,14 +458,16 @@ export default {
429458
return this.t('libresign', 'Add new signer')
430459
},
431460
enabledMethods() {
432-
const enabledMethods = this.methods.filter(method => method.enabled)
433-
434461
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
435462
const signerMethod = this.signerToEdit.identifyMethods[0].method
436-
return enabledMethods.filter(method => method.name === signerMethod)
463+
const signerMethodConfig = this.methods.find(m => m.name === signerMethod)
464+
465+
if (signerMethodConfig) {
466+
return [signerMethodConfig]
467+
}
437468
}
438469
439-
return enabledMethods
470+
return this.methods.filter(method => method.enabled)
440471
},
441472
isSignerMethodDisabled() {
442473
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
@@ -494,6 +525,14 @@ export default {
494525
return iconMap[`svg${name.charAt(0).toUpperCase() + name.slice(1)}`] || iconMap.svgAccount
495526
},
496527
canSignerActInOrder(signer) {
528+
const method = signer.identifyMethods?.[0]?.method
529+
if (method) {
530+
const methodConfig = this.methods.find(m => m.name === method)
531+
if (!methodConfig?.enabled) {
532+
return false
533+
}
534+
}
535+
497536
if (!this.isOrderedNumeric) {
498537
return true
499538
}

src/Components/Signers/Signer.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:counter-type="counterType"
1010
:force-display-actions="true"
1111
:class="signerClass"
12+
:title="disabledTooltip"
1213
@click="signerClickAction">
1314
<template #icon>
1415
<NcAvatar :size="44" :display-name="signer.displayName" />
@@ -89,6 +90,7 @@ export default {
8990
data() {
9091
return {
9192
canRequestSign: loadState('libresign', 'can_request_sign', false),
93+
methods: loadState('libresign', 'identify_methods', []),
9294
}
9395
},
9496
computed: {
@@ -114,9 +116,32 @@ export default {
114116
counterType() {
115117
return this.counterNumber !== null ? 'highlighted' : undefined
116118
},
119+
isMethodDisabled() {
120+
if (!this.signer.identifyMethods?.length) {
121+
return false
122+
}
123+
const signerMethod = this.signer.identifyMethods[0].method
124+
const methodConfig = this.methods.find(m => m.name === signerMethod)
125+
return !methodConfig?.enabled
126+
},
127+
disabledMethodLabel() {
128+
if (!this.signer.identifyMethods?.length) {
129+
return ''
130+
}
131+
const signerMethod = this.signer.identifyMethods[0].method
132+
const methodConfig = this.methods.find(m => m.name === signerMethod)
133+
return methodConfig?.friendly_name || signerMethod
134+
},
135+
disabledTooltip() {
136+
if (this.isMethodDisabled) {
137+
return this.t('libresign', 'This signer cannot be used because the identification method "{method}" has been disabled by the administrator.', { method: this.disabledMethodLabel })
138+
}
139+
return ''
140+
},
117141
signerClass() {
118142
return {
119143
'signer-signed': this.signer.signed,
144+
'signer-method-disabled': this.isMethodDisabled,
120145
}
121146
},
122147
showDragHandle() {
@@ -173,6 +198,9 @@ export default {
173198
if (this.signer.signed) {
174199
return
175200
}
201+
if (this.isMethodDisabled) {
202+
return
203+
}
176204
emit(this.event, this.signer)
177205
},
178206
closeActions() {
@@ -220,4 +248,33 @@ export default {
220248
cursor: not-allowed;
221249
opacity: 0.3;
222250
}
251+
252+
.signer-method-disabled {
253+
opacity: 0.6;
254+
255+
:deep(.list-item__wrapper) {
256+
cursor: not-allowed !important;
257+
}
258+
259+
:deep(.list-item-content__wrapper) {
260+
position: relative;
261+
262+
&::after {
263+
content: '';
264+
position: absolute;
265+
top: 0;
266+
left: 0;
267+
right: 0;
268+
bottom: 0;
269+
background-color: var(--color-background-dark);
270+
opacity: 0.2;
271+
pointer-events: none;
272+
}
273+
}
274+
275+
:deep(.list-item-content__actions) {
276+
opacity: 1;
277+
pointer-events: auto;
278+
}
279+
}
223280
</style>

0 commit comments

Comments
 (0)