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|
New Routing Rule
{renderForm rule hubs}
|]
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))