feat working on vendor views.

This commit is contained in:
2025-01-16 08:02:13 -05:00
parent 6f2e87e886
commit d4a8444700
8 changed files with 239 additions and 132 deletions

View File

@@ -3,12 +3,65 @@ import ElementaryHTMX
import SharedModels
struct VendorDetail: HTML {
let vendor: Vendor?
let vendor: Vendor
var content: some HTML {
div(.class("container")) {
VendorForm(vendor: vendor)
// TODO: Branch table + form.
Float(shouldDisplay: true) {
VendorForm(.formOnly(vendor))
BranchTable(branches: vendor.branches ?? [])
div(.class("row btn-row")) {
button(.class("btn-done")) { "Done" }
button(.class("danger")) { "Delete" }
}
}
}
struct BranchTable: HTML {
let branches: [VendorBranch]
var content: some HTML {
div {
form(
.id("branch-form"),
.custom(name: "hx-on::after-request", value: "if(event.detail.successful) this.reset();")
) {
div(.class("row"), .style("margin: 0;")) {
input(.type(.text), .class("col-10"), .placeholder("Branch Name"), .required)
button(
.type(.submit),
.class("btn-secondary"),
.style("float: right; padding: 10px 50px;"),
.hx.target("#branch-table"),
.hx.swap(.beforeEnd)
) { "+" }
}
}
table {
thead {
tr {
th(.class("label col-11")) { "Branch Location" }
th(.class("col-1")) {}
}
}
tbody(.id("branch-table")) {
for branch in branches {
Row(branch: branch)
}
}
}
}
}
struct Row: HTML {
let branch: VendorBranch
var content: some HTML<HTMLTag.tr> {
tr {
td(.class("col-11")) { branch.name }
td(.class("col-1")) { Button.danger { "Delete" } }
}
}
}
}