feat: Working vendor views, does need some tweeks to user experience.

This commit is contained in:
2025-01-16 11:09:35 -05:00
parent d4a8444700
commit 51124205b8
7 changed files with 155 additions and 91 deletions

View File

@@ -42,7 +42,7 @@ struct VendorForm: HTML {
form(
.id("vendor-form"),
vendor != nil ? .hx.put(targetURL) : .hx.post(targetURL),
.hx.target("#float"),
.hx.target("#content"),
.hx.swap(.outerHTML)
) {
div(.class("row")) {
@@ -53,11 +53,27 @@ struct VendorForm: HTML {
.name("name"),
.value(vendor?.name ?? ""),
.placeholder("Vendor Name"),
vendor != nil ? .hx.put(targetURL) : .hx.post(targetURL),
.hx.trigger(.event(.keyup).changed().delay("500ms")),
.required
)
if let vendor {
button(
.class("danger"),
.style("font-size: 1.25em; padding: 10px 20px; border-radius: 10px;"),
.hx.delete("/api/v1/vendors/\(vendor.id)"),
.hx.confirm("Are you sure you want to delete this vendor?"),
.hx.target("#vendor_\(vendor.id)"),
.hx.swap(.outerHTML.transition(true).swap("1s")),
.custom(
name: "hx-on::after-request",
value: "if(event.detail.successful) toggleContent('float'); window.location.href='/vendors';"
)
) { "Delete" }
}
button(
.type(.submit),
.class("col-1 btn-primary"),
.class("btn-primary"),
.style("float: right")
) { buttonLabel }
}