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

@@ -6,7 +6,8 @@ public struct Room: Codable, Equatable, Identifiable, Sendable {
public let projectID: Project.ID
public let name: String
public let heatingLoad: Double
public let coolingLoad: Double
public let coolingTotal: Double
public let coolingSensible: Double?
public let registerCount: Int
public let createdAt: Date
public let updatedAt: Date
@@ -16,7 +17,8 @@ public struct Room: Codable, Equatable, Identifiable, Sendable {
projectID: Project.ID,
name: String,
heatingLoad: Double,
coolingLoad: Double,
coolingTotal: Double,
coolingSensible: Double? = nil,
registerCount: Int = 1,
createdAt: Date,
updatedAt: Date
@@ -25,7 +27,8 @@ public struct Room: Codable, Equatable, Identifiable, Sendable {
self.projectID = projectID
self.name = name
self.heatingLoad = heatingLoad
self.coolingLoad = coolingLoad
self.coolingTotal = coolingTotal
self.coolingSensible = coolingSensible
self.registerCount = registerCount
self.createdAt = createdAt
self.updatedAt = updatedAt
@@ -38,75 +41,48 @@ extension Room {
public let projectID: Project.ID
public let name: String
public let heatingLoad: Double
public let coolingLoad: Double
public let coolingTotal: Double
public let coolingSensible: Double?
public let registerCount: Int
public init(
projectID: Project.ID,
name: String,
heatingLoad: Double,
coolingLoad: Double,
coolingTotal: Double,
coolingSensible: Double? = nil,
registerCount: Int = 1
) {
self.projectID = projectID
self.name = name
self.heatingLoad = heatingLoad
self.coolingLoad = coolingLoad
self.coolingTotal = coolingTotal
self.coolingSensible = coolingSensible
self.registerCount = registerCount
}
public init(
form: Room.Form,
projectID: Project.ID
) {
self.init(
projectID: projectID,
name: form.name,
heatingLoad: form.heatingLoad,
coolingLoad: form.coolingLoad,
registerCount: form.registerCount
)
}
}
public struct Update: Codable, Equatable, Sendable {
public let id: Room.ID
public let name: String?
public let heatingLoad: Double?
public let coolingLoad: Double?
public let coolingTotal: Double?
public let coolingSensible: Double?
public let registerCount: Int?
public init(
id: Room.ID,
name: String? = nil,
heatingLoad: Double? = nil,
coolingLoad: Double? = nil,
coolingTotal: Double? = nil,
coolingSensible: Double? = nil,
registerCount: Int? = nil
) {
self.id = id
self.name = name
self.heatingLoad = heatingLoad
self.coolingLoad = coolingLoad
self.registerCount = registerCount
}
}
// TODO: Remove and just use create.
public struct Form: Codable, Equatable, Sendable {
public let name: String
public let heatingLoad: Double
public let coolingLoad: Double
public let registerCount: Int
public init(
name: String,
heatingLoad: Double,
coolingLoad: Double,
registerCount: Int
) {
self.name = name
self.heatingLoad = heatingLoad
self.coolingLoad = coolingLoad
self.coolingTotal = coolingTotal
self.coolingSensible = coolingSensible
self.registerCount = registerCount
}
}
@@ -121,7 +97,7 @@ extension Room {
projectID: UUID(0),
name: "Kitchen",
heatingLoad: 12345,
coolingLoad: 1234,
coolingTotal: 1234,
registerCount: 2,
createdAt: Date(),
updatedAt: Date()
@@ -131,7 +107,7 @@ extension Room {
projectID: UUID(1),
name: "Bedroom - 1",
heatingLoad: 12345,
coolingLoad: 1456,
coolingTotal: 1456,
registerCount: 1,
createdAt: Date(),
updatedAt: Date()
@@ -141,7 +117,7 @@ extension Room {
projectID: UUID(2),
name: "Family Room",
heatingLoad: 12345,
coolingLoad: 1673,
coolingTotal: 1673,
registerCount: 3,
createdAt: Date(),
updatedAt: Date()