feat: Adds ability to toggle an employee's active status (#3)
Reviewed-on: #3
This commit is contained in:
@@ -77,7 +77,7 @@ extension SiteRoute.View.EmployeeRoute {
|
||||
return try await render(mainPage, isHtmxRequest, EmployeeForm(shouldShow: true))
|
||||
|
||||
case let .select(context: context):
|
||||
return try await context.toHTML(employees: employees.fetchAll())
|
||||
return try await context.toHTML(employees: employees.fetchAll(.active))
|
||||
|
||||
case .index:
|
||||
return try await mainPage(EmployeeForm())
|
||||
|
||||
@@ -42,6 +42,20 @@ struct EmployeeForm: HTML {
|
||||
.placeholder("Last Name"), .required
|
||||
)
|
||||
}
|
||||
if let employee {
|
||||
div(.class("row"), .style("margin: 20px; float: left;")) {
|
||||
label(.for("active"), .style("margin-right: 15px;")) { h2 { "Active" } }
|
||||
if employee.active {
|
||||
input(
|
||||
.type(.checkbox), .id("active"), .name("active"), .checked
|
||||
)
|
||||
} else {
|
||||
input(
|
||||
.type(.checkbox), .id("active"), .name("active")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
div(.class("btn-row")) {
|
||||
button(.type(.submit), .class("btn-primary")) {
|
||||
buttonLabel
|
||||
@@ -59,6 +73,18 @@ struct EmployeeForm: HTML {
|
||||
}
|
||||
}
|
||||
}
|
||||
if employee != nil {
|
||||
h3 {
|
||||
i {
|
||||
span(.class("primary"), .style("padding-right: 15px;")) {
|
||||
"Note:"
|
||||
}
|
||||
span(.class("secondary")) {
|
||||
"It is better to mark an employee as in-active instead of deleting them."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct PurchaseOrderFilter: HTML, Sendable {
|
||||
|
||||
var content: some HTML {
|
||||
form(
|
||||
.id("filter-form")
|
||||
) {
|
||||
input(.type(.text), .name("id"), .placeholder("Filter: (12345)"), .required)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user