module Web.View.Annotations.New where
import Web.View.Prelude
import Web.Routes ()
data NewView = NewView
{ widget :: !Widget
, annotation :: !Annotation
, categories :: ![AnnotationCategoryRegistry]
}
instance View NewView where
html NewView { .. } = [hsx|
Add Annotation
{renderForm annotation widget.id categories}
|]
renderForm :: Annotation -> Id Widget -> [AnnotationCategoryRegistry] -> Html
renderForm annotation widgetId categories = formFor annotation [hsx|
{(textareaField #body) { fieldLabel = "Comment" }}
{selectField #category (categoryOptions categories)}
{selectField #severity severityOptions}
{submitButton}
|]
categoryOptions :: [AnnotationCategoryRegistry] -> [(Text, Text)]
categoryOptions = map (\r -> (r.label_, r.name))
severityOptions :: [(Text, Text)]
severityOptions =
[ ("Low", "low")
, ("Medium", "medium")
, ("High", "high")
, ("Critical", "critical")
]