module Web.View.RequirementCandidates.Edit where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude data EditView = EditView { candidate :: !RequirementCandidate , widgets :: ![Widget] , threads :: ![AnnotationThread] } instance View EditView where html EditView { .. } = [hsx|
Candidates / {candidate.title} / Edit

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 #sourceThreadId (threadOptions threads)} {selectField #category categoryOptions} {submitButton} |] widgetOptions :: [Widget] -> [(Text, Text)] widgetOptions = map (\w -> (w.name, show w.id)) threadOptions :: [AnnotationThread] -> [(Text, Text)] threadOptions threads = ("None", "") : map (\t -> (t.title, show t.id)) threads categoryOptions :: [(Text, Text)] categoryOptions = [ ("Friction", "friction") , ("Defect", "defect") , ("Wish", "wish") , ("Policy Concern", "policy_concern") , ("Documentation Gap", "doc_gap") , ("Trust", "trust") , ("Other", "other") ]