feat: Adds purchase-order form only renders a new row rather than whole table.
This commit is contained in:
@@ -87,6 +87,10 @@ td, th {
|
|||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table th {
|
||||||
|
color: #00ffcc;
|
||||||
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
input[type=submit] {
|
||||||
padding: 5px 20px;
|
padding: 5px 20px;
|
||||||
}
|
}
|
||||||
|
|||||||
13
Resources/Views/purchaseOrders/table-row.leaf
Normal file
13
Resources/Views/purchaseOrders/table-row.leaf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<tr id="#(id)">
|
||||||
|
<td>#(id)</td>
|
||||||
|
<td>#(workOrder)</td>
|
||||||
|
<td>#(customer)</td>
|
||||||
|
<td>#capitalized(vendorBranch.vendor.name) - #capitalized(vendorBranch.name)</td>
|
||||||
|
<td>#(materials)</td>
|
||||||
|
<td>#capitalized(createdFor.firstName) #capitalized(createdFor.lastName)</td>
|
||||||
|
<td>#(createdBy.username)</td>
|
||||||
|
<td>#capitalized(truckStock)</td>
|
||||||
|
<td>
|
||||||
|
<!-- TODO: add buttons here -->
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>PO</th>
|
<th>PO</th>
|
||||||
<th>Work Order</th>
|
<th>Work Order</th>
|
||||||
|
<th>Customer</th>
|
||||||
<th>Vendor</th>
|
<th>Vendor</th>
|
||||||
<th>Materials</th>
|
<th>Materials</th>
|
||||||
<th>Created For</th>
|
<th>Created For</th>
|
||||||
@@ -11,18 +12,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tbody id="po-table-body">
|
<tbody id="po-table-body">
|
||||||
#for(po in purchaseOrders):
|
#for(po in purchaseOrders):
|
||||||
<tr id="po_#(po.id)">
|
#extend("purchaseOrders/table-row", po)
|
||||||
<td>#(po.id)</td>
|
|
||||||
<td>#(po.workOrder)</td>
|
|
||||||
<td>#capitalized(po.vendorBranch.vendor.name) - #capitalized(po.vendorBranch.name)</td>
|
|
||||||
<td>#(po.materials)</td>
|
|
||||||
<td>#capitalized(po.createdFor.firstName) #capitalized(po.createdFor.lastName)</td>
|
|
||||||
<td>#(po.createdBy.username)</td>
|
|
||||||
<td>#capitalized(po.truckStock)</td>
|
|
||||||
<td>
|
|
||||||
<!-- TODO: add buttons here -->
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
#endfor
|
#endfor
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ struct ApiController: RouteCollection {
|
|||||||
|
|
||||||
// MARK: - PurchaseOrders
|
// MARK: - PurchaseOrders
|
||||||
|
|
||||||
|
// TODO: Add fetch by id.
|
||||||
|
|
||||||
// TODO: Add pagination and filters.
|
// TODO: Add pagination and filters.
|
||||||
@Sendable
|
@Sendable
|
||||||
func purchaseOrdersIndex(req: Request) async throws -> [PurchaseOrder.DTO] {
|
func purchaseOrdersIndex(req: Request) async throws -> [PurchaseOrder.DTO] {
|
||||||
|
|||||||
@@ -42,9 +42,19 @@ struct PurchaseOrderViewController: RouteCollection {
|
|||||||
|
|
||||||
let purchaseOrder = create.toModel(createdByID: createdById)
|
let purchaseOrder = create.toModel(createdByID: createdById)
|
||||||
try await purchaseOrder.save(on: req.db)
|
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-row", loaded)
|
||||||
return try await req.view.render("purchaseOrders/table", ["purchaseOrders": purchaseOrders])
|
|
||||||
|
// 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",
|
formClass: "po-form",
|
||||||
formId: "po-form",
|
formId: "po-form",
|
||||||
htmxTargetUrl: .post("/purchase-orders"),
|
htmxTargetUrl: .post("/purchase-orders"),
|
||||||
htmxTarget: "#po-table",
|
htmxTarget: "#po-table-body",
|
||||||
htmxPushUrl: false,
|
htmxPushUrl: false,
|
||||||
htmxResetAfterRequest: true,
|
htmxResetAfterRequest: true,
|
||||||
htmxSwapOob: nil,
|
htmxSwapOob: nil,
|
||||||
htmxSwap: .outerHTML,
|
htmxSwap: .afterbegin,
|
||||||
context: .init(branches: branches, employees: employees)
|
context: .init(branches: branches, employees: employees)
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user