feat: Updating id key for usage in views, for typesafe keys

This commit is contained in:
2025-01-19 20:07:32 -05:00
parent 81f0e03549
commit 2de85ed758
13 changed files with 203 additions and 119 deletions

View File

@@ -17,7 +17,7 @@ struct EmployeeForm: HTML {
}
var content: some HTML {
Float(shouldDisplay: shouldShow, resetURL: "/employees") {
Float(shouldDisplay: shouldShow, resetURL: .employee(.index)) {
form(
employee == nil ? .hx.post(route: targetURL) : .hx.put(route: targetURL),
.hx.target(target),
@@ -64,9 +64,9 @@ struct EmployeeForm: HTML {
private var target: HXTarget {
guard let employee else {
return .employee(.table)
return .id(.employee(.table))
}
return .employee(.row(id: employee.id))
return .id(.employee(.row(id: employee.id)))
}
private var buttonLabel: String {

View File

@@ -15,7 +15,7 @@ struct EmployeeTable: HTML {
.attributes(
.style("padding: 0px 10px;"),
.hx.get(route: .employee(.form)),
.hx.target(.float),
.hx.target(.id(.float)),
.hx.swap(.outerHTML.transition(true).swap("0.5s"))
)
}
@@ -40,7 +40,7 @@ struct EmployeeTable: HTML {
.attributes(
.style("padding-left: 15px;"),
.hx.get(route: .employee(.get(id: employee.id))),
.hx.target(.float),
.hx.target(.id(.float)),
.hx.pushURL(true),
.hx.swap(.outerHTML.transition(true).swap("0.5s"))
)