generated from coulomb/repo-seed
Fix compilation errors across 6 controllers and 29 views: import cleanup, ResponseException pattern for API auth, type fixes, unused import removal. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
1.0 KiB
Haskell
32 lines
1.0 KiB
Haskell
module Web.View.HubRoutingRules.New where
|
|
|
|
import Web.View.Prelude
|
|
import Web.Routes ()
|
|
|
|
data NewView = NewView
|
|
{ rule :: !HubRoutingRule
|
|
, hubs :: ![Hub]
|
|
}
|
|
|
|
instance View NewView where
|
|
html NewView { .. } = [hsx|
|
|
<div class="max-w-lg">
|
|
<h1 class="text-2xl font-semibold mb-6">New Routing Rule</h1>
|
|
{renderForm rule hubs}
|
|
</div>
|
|
|]
|
|
|
|
renderForm :: HubRoutingRule -> [Hub] -> Html
|
|
renderForm rule hubs = formFor rule [hsx|
|
|
{(selectField #sourceHubId (hubOptions hubs)){ fieldLabel = "Source Hub" }}
|
|
{(selectField #targetHubId (hubOptions hubs)){ fieldLabel = "Target Hub" }}
|
|
{(textField #matchCategory){ helpText = "Leave blank to match any category" }}
|
|
{(textField #matchWidgetType){ helpText = "Leave blank to match any widget type" }}
|
|
{(numberField #priority){ helpText = "Higher priority rules are evaluated first" }}
|
|
{textareaField #notes}
|
|
{submitButton}
|
|
|]
|
|
|
|
hubOptions :: [Hub] -> [(Text, Id Hub)]
|
|
hubOptions = map (\h -> (h.name, h.id))
|