feat: introducing badges and subtitle support for table
This commit is contained in:
@@ -44,15 +44,15 @@
|
|||||||
|
|
||||||
<HoppSmartTable
|
<HoppSmartTable
|
||||||
v-else-if="usersList.length >= 1"
|
v-else-if="usersList.length >= 1"
|
||||||
|
padding="px-6 py-3"
|
||||||
:list="newUsersList"
|
:list="newUsersList"
|
||||||
:headings="headings"
|
:headings="headings"
|
||||||
@goToDetails="goToUserDetails"
|
@goToDetails="goToUserDetails"
|
||||||
:subtitle="{
|
badge-name="Admin"
|
||||||
index: 'name',
|
:badge-row-index="adminUsers"
|
||||||
label: 'Admin',
|
badge-col-name="name"
|
||||||
}"
|
subtitle-col-name="createdOn"
|
||||||
hide-col="isAdmin"
|
:subtitle="createdTime"
|
||||||
padding="px-6 py-3"
|
|
||||||
>
|
>
|
||||||
<template #action="{ item }">
|
<template #action="{ item }">
|
||||||
<td>
|
<td>
|
||||||
@@ -202,7 +202,21 @@ const newUsersList = computed(() => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const headings = ['User UID', 'Name', 'Email', 'Created On'];
|
const headings = ['User UID', 'Name', 'Email', 'Created On', ''];
|
||||||
|
|
||||||
|
const adminUsers = computed(() => {
|
||||||
|
return usersList.value.map((user, index) => {
|
||||||
|
if (user.isAdmin) {
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const createdTime = computed(() => {
|
||||||
|
return usersList.value.map((user) => {
|
||||||
|
return getCreatedTime(user.createdOn);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Send Invitation through Email
|
// Send Invitation through Email
|
||||||
const sendInvitation = useMutation(InviteNewUserDocument);
|
const sendInvitation = useMutation(InviteNewUserDocument);
|
||||||
|
|||||||
@@ -15,61 +15,50 @@
|
|||||||
|
|
||||||
<tbody class="divide-y divide-divider">
|
<tbody class="divide-y divide-divider">
|
||||||
<tr
|
<tr
|
||||||
v-for="item in list"
|
v-for="(item, rowIndex) in list"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="text-secondaryDark hover:bg-divider hover:cursor-pointer rounded-xl"
|
class="text-secondaryDark hover:bg-divider hover:cursor-pointer rounded-xl"
|
||||||
:class="xBorder ? 'divide-x divide-divider' : ''"
|
:class="xBorder ? 'divide-x divide-divider' : ''"
|
||||||
>
|
>
|
||||||
<td
|
<td
|
||||||
v-for="(data, index) in item"
|
v-for="(data, colIndex) in item"
|
||||||
:key="index"
|
:key="colIndex"
|
||||||
@click="$emit('goToDetails', item)"
|
@click="$emit('goToDetails', item)"
|
||||||
class="max-w-40"
|
class="max-w-40"
|
||||||
:class="padding"
|
:class="padding"
|
||||||
>
|
>
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<div class="flex flex-col">
|
<!-- Column with Badge -->
|
||||||
{{ data }}
|
<div
|
||||||
<!-- <div v-if="subdata" class="text-gray-400 text-tiny">
|
v-if="
|
||||||
{{ subdata }}
|
colIndex.toString() === badgeColName &&
|
||||||
</div> -->
|
badgeRowIndex.includes(rowIndex)
|
||||||
</div>
|
"
|
||||||
</div>
|
>
|
||||||
</td>
|
<div class="flex flex-col">
|
||||||
|
{{ data }}
|
||||||
<!-- <td @click="$emit('goToUserDetails', user.uid)" class="py-2 px-3">
|
<span
|
||||||
<div class="flex items-center">
|
class="text-xs font-medium px-3 py-0.5 rounded-full bg-green-900 text-green-300"
|
||||||
<div class="flex flex-col">
|
>
|
||||||
{{ getCreatedDate(user.createdOn) }}
|
{{ badgeName }}
|
||||||
<div class="text-gray-400 text-tiny">
|
</span>
|
||||||
{{ getCreatedTime(user.createdOn) }}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<!-- Column with Subtitles -->
|
||||||
</td> -->
|
<div
|
||||||
|
v-else-if="colIndex.toString() === subtitleColName"
|
||||||
<!-- <td @click="$emit('goToUserDetails', user.uid)" class="py-2 px-3">
|
class="flex flex-col"
|
||||||
<div v-if="user.displayName" class="flex items-center space-x-3">
|
|
||||||
<span>
|
|
||||||
{{ user.displayName }}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
v-if="user.isAdmin"
|
|
||||||
class="text-xs font-medium px-3 py-0.5 rounded-full bg-green-900 text-green-300"
|
|
||||||
>
|
>
|
||||||
Admin
|
<div>
|
||||||
</span>
|
{{ data }}
|
||||||
|
<div class="text-gray-400 text-tiny">
|
||||||
|
{{ subtitle[rowIndex] }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else class="flex flex-col">{{ data }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="flex items-center space-x-3">
|
</td>
|
||||||
<span> (Unnamed user) </span>
|
|
||||||
<span
|
|
||||||
v-if="user.isAdmin"
|
|
||||||
class="text-xs font-medium px-3 py-0.5 rounded-full bg-green-900 text-green-300"
|
|
||||||
>
|
|
||||||
Admin
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</td> -->
|
|
||||||
|
|
||||||
<slot name="action" :item="item"></slot>
|
<slot name="action" :item="item"></slot>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -85,19 +74,16 @@ defineProps<{
|
|||||||
headings: []
|
headings: []
|
||||||
padding: string
|
padding: string
|
||||||
itemStyle: string
|
itemStyle: string
|
||||||
subtitle: {
|
badgeName: string
|
||||||
index: string
|
badgeRowIndex: (number | undefined)[]
|
||||||
label: string
|
badgeColName: string
|
||||||
}
|
subtitleColName: string
|
||||||
hideCol: number
|
subtitle: []
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
defineEmits<{
|
defineEmits<{
|
||||||
(event: "goToDetails", uid: string): void
|
(event: "goToDetails", uid: string): void
|
||||||
(event: "id", uid: string): void
|
(event: "id", uid: string): void
|
||||||
(event: "makeUserAdmin", uid: string): void
|
|
||||||
(event: "makeAdminToUser", uid: string): void
|
|
||||||
(event: "deleteUser", uid: string): void
|
|
||||||
}>()
|
}>()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user