scinote-web/app/javascript/vue/projects/renderers/users.vue

45 lines
1.2 KiB
Vue
Raw Normal View History

2023-11-10 20:34:36 +08:00
<template>
2023-12-05 03:59:16 +08:00
<div v-if="!params.data.folder" class="flex items-center gap-1 cursor-pointer h-10" @click="openAccessModal">
2023-11-10 20:34:36 +08:00
<div v-for="(user, i) in visibleUsers" :key="i" :title="user.full_name">
<img :src="user.avatar" class="w-7 h-7" />
</div>
2023-12-11 16:18:22 +08:00
<div v-if="hiddenUsers.length > 0" :title="hiddenUsersTitle"
class="flex shrink-0 items-center justify-center w-7 h-7 text-xs rounded-full bg-sn-dark-grey text-sn-white">
2023-11-10 20:34:36 +08:00
+{{ hiddenUsers.length }}
</div>
<div class="flex items-center shrink-0 justify-center w-7 h-7 rounded-full bg-sn-light-grey text-sn-dark-grey">
<i class="sn-icon sn-icon-new-task"></i>
</div>
</div>
</template>
<script>
export default {
name: 'UsersRenderer',
props: {
params: {
2023-12-11 16:18:22 +08:00
required: true,
2023-12-05 03:59:16 +08:00
},
2023-11-10 20:34:36 +08:00
},
computed: {
users() {
2023-12-11 16:18:22 +08:00
return this.params.value || [];
2023-11-10 20:34:36 +08:00
},
visibleUsers() {
2023-12-11 16:18:22 +08:00
return this.users.slice(0, 4);
2023-11-10 20:34:36 +08:00
},
hiddenUsers() {
2023-12-11 16:18:22 +08:00
return this.users.slice(4);
2023-11-10 20:34:36 +08:00
},
hiddenUsersTitle() {
2023-12-11 16:18:22 +08:00
return this.hiddenUsers.map((user) => user.full_name).join('\u000d');
2023-12-12 19:17:38 +08:00
}
2023-12-05 03:59:16 +08:00
},
methods: {
openAccessModal() {
2023-12-11 16:18:22 +08:00
this.params.dtComponent.$emit('access', {}, [this.params.data]);
2023-12-12 19:17:38 +08:00
}
}
2023-12-11 16:18:22 +08:00
};
</script>