feat: Working on adding updates to project form, it's currently not loading an existing project.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user