@@ -29,20 +29,36 @@ templ DateTime(ts time.Time) {
29
29
30
30
// Rows renders the table rows for a scaffold table
31
31
templ Rows (config *TableConfig) {
32
+ {{ pageCtx := composables.UsePageCtx (ctx) }}
32
33
<tr class =" hidden" >
33
34
<td colspan ={ fmt.Sprintf (" %d " , len (config.Columns )) }>
34
35
@ loaders.Spinner (loaders.SpinnerProps {
35
36
ContainerClass : templ.Classes (" flex justify-center items-center py-4" ),
36
37
})
37
38
</td >
38
39
</tr >
39
- for _ , item := range config.Rows {
40
+ if len ( config.Rows ) == 0 {
40
41
@ base.TableRow (base.TableRowProps {
41
42
Attrs : templ.Attributes {" class" : " hide-on-load" },
42
43
}) {
43
- for _ , cell := range item.Cells () {
44
- @ base.TableCell (base.TableCellProps {}) {
45
- @ cell
44
+ @ base.TableCell (base.TableCellProps {
45
+ Classes : templ.Classes (" text-center" ),
46
+ Attrs : templ.Attributes {
47
+ " colspan" : fmt.Sprintf (" %d " , len (config.Columns )),
48
+ },
49
+ }) {
50
+ { pageCtx.T (" Scaffold.Table.NothingFound" ) }
51
+ }
52
+ }
53
+ } else {
54
+ for _ , item := range config.Rows {
55
+ @ base.TableRow (base.TableRowProps {
56
+ Attrs : templ.Attributes {" class" : " hide-on-load" },
57
+ }) {
58
+ for _ , cell := range item.Cells () {
59
+ @ base.TableCell (base.TableCellProps {}) {
60
+ @ cell
61
+ }
46
62
}
47
63
}
48
64
}
@@ -75,61 +91,58 @@ templ TableSection(config *TableConfig) {
75
91
<form
76
92
hx-get ={ config.DataURL }
77
93
hx-push-url =" true"
78
- hx-trigger =" keyup changed delay:300ms from:(form input) , change from:(form select) , change from:(form input[type='checkbox']) "
94
+ hx-trigger =" keyup changed delay:300ms from:input, change from:select, change from:input[type='checkbox']"
79
95
hx-target =" #table-body"
80
96
hx-swap =" innerHTML"
81
97
hx-indicator =" #table-body"
82
- class =" flex gap-5"
83
- x-data =" checkboxes"
84
- x-init =" init"
85
98
>
86
- <!-- Left sidebar with filters -- >
87
- if config. SideFilter != nil {
88
- < div class = " hidden md:block w-64 flex-shrink-0 " >
89
- <div class =" bg-surface-600 border border-primary rounded-lg p-4 mb-4 " >
99
+ <div class = " flex gap-5 " >
100
+ <!-- Left sidebar with filters -->
101
+ if config. SideFilter != nil {
102
+ <div class =" hidden md:block w-64 flex-shrink-0 " >
90
103
@ config.SideFilter
91
104
</div >
92
- </ div >
93
- }
94
- <!-- Main content area with search, filters, and table -- >
95
- <div class =" flex-1 " >
96
- <div class =" bg-surface-600 border border-primary rounded-lg " >
97
- <div class =" p-4 flex flex-row md:items-center gap-3 " >
98
- < div class = " flex-1 " >
99
- @ input. Text ( &input.Props {
100
- AddonLeft : &input. Addon {
101
- Component: icons. MagnifyingGlass (icons. Props {Size: " 20 " }) ,
102
- } ,
103
- Placeholder : pageCtx. T ( " Search " ),
104
- Attrs : templ. Attributes {
105
- " name " : " search " ,
106
- " value " : " " ,
107
- },
108
- })
109
- </ div >
110
- < div class = " hidden md:flex gap-3 h-full " >
111
- for _ , filter := range config. Filters {
112
- @ filter
113
- }
105
+ }
106
+ <!-- Main content area with search, filters, and table -->
107
+ < div class = " flex-1 " >
108
+ <div class =" bg-surface-600 border border-primary rounded-lg " >
109
+ <div class =" p-4 flex flex-row md:items-center gap-3 " >
110
+ <div class =" flex-1 " >
111
+ @ input. Text (&input. Props {
112
+ AddonLeft : &input.Addon {
113
+ Component: icons. MagnifyingGlass (icons. Props {Size: " 20 " }),
114
+ } ,
115
+ Placeholder : pageCtx. T ( " Search " ) ,
116
+ Attrs : templ. Attributes {
117
+ " name " : " Search " ,
118
+ " value " : " " ,
119
+ } ,
120
+ })
121
+ </ div >
122
+ < div class = " hidden md:flex gap-3 h-full " >
123
+ for _ , filter := range config. Filters {
124
+ @ filter
125
+ }
126
+ </ div >
114
127
</div >
128
+ @ Table (config)
115
129
</div >
116
- @ Table (config)
117
130
</div >
118
131
</div >
132
+ @ filters.Drawer (filters.DrawerProps {
133
+ Heading : pageCtx.T (" Scaffold.Filters.Title" ),
134
+ Action : " open-filters" ,
135
+ }) {
136
+ @ config.SideFilter
137
+ for _ , filter := range config.Filters {
138
+ @ filter
139
+ }
140
+ }
119
141
</form >
120
142
}
121
143
122
144
// Content renders the complete scaffold page content with filters and table
123
145
templ Content (config *TableConfig) {
124
- {{ pageCtx := composables.UsePageCtx (ctx) }}
125
- @ filters.Drawer (filters.DrawerProps {
126
- Heading : pageCtx.T (" Scaffold.Filters.Title" ),
127
- Action : " open-filters" ,
128
- }) {
129
- for _ , filter := range config.Filters {
130
- @ filter
131
- }
132
- }
133
146
<div class =" m-6" >
134
147
<div class =" flex justify-between md:justify-start" >
135
148
<h1 class =" text-2xl font-medium" >
0 commit comments