module Web.View.WidgetPatterns.Show where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude import Web.Routes () import Data.Aeson (encode) import qualified Data.ByteString.Lazy.Char8 as BL data ShowView = ShowView { pattern :: !WidgetPattern , hub :: !Hub , versions :: ![WidgetPatternVersion] , adopterCount :: !Int , anonCount :: !Int , meanFriction :: !(Maybe Double) , outcomeCount :: !Int } instance View ShowView where html ShowView { .. } = [hsx|
Hub: {hub.name}
{tshow adopterCount} adopters
{maybe mempty renderPatternDescription pattern.description} {aggregatePanel adopterCount anonCount meanFriction outcomeCount}Total Adopters
{tshow adopterCount}
{if anonCount > 0 then renderAnonCountNote anonCount else mempty}Mean Friction Score
{maybe "—" (\f -> tshow (round f :: Int)) meanFriction}
non-anonymous adopters
Outcome Signals
{tshow outcomeCount}
{cs (BL.unpack (encode v.definition)) :: Text}
{d}
|] renderAnonCountNote :: Int -> Html renderAnonCountNote n = [hsx|{tshow n} opted out of aggregate feedback
|] renderChangelog :: Text -> Html renderChangelog c = [hsx|{c}
|] renderPatternActions :: Bool -> Id WidgetPattern -> Html renderPatternActions False pid = [hsx| Edit Publish |] renderPatternActions True pid = [hsx| Adopt Pattern |] renderVersionHistory :: [WidgetPatternVersion] -> Html renderVersionHistory [] = [hsx|No versions published yet.
|] renderVersionHistory vs = [hsx|