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

@@ -63,7 +63,8 @@ extension Room.Create {
return .init(
name: name,
heatingLoad: heatingLoad,
coolingLoad: coolingLoad,
coolingTotal: coolingTotal,
coolingSensible: coolingSensible,
registerCount: registerCount,
projectID: projectID
)
@@ -76,9 +77,14 @@ extension Room.Create {
guard heatingLoad >= 0 else {
throw ValidationError("Room heating load should not be less than 0.")
}
guard coolingLoad >= 0 else {
guard coolingTotal >= 0 else {
throw ValidationError("Room cooling total should not be less than 0.")
}
if let coolingSensible {
guard coolingSensible >= 0 else {
throw ValidationError("Room cooling sensible should not be less than 0.")
}
}
guard registerCount >= 1 else {
throw ValidationError("Room cooling sensible should not be less than 1.")
}
@@ -98,11 +104,16 @@ extension Room.Update {
throw ValidationError("Room heating load should not be less than 0.")
}
}
if let coolingLoad {
guard coolingLoad >= 0 else {
if let coolingTotal {
guard coolingTotal >= 0 else {
throw ValidationError("Room cooling total should not be less than 0.")
}
}
if let coolingSensible {
guard coolingSensible >= 0 else {
throw ValidationError("Room cooling sensible should not be less than 0.")
}
}
if let registerCount {
guard registerCount >= 1 else {
throw ValidationError("Room cooling sensible should not be less than 1.")
@@ -120,7 +131,8 @@ extension Room {
.id()
.field("name", .string, .required)
.field("heatingLoad", .double, .required)
.field("coolingLoad", .double, .required)
.field("coolingTotal", .double, .required)
.field("coolingSensible", .double)
.field("registerCount", .int8, .required)
.field("createdAt", .datetime)
.field("updatedAt", .datetime)
@@ -150,8 +162,11 @@ final class RoomModel: Model, @unchecked Sendable {
@Field(key: "heatingLoad")
var heatingLoad: Double
@Field(key: "coolingLoad")
var coolingLoad: Double
@Field(key: "coolingTotal")
var coolingTotal: Double
@Field(key: "coolingSensible")
var coolingSensible: Double?
@Field(key: "registerCount")
var registerCount: Int
@@ -171,7 +186,8 @@ final class RoomModel: Model, @unchecked Sendable {
id: UUID? = nil,
name: String,
heatingLoad: Double,
coolingLoad: Double,
coolingTotal: Double,
coolingSensible: Double? = nil,
registerCount: Int,
createdAt: Date? = nil,
updatedAt: Date? = nil,
@@ -180,7 +196,8 @@ final class RoomModel: Model, @unchecked Sendable {
self.id = id
self.name = name
self.heatingLoad = heatingLoad
self.coolingLoad = coolingLoad
self.coolingTotal = coolingTotal
self.coolingSensible = coolingSensible
self.registerCount = registerCount
self.createdAt = createdAt
self.updatedAt = updatedAt
@@ -193,7 +210,8 @@ final class RoomModel: Model, @unchecked Sendable {
projectID: $project.id,
name: name,
heatingLoad: heatingLoad,
coolingLoad: coolingLoad,
coolingTotal: coolingTotal,
coolingSensible: coolingSensible,
registerCount: registerCount,
createdAt: createdAt!,
updatedAt: updatedAt!
@@ -211,9 +229,13 @@ final class RoomModel: Model, @unchecked Sendable {
hasUpdates = true
self.heatingLoad = heatingLoad
}
if let coolingLoad = updates.coolingLoad, coolingLoad != self.coolingLoad {
if let coolingTotal = updates.coolingTotal, coolingTotal != self.coolingTotal {
hasUpdates = true
self.coolingLoad = coolingLoad
self.coolingTotal = coolingTotal
}
if let coolingSensible = updates.coolingSensible, coolingSensible != self.coolingSensible {
hasUpdates = true
self.coolingSensible = coolingSensible
}
if let registerCount = updates.registerCount, registerCount != self.registerCount {
hasUpdates = true