WIP: Moves friction rate route to be part of project detail routes.
This commit is contained in:
@@ -5,6 +5,7 @@ import Styleguide
|
||||
|
||||
struct ComponentLossForm: HTML, Sendable {
|
||||
let dismiss: Bool
|
||||
let projectID: Project.ID
|
||||
|
||||
var body: some HTML {
|
||||
ModalForm(id: "componentLossForm", dismiss: dismiss) {
|
||||
@@ -25,7 +26,10 @@ struct ComponentLossForm: HTML, Sendable {
|
||||
div {
|
||||
CancelButton()
|
||||
.attributes(
|
||||
.hx.get(route: .frictionRate(.form(.componentPressureLoss, dismiss: true))),
|
||||
.hx.get(
|
||||
route: .project(
|
||||
.detail(projectID, .frictionRate(.form(.componentPressureLoss, dismiss: true))))
|
||||
),
|
||||
.hx.target("#componentLossForm"),
|
||||
.hx.swap(.outerHTML)
|
||||
)
|
||||
|
||||
@@ -3,9 +3,12 @@ import ElementaryHTMX
|
||||
import ManualDCore
|
||||
import Styleguide
|
||||
|
||||
// TODO: Load component losses when view appears??
|
||||
|
||||
struct ComponentPressureLossesView: HTML, Sendable {
|
||||
|
||||
let componentPressureLosses: [ComponentPressureLoss]
|
||||
let projectID: Project.ID
|
||||
|
||||
private var total: Double {
|
||||
componentPressureLosses.reduce(into: 0) { $0 += $1.value }
|
||||
@@ -23,7 +26,10 @@ struct ComponentPressureLossesView: HTML, Sendable {
|
||||
h1(.class("text-2xl font-bold")) { "Component Pressure Losses" }
|
||||
PlusButton()
|
||||
.attributes(
|
||||
.hx.get(route: .frictionRate(.form(.componentPressureLoss, dismiss: false))),
|
||||
.hx.get(
|
||||
route: .project(
|
||||
.detail(projectID, .frictionRate(.form(.componentPressureLoss, dismiss: false))))
|
||||
),
|
||||
.hx.target("#componentLossForm"),
|
||||
.hx.swap(.outerHTML)
|
||||
)
|
||||
@@ -43,8 +49,7 @@ struct ComponentPressureLossesView: HTML, Sendable {
|
||||
.attributes(.class("text-xl font-bold"))
|
||||
}
|
||||
}
|
||||
// div(.id("componentLossForm")) {}
|
||||
ComponentLossForm(dismiss: true)
|
||||
ComponentLossForm(dismiss: true, projectID: projectID)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import Styleguide
|
||||
struct EquipmentForm: HTML, Sendable {
|
||||
|
||||
let dismiss: Bool
|
||||
let projectID: Project.ID
|
||||
|
||||
var body: some HTML {
|
||||
ModalForm(id: "equipmentForm", dismiss: dismiss) {
|
||||
@@ -33,7 +34,11 @@ struct EquipmentForm: HTML, Sendable {
|
||||
div(.class("space-x-4")) {
|
||||
CancelButton()
|
||||
.attributes(
|
||||
.hx.get(route: .frictionRate(.form(.equipmentInfo, dismiss: true))),
|
||||
.hx.get(
|
||||
route: .project(
|
||||
.detail(projectID, .frictionRate(.form(.equipmentInfo, dismiss: true)))
|
||||
)
|
||||
),
|
||||
.hx.target("#equipmentForm"),
|
||||
.hx.swap(.outerHTML)
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@ import Styleguide
|
||||
|
||||
struct EquipmentInfoView: HTML, Sendable {
|
||||
let equipmentInfo: EquipmentInfo
|
||||
var projectID: Project.ID { equipmentInfo.projectID }
|
||||
|
||||
var body: some HTML {
|
||||
div(.class("space-y-4 border border-gray-200 rounded-lg shadow-lg p-4")) {
|
||||
@@ -33,7 +34,7 @@ struct EquipmentInfoView: HTML, Sendable {
|
||||
div {}
|
||||
EditButton()
|
||||
.attributes(
|
||||
.hx.get(route: .frictionRate(.form(.equipmentInfo))),
|
||||
.hx.get(route: .project(.detail(projectID, .frictionRate(.form(.equipmentInfo))))),
|
||||
.hx.target("#equipmentForm"),
|
||||
.hx.swap(.outerHTML)
|
||||
)
|
||||
|
||||
@@ -4,11 +4,16 @@ import Styleguide
|
||||
|
||||
struct FrictionRateView: HTML, Sendable {
|
||||
|
||||
let componentLosses: [ComponentPressureLoss]
|
||||
let projectID: Project.ID
|
||||
|
||||
var body: some HTML {
|
||||
div(.class("p-4 space-y-6")) {
|
||||
h1(.class("text-4xl font-bold pb-6")) { "Friction Rate" }
|
||||
EquipmentInfoView(equipmentInfo: EquipmentInfo.mock)
|
||||
ComponentPressureLossesView(componentPressureLosses: ComponentPressureLoss.mock)
|
||||
ComponentPressureLossesView(
|
||||
componentPressureLosses: componentLosses, projectID: projectID
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user