module Web.View.Annotations.Index where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude data IndexView = IndexView { widget :: !Widget , annotations :: ![Annotation] } instance View IndexView where html IndexView { .. } = [hsx|
Widgets / {widget.name} / Annotations

Annotations for {widget.name}

Add Annotation
{forEach rootAnnotations (renderAnnotation childrenOf)}
|] where rootAnnotations = filter (\a -> isNothing a.parentId) annotations childrenOf parent = filter (\a -> a.parentId == Just parent.id) annotations renderAnnotation :: (Annotation -> [Annotation]) -> Annotation -> Html renderAnnotation childrenOf a = [hsx|
{a.category} {a.actorType} {if isJust a.retractedAt then [hsx|retracted|] else mempty} {show a.createdAt}

{a.body}

Reply
{forEach (childrenOf a) (renderAnnotation childrenOf)}
|]