feat: added the ability to add subtitles in multiple columns

This commit is contained in:
Joel Jacob Stephen
2023-07-06 23:40:09 +05:30
parent 834efce1c2
commit dfabf7e8bc
3 changed files with 52 additions and 12 deletions

View File

@@ -147,7 +147,7 @@ const teamList = computed(() => {
}); });
}); });
const headings = ['Team ID', 'Team Name', 'Number of Members']; const headings = ['Team ID', 'Team Name', 'Number of Members', ''];
// Create Team // Create Team
const createTeamMutation = useMutation(CreateTeamDocument); const createTeamMutation = useMutation(CreateTeamDocument);

View File

@@ -51,8 +51,7 @@
badge-name="Admin" badge-name="Admin"
:badge-row-index="adminUsers" :badge-row-index="adminUsers"
badge-col-name="name" badge-col-name="name"
subtitle-col-name="createdOn" :subtitle="subtitle"
:subtitle="createdTime"
> >
<template #action="{ item }"> <template #action="{ item }">
<td> <td>
@@ -141,7 +140,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { format } from 'date-fns'; import { format } from 'date-fns';
import { computed, ref, watch } from 'vue'; import { computed, onMounted, reactive, ref, watch } from 'vue';
import { useMutation } from '@urql/vue'; import { useMutation } from '@urql/vue';
import { import {
InviteNewUserDocument, InviteNewUserDocument,
@@ -218,6 +217,22 @@ const createdTime = computed(() => {
}); });
}); });
onMounted(() => {
console.log(createdTime);
console.log(createdTime.value);
for (var item in createdTime.value) {
console.log(item);
}
});
const subtitle = reactive([
{
colName: 'createdOn',
subtitle: createdTime,
},
]);
// 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

@@ -46,13 +46,20 @@
</div> </div>
<!-- Column with Subtitles --> <!-- Column with Subtitles -->
<div <div
v-else-if="colIndex.toString() === subtitleColName" v-else-if="subCol.includes(colIndex.toString())"
class="flex flex-col" class="flex flex-col"
> >
<div> {{ data }}
{{ data }} <div v-for="item in subtitle">
<div class="text-gray-400 text-tiny"> <div
{{ subtitle[rowIndex] }} v-if="item.colName === colIndex.toString()"
class="text-gray-400 text-tiny"
>
<span>
<span>
{{ itemSubtitle(item.subtitle, rowIndex) }}
</span>
</span>
</div> </div>
</div> </div>
</div> </div>
@@ -68,7 +75,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
defineProps<{ import { computed, onMounted } from "vue"
const props = defineProps<{
xBorder: Boolean xBorder: Boolean
list: [] list: []
headings: [] headings: []
@@ -77,14 +86,30 @@ defineProps<{
badgeName: string badgeName: string
badgeRowIndex: (number | undefined)[] badgeRowIndex: (number | undefined)[]
badgeColName: string badgeColName: string
subtitleColName: string subtitle: [
subtitle: [] {
colName: string
subtitle: string | []
}
]
}>() }>()
defineEmits<{ defineEmits<{
(event: "goToDetails", uid: string): void (event: "goToDetails", uid: string): void
(event: "id", uid: string): void (event: "id", uid: string): void
}>() }>()
const subCol = computed(() =>
props.subtitle ? props.subtitle.map((item) => item.colName) : []
)
onMounted(() => {
console.log(props.subtitle)
console.log(subCol)
})
const itemSubtitle = (subtitle: string | string[], rowIndex: number) =>
typeof subtitle === "object" ? subtitle[rowIndex] : subtitle
</script> </script>
<style scoped> <style scoped>