feat: Initial view controller dependency and snapshot tests.
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
struct PurchaseOrderSearch: HTML {
|
||||
|
||||
typealias Context = SharedModels.ViewRoute.PurchaseOrderRoute.Search.Context
|
||||
|
||||
let context: Context
|
||||
|
||||
init(context: Context? = nil) {
|
||||
self.context = context ?? .employee
|
||||
}
|
||||
|
||||
var content: some HTML {
|
||||
form(
|
||||
.id(.purchaseOrder(.search)),
|
||||
.hx.post(route: .purchaseOrder(.search(.index()))),
|
||||
.hx.target(.id(.purchaseOrder())),
|
||||
.hx.swap(.outerHTML)
|
||||
) {
|
||||
div(.class("btn-row")) {
|
||||
button(
|
||||
.class("btn-secondary"), .style("position: absolute; top: 80px; right: 20px;"),
|
||||
.hx.get(route: .purchaseOrder(.index)), .hx.pushURL(true), .hx.target("body")
|
||||
)
|
||||
{ "x" }
|
||||
}
|
||||
div(.class("row")) {
|
||||
select(
|
||||
.name("context"), .class("col-3"),
|
||||
.hx.get(route: .purchaseOrder(.search(.index()))),
|
||||
.hx.target(.id(.purchaseOrder(.search))),
|
||||
.hx.swap(.outerHTML.transition(true).swap("0.5s")),
|
||||
.hx.pushURL(true)
|
||||
) {
|
||||
for context in Context.allCases {
|
||||
option(.value(context.rawValue)) { context.rawValue.capitalized }
|
||||
.attributes(.selected, when: self.context == context)
|
||||
}
|
||||
}
|
||||
|
||||
if context == .employee {
|
||||
EmployeeSelect.purchaseOrderSearch()
|
||||
} else if context == .customer {
|
||||
input(
|
||||
.type(.text), .class("col-6"), .style("margin-left: 60px; margin-top: 18px;"),
|
||||
.name("customerSearch"), .placeholder("Search"), .required
|
||||
)
|
||||
} else if context == .vendor {
|
||||
VendorBranchSelect.purchaseOrderSearch()
|
||||
}
|
||||
}
|
||||
|
||||
div(.class("btn-row")) {
|
||||
button(.type(.submit), .class("btn-primary"))
|
||||
{ "Search" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user