feat: Initial csv parsing for uploading rooms for a project. Need to style the upload form.
All checks were successful
CI / Linux Tests (push) Successful in 5m41s
All checks were successful
CI / Linux Tests (push) Successful in 5m41s
This commit is contained in:
@@ -47,8 +47,6 @@ struct RoomForm: HTML, Sendable {
|
||||
.hx.swap(.outerHTML)
|
||||
) {
|
||||
|
||||
input(.class("hidden"), .name("projectID"), .value("\(projectID)"))
|
||||
|
||||
if let id = room?.id {
|
||||
input(.class("hidden"), .name("id"), .value("\(id)"))
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ struct RoomsView: HTML, Sendable {
|
||||
let rooms: [Room]
|
||||
let sensibleHeatRatio: Double?
|
||||
|
||||
private var csvRoute: String {
|
||||
SiteRoute.router.path(for: .view(.project(.detail(projectID, .rooms(.index)))))
|
||||
.appendingPath("csv")
|
||||
}
|
||||
|
||||
var body: some HTML {
|
||||
div(.class("flex w-full flex-col")) {
|
||||
PageTitleRow {
|
||||
@@ -44,6 +49,18 @@ struct RoomsView: HTML, Sendable {
|
||||
.attributes(.class("border border-error"), when: sensibleHeatRatio == nil)
|
||||
}
|
||||
.attributes(.class("tooltip-open"), when: sensibleHeatRatio == nil)
|
||||
|
||||
Tooltip("Upload csv file", position: .left) {
|
||||
form(
|
||||
.hx.post(csvRoute),
|
||||
.hx.target("body"),
|
||||
.hx.swap(.outerHTML),
|
||||
.custom(name: "enctype", value: "multipart/form-data")
|
||||
) {
|
||||
input(.type(.file), .name("file"), .accept(".csv"))
|
||||
SubmitButton()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div(.class("flex items-end space-x-4 font-bold")) {
|
||||
|
||||
Reference in New Issue
Block a user