refactor: modified components to suit the changes in the table component

This commit is contained in:
Joel Jacob Stephen
2023-07-21 22:48:10 +05:30
parent 27eb7690ba
commit 6e7db67c9b
4 changed files with 22 additions and 27 deletions

View File

@@ -31,8 +31,7 @@
<HoppSmartTable <HoppSmartTable
:list="newTeamsList" :list="newTeamsList"
:headings="headings" :headings="headings"
@openRowContent="goToTeamDetails" @on-row-clicked="goToTeamDetails"
:modify-col-names="['action']"
cell-styles="px-6 py-1" cell-styles="px-6 py-1"
> >
<template #action="{ item }"> <template #action="{ item }">
@@ -154,8 +153,13 @@ const newTeamsList = computed(() => {
}); });
}); });
// Headers that are used in the table // Table Headings
const headings = [t('teams.id'), t('teams.name'), t('teams.members'), '']; const headings = [
{ key: 'id', label: t('teams.id') },
{ key: 'name', label: t('teams.name') },
{ key: 'members', label: t('teams.members') },
{ key: 'action', label: '', preventClick: true },
];
// Create Team // Create Team
const createTeamMutation = useMutation(CreateTeamDocument); const createTeamMutation = useMutation(CreateTeamDocument);

View File

@@ -36,8 +36,7 @@
cell-styles="px-6 py-1" cell-styles="px-6 py-1"
:list="newUsersList" :list="newUsersList"
:headings="headings" :headings="headings"
:modify-col-names="colNames" @on-row-clicked="goToUserDetails"
@openRowContent="goToUserDetails"
> >
<template #name="{ item }"> <template #name="{ item }">
<div> <div>
@@ -168,7 +167,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { format } from 'date-fns'; import { format } from 'date-fns';
import { computed, reactive, ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { useMutation } from '@urql/vue'; import { useMutation } from '@urql/vue';
import { import {
InviteNewUserDocument, InviteNewUserDocument,
@@ -234,18 +233,15 @@ const isUserAdmin = (
})[0].isAdmin; })[0].isAdmin;
}; };
// Headers that are used in the table // Table Headings
const headings = [ const headings = [
t('users.id'), { key: 'uid', label: t('users.id') },
t('users.name'), { key: 'name', label: t('users.name') },
t('users.email'), { key: 'email', label: t('users.email') },
t('users.date'), { key: 'createdOn', label: t('users.date') },
'', { key: 'action', label: '', preventClick: true },
]; ];
//Names of the columns to be modified by this component
const colNames = ['name', 'createdOn', 'action'];
// Send Invitation through Email // Send Invitation through Email
const sendInvitation = useMutation(InviteNewUserDocument); const sendInvitation = useMutation(InviteNewUserDocument);
const showInviteUserModal = ref(false); const showInviteUserModal = ref(false);

View File

@@ -29,7 +29,6 @@
cell-styles="px-6 py-1" cell-styles="px-6 py-1"
:list="newInvitedUsersList" :list="newInvitedUsersList"
:headings="headings" :headings="headings"
:modify-col-names="colNames"
> >
<template #invitedOn="{ item }"> <template #invitedOn="{ item }">
<div class="flex flex-col truncate"> <div class="flex flex-col truncate">
@@ -90,13 +89,11 @@ const newInvitedUsersList = computed(() => {
}); });
}); });
// Headings used in the table // Table Headings
const headings = [ const headings = [
t('users.admin_id'), { key: 'adminUid', label: t('users.admin_id') },
t('users.admin_email'), { key: 'adminEmail', label: t('users.admin_email') },
t('users.invitee_email'), { key: 'inviteeEmail', label: t('users.invitee_email') },
t('users.invited_on'), { key: 'invitedOn', label: t('users.invited_on') },
]; ];
const colNames = ['invitedOn'];
</script> </script>

View File

@@ -63,7 +63,5 @@ const emit = defineEmits<{
(event: "onRowClicked", item: Item): void (event: "onRowClicked", item: Item): void
}>() }>()
const onRowClicked = (item: Item) => { const onRowClicked = (item: Item) => emit("onRowClicked", item)
emit("onRowClicked", item)
}
</script> </script>