|
1 | 1 | <script setup lang="ts">
|
2 | 2 | import type { Hits, SearchResponse } from '@stacksjs/types'
|
3 | 3 | import { isString } from '@stacksjs/validation'
|
4 |
| -import { useTable } from '../functions/table' |
| 4 | +import test from '../functions/table' |
5 | 5 |
|
6 | 6 | interface Props {
|
7 | 7 | type: string // the Meilisearch index you would like to use for this table
|
@@ -50,87 +50,68 @@ const {
|
50 | 50 | selectedAll = false,
|
51 | 51 | } = defineProps<Props>()
|
52 | 52 |
|
53 |
| -const parsedColumns = computed((): string[] => { |
54 |
| - if (isString(columns)) |
55 |
| - return (columns as string).split(',').map(col => col.trim()) |
| 53 | +// const parsedColumns = computed((): string[] => { |
| 54 | +// if (isString(columns)) |
| 55 | +// return (columns as string).split(',').map(col => col.trim()) |
56 | 56 |
|
57 |
| - return columns as string[] |
58 |
| -}) |
| 57 | +// return columns as string[] |
| 58 | +// }) |
59 | 59 |
|
60 |
| -const parsedSorts = computed((): string[] => { |
61 |
| - if (isString(sorts)) |
62 |
| - return (sorts as string).split(',').map(col => col.trim()) |
| 60 | +// const parsedSorts = computed((): string[] => { |
| 61 | +// if (isString(sorts)) |
| 62 | +// return (sorts as string).split(',').map(col => col.trim()) |
63 | 63 |
|
64 |
| - return sorts as string[] |
65 |
| -}) |
| 64 | +// return sorts as string[] |
| 65 | +// }) |
66 | 66 |
|
67 |
| -const parsedFilters = computed((): string[] => { |
68 |
| - if (isString(filters)) |
69 |
| - return (filters as string).split(',').map(col => col.trim()) |
| 67 | +// const parsedFilters = computed((): string[] => { |
| 68 | +// if (isString(filters)) |
| 69 | +// return (filters as string).split(',').map(col => col.trim()) |
70 | 70 |
|
71 |
| - return filters as string[] |
72 |
| -}) |
| 71 | +// return filters as string[] |
| 72 | +// }) |
73 | 73 |
|
74 |
| -const itemsPerPage = computed((): number => { |
75 |
| - if (isString(perPage)) |
76 |
| - return Number.parseInt(perPage as string) |
| 74 | +// const itemsPerPage = computed((): number => { |
| 75 | +// if (isString(perPage)) |
| 76 | +// return Number.parseInt(perPage as string) |
77 | 77 |
|
78 |
| - return perPage as number |
79 |
| -}) |
| 78 | +// return perPage as number |
| 79 | +// }) |
80 | 80 |
|
81 | 81 | // let's use (init) the table by passing the default state
|
82 |
| -const { table, search, columnName } = await useTable({ |
83 |
| - source, |
84 |
| - password, |
85 |
| - type, |
86 |
| - columns: parsedColumns.value, |
87 |
| - searchable, |
88 |
| - query, |
89 |
| - sortable, |
90 |
| - sort, |
91 |
| - sorts: parsedSorts.value, |
92 |
| - filterable, |
93 |
| - filters: parsedFilters.value, |
94 |
| - actionable, |
95 |
| - actions, |
96 |
| - perPage: itemsPerPage.value, |
97 |
| - currentPage: 1, |
98 |
| - selectable: true, |
99 |
| - selectedRows: [], |
100 |
| - selectedAll: false, |
101 |
| -}) |
| 82 | +// const { test } = await useTable() |
102 | 83 |
|
103 | 84 | // let's run the initial search upon page view/load
|
104 | 85 |
|
105 | 86 | // console.log('running initial search')
|
106 |
| -const results = await search() |
| 87 | +// const results = await search() |
107 | 88 | // eslint-disable-next-line no-console
|
108 |
| -console.log('initial search complete', results) |
| 89 | +// console.log('initial search complete', results) |
109 | 90 |
|
110 | 91 | // now that we have the search results, let's update/set the state of the table
|
111 |
| -table.source = source |
112 |
| -table.password = password |
113 |
| -table.hits = results?.hits |
114 |
| -table.type = type |
115 |
| -table.columns = parsedColumns.value |
116 |
| -table.searchable = searchable |
117 |
| -table.query = query |
118 |
| -table.filterable = filterable |
119 |
| -table.filters = parsedFilters.value |
120 |
| -table.sortable = sortable |
121 |
| -table.sort = sort |
122 |
| -table.sorts = parsedSorts.value |
123 |
| -table.perPage = itemsPerPage.value |
124 |
| -table.actionable = actionable |
125 |
| -table.actions = actions |
126 |
| -table.selectable = selectable |
127 |
| -table.selectedRows = selectedRows |
128 |
| -table.selectedAll = selectedAll |
129 |
| -table.results = results as SearchResponse |
| 92 | +// table.source = source |
| 93 | +// table.password = password |
| 94 | +// table.hits = results?.hits |
| 95 | +// table.type = type |
| 96 | +// table.columns = parsedColumns.value |
| 97 | +// table.searchable = searchable |
| 98 | +// table.query = query |
| 99 | +// table.filterable = filterable |
| 100 | +// table.filters = parsedFilters.value |
| 101 | +// table.sortable = sortable |
| 102 | +// table.sort = sort |
| 103 | +// table.sorts = parsedSorts.value |
| 104 | +// table.perPage = itemsPerPage.value |
| 105 | +// table.actionable = actionable |
| 106 | +// table.actions = actions |
| 107 | +// table.selectable = selectable |
| 108 | +// table.selectedRows = selectedRows |
| 109 | +// table.selectedAll = selectedAll |
| 110 | +// table.results = results as SearchResponse |
130 | 111 | </script>
|
131 | 112 |
|
132 | 113 | <template>
|
133 |
| - <div class="px-4 lg:px-8 sm:px-6"> |
| 114 | +<div class="px-4 lg:px-8 sm:px-6"> |
134 | 115 | <div class="mt-8 flex flex-col">
|
135 | 116 | <div class="overflow-x-auto -mx-4 -my-2 lg:-mx-8 sm:-mx-6">
|
136 | 117 | <div class="inline-block min-w-full py-2 align-middle lg:px-8 md:px-6">
|
|
0 commit comments