feat: Adds api route tests. Tested user interface works as expected, still needs some work on vendors form.
This commit is contained in:
@@ -6,7 +6,7 @@ import Vapor
|
||||
struct EmployeeSelect: HTML {
|
||||
|
||||
let employees: [Employee]?
|
||||
let context: SelectContext
|
||||
let context: ViewRoute.SelectContext
|
||||
|
||||
var content: some HTML {
|
||||
if let employees {
|
||||
@@ -18,7 +18,7 @@ struct EmployeeSelect: HTML {
|
||||
.attributes(.style("margin-left: 15px;"), when: context == .purchaseOrderSearch)
|
||||
} else {
|
||||
div(
|
||||
.hx.get("/select/employee?context=\(context.rawValue)"),
|
||||
.hx.get(route: .employee(.select(context: context))),
|
||||
.hx.target("this"),
|
||||
.hx.swap(.outerHTML.transition(true).swap("0.5s")),
|
||||
.hx.indicator("next .hx-indicator"),
|
||||
@@ -42,11 +42,11 @@ struct EmployeeSelect: HTML {
|
||||
|
||||
struct VendorBranchSelect: HTML {
|
||||
let branches: [VendorBranch.Detail]?
|
||||
let context: SelectContext
|
||||
let context: ViewRoute.SelectContext
|
||||
|
||||
var content: some HTML {
|
||||
if let branches {
|
||||
select(.name("vendorBranchID"), .class(context.classString)) {
|
||||
select(.name("vendorBranchID"), .class("col-4")) {
|
||||
for branch in branches {
|
||||
option(.value(branch.id.uuidString)) { "\(branch.vendor.name) - \(branch.name)" }
|
||||
}
|
||||
@@ -54,8 +54,8 @@ struct VendorBranchSelect: HTML {
|
||||
.attributes(.style("margin-left: 15px;"), when: context == .purchaseOrderSearch)
|
||||
} else {
|
||||
div(
|
||||
.hx.get("/select/vendor-branches?context=\(context.rawValue)"),
|
||||
.hx.target("this"),
|
||||
.hx.get(route: .vendorBranch(.select(context: context))),
|
||||
.hx.target(.this),
|
||||
.hx.swap(.outerHTML.transition(true).swap("0.5s")),
|
||||
.hx.indicator("next .hx-indicator"),
|
||||
.hx.trigger(.event(.revealed)),
|
||||
@@ -75,10 +75,11 @@ struct VendorBranchSelect: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
enum SelectContext: String, Codable, Content {
|
||||
case purchaseOrderForm
|
||||
case purchaseOrderSearch
|
||||
// enum SelectContext: String, Codable, Content {
|
||||
// case purchaseOrderForm
|
||||
// case purchaseOrderSearch
|
||||
|
||||
extension ViewRoute.SelectContext {
|
||||
var classString: String {
|
||||
switch self {
|
||||
case .purchaseOrderForm: return "col-3"
|
||||
|
||||
Reference in New Issue
Block a user