feat: Fixes release build failures and get's release dockerfile working.
This commit is contained in:
@@ -8,6 +8,7 @@ import ViewController
|
||||
|
||||
public extension SharedModels.ViewRoute {
|
||||
|
||||
@Sendable
|
||||
func view(
|
||||
isHtmxRequest: Bool,
|
||||
logger: Logger,
|
||||
@@ -55,9 +56,10 @@ extension SharedModels.ViewRoute.EmployeeRoute {
|
||||
|
||||
private func mainPage<C: HTML>(
|
||||
_ html: C
|
||||
) async throws -> some SendableHTMLDocument where C: Sendable {
|
||||
) async throws -> AnySendableHTML where C: Sendable {
|
||||
@Dependency(\.database) var database
|
||||
let employees = try await database.employees.fetchAll()
|
||||
// return EmployeeMainPage(employees: employees, html: html)
|
||||
return MainPage(displayNav: true, route: .employees) {
|
||||
div(.class("container")) {
|
||||
html
|
||||
@@ -66,6 +68,7 @@ extension SharedModels.ViewRoute.EmployeeRoute {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database.employees) var employees
|
||||
|
||||
@@ -98,7 +101,7 @@ extension SharedModels.ViewRoute.EmployeeRoute {
|
||||
extension SharedModels.ViewRoute.PurchaseOrderRoute {
|
||||
private func mainPage<C: HTML>(
|
||||
_ html: C
|
||||
) async throws -> some SendableHTMLDocument where C: Sendable {
|
||||
) async throws -> AnySendableHTML where C: Sendable {
|
||||
@Dependency(\.database.purchaseOrders) var purchaseOrders
|
||||
let page = try await purchaseOrders.fetchPage(.init(page: 1, per: 25))
|
||||
return MainPage(displayNav: true, route: .purchaseOrders) {
|
||||
@@ -109,6 +112,7 @@ extension SharedModels.ViewRoute.PurchaseOrderRoute {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database.purchaseOrders) var purchaseOrders
|
||||
|
||||
@@ -146,7 +150,7 @@ extension SharedModels.ViewRoute.PurchaseOrderRoute {
|
||||
|
||||
extension SharedModels.ViewRoute.PurchaseOrderRoute.Search {
|
||||
|
||||
func mainPage(search: PurchaseOrderSearch = .init()) -> some SendableHTMLDocument {
|
||||
func mainPage(search: PurchaseOrderSearch = .init()) -> AnySendableHTML {
|
||||
MainPage(displayNav: true, route: .purchaseOrders) {
|
||||
div(.class("container"), .id("purchase-order-content")) {
|
||||
search
|
||||
@@ -158,6 +162,7 @@ extension SharedModels.ViewRoute.PurchaseOrderRoute.Search {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database) var database
|
||||
switch self {
|
||||
@@ -177,7 +182,7 @@ extension SharedModels.ViewRoute.PurchaseOrderRoute.Search {
|
||||
|
||||
extension SharedModels.ViewRoute.UserRoute {
|
||||
|
||||
private func mainPage<C: HTML>(_ html: C) async throws -> some SendableHTMLDocument where C: Sendable {
|
||||
private func mainPage<C: HTML>(_ html: C) async throws -> AnySendableHTML where C: Sendable {
|
||||
@Dependency(\.database) var database
|
||||
let users = try await database.users.fetchAll()
|
||||
return MainPage(displayNav: true, route: .users) {
|
||||
@@ -188,6 +193,7 @@ extension SharedModels.ViewRoute.UserRoute {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database.users) var users
|
||||
|
||||
@@ -215,7 +221,7 @@ extension SharedModels.ViewRoute.UserRoute {
|
||||
}
|
||||
|
||||
extension SharedModels.ViewRoute.VendorRoute {
|
||||
private func mainPage<C: HTML>(_ html: C) async throws -> some SendableHTMLDocument where C: Sendable {
|
||||
private func mainPage<C: HTML>(_ html: C) async throws -> AnySendableHTML where C: Sendable {
|
||||
@Dependency(\.database) var database
|
||||
let vendors = try await database.vendors.fetchAll(.withBranches)
|
||||
return MainPage(displayNav: true, route: .vendors) {
|
||||
@@ -226,6 +232,7 @@ extension SharedModels.ViewRoute.VendorRoute {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database) var database
|
||||
|
||||
@@ -262,6 +269,7 @@ extension SharedModels.ViewRoute.VendorRoute {
|
||||
|
||||
extension SharedModels.ViewRoute.VendorBranchRoute {
|
||||
|
||||
@Sendable
|
||||
func view(isHtmxRequest: Bool) async throws -> AnySendableHTML {
|
||||
@Dependency(\.database) var database
|
||||
|
||||
@@ -286,6 +294,7 @@ extension SharedModels.ViewRoute.VendorBranchRoute {
|
||||
|
||||
extension SharedModels.ViewRoute.PurchaseOrderRoute.Search.Request {
|
||||
|
||||
@Sendable
|
||||
func toDatabaseQuery() throws -> PurchaseOrder.SearchContext {
|
||||
switch context {
|
||||
case .employee:
|
||||
@@ -308,6 +317,8 @@ extension SharedModels.ViewRoute.PurchaseOrderRoute.Search.Request {
|
||||
}
|
||||
|
||||
extension SharedModels.ViewRoute.SelectContext {
|
||||
|
||||
@Sendable
|
||||
func toHTML(employees: [Employee]) -> EmployeeSelect {
|
||||
switch self {
|
||||
case .purchaseOrderForm:
|
||||
@@ -327,8 +338,9 @@ extension SharedModels.ViewRoute.SelectContext {
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
private func render<C: HTML>(
|
||||
_ mainPage: (C) async throws -> any SendableHTMLDocument,
|
||||
_ mainPage: (C) async throws -> AnySendableHTML,
|
||||
_ isHtmxRequest: Bool,
|
||||
@HTMLBuilder html: () -> C
|
||||
) async rethrows -> AnySendableHTML where C: Sendable {
|
||||
@@ -338,8 +350,9 @@ private func render<C: HTML>(
|
||||
return html()
|
||||
}
|
||||
|
||||
@Sendable
|
||||
private func render<C: HTML>(
|
||||
_ mainPage: (C) async throws -> any SendableHTMLDocument,
|
||||
_ mainPage: (C) async throws -> AnySendableHTML,
|
||||
_ isHtmxRequest: Bool,
|
||||
_ html: @autoclosure @escaping () -> C
|
||||
) async rethrows -> AnySendableHTML where C: Sendable {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct EmployeeTable: HTML {
|
||||
struct EmployeeTable: HTML, Sendable {
|
||||
let employees: [Employee]
|
||||
|
||||
var content: some HTML {
|
||||
@@ -29,7 +29,7 @@ struct EmployeeTable: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct Row: HTML {
|
||||
struct Row: HTML, Sendable {
|
||||
let employee: Employee
|
||||
|
||||
var content: some HTML {
|
||||
|
||||
@@ -3,24 +3,29 @@ import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
extension HTMLAttribute.hx {
|
||||
@Sendable
|
||||
static func get(route: SharedModels.ViewRoute) -> HTMLAttribute {
|
||||
get(SharedModels.ViewRoute.router.path(for: route))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func post(route: SharedModels.ViewRoute) -> HTMLAttribute {
|
||||
post(SharedModels.ViewRoute.router.path(for: route))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func put(route: SharedModels.ViewRoute) -> HTMLAttribute {
|
||||
put(SharedModels.ViewRoute.router.path(for: route))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func delete(route: SharedModels.ApiRoute) -> HTMLAttribute {
|
||||
delete(SharedModels.ApiRoute.router.path(for: route))
|
||||
}
|
||||
}
|
||||
|
||||
extension HTMLAttribute.hx {
|
||||
@Sendable
|
||||
static func target(_ target: HXTarget) -> HTMLAttribute {
|
||||
Self.target(target.selector)
|
||||
}
|
||||
@@ -28,37 +33,43 @@ extension HTMLAttribute.hx {
|
||||
|
||||
extension HTMLAttribute.hx where Tag: HTMLTrait.Attributes.Global {
|
||||
|
||||
@Sendable
|
||||
static func on(_ event: HXOnEvent, value: String) -> HTMLAttribute {
|
||||
HTMLAttribute.custom(name: "hx-on::\(event.rawValue)", value: value)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func on(_ event: HXOnEvent, _ value: HXOnValue) -> HTMLAttribute {
|
||||
on(event, value: value.value)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func on(_ event: HXOnEvent, _ values: HXOnValue...) -> HTMLAttribute {
|
||||
on(event, value: values.value)
|
||||
}
|
||||
}
|
||||
|
||||
enum HXOnEvent: String {
|
||||
enum HXOnEvent: String, Sendable {
|
||||
case afterRequest = "after-request"
|
||||
}
|
||||
|
||||
indirect enum HXOnValue {
|
||||
indirect enum HXOnValue: Sendable {
|
||||
case ifSuccessful([Self])
|
||||
case resetForm
|
||||
case setWindowLocation(String)
|
||||
case toggleContent(id: String)
|
||||
|
||||
@Sendable
|
||||
static func toggleContent(_ toggle: Toggle) -> Self {
|
||||
toggleContent(id: toggle.rawValue)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func setWindowLocation(to route: ViewRoute) -> Self {
|
||||
setWindowLocation(ViewRoute.router.path(for: route))
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func ifSuccessful(_ values: Self...) -> Self {
|
||||
.ifSuccessful(values)
|
||||
}
|
||||
@@ -76,7 +87,7 @@ indirect enum HXOnValue {
|
||||
}
|
||||
}
|
||||
|
||||
enum Toggle: String {
|
||||
enum Toggle: String, Sendable {
|
||||
case float
|
||||
}
|
||||
}
|
||||
@@ -89,12 +100,14 @@ extension Array where Element == HXOnValue {
|
||||
}
|
||||
|
||||
extension HTMLAttribute where Tag: HTMLTrait.Attributes.Global {
|
||||
|
||||
@Sendable
|
||||
static func id(_ key: IDKey) -> Self {
|
||||
id(key.description)
|
||||
}
|
||||
}
|
||||
|
||||
enum IDKey: CustomStringConvertible {
|
||||
enum IDKey: CustomStringConvertible, Sendable {
|
||||
case branch(Branch)
|
||||
case employee(Employee)
|
||||
case float
|
||||
@@ -115,7 +128,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum Branch: CustomStringConvertible {
|
||||
enum Branch: CustomStringConvertible, Sendable {
|
||||
case list
|
||||
case form
|
||||
case row(id: VendorBranch.ID)
|
||||
@@ -129,7 +142,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum Employee: CustomStringConvertible {
|
||||
enum Employee: CustomStringConvertible, Sendable {
|
||||
case table
|
||||
case row(id: SharedModels.Employee.ID)
|
||||
|
||||
@@ -141,7 +154,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum PurchaseOrder: CustomStringConvertible {
|
||||
enum PurchaseOrder: CustomStringConvertible, Sendable {
|
||||
case content
|
||||
case row(id: SharedModels.PurchaseOrder.ID)
|
||||
case search
|
||||
@@ -157,7 +170,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum User: CustomStringConvertible {
|
||||
enum User: CustomStringConvertible, Sendable {
|
||||
case form
|
||||
case row(id: SharedModels.User.ID)
|
||||
case table
|
||||
@@ -171,7 +184,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum Vendor: CustomStringConvertible {
|
||||
enum Vendor: CustomStringConvertible, Sendable {
|
||||
case form
|
||||
case row(id: SharedModels.Vendor.ID)
|
||||
|
||||
@@ -185,7 +198,7 @@ enum IDKey: CustomStringConvertible {
|
||||
}
|
||||
}
|
||||
|
||||
enum HXTarget: CustomStringConvertible {
|
||||
enum HXTarget: CustomStringConvertible, Sendable {
|
||||
case body
|
||||
case id(IDKey)
|
||||
case this
|
||||
|
||||
@@ -49,7 +49,7 @@ extension MainPage where Inner == LoggedIn {
|
||||
}
|
||||
}
|
||||
|
||||
struct LoggedIn: HTML {
|
||||
struct LoggedIn: HTML, Sendable {
|
||||
let next: String?
|
||||
var content: some HTML {
|
||||
div(
|
||||
@@ -72,7 +72,7 @@ struct LoggedIn: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct RouteHeaderView: HTML {
|
||||
struct RouteHeaderView: HTML, Sendable {
|
||||
|
||||
let title: String
|
||||
let description: String
|
||||
@@ -95,7 +95,7 @@ struct RouteHeaderView: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
enum ViewRoute: String {
|
||||
enum ViewRoute: String, Sendable {
|
||||
|
||||
case employees
|
||||
case login
|
||||
|
||||
@@ -3,7 +3,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct PurchaseOrderForm: HTML {
|
||||
struct PurchaseOrderForm: HTML, Sendable {
|
||||
|
||||
@Dependency(\.dateFormatter) var dateFormatter
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import ElementaryHTMX
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
struct PurchaseOrderSearch: HTML {
|
||||
struct PurchaseOrderSearch: HTML, Sendable {
|
||||
|
||||
typealias Context = SharedModels.ViewRoute.PurchaseOrderRoute.Search.Context
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Fluent
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
struct PurchaseOrderTable: HTML {
|
||||
struct PurchaseOrderTable: HTML, Sendable {
|
||||
typealias SearchContext = SharedModels.ViewRoute.PurchaseOrderRoute.Search.Context
|
||||
|
||||
let page: Page<PurchaseOrder>
|
||||
@@ -72,7 +72,7 @@ struct PurchaseOrderTable: HTML {
|
||||
}
|
||||
|
||||
// Produces only the rows for the given page
|
||||
struct Rows: HTML {
|
||||
struct Rows: HTML, Sendable {
|
||||
let page: Page<PurchaseOrder>
|
||||
|
||||
var content: some HTML {
|
||||
@@ -98,7 +98,7 @@ struct PurchaseOrderTable: HTML {
|
||||
}
|
||||
|
||||
// A single row.
|
||||
struct Row: HTML {
|
||||
struct Row: HTML, Sendable {
|
||||
let purchaseOrder: PurchaseOrder
|
||||
|
||||
var content: some HTML<HTMLTag.tr> {
|
||||
@@ -124,7 +124,7 @@ struct PurchaseOrderTable: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
enum Context: String {
|
||||
enum Context: String, Sendable {
|
||||
case `default`
|
||||
case search
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ struct UserForm: HTML, Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
enum Context: Equatable {
|
||||
enum Context: Equatable, Sendable {
|
||||
case create
|
||||
case login(next: String?)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct UserTable: HTML {
|
||||
struct UserTable: HTML, Sendable {
|
||||
|
||||
let users: [User]
|
||||
|
||||
@@ -32,7 +32,7 @@ struct UserTable: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct Row: HTML {
|
||||
struct Row: HTML, Sendable {
|
||||
let user: User
|
||||
|
||||
init(user: User) {
|
||||
|
||||
@@ -2,7 +2,8 @@ import Elementary
|
||||
import SharedModels
|
||||
import URLRouting
|
||||
|
||||
struct ToggleFormButton: HTML {
|
||||
// TODO: Remove.
|
||||
struct ToggleFormButton: HTML, Sendable {
|
||||
var content: some HTML<HTMLTag.a> {
|
||||
a(.href("javascript:void(0)"), .on(.click, "toggleContent('form')"), .class("btn-add")) {
|
||||
"+"
|
||||
@@ -12,20 +13,24 @@ struct ToggleFormButton: HTML {
|
||||
|
||||
enum Button {
|
||||
|
||||
@Sendable
|
||||
static func add() -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn btn-add")) { "+" }
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func danger<C: HTML>(@HTMLBuilder body: () -> C) -> some HTML<HTMLTag.button> {
|
||||
button(.class("danger")) { body() }
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func close(id: String, resetURL: String? = nil) -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-close"), .on(.click, makeOnClick(id, resetURL))) {
|
||||
"x"
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func close(id: IDKey, resetURL route: ViewRoute? = nil) -> some HTML<HTMLTag.button> {
|
||||
close(
|
||||
id: id.description,
|
||||
@@ -33,16 +38,19 @@ enum Button {
|
||||
)
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func update() -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-update")) { "Update" }
|
||||
}
|
||||
|
||||
@Sendable
|
||||
static func detail() -> some HTML<HTMLTag.button> {
|
||||
button(.class("btn-detail")) {
|
||||
"〉"
|
||||
}
|
||||
}
|
||||
|
||||
@Sendable
|
||||
private static func makeOnClick(_ id: String, _ resetURL: String?) -> String {
|
||||
let output = "toggleContent('\(id)');"
|
||||
if let resetURL {
|
||||
|
||||
@@ -49,7 +49,7 @@ struct Float<C: HTML, B: HTML>: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct DefaultCloseButton: HTML {
|
||||
struct DefaultCloseButton: HTML, Sendable {
|
||||
let id: String
|
||||
let resetURL: String?
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import ElementaryHTMX
|
||||
import SharedModels
|
||||
import Vapor
|
||||
|
||||
struct EmployeeSelect: HTML {
|
||||
struct EmployeeSelect: HTML, Sendable {
|
||||
|
||||
let employees: [Employee]?
|
||||
let context: ViewRoute.SelectContext
|
||||
@@ -40,7 +40,7 @@ struct EmployeeSelect: HTML {
|
||||
|
||||
}
|
||||
|
||||
struct VendorBranchSelect: HTML {
|
||||
struct VendorBranchSelect: HTML, Sendable {
|
||||
let branches: [VendorBranch.Detail]?
|
||||
let context: ViewRoute.SelectContext
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct VendorBranchForm: HTML {
|
||||
struct VendorBranchForm: HTML, Sendable {
|
||||
let vendorID: Vendor.ID
|
||||
|
||||
var content: some HTML {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct VendorBranchList: HTML {
|
||||
struct VendorBranchList: HTML, Sendable {
|
||||
let vendorID: Vendor.ID
|
||||
let branches: [VendorBranch]?
|
||||
|
||||
@@ -25,7 +25,7 @@ struct VendorBranchList: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct Row: HTML {
|
||||
struct Row: HTML, Sendable {
|
||||
let branch: VendorBranch
|
||||
|
||||
var content: some HTML<HTMLTag.li> {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct VendorDetail: HTML {
|
||||
struct VendorDetail: HTML, Sendable {
|
||||
|
||||
let vendor: Vendor
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct VendorForm: HTML {
|
||||
struct VendorForm: HTML, Sendable {
|
||||
|
||||
let context: Context
|
||||
var vendor: Vendor? { context.vendor }
|
||||
@@ -15,7 +15,7 @@ struct VendorForm: HTML {
|
||||
|
||||
init() { self.init(.float(nil)) }
|
||||
|
||||
enum Context {
|
||||
enum Context: Sendable {
|
||||
case float(Vendor? = nil, shouldShow: Bool = false)
|
||||
case formOnly(Vendor)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Elementary
|
||||
import ElementaryHTMX
|
||||
import SharedModels
|
||||
|
||||
struct VendorTable: HTML {
|
||||
struct VendorTable: HTML, Sendable {
|
||||
let vendors: [Vendor]
|
||||
|
||||
var content: some HTML {
|
||||
@@ -30,7 +30,7 @@ struct VendorTable: HTML {
|
||||
}
|
||||
}
|
||||
|
||||
struct Row: HTML {
|
||||
struct Row: HTML, Sendable {
|
||||
let vendor: Vendor
|
||||
|
||||
var content: some HTML<HTMLTag.tr> {
|
||||
|
||||
Reference in New Issue
Block a user