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

46 lines
1.3 KiB
Vue
Raw Normal View History

2023-11-10 20:34:36 +08:00
<template>
2024-02-01 18:45:13 +08:00
<div v-if="!params.data.folder" class="flex items-center gap-1 cursor-pointer h-9" @click="openAccessModal">
2023-11-10 20:34:36 +08:00
<div v-for="(user, i) in visibleUsers" :key="i" :title="user.full_name">
2024-03-04 18:07:15 +08:00
<img :src="user.avatar" class="w-7 h-7 rounded-full" />
2023-11-10 20:34:36 +08:00
</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 v-if="params.data.permissions['manage_users_assignments']"
class="flex items-center shrink-0 justify-center w-7 h-7 rounded-full bg-sn-light-grey text-sn-dark-grey">
2023-11-10 20:34:36 +08:00
<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>