module Web.View.RequirementCandidates.Edit where
import Web.View.Prelude
import Web.Routes ()
data EditView = EditView
{ candidate :: !RequirementCandidate
, widgets :: ![Widget]
, threads :: ![AnnotationThread]
}
instance View EditView where
html EditView { .. } = [hsx|
Edit Candidate
{renderForm candidate widgets threads}
|]
renderForm :: RequirementCandidate -> [Widget] -> [AnnotationThread] -> Html
renderForm candidate widgets threads = formFor candidate [hsx|
{(textField #title) { fieldLabel = "Title" }}
{(textareaField #description) { fieldLabel = "Description" }}
{selectField #sourceWidgetId (widgetOptions widgets)}
{selectField #category categoryOptions}
{submitButton}
|]
widgetOptions :: [Widget] -> [(Text, Id Widget)]
widgetOptions = map (\w -> (w.name, w.id))
renderThreadOption :: AnnotationThread -> Html
renderThreadOption t = [hsx||]
categoryOptions :: [(Text, Text)]
categoryOptions =
[ ("Friction", "friction")
, ("Defect", "defect")
, ("Wish", "wish")
, ("Policy Concern", "policy_concern")
, ("Documentation Gap", "doc_gap")
, ("Trust", "trust")
, ("Other", "other")
]