Skip to content

Commit

Permalink
simplify since we arent allowing editing on load
Browse files Browse the repository at this point in the history
  • Loading branch information
maddalax committed Oct 28, 2024
1 parent 1fd773f commit 60e1a16
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions htmgo-site/partials/snippets/click-to-edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ type Record struct {
Salary string
}

type TableProps struct {
EditingId string
}

var records = []Record{
{
Id: "1",
Expand All @@ -43,10 +39,7 @@ func ClickToEdit(ctx *h.RequestContext) *h.Partial {
return h.NewPartial(
h.Div(
h.Class("flex gap-2 items-center w-full"),
Table(TableProps{
// no record is being edited initially
EditingId: "",
}),
Table(),
),
)
}
Expand Down Expand Up @@ -89,7 +82,7 @@ func SaveEditing(ctx *h.RequestContext) *h.Partial {
return h.SwapPartial(ctx, TableRow(&record, false))
}

func Table(props TableProps) *h.Element {
func Table() *h.Element {
return h.Div(
h.Class("overflow-x-auto w-full"),
h.Table(
Expand Down Expand Up @@ -120,8 +113,7 @@ func Table(props TableProps) *h.Element {
h.TBody(
h.Class("divide-y divide-gray-200"),
h.List(records, func(record Record, index int) *h.Element {
editing := props.EditingId == record.Id
return TableRow(&record, editing)
return TableRow(&record, false)
}),
),
),
Expand Down

0 comments on commit 60e1a16

Please sign in to comment.