WIP: Inital duct rectangular form, needs better thought out.
This commit is contained in:
@@ -3,6 +3,8 @@ import ElementaryHTMX
|
||||
import ManualDCore
|
||||
import Styleguide
|
||||
|
||||
// FIX: The value field is sometimes wonky as far as what values it accepts.
|
||||
|
||||
struct ComponentLossForm: HTML, Sendable {
|
||||
|
||||
static func id(_ componentLoss: ComponentPressureLoss? = nil) -> String {
|
||||
@@ -49,7 +51,7 @@ struct ComponentLossForm: HTML, Sendable {
|
||||
label(.for("value")) { "Value" }
|
||||
Input(id: "value", placeholder: "Pressure loss")
|
||||
.attributes(
|
||||
.type(.number), .min("0.03"), .max("1.0"), .step("0.1"), .required,
|
||||
.type(.number), .min("0.03"), .max("1.0"), .step("0.01"), .required,
|
||||
.value(componentLoss?.value)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,12 +7,27 @@ import Styleguide
|
||||
|
||||
struct DuctSizingView: HTML, Sendable {
|
||||
|
||||
let projectID: Project.ID
|
||||
let rooms: [DuctSizing.RoomContainer]
|
||||
|
||||
var body: some HTML {
|
||||
div {
|
||||
h1(.class("text-2xl py-4")) { "Duct Sizes" }
|
||||
if rooms.count == 0 {
|
||||
p(.class("text-error italic")) {
|
||||
"Must complete all the previous sections to display duct sizing calculations."
|
||||
}
|
||||
} else {
|
||||
RoomsTable(projectID: projectID, rooms: rooms)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct RoomsTable: HTML, Sendable {
|
||||
let projectID: Project.ID
|
||||
let rooms: [DuctSizing.RoomContainer]
|
||||
|
||||
var body: some HTML<HTMLTag.div> {
|
||||
div(.class("overflow-x-auto")) {
|
||||
table(.class("table table-zebra")) {
|
||||
thead {
|
||||
@@ -27,12 +42,14 @@ struct DuctSizingView: HTML, Sendable {
|
||||
th(.class("hidden xl:table-cell")) { "Round Size" }
|
||||
th { "Velocity" }
|
||||
th { "Final Size" }
|
||||
th { "Height" }
|
||||
th { "Width" }
|
||||
th { "Flex Size" }
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
for room in rooms {
|
||||
RoomRow(room: room)
|
||||
RoomRow(projectID: projectID, room: room)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,10 +58,19 @@ struct DuctSizingView: HTML, Sendable {
|
||||
}
|
||||
|
||||
struct RoomRow: HTML, Sendable {
|
||||
let projectID: Project.ID
|
||||
let room: DuctSizing.RoomContainer
|
||||
|
||||
var route: String {
|
||||
SiteRoute.View.router.path(
|
||||
for: .project(.detail(projectID, .ductSizing(.index)))
|
||||
)
|
||||
.appendingPath("room")
|
||||
.appendingPath(room.roomID)
|
||||
}
|
||||
|
||||
var body: some HTML<HTMLTag.tr> {
|
||||
tr(.class("text-lg")) {
|
||||
tr(.class("text-lg"), .id(room.roomID.idString)) {
|
||||
td { room.registerID }
|
||||
td { room.roomName }
|
||||
td { Number(room.heatingLoad, digits: 0) }
|
||||
@@ -62,6 +88,32 @@ struct DuctSizingView: HTML, Sendable {
|
||||
Number(room.finalSize)
|
||||
.attributes(.class("badge badge-outline badge-secondary text-xl font-bold"))
|
||||
}
|
||||
td {
|
||||
form(
|
||||
.hx.post(route),
|
||||
.hx.target("body"),
|
||||
.hx.swap(.outerHTML)
|
||||
// .hx.trigger(
|
||||
// .event(.change).from("#rectangularSize_\(room.roomID.idString)")
|
||||
// )
|
||||
) {
|
||||
input(.class("hidden"), .name("register"), .value("\(room.roomName.last!)"))
|
||||
Row {
|
||||
Input(
|
||||
id: "height",
|
||||
name: "height",
|
||||
placeholder: "Height"
|
||||
)
|
||||
.attributes(.type(.number), .min("0"), .value(room.rectangularSize?.height))
|
||||
SubmitButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
td {
|
||||
if let width = room.rectangularWidth {
|
||||
Number(width)
|
||||
}
|
||||
}
|
||||
td {
|
||||
Number(room.flexSize)
|
||||
.attributes(.class("badge badge-outline badge-primary text-xl font-bold"))
|
||||
|
||||
@@ -2,6 +2,8 @@ import Elementary
|
||||
import ManualDCore
|
||||
import Styleguide
|
||||
|
||||
// FIX: Need to update available static, etc. when equipment info is submitted.
|
||||
|
||||
struct FrictionRateView: HTML, Sendable {
|
||||
|
||||
let equipmentInfo: EquipmentInfo?
|
||||
@@ -46,8 +48,8 @@ struct FrictionRateView: HTML, Sendable {
|
||||
div(.class("p-4 space-y-6")) {
|
||||
h1(.class("text-4xl font-bold pb-6")) { "Friction Rate" }
|
||||
div(.class("flex space-x-4")) {
|
||||
Label("Available Static Pressure")
|
||||
if let availableStaticPressure {
|
||||
Label("Available Static Pressure")
|
||||
Number(availableStaticPressure, digits: 2)
|
||||
.attributes(.class("badge badge-lg badge-outline font-bold ms-4"))
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ struct ProjectView: HTML, Sendable {
|
||||
)
|
||||
case .ductSizing:
|
||||
try await DuctSizingView(
|
||||
projectID: projectID,
|
||||
rooms: manualD.calculate(
|
||||
rooms: database.rooms.fetch(projectID),
|
||||
designFrictionRateResult: database.designFrictionRate(projectID: projectID),
|
||||
|
||||
Reference in New Issue
Block a user