Skip to content

Commit db9522a

Browse files
committed
Add mini mode.
1 parent 61362bb commit db9522a

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

docs/TableDemo.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ const layouts: IwProps.SimpleLayoutProps[] = [
610610
]
611611
612612
const _tableProps: IwProps.SimpleTableProps = {
613+
// mini: true,
613614
pkColumnName: 'no',
614615
parentPkColumnName: 'pno',
615616
columns,

src/Skeleton.vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ function setHeight() {
5858
// Set table height
5959
Array.prototype.forEach.call(document.getElementsByClassName('iw-tt'), (ttEle) => {
6060
const outHeight = ttEle.parentElement?.clientHeight
61-
const headerHeight = ttEle.getElementsByClassName('iw-tt-header')[0].offsetHeight
61+
const headerEle = ttEle.getElementsByClassName('iw-tt-header')
62+
const headerHeight = headerEle.length > 0 ? headerEle[0].offsetHeight : 0
6263
Array.prototype.forEach.call(ttEle.getElementsByClassName('iw-tt-layout'), (layoutEle) => {
63-
const toolbarHeight = layoutEle.getElementsByClassName('iw-tt-toolbar').length > 0 ? layoutEle.getElementsByClassName('iw-tt-toolbar')[0].offsetHeight : 0
64+
const toolbarEle = layoutEle.getElementsByClassName('iw-tt-toolbar')
65+
const toolbarHeight = toolbarEle.length > 0 ? toolbarEle[0].offsetHeight : 0
6466
const footerHeight = layoutEle.getElementsByClassName('iw-tt-footer')[0].offsetHeight
6567
layoutEle.getElementsByClassName('iw-tt-table')[0].style.height = `${outHeight - headerHeight - toolbarHeight - footerHeight}px`
6668
})
@@ -121,9 +123,11 @@ onMounted(async () => {
121123
:class="`${tableConf.styles.tableClass} iw-tt w-full text-sm text-base-content bg-base-100 relative`"
122124
>
123125
<div
126+
v-if="!tableConf.mini || tableConf.quickSearch"
124127
:class="`${tableConf.styles.headerClass} iw-tt-header flex justify-between p-0 min-h-0`"
125128
>
126129
<ScrollableComp
130+
v-if="!tableConf.mini"
127131
class="flex-1"
128132
>
129133
<div class="tablist iw-tabs iw-tabs-sm iw-tabs-boxed">
@@ -139,13 +143,17 @@ onMounted(async () => {
139143
</a>
140144
</div>
141145
</ScrollableComp>
146+
<div v-else class="flex-1">
147+
&nbsp;
148+
</div>
142149
<div class="flex items-center">
143150
<QuickSearchComp
144151
v-if="tableConf.quickSearch"
145152
class="mx-2"
146153
:quick-search="tableConf.quickSearch"
147154
/>
148155
<TableSettingComp
156+
v-if="!tableConf.mini"
149157
:table-conf="tableConf"
150158
:layout-conf="currentLayoutConf"
151159
:layout-columns-conf="currentLayoutColumnsConf"
@@ -156,7 +164,7 @@ onMounted(async () => {
156164
<template v-for="layout in layoutsConf" :key="layout.id">
157165
<div v-show="currentLayoutId === layout.id" :id="`iw-tt-layout-${layout.id}`" class="iw-tt-layout">
158166
<div
159-
v-if="layout.sort || layout.filter"
167+
v-if="!tableConf.mini && (layout.sort || layout.filter)"
160168
class="iw-tt-toolbar flex items-center h-8 p-0.5"
161169
>
162170
<RowSortSettingComp v-if="layout.sort" :layout-id="layout.id" :sort="layout.sort" :layout-columns-conf="currentLayoutColumnsConf" />

src/components/conf.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface TableConf extends CommonFunctionProps {
1414
columns: TableColumnProps[]
1515
styles: TableStyleProps
1616
quickSearch?: QuickSearchProps
17+
mini: boolean
1718
}
1819

1920
export interface LayoutConf extends LayoutProps {
@@ -46,6 +47,7 @@ export function init(props: SimpleTableProps): {
4647
columns: tableProps.columns,
4748
styles: tableProps.styles,
4849
quickSearch: tableProps.quickSearch,
50+
mini: tableProps.mini,
4951

5052
slice: tableProps.slice,
5153
showSelectColumn: tableProps.showSelectColumn,

src/props/kernelProps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export interface TableProps extends CommonFunctionProps {
8989
styles: TableStyleProps
9090

9191
quickSearch?: QuickSearchProps
92+
93+
mini: boolean
9294
}
9395
export interface SimpleTableProps extends SimpleCommonFunctionProps {
9496
id?: string
@@ -99,6 +101,8 @@ export interface SimpleTableProps extends SimpleCommonFunctionProps {
99101
events: TableEventProps
100102
styles?: SimpleTableStyleProps
101103
quickSearch?: QuickSearchProps
104+
105+
mini?: boolean
102106
}
103107
export function generateTableProps(simple: SimpleTableProps): TableProps {
104108
const columns = simple.columns.map(col => generateTableColumnProps(col))
@@ -117,6 +121,7 @@ export function generateTableProps(simple: SimpleTableProps): TableProps {
117121
...commonFunctions,
118122
})),
119123
styles: generateTableStyleProps(simple.styles ?? {}),
124+
mini: simple.mini ?? false,
120125
}
121126
}
122127

0 commit comments

Comments
 (0)