feat: Working on route and id helpers for views.
This commit is contained in:
@@ -9,7 +9,7 @@ struct UserTable: HTML {
|
||||
let users: [User]
|
||||
|
||||
var content: some HTML {
|
||||
table(.id("user-table")) {
|
||||
table(.id(.user(.table()))) {
|
||||
thead {
|
||||
tr {
|
||||
th { "Username" }
|
||||
@@ -17,14 +17,14 @@ struct UserTable: HTML {
|
||||
th(.style("width: 50px;")) {
|
||||
Button.add()
|
||||
.attributes(
|
||||
.hx.get("/users/create"),
|
||||
.hx.target("#float"),
|
||||
.hx.get(route: .users(.create)),
|
||||
.hx.target(.float),
|
||||
.hx.swap(.outerHTML)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
tbody(.id("user-table-body")) {
|
||||
tbody(.id(.user(.table(.body)))) {
|
||||
for user in users {
|
||||
Row(user: user)
|
||||
}
|
||||
@@ -40,13 +40,13 @@ struct UserTable: HTML {
|
||||
}
|
||||
|
||||
var content: some HTML<HTMLTag.tr> {
|
||||
tr(.id("user_\(user.id)")) {
|
||||
tr(.id(.user(.row(id: user.id)))) {
|
||||
td { user.username }
|
||||
td { user.email }
|
||||
td {
|
||||
Button.detail().attributes(
|
||||
.hx.get("/users/\(user.id.uuidString)"),
|
||||
.hx.target("#float"),
|
||||
.hx.get(route: .users(.id(user.id))),
|
||||
.hx.target(.float),
|
||||
.hx.swap(.outerHTML),
|
||||
.hx.pushURL(true)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user