feat: Working on search for purchase orders.
This commit is contained in:
50
Sources/App/Views/PurchaseOrders/PurchaseOrderSearch.swift
Normal file
50
Sources/App/Views/PurchaseOrders/PurchaseOrderSearch.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
struct PurchaseOrderSearch: HTML {
|
||||
|
||||
let context: PurchaseOrderSearchContext?
|
||||
|
||||
init(context: PurchaseOrderSearchContext? = nil) {
|
||||
self.context = context
|
||||
}
|
||||
|
||||
var content: some HTML {
|
||||
form(
|
||||
.id("search"),
|
||||
.hx.post("/purchase-orders/search"),
|
||||
.hx.target("#purchase-order-table"),
|
||||
.hx.swap(.outerHTML.transition(true).swap("1s"))
|
||||
) {
|
||||
select(
|
||||
.name("context"), .class("col-3"),
|
||||
.hx.get("/purchase-orders/search"),
|
||||
.hx.target("#search"),
|
||||
.hx.swap(.outerHTML)
|
||||
) {
|
||||
option(.value("employee")) { "Employee" }
|
||||
.attributes(.selected, when: context == .employee || context == nil)
|
||||
|
||||
option(.value("customer")) { "Customer" }
|
||||
.attributes(.selected, when: context == .customer)
|
||||
}
|
||||
|
||||
if context == .employee || context == nil {
|
||||
EmployeeSelect.purchaseOrderSearch()
|
||||
} else if context == .customer {
|
||||
input(.type(.text), .name("search"), .placeholder("Search"), .required)
|
||||
}
|
||||
|
||||
button(.type(.submit), .class("btn-primary")) { "Search" }
|
||||
// Img.spinner().attributes(.class("hx-indicator"))
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum PurchaseOrderSearchContext: String, Codable, Content {
|
||||
case employee
|
||||
case customer
|
||||
}
|
||||
Reference in New Issue
Block a user