feat: Working on adding updates to project form, it's currently not loading an existing project.

This commit is contained in:
2026-01-05 17:04:25 -05:00
parent 4c8a23be94
commit fc12e47b5c
9 changed files with 178 additions and 35 deletions

View File

@@ -18,7 +18,7 @@ struct ProjectDetail: HTML, Sendable {
h1(.class("text-2xl font-bold")) { "Project" }
EditButton()
.attributes(
.hx.get(route: .project(.form(dismiss: false))),
.hx.get(route: .project(.form(id: project.id, dismiss: false))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
@@ -54,6 +54,6 @@ struct ProjectDetail: HTML, Sendable {
}
}
div(.id("projectForm")) {}
ProjectForm(dismiss: true)
}
}

View File

@@ -21,9 +21,16 @@ struct ProjectForm: HTML, Sendable {
h1(.class("text-3xl font-bold pb-6 ps-2")) { "Project" }
form(
.class("space-y-4 p-4"),
.method(.post),
.action(route: .project(.index))
project == nil
? .hx.post(route: .project(.index))
: .hx.patch(route: .project(.index)),
.hx.target("body"),
.hx.swap(.outerHTML)
) {
if let project {
input(.class("hidden"), .name("id"), .value("\(project.id)"))
}
div {
label(.for("name")) { "Name" }
Input(id: "name", placeholder: "Name")
@@ -32,35 +39,32 @@ struct ProjectForm: HTML, Sendable {
div {
label(.for("streetAddress")) { "Address" }
Input(id: "streetAddress", placeholder: "Street Address")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.streetAddress))
}
div {
label(.for("city")) { "City" }
Input(id: "city", placeholder: "City")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.city))
}
div {
label(.for("state")) { "State" }
Input(id: "state", placeholder: "State")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.state))
}
div {
label(.for("zipCode")) { "Zip" }
Input(id: "zipCode", placeholder: "Zip code")
.attributes(.type(.text), .required)
.attributes(.type(.text), .required, .value(project?.zipCode))
}
Row {
div {}
div(.class("space-x-4")) {
CancelButton()
.attributes(
.hx.get(route: .project(.form(dismiss: true))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
SubmitButton()
}
div(.class("flex justify-end space-x-6")) {
CancelButton()
.attributes(
.hx.get(route: .project(.form(dismiss: true))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
SubmitButton()
}
}
}

View File

@@ -61,6 +61,7 @@ struct RoomsView: HTML, Sendable {
.class("badge badge-outline badge-success badge-xl"))
}
td {}
td {}
}
}
}
@@ -87,10 +88,11 @@ struct RoomsView: HTML, Sendable {
Number(room.registerCount)
}
td {
Row {
div(.class("flex justify-end space-x-6")) {
TrashButton()
.attributes(
.hx.delete(route: .project(.detail(room.projectID, .rooms(.delete(id: room.id))))),
.hx.delete(
route: .project(.detail(room.projectID, .rooms(.delete(id: room.id))))),
.hx.target("closest tr"),
.hx.confirm("Are you sure?")
)