refactor: renamed emit event and removed action slot

This commit is contained in:
Joel Jacob Stephen
2023-07-20 21:51:08 +05:30
parent 24f32d79b3
commit d5e4211347
4 changed files with 87 additions and 88 deletions

View File

@@ -22,10 +22,13 @@ declare module '@vue/runtime-core' {
HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem'] HoppSmartItem: typeof import('@hoppscotch/ui')['HoppSmartItem']
HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal'] HoppSmartModal: typeof import('@hoppscotch/ui')['HoppSmartModal']
HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture'] HoppSmartPicture: typeof import('@hoppscotch/ui')['HoppSmartPicture']
HoppSmartPlaceholder: typeof import('@hoppscotch/ui')['HoppSmartPlaceholder']
HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner'] HoppSmartSpinner: typeof import('@hoppscotch/ui')['HoppSmartSpinner']
HoppSmartTab: typeof import('@hoppscotch/ui')['HoppSmartTab']
HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable'] HoppSmartTable: typeof import('@hoppscotch/ui')['HoppSmartTable']
IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default'] IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']
IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default'] IconLucideChevronDown: typeof import('~icons/lucide/chevron-down')['default']
IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default']
IconLucideInbox: typeof import('~icons/lucide/inbox')['default'] IconLucideInbox: typeof import('~icons/lucide/inbox')['default']
IconLucideUser: typeof import('~icons/lucide/user')['default'] IconLucideUser: typeof import('~icons/lucide/user')['default']
TeamsAdd: typeof import('./components/teams/Add.vue')['default'] TeamsAdd: typeof import('./components/teams/Add.vue')['default']

View File

@@ -31,11 +31,11 @@
<HoppSmartTable <HoppSmartTable
:list="newTeamsList" :list="newTeamsList"
:headings="headings" :headings="headings"
@goToDetails="goToTeamDetails" @openRowContent="goToTeamDetails"
cell-styles="px-6 py-3" :modify-col-names="['action']"
cell-styles="px-6 py-1"
> >
<template #action="{ item }"> <template #action="{ item }">
<td>
<div class="relative"> <div class="relative">
<tippy interactive trigger="click" theme="popover"> <tippy interactive trigger="click" theme="popover">
<HoppButtonSecondary <HoppButtonSecondary
@@ -59,7 +59,6 @@
</template> </template>
</tippy> </tippy>
</div> </div>
</td>
</template> </template>
</HoppSmartTable> </HoppSmartTable>
</div> </div>
@@ -150,6 +149,7 @@ const newTeamsList = computed(() => {
id: team.id, id: team.id,
name: team.name, name: team.name,
members: team.members.length, members: team.members.length,
action: '',
}; };
}); });
}); });

View File

@@ -37,7 +37,7 @@
:list="newUsersList" :list="newUsersList"
:headings="headings" :headings="headings"
:modify-col-names="colNames" :modify-col-names="colNames"
@goToDetails="goToUserDetails" @openRowContent="goToUserDetails"
> >
<template #name="{ item }"> <template #name="{ item }">
<div> <div>
@@ -49,9 +49,7 @@
{{ item.name }} {{ item.name }}
</span> </span>
<span <span v-if="item.name.length === 0 && !isUserAdmin(item)"
v-if="item.name.length === 0 && !isUserAdmin(item)"
class="mx-auto justify-center"
>-</span >-</span
> >
@@ -85,7 +83,6 @@
</template> </template>
<template #action="{ item }"> <template #action="{ item }">
<td>
<div class="relative"> <div class="relative">
<span> <span>
<tippy interactive trigger="click" theme="popover"> <tippy interactive trigger="click" theme="popover">
@@ -126,7 +123,6 @@
</tippy> </tippy>
</span> </span>
</div> </div>
</td>
</template> </template>
</HoppSmartTable> </HoppSmartTable>
</div> </div>
@@ -225,6 +221,7 @@ const newUsersList = computed(() => {
name: user.displayName ?? '', name: user.displayName ?? '',
email: user.email ?? '', email: user.email ?? '',
createdOn: user.createdOn, createdOn: user.createdOn,
action: '',
}; };
}); });
}); });
@@ -247,7 +244,7 @@ const headings = [
]; ];
//Names of the columns to be modified by this component //Names of the columns to be modified by this component
const colNames = ['name', 'createdOn']; const colNames = ['name', 'createdOn', 'action'];
// Send Invitation through Email // Send Invitation through Email
const sendInvitation = useMutation(InviteNewUserDocument); const sendInvitation = useMutation(InviteNewUserDocument);

View File

@@ -21,27 +21,26 @@
<td <td
v-for="(data, colIndex) in item" v-for="(data, colIndex) in item"
:key="colIndex" :key="colIndex"
@click="$emit('goToDetails', item)" @click="$emit('openRowContent', item)"
class="max-w-40" class="max-w-40"
:class="cellStyles" :class="cellStyles"
> >
<!-- Custom implementation of the particular column --> <!-- Custom implementation of the particular column -->
<div class="flex items-center">
<div v-if="modifyColNames?.includes(colIndex.toString())"> <div v-if="modifyColNames?.includes(colIndex.toString())">
<slot :name="colIndex.toString()" :item="item"></slot> <slot :name="colIndex.toString()" :item="item"></slot>
</div> </div>
<!-- Generic implementation of the column --> <!-- Generic implementation of the column -->
<div v-else class="flex flex-col truncate text-center"> <div v-else class="flex flex-col truncate">
<span v-if="data" class="truncate"> <span v-if="data" class="truncate">
{{ data }} {{ data }}
</span> </span>
<span v-else class=""> - </span> <span v-else class=""> - </span>
</div> </div>
</div>
</td> </td>
<slot name="action" :item="item"></slot> <!-- <slot name="action" :item="item"></slot> -->
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -63,6 +62,6 @@ defineProps<{
}>() }>()
defineEmits<{ defineEmits<{
(event: "goToDetails", item: Item): void (event: "openRowContent", item: Item): void
}>() }>()
</script> </script>