From 9709eaaf8e952401ff17a4a29db2629e2a2e02ad Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Thu, 15 Jan 2026 15:18:42 -0500 Subject: [PATCH] feat: Removes register-id in favor of using the room name with register number in duct sizing forms / tables. --- Sources/ManualDClient/ManualDClient.swift | 3 - Sources/ManualDCore/DuctSizing.swift | 4 -- .../DuctSizing/RectangularSizeForm.swift | 2 +- .../Views/DuctSizing/RoomsTable.swift | 8 +-- Sources/ViewController/Views/Navbar.swift | 69 ++++++------------- .../Views/Project/ProjectsTable.swift | 4 +- 6 files changed, 26 insertions(+), 64 deletions(-) diff --git a/Sources/ManualDClient/ManualDClient.swift b/Sources/ManualDClient/ManualDClient.swift index 0037c4d..4522aef 100644 --- a/Sources/ManualDClient/ManualDClient.swift +++ b/Sources/ManualDClient/ManualDClient.swift @@ -44,7 +44,6 @@ public struct ManualDClient: Sendable { logger: Logger? = nil ) async throws -> [DuctSizing.RoomContainer] { - var registerIDCount = 1 var retval: [DuctSizing.RoomContainer] = [] let totalHeatingLoad = rooms.totalHeatingLoad let totalCoolingSensible = rooms.totalCoolingSensible(shr: projectSHR) @@ -76,7 +75,6 @@ public struct ManualDClient: Sendable { retval.append( .init( - registerID: "SR-\(registerIDCount)", roomID: room.id, roomName: "\(room.name)-\(n)", roomRegister: n, @@ -93,7 +91,6 @@ public struct ManualDClient: Sendable { rectangularWidth: rectangularWidth ) ) - registerIDCount += 1 } } diff --git a/Sources/ManualDCore/DuctSizing.swift b/Sources/ManualDCore/DuctSizing.swift index 6ddecb0..f6f7305 100644 --- a/Sources/ManualDCore/DuctSizing.swift +++ b/Sources/ManualDCore/DuctSizing.swift @@ -50,12 +50,10 @@ public enum DuctSizing { } } - // TODO: Remove registerID and just use the roomName // TODO: Uses SizeContainer public struct RoomContainer: Codable, Equatable, Sendable { - public let registerID: String public let roomID: Room.ID public let roomName: String public let roomRegister: Int @@ -72,7 +70,6 @@ public enum DuctSizing { public let rectangularWidth: Int? public init( - registerID: String, roomID: Room.ID, roomName: String, roomRegister: Int, @@ -88,7 +85,6 @@ public enum DuctSizing { rectangularSize: RectangularDuct? = nil, rectangularWidth: Int? = nil ) { - self.registerID = registerID self.roomID = roomID self.roomName = roomName self.roomRegister = roomRegister diff --git a/Sources/ViewController/Views/DuctSizing/RectangularSizeForm.swift b/Sources/ViewController/Views/DuctSizing/RectangularSizeForm.swift index 64c9a07..cd134b2 100644 --- a/Sources/ViewController/Views/DuctSizing/RectangularSizeForm.swift +++ b/Sources/ViewController/Views/DuctSizing/RectangularSizeForm.swift @@ -7,7 +7,7 @@ struct RectangularSizeForm: HTML, Sendable { static func id(_ room: DuctSizing.RoomContainer) -> String { let base = "rectangularSize" - return "\(base)_\(room.registerID.idString)" + return "\(base)_\(room.roomName.idString)" } @Environment(ProjectViewValue.$projectID) var projectID diff --git a/Sources/ViewController/Views/DuctSizing/RoomsTable.swift b/Sources/ViewController/Views/DuctSizing/RoomsTable.swift index ff19948..abc102f 100644 --- a/Sources/ViewController/Views/DuctSizing/RoomsTable.swift +++ b/Sources/ViewController/Views/DuctSizing/RoomsTable.swift @@ -16,7 +16,6 @@ extension DuctSizingView { table(.class("table table-zebra text-lg")) { thead { tr(.class("text-lg")) { - th { "ID" } th { "Name" } th { "BTU" } th { "CFM" } @@ -36,7 +35,7 @@ extension DuctSizingView { struct RoomRow: HTML, Sendable { static func id(_ room: DuctSizing.RoomContainer) -> String { - "roomRow_\(room.registerID.idString)" + "roomRow_\(room.roomName.idString)" } @Environment(ProjectViewValue.$projectID) var projectID @@ -65,10 +64,9 @@ extension DuctSizingView { var body: some HTML { tr(.class("text-lg"), .id(rowID)) { - td { room.registerID } td { room.roomName } td { - div(.class("grid grid-cols-2 gap-2")) { + div(.class("flex flex-wrap grid grid-cols-2 gap-2")) { span(.class("label")) { "Heating" } Number(room.heatingLoad, digits: 0) @@ -78,7 +76,7 @@ extension DuctSizingView { } td { - div(.class("grid grid-cols-2 gap-2")) { + div(.class("flex flex-wrap grid grid-cols-2 gap-2")) { span(.class("label")) { "Design" } div(.class("flex justify-center")) { diff --git a/Sources/ViewController/Views/Navbar.swift b/Sources/ViewController/Views/Navbar.swift index 1845010..44ff889 100644 --- a/Sources/ViewController/Views/Navbar.swift +++ b/Sources/ViewController/Views/Navbar.swift @@ -24,31 +24,29 @@ struct Navbar: HTML, Sendable { ) { div(.class("flex flex-1 space-x-4 items-center")) { if sidebarToggle { - Tooltip("Open sidebar", position: .right) { - label( - .for("my-drawer-1"), - .class("size-7"), - .init(name: "aria-label", value: "open sidebar") - ) { - SVG(.sidebarToggle) - } - .navButton() - } - - } - - Tooltip("Home", position: .right) { - a( - .class("flex w-fit h-fit text-xl items-end px-4 py-2"), - .href(route: .project(.index)) + label( + .for("my-drawer-1"), + .class("size-7"), + .init(name: "aria-label", value: "open sidebar") ) { - img( - .src("/images/mand_logo_sm.webp"), - ) - span { "Duct Calc" } + SVG(.sidebarToggle) } .navButton() + .tooltip("Open sidebar", position: .right) + } + + a( + .class("flex w-fit h-fit text-xl items-end px-4 py-2"), + .href(route: .project(.index)) + ) { + img( + .src("/images/mand_logo_sm.webp"), + ) + span { "Duct Calc" } + } + .navButton() + .tooltip("Home", position: .right) } if userProfile { // TODO: Make dropdown @@ -59,34 +57,7 @@ struct Navbar: HTML, Sendable { SVG(.circleUser) } .navButton() - // details(.class("dropdown dropdown-left dropdown-bottom")) { - // summary(.class("btn w-fit px-4 py-2")) { - // SVG(.circleUser) - // } - // .navButton() - // - // ul( - // .class( - // """ - // menu dropdown-content bg-base-100 - // rounded-box z-1 w-fit p-2 shadow-sm - // """ - // ) - // ) { - // li(.class("w-full")) { - // // TODO: Save theme to user profile ?? - // div(.class("flex justify-between p-4 space-x-6")) { - // Label("Theme") - // input(.type(.checkbox), .class("toggle theme-controller"), .value("light")) - // } - // } - // } - // - // // button(.class("w-fit px-4 py-2")) { - // // SVG(.circleUser) - // // } - // // .navButton() - // } + .tooltip("Profile") } } } diff --git a/Sources/ViewController/Views/Project/ProjectsTable.swift b/Sources/ViewController/Views/Project/ProjectsTable.swift index 680c441..375a4b2 100644 --- a/Sources/ViewController/Views/Project/ProjectsTable.swift +++ b/Sources/ViewController/Views/Project/ProjectsTable.swift @@ -19,12 +19,12 @@ struct ProjectsTable: HTML, Sendable { div { Navbar(sidebarToggle: false) div(.class("m-6")) { - Row { + PageTitleRow { PageTitle { "Projects" } Tooltip("Add project") { PlusButton() .attributes( - .class("btn-ghost"), + .class("btn-primary"), .showModal(id: ProjectForm.id) ) }