feat: Adds multi-select option for selecting rooms in trunk sizing form.
This commit is contained in:
@@ -17,7 +17,7 @@ extension ViewController.Request {
|
||||
@Dependency(\.pdfClient) var pdfClient
|
||||
|
||||
switch route {
|
||||
case .home:
|
||||
case .home:
|
||||
return await view {
|
||||
HomeView()
|
||||
}
|
||||
@@ -104,7 +104,7 @@ extension ViewController.Request {
|
||||
let inner = await inner()
|
||||
let theme = await self.theme
|
||||
|
||||
return MainPage(displayFooter: displayFooter, theme: theme) {
|
||||
return MainPage(displayFooter: displayFooter, theme: theme ?? .default) {
|
||||
inner
|
||||
}
|
||||
}
|
||||
@@ -605,6 +605,7 @@ extension SiteRoute.View.ProjectRoute.DuctSizingRoute {
|
||||
try await database.trunkSizes.delete(id)
|
||||
}
|
||||
case .submit(let form):
|
||||
request.logger.debug("Trunk Form: \(form)")
|
||||
return await view(on: request, projectID: projectID) {
|
||||
_ = try await database.trunkSizes.create(
|
||||
form.toCreate(logger: request.logger)
|
||||
|
||||
@@ -39,6 +39,7 @@ struct TrunkSizeForm: HTML, Sendable {
|
||||
}
|
||||
|
||||
var body: some HTML {
|
||||
script(.src("/js/daisy-multiselect.js")) {}
|
||||
ModalForm(id: Self.id(container), dismiss: dismiss) {
|
||||
h1(.class("text-lg font-bold mb-4")) { "Trunk / Runout Size" }
|
||||
form(
|
||||
@@ -77,40 +78,33 @@ struct TrunkSizeForm: HTML, Sendable {
|
||||
.type(.text),
|
||||
.name("name"),
|
||||
.value(trunk?.name),
|
||||
.placeholder("Trunk-1 (Optional)")
|
||||
.placeholder("Trunk-1"),
|
||||
.required
|
||||
)
|
||||
|
||||
div {
|
||||
h2(.class("label font-bold col-span-3 mb-6")) { "Associated Supply Runs" }
|
||||
div(
|
||||
.class(
|
||||
"""
|
||||
grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 justify-center items-center gap-4
|
||||
"""
|
||||
)
|
||||
daisyMultiSelect(
|
||||
.class("z-50 bg-base-200"),
|
||||
.placeholder("Select rooms"),
|
||||
.name("rooms"),
|
||||
.chipStyle,
|
||||
.showSelectAll,
|
||||
.showClear,
|
||||
.required,
|
||||
.virtualScroll
|
||||
) {
|
||||
for room in rooms {
|
||||
div(.class("block grow")) {
|
||||
div(.class("grid grid-cols-1 space-y-1")) {
|
||||
div(.class("flex justify-center")) {
|
||||
p(.class("label")) { room.roomName }
|
||||
}
|
||||
div(.class("flex justify-center")) {
|
||||
input(
|
||||
.class("checkbox"),
|
||||
.type(.checkbox),
|
||||
.name("rooms"),
|
||||
.value("\(room.roomID)_\(room.roomRegister)")
|
||||
)
|
||||
.attributes(
|
||||
.checked,
|
||||
when: trunk == nil ? false : trunk!.rooms.hasRoom(room)
|
||||
)
|
||||
}
|
||||
}
|
||||
option(.value("\(room.roomID)_\(room.roomRegister)")) {
|
||||
room.roomName
|
||||
}
|
||||
.attributes(
|
||||
.selected,
|
||||
when: trunk == nil ? false : trunk!.rooms.hasRoom(room)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubmitButton()
|
||||
|
||||
@@ -43,7 +43,7 @@ struct HomeView: HTML, Sendable {
|
||||
header
|
||||
a(
|
||||
.class("btn btn-ghost text-md text-primary font-bold italic"),
|
||||
.href("https://git.housh.dev/michael/swift-manual-d"),
|
||||
.href("https://git.housh.dev/michael/swift-duct-calc"),
|
||||
.target(.blank)
|
||||
) {
|
||||
"Open source residential duct design program"
|
||||
@@ -70,6 +70,7 @@ struct HomeView: HTML, Sendable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
div(.class("grid grid-cols-1 md:grid-cols-2 gap-4 mx-20 my-6")) {
|
||||
|
||||
@@ -52,6 +52,7 @@ public struct MainPage<Inner: HTML>: SendableHTMLDocument where Inner: Sendable
|
||||
script(.src("https://unpkg.com/htmx.org@2.0.8")) {}
|
||||
script(.src("/js/htmx-download.js")) {}
|
||||
script(.src("/js/main.js")) {}
|
||||
script(.src("https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4")) {}
|
||||
link(.rel(.stylesheet), .href("/css/output.css"))
|
||||
link(.rel(.stylesheet), .href("/css/htmx.css"))
|
||||
link(
|
||||
@@ -104,7 +105,7 @@ public struct MainPage<Inner: HTML>: SendableHTMLDocument where Inner: Sendable
|
||||
}
|
||||
a(
|
||||
.class("btn btn-ghost"),
|
||||
.href("https://git.housh.dev/michael/swift-manual-d/src/branch/main/LICENSE"),
|
||||
.href("https://git.housh.dev/michael/swift-duct-calc/src/branch/main/LICENSE"),
|
||||
.target(.blank)
|
||||
) {
|
||||
"Openly licensed via CC-BY-NC-SA 4.0"
|
||||
|
||||
@@ -190,25 +190,25 @@ extension ProjectView {
|
||||
div(.class("flex items-center justify-center")) {
|
||||
SVG(icon)
|
||||
}
|
||||
.attributes(.class("is-drawer-close:text-green-400"), when: isComplete)
|
||||
.attributes(.class("is-drawer-close:text-error"), when: !isComplete && !hideIsComplete)
|
||||
.attributes(.class("text-green-400"), when: isComplete)
|
||||
.attributes(.class("text-error"), when: !isComplete && !hideIsComplete)
|
||||
|
||||
div(.class("flex items-center justify-center")) {
|
||||
span { title }
|
||||
}
|
||||
}
|
||||
|
||||
if !hideIsComplete {
|
||||
div(.class("flex grow justify-end items-end is-drawer-close:hidden")) {
|
||||
if isComplete {
|
||||
SVG(.badgeCheck)
|
||||
} else {
|
||||
SVG(.ban)
|
||||
}
|
||||
}
|
||||
.attributes(.class("text-green-400"), when: isComplete)
|
||||
.attributes(.class("text-error"), when: !isComplete)
|
||||
}
|
||||
// if !hideIsComplete {
|
||||
// div(.class("flex grow justify-end items-end is-drawer-close:hidden")) {
|
||||
// if isComplete {
|
||||
// SVG(.badgeCheck)
|
||||
// } else {
|
||||
// SVG(.ban)
|
||||
// }
|
||||
// }
|
||||
// .attributes(.class("text-green-400"), when: isComplete)
|
||||
// .attributes(.class("text-error"), when: !isComplete)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user