feat: Better modal form using dialog, some forms still need updated to use it effectively.

This commit is contained in:
2026-01-06 10:12:48 -05:00
parent fc12e47b5c
commit 5fcc5b88fa
14 changed files with 161 additions and 130 deletions

View File

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

View File

@@ -34,7 +34,7 @@ struct ProjectForm: HTML, Sendable {
div {
label(.for("name")) { "Name" }
Input(id: "name", placeholder: "Name")
.attributes(.type(.text), .required, .autofocus)
.attributes(.type(.text), .required, .autofocus, .value(project?.name))
}
div {
label(.for("streetAddress")) { "Address" }
@@ -57,14 +57,9 @@ struct ProjectForm: HTML, Sendable {
.attributes(.type(.text), .required, .value(project?.zipCode))
}
div(.class("flex justify-end space-x-6")) {
CancelButton()
.attributes(
.hx.get(route: .project(.form(dismiss: true))),
.hx.target("#projectForm"),
.hx.swap(.outerHTML)
)
div(.class("flex mt-6")) {
SubmitButton()
.attributes(.class("btn-block"))
}
}
}

View File

@@ -67,8 +67,7 @@ extension ProjectsTable {
td { "\(project.name)" }
td { "\(project.streetAddress)" }
td {
Row {
div {}
div(.class("flex justify-end space-x-6")) {
TrashButton()
.attributes(
.hx.delete(route: .project(.delete(id: project.id))),