File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3737 </NcActions >
3838</template >
3939
40- <script >
40+ <script setup lang="ts" >
4141import NcActionButton from ' @nextcloud/vue/components/NcActionButton'
4242import NcActions from ' @nextcloud/vue/components/NcActions'
4343import NcAvatar from ' @nextcloud/vue/components/NcAvatar'
4444import NcIconSvgWrapper from ' @nextcloud/vue/components/NcIconSvgWrapper'
4545
4646import { mdiChevronDown } from ' @mdi/js'
4747
48- export default {
48+ defineOptions ( {
4949 name: ' SignerMenu' ,
50- emits: [' change' ],
51- components: {
52- NcActionButton,
53- NcActions,
54- NcAvatar,
55- NcIconSvgWrapper,
56- },
57- setup () {
58- return {
59- mdiChevronDown,
60- }
61- },
62- props: {
63- signers: {
64- type: Array ,
65- default : () => [],
66- },
67- currentSigner: {
68- type: Object ,
69- default: null ,
70- },
71- getSignerLabel: {
72- type: Function ,
73- default: null ,
74- },
75- show: {
76- type: Boolean ,
77- default: true ,
78- },
79- },
80- methods: {
81- label (signer ) {
82- if (this .getSignerLabel ) {
83- return this .getSignerLabel (signer)
84- }
85- if (! signer) {
86- return ' '
87- }
88- return signer .displayName || signer .name || signer .email || signer .id || ' '
89- },
90- signerKey (signer ) {
91- return signer? .signRequestId || signer? .uuid || signer? .id || signer? .email || ' '
92- },
93- selectSigner (signer ) {
94- this .$emit (' change' , signer)
95- },
96- },
50+ })
51+
52+ type Signer = {
53+ signRequestId? : string | number
54+ uuid? : string
55+ id? : string | number
56+ email? : string
57+ name? : string
58+ displayName? : string
9759}
60+
61+ const props = withDefaults (defineProps <{
62+ signers? : Signer []
63+ currentSigner? : Signer | null
64+ getSignerLabel? : ((signer : Signer | null | undefined ) => string ) | null
65+ show? : boolean
66+ }>(), {
67+ signers : () => [],
68+ currentSigner: null ,
69+ getSignerLabel: null ,
70+ show: true ,
71+ })
72+
73+ const emit = defineEmits <{
74+ change: [signer : Signer ]
75+ }>()
76+
77+ function label(signer : Signer | null | undefined ) {
78+ if (props .getSignerLabel ) {
79+ return props .getSignerLabel (signer )
80+ }
81+ if (! signer ) {
82+ return ' '
83+ }
84+ return signer .displayName || signer .name || signer .email || signer .id || ' '
85+ }
86+
87+ function signerKey(signer : Signer ) {
88+ return signer ?.signRequestId || signer ?.uuid || signer ?.id || signer ?.email || ' '
89+ }
90+
91+ function selectSigner(signer : Signer ) {
92+ emit (' change' , signer )
93+ }
94+
95+ defineExpose ({
96+ label ,
97+ signerKey ,
98+ selectSigner ,
99+ })
98100 </script >
99101
100102<style lang="scss">
You can’t perform that action at this time.
0 commit comments