simplify since we arent allowing editing on load
This commit is contained in:
parent
1fd773f726
commit
60e1a161ca
1 changed files with 3 additions and 11 deletions
|
|
@ -18,10 +18,6 @@ type Record struct {
|
||||||
Salary string
|
Salary string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TableProps struct {
|
|
||||||
EditingId string
|
|
||||||
}
|
|
||||||
|
|
||||||
var records = []Record{
|
var records = []Record{
|
||||||
{
|
{
|
||||||
Id: "1",
|
Id: "1",
|
||||||
|
|
@ -43,10 +39,7 @@ func ClickToEdit(ctx *h.RequestContext) *h.Partial {
|
||||||
return h.NewPartial(
|
return h.NewPartial(
|
||||||
h.Div(
|
h.Div(
|
||||||
h.Class("flex gap-2 items-center w-full"),
|
h.Class("flex gap-2 items-center w-full"),
|
||||||
Table(TableProps{
|
Table(),
|
||||||
// no record is being edited initially
|
|
||||||
EditingId: "",
|
|
||||||
}),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +82,7 @@ func SaveEditing(ctx *h.RequestContext) *h.Partial {
|
||||||
return h.SwapPartial(ctx, TableRow(&record, false))
|
return h.SwapPartial(ctx, TableRow(&record, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Table(props TableProps) *h.Element {
|
func Table() *h.Element {
|
||||||
return h.Div(
|
return h.Div(
|
||||||
h.Class("overflow-x-auto w-full"),
|
h.Class("overflow-x-auto w-full"),
|
||||||
h.Table(
|
h.Table(
|
||||||
|
|
@ -120,8 +113,7 @@ func Table(props TableProps) *h.Element {
|
||||||
h.TBody(
|
h.TBody(
|
||||||
h.Class("divide-y divide-gray-200"),
|
h.Class("divide-y divide-gray-200"),
|
||||||
h.List(records, func(record Record, index int) *h.Element {
|
h.List(records, func(record Record, index int) *h.Element {
|
||||||
editing := props.EditingId == record.Id
|
return TableRow(&record, false)
|
||||||
return TableRow(&record, editing)
|
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue