feat: Working on route and id helpers for views.
This commit is contained in:
@@ -24,13 +24,10 @@ struct PurchaseOrderForm: HTML {
|
||||
}
|
||||
}
|
||||
form(
|
||||
.hx.post("/purchase-orders"),
|
||||
.hx.target("#purchase-order-table"),
|
||||
.hx.post(route: .purchaseOrders()),
|
||||
.hx.target(.purchaseOrders(.table)),
|
||||
.hx.swap(.afterBegin),
|
||||
.custom(
|
||||
name: "hx-on::after-request",
|
||||
value: "if(event.detail.successful) toggleContent('float')"
|
||||
)
|
||||
.customToggleFloatAfterRequest
|
||||
) {
|
||||
div(.class("row")) {
|
||||
label(
|
||||
@@ -65,16 +62,7 @@ struct PurchaseOrderForm: HTML {
|
||||
.for("vendorBranchID"), .class("label col-2"), .style("margin-right: 15px; margin-bottom: 5px;")
|
||||
) { "Vendor:" }
|
||||
if purchaseOrder == nil {
|
||||
div(
|
||||
.class("col-4"),
|
||||
.hx.get("/purchase-orders/create/vendor-branch-select"),
|
||||
.hx.target("this"),
|
||||
.hx.swap(.outerHTML.transition(true).swap("0.5s")),
|
||||
.hx.trigger(.event(.revealed)),
|
||||
.hx.indicator(".hx-indicator")
|
||||
) {
|
||||
Img.spinner().attributes(.class("hx-indicator"), .style("float: left;"))
|
||||
}
|
||||
VendorBranchSelect.purchaseOrderForm()
|
||||
} else {
|
||||
input(
|
||||
.type(.text), .class("col-4"),
|
||||
@@ -89,16 +77,7 @@ struct PurchaseOrderForm: HTML {
|
||||
.for("createdForID"), .class("label col-2"), .style("margin-right: 15px; margin-bottom: 5px;")
|
||||
) { "Employee:" }
|
||||
if purchaseOrder == nil {
|
||||
div(
|
||||
.class("col-3"),
|
||||
.hx.get("/purchase-orders/create/employee-select"),
|
||||
.hx.target("this"),
|
||||
.hx.swap(.outerHTML.transition(true).swap("0.5s")),
|
||||
.hx.trigger(.event(.revealed)),
|
||||
.hx.indicator(".hx-indicator")
|
||||
) {
|
||||
Img.spinner().attributes(.class("hx-indicator"), .style("float: left;"))
|
||||
}
|
||||
EmployeeSelect.purchaseOrderForm()
|
||||
} else {
|
||||
input(
|
||||
.type(.text), .class("col-3"),
|
||||
@@ -134,28 +113,4 @@ struct PurchaseOrderForm: HTML {
|
||||
guard purchaseOrder != nil else { return "Create" }
|
||||
return "Update"
|
||||
}
|
||||
|
||||
struct VendorSelect: HTML {
|
||||
let vendorBranches: [VendorBranch.Detail]
|
||||
|
||||
var content: some HTML<HTMLTag.select> {
|
||||
select(.name("vendorBranchID"), .class("col-4")) {
|
||||
for branch in vendorBranches {
|
||||
option(.value(branch.id.uuidString)) { "\(branch.vendor.name) - \(branch.name)" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EmployeeSelect: HTML {
|
||||
let employees: [Employee]
|
||||
|
||||
var content: some HTML<HTMLTag.select> {
|
||||
select(.name("createdForID"), .class("col-3")) {
|
||||
for employee in employees {
|
||||
option(.value(employee.id.uuidString)) { employee.fullName }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user