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>
45 lines
1.4 KiB
Haskell
45 lines
1.4 KiB
Haskell
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|
|
|
<div class="max-w-lg">
|
|
<div class="flex items-center gap-2 text-sm text-gray-500 mb-4">
|
|
<a href={ShowWidgetAction (widget.id)} class="hover:text-gray-700">{widget.name}</a>
|
|
<span>/</span>
|
|
<a href={WidgetAnnotationsAction (widget.id)} class="hover:text-gray-700">Annotations</a>
|
|
<span>/</span>
|
|
<span>New</span>
|
|
</div>
|
|
<h1 class="text-2xl font-semibold mb-6">Add Annotation</h1>
|
|
{renderForm annotation widget.id categories}
|
|
</div>
|
|
|]
|
|
|
|
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")
|
|
]
|