Skip to content

Commit c9dba8d

Browse files
committed
feat: add visual indicators for signing order in Signer component
Display counter-number badge with highlighted style when in ordered_numeric mode. Show DragVertical icon handle when drag-and-drop is enabled. Add closeActions method to programmatically close action menu after input submission. Signed-off-by: Vitor Mattos <[email protected]>
1 parent 8e3411b commit c9dba8d

1 file changed

Lines changed: 84 additions & 2 deletions

File tree

src/Components/Signers/Signer.vue

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,29 @@
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
55
<template>
6-
<NcListItem :name="signer.displayName"
6+
<NcListItem ref="listItem"
7+
:name="signerName"
8+
:counter-number="counterNumber"
9+
:counter-type="counterType"
710
:force-display-actions="true"
11+
:class="signerClass"
812
@click="signerClickAction">
913
<template #icon>
1014
<NcAvatar :size="44" :display-name="signer.displayName" />
1115
</template>
1216
<template #subname>
1317
<Bullet v-for="method in identifyMethodsNames" :key="method" :name="method" />
1418
</template>
15-
<slot slot="actions" name="actions" />
19+
<template #extra>
20+
<div v-if="showDragHandle" class="drag-handle-wrapper">
21+
<DragVertical :size="20"
22+
class="drag-handle"
23+
:title="t('libresign', 'Drag to reorder')" />
24+
</div>
25+
</template>
26+
<template #actions>
27+
<slot name="actions" :closeActions="closeActions" />
28+
</template>
1629
<template #indicator>
1730
<CheckboxBlankCircle :size="16"
1831
:fill-color="statusColor"
@@ -22,6 +35,7 @@
2235
</template>
2336
<script>
2437
import CheckboxBlankCircle from 'vue-material-design-icons/CheckboxBlankCircle.vue'
38+
import DragVertical from 'vue-material-design-icons/DragVertical.vue'
2539
2640
import { emit } from '@nextcloud/event-bus'
2741
import { loadState } from '@nextcloud/initial-state'
@@ -40,6 +54,7 @@ export default {
4054
NcListItem,
4155
NcAvatar,
4256
CheckboxBlankCircle,
57+
DragVertical,
4358
Bullet,
4459
},
4560
props: {
@@ -52,6 +67,11 @@ export default {
5267
required: false,
5368
default: '',
5469
},
70+
draggable: {
71+
type: Boolean,
72+
required: false,
73+
default: false,
74+
},
5575
},
5676
setup() {
5777
const filesStore = useFilesStore()
@@ -60,12 +80,46 @@ export default {
6080
data() {
6181
return {
6282
canRequestSign: loadState('libresign', 'can_request_sign', false),
83+
signatureFlow: loadState('libresign', 'signature_flow', 'parallel'),
6384
}
6485
},
6586
computed: {
6687
signer() {
6788
return this.filesStore.getFile().signers[this.currentSigner]
6889
},
90+
signerName() {
91+
return this.signer.displayName
92+
},
93+
counterNumber() {
94+
const file = this.filesStore.getFile()
95+
const totalSigners = file?.signers?.length || 0
96+
if (this.signatureFlow === 'ordered_numeric' && totalSigners > 1 && this.signer.signingOrder) {
97+
return this.signer.signingOrder
98+
}
99+
return null
100+
},
101+
counterType() {
102+
return this.counterNumber !== null ? 'highlighted' : undefined
103+
},
104+
signerClass() {
105+
return {
106+
'signer-signed': this.signer.signed,
107+
}
108+
},
109+
showDragHandle() {
110+
if (!this.draggable) {
111+
return false
112+
}
113+
const file = this.filesStore.getFile()
114+
if (!file || !file.signers) {
115+
return false
116+
}
117+
const totalSigners = file.signers.length
118+
return this.signatureFlow === 'ordered_numeric' &&
119+
totalSigners > 1 &&
120+
!this.signer.signed &&
121+
this.filesStore.canSave()
122+
},
69123
identifyMethodsNames() {
70124
return this.signer.identifyMethods.map(method => method.method)
71125
},
@@ -107,6 +161,34 @@ export default {
107161
}
108162
emit(this.event, this.signer)
109163
},
164+
closeActions() {
165+
const actionsRef = this.$refs.listItem?.$refs.actions
166+
if (actionsRef && typeof actionsRef.closeMenu === 'function') {
167+
actionsRef.closeMenu()
168+
}
169+
},
110170
},
111171
}
112172
</script>
173+
<style lang="scss" scoped>
174+
.drag-handle-wrapper {
175+
display: flex;
176+
align-items: center;
177+
height: 100%;
178+
}
179+
180+
.drag-handle {
181+
cursor: grab;
182+
color: var(--color-text-maxcontrast);
183+
opacity: 0.7;
184+
185+
&:hover {
186+
opacity: 1;
187+
}
188+
}
189+
190+
.signer-signed .drag-handle {
191+
cursor: not-allowed;
192+
opacity: 0.3;
193+
}
194+
</style>

0 commit comments

Comments
 (0)