Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed May 19, 2022
1 parent 50641fc commit d5ee279
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/components/Table.vue
Expand Up @@ -67,7 +67,7 @@ const itemsPerPage = $computed((): number => {
})
// let's use (init) the table by passing the default state
const { table, search } = await useTable({
const { table, search, colName } = await useTable({
source,
password,
type,
Expand Down Expand Up @@ -107,10 +107,6 @@ table.value.perPage = itemsPerPage
table.value.actions = actions
table.value.actionable = actionable
table.value.checkable = checkable
function colName(col: string) {
return col.split(':')[0].trim()
}
</script>

<template>
Expand Down
7 changes: 1 addition & 6 deletions src/components/TableBody.vue
@@ -1,13 +1,8 @@
<script setup lang="ts">
import { isString } from '@vueuse/core'
// eslint-disable-next-line no-console
console.log('TableBody.vue')
const { table } = $(await useTable())
function colName(col: any) {
return col.split(':')[0].trim()
}
const { table, colName } = $(await useTable())
</script>

<template>
Expand Down
6 changes: 1 addition & 5 deletions src/components/TableRow.vue
@@ -1,7 +1,7 @@
<script setup lang="ts">
const { hit } = defineProps<{ hit: any }>()
const { table } = $(await useTable())
const { table, colName } = $(await useTable())
// let's generate the value of the row
function generateValue(hit: any, col: any) {
Expand All @@ -10,10 +10,6 @@ function generateValue(hit: any, col: any) {
return JSON.parse(hit[col])
}
function colName(col: any) {
return col.split(':')[0].trim()
}
</script>

<template>
Expand Down
5 changes: 5 additions & 0 deletions src/composables/table.ts
Expand Up @@ -205,6 +205,10 @@ function toggleSort(col: string | Ref<string>) {
console.log('table.sort', table.sort)
}

function colName(col: string) {
return col.split(':')[0].trim()
}

export async function useTable(store?: TableStore) {
return $$({
store,
Expand All @@ -227,5 +231,6 @@ export async function useTable(store?: TableStore) {
isColumnUsedAsSort,
actionable,
actions,
colName,
})
}

0 comments on commit d5ee279

Please sign in to comment.