feat: Updates form routes and database routes to use id's in the url path.
This commit is contained in:
@@ -18,18 +18,11 @@ struct EquipmentInfoForm: HTML, Sendable {
|
||||
return "\(staticPressure)"
|
||||
}
|
||||
|
||||
var heatingCFM: String {
|
||||
guard let heatingCFM = equipmentInfo?.heatingCFM else {
|
||||
return ""
|
||||
}
|
||||
return "\(heatingCFM)"
|
||||
}
|
||||
|
||||
var coolingCFM: String {
|
||||
guard let heatingCFM = equipmentInfo?.heatingCFM else {
|
||||
return ""
|
||||
}
|
||||
return "\(heatingCFM)"
|
||||
var route: String {
|
||||
SiteRoute.View.router.path(
|
||||
for: .project(.detail(projectID, .equipment(.index)))
|
||||
)
|
||||
.appendingPath(equipmentInfo?.id)
|
||||
}
|
||||
|
||||
var body: some HTML {
|
||||
@@ -38,8 +31,8 @@ struct EquipmentInfoForm: HTML, Sendable {
|
||||
form(
|
||||
.class("space-y-4 p-4"),
|
||||
equipmentInfo != nil
|
||||
? .hx.patch(route: .project(.detail(projectID, .equipment(.index))))
|
||||
: .hx.post(route: .project(.detail(projectID, .equipment(.index)))),
|
||||
? .hx.patch(route)
|
||||
: .hx.post(route),
|
||||
.hx.target("#equipmentInfo"),
|
||||
.hx.swap(.outerHTML)
|
||||
) {
|
||||
@@ -59,12 +52,12 @@ struct EquipmentInfoForm: HTML, Sendable {
|
||||
div {
|
||||
label(.for("heatingCFM")) { "Heating CFM" }
|
||||
Input(id: "heatingCFM", placeholder: "CFM")
|
||||
.attributes(.type(.number), .min("0"), .value(heatingCFM))
|
||||
.attributes(.type(.number), .min("0"), .value(equipmentInfo?.heatingCFM))
|
||||
}
|
||||
div {
|
||||
label(.for("coolingCFM")) { "Cooling CFM" }
|
||||
Input(id: "coolingCFM", placeholder: "CFM")
|
||||
.attributes(.type(.number), .min("0"), .value(coolingCFM))
|
||||
.attributes(.type(.number), .min("0"), .value(equipmentInfo?.coolingCFM))
|
||||
}
|
||||
div {
|
||||
SubmitButton(title: "Save")
|
||||
|
||||
@@ -23,24 +23,28 @@ struct EquipmentInfoView: HTML, Sendable {
|
||||
|
||||
if let equipmentInfo {
|
||||
|
||||
Row {
|
||||
Label { "Static Pressure" }
|
||||
Number(equipmentInfo.staticPressure)
|
||||
table(.class("table table-zebra")) {
|
||||
thead {
|
||||
tr {
|
||||
th { Label("Name") }
|
||||
th { Label("Value") }
|
||||
}
|
||||
}
|
||||
tbody(.class("text-lg")) {
|
||||
tr {
|
||||
td { "Static Pressure" }
|
||||
td { Number(equipmentInfo.staticPressure) }
|
||||
}
|
||||
tr {
|
||||
td { "Heating CFM" }
|
||||
td { Number(equipmentInfo.heatingCFM) }
|
||||
}
|
||||
tr {
|
||||
td { "Cooling CFM" }
|
||||
td { Number(equipmentInfo.coolingCFM) }
|
||||
}
|
||||
}
|
||||
}
|
||||
.attributes(.class("border-b border-gray-200"))
|
||||
|
||||
Row {
|
||||
Label { "Heating CFM" }
|
||||
Number(equipmentInfo.heatingCFM)
|
||||
}
|
||||
.attributes(.class("border-b border-gray-200"))
|
||||
|
||||
Row {
|
||||
Label { "Cooling CFM" }
|
||||
Number(equipmentInfo.coolingCFM)
|
||||
}
|
||||
.attributes(.class("border-b border-gray-200"))
|
||||
|
||||
}
|
||||
EquipmentInfoForm(
|
||||
dismiss: true, projectID: projectID, equipmentInfo: equipmentInfo
|
||||
|
||||
Reference in New Issue
Block a user