|
23 | 23 | </NcListItem> |
24 | 24 | </template> |
25 | 25 |
|
26 | | -<script> |
| 26 | +<script setup lang="ts"> |
27 | 27 | import { t } from '@nextcloud/l10n' |
| 28 | +import { computed } from 'vue' |
28 | 29 |
|
29 | 30 | import { emit } from '@nextcloud/event-bus' |
30 | 31 | import Moment from '@nextcloud/moment' |
31 | 32 |
|
32 | 33 | import NcAvatar from '@nextcloud/vue/components/NcAvatar' |
33 | 34 | import NcListItem from '@nextcloud/vue/components/NcListItem' |
34 | 35 |
|
35 | | -export default { |
| 36 | +defineOptions({ |
36 | 37 | name: 'SignerRow', |
37 | 38 | inheritAttrs: false, |
38 | | - components: { |
39 | | - NcListItem, |
40 | | - NcAvatar, |
41 | | - }, |
42 | | - props: { |
43 | | - signer: { |
44 | | - type: Object, |
45 | | - required: true, |
46 | | - }, |
47 | | - to: { |
48 | | - type: Object, |
49 | | - required: false, |
50 | | - default: undefined, |
51 | | - }, |
52 | | - event: { |
53 | | - type: String, |
54 | | - required: false, |
55 | | - default: '', |
56 | | - }, |
57 | | - }, |
58 | | - computed: { |
59 | | - displayName() { |
60 | | - const { signer } = this |
61 | | -
|
62 | | - if (signer.displayName) { |
63 | | - return signer.displayName |
64 | | - } |
65 | | -
|
66 | | - if (signer.email) { |
67 | | - return signer.email |
68 | | - } |
69 | | -
|
70 | | - return t('libresign', 'Account does not exist') |
71 | | - }, |
72 | | - status() { |
73 | | - const { signer } = this |
74 | | - return signer.signed ? 'signed' : 'pending' |
75 | | - }, |
76 | | - signDate() { |
77 | | - const { signer } = this |
78 | | -
|
79 | | - return signer.signed |
80 | | - ? Moment(signer.signed, 'YYYY-MM-DD').toDate() |
81 | | - : '' |
82 | | - }, |
83 | | - element() { |
84 | | - return this.signer.element || {} |
85 | | - }, |
86 | | - hasElement() { |
87 | | - return this.element.elementId > 0 |
88 | | - }, |
89 | | - }, |
90 | | - methods: { |
91 | | - t, |
92 | | - signerClickAction(signer) { |
93 | | - emit(this.event, this.signer) |
94 | | - }, |
95 | | - }, |
| 39 | +}) |
| 40 | +
|
| 41 | +type Signer = { |
| 42 | + displayName?: string |
| 43 | + email?: string |
| 44 | + signed?: string | boolean |
| 45 | + element?: { |
| 46 | + elementId?: number |
| 47 | + } |
| 48 | +} |
| 49 | +
|
| 50 | +const props = withDefaults(defineProps<{ |
| 51 | + signer: Signer |
| 52 | + to?: Record<string, unknown> |
| 53 | + event?: string |
| 54 | +}>(), { |
| 55 | + to: undefined, |
| 56 | + event: '', |
| 57 | +}) |
| 58 | +
|
| 59 | +const displayName = computed(() => { |
| 60 | + if (props.signer.displayName) { |
| 61 | + return props.signer.displayName |
| 62 | + } |
| 63 | +
|
| 64 | + if (props.signer.email) { |
| 65 | + return props.signer.email |
| 66 | + } |
| 67 | +
|
| 68 | + return t('libresign', 'Account does not exist') |
| 69 | +}) |
| 70 | +
|
| 71 | +const status = computed(() => (props.signer.signed ? 'signed' : 'pending')) |
| 72 | +
|
| 73 | +const signDate = computed(() => ( |
| 74 | + props.signer.signed |
| 75 | + ? Moment(props.signer.signed, 'YYYY-MM-DD').toDate() |
| 76 | + : '' |
| 77 | +)) |
| 78 | +
|
| 79 | +const element = computed(() => props.signer.element || {}) |
| 80 | +
|
| 81 | +const hasElement = computed(() => (element.value.elementId || 0) > 0) |
| 82 | +
|
| 83 | +function signerClickAction() { |
| 84 | + emit(props.event, props.signer) |
96 | 85 | } |
97 | 86 | </script> |
98 | 87 |
|
|
0 commit comments