feat: Adds purchase-order form only renders a new row rather than whole table.
This commit is contained in:
@@ -42,9 +42,19 @@ struct PurchaseOrderViewController: RouteCollection {
|
||||
|
||||
let purchaseOrder = create.toModel(createdByID: createdById)
|
||||
try await purchaseOrder.save(on: req.db)
|
||||
let loaded = try await PurchaseOrder.query(on: req.db)
|
||||
.filter(\.$id == purchaseOrder.requireID())
|
||||
.with(\.$createdFor)
|
||||
.with(\.$createdBy)
|
||||
.with(\.$vendorBranch) {
|
||||
$0.with(\.$vendor)
|
||||
}
|
||||
.first()
|
||||
|
||||
let purchaseOrders = try await api.purchaseOrdersIndex(req: req)
|
||||
return try await req.view.render("purchaseOrders/table", ["purchaseOrders": purchaseOrders])
|
||||
return try await req.view.render("purchaseOrders/table-row", loaded)
|
||||
|
||||
// let purchaseOrders = try await api.purchaseOrdersIndex(req: req)
|
||||
// return try await req.view.render("purchaseOrders/table", ["purchaseOrders": purchaseOrders])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,11 +77,11 @@ private struct PurchaseOrderFormCTX: Content {
|
||||
formClass: "po-form",
|
||||
formId: "po-form",
|
||||
htmxTargetUrl: .post("/purchase-orders"),
|
||||
htmxTarget: "#po-table",
|
||||
htmxTarget: "#po-table-body",
|
||||
htmxPushUrl: false,
|
||||
htmxResetAfterRequest: true,
|
||||
htmxSwapOob: nil,
|
||||
htmxSwap: .outerHTML,
|
||||
htmxSwap: .afterbegin,
|
||||
context: .init(branches: branches, employees: employees)
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user