Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Add some "nothing here" when lists are empty (issue #823)
Browse files Browse the repository at this point in the history
  • Loading branch information
np committed Jul 7, 2016
1 parent 71bbbe6 commit 5d27900
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/Frontend/Fragment/DelegationTab.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ import qualified Frontend.Path as U


renderDelegations :: forall m. Monad m => Bool -> DelegationListsMap -> HtmlT m ()
renderDelegations showScope delegations = do
ul_ [class_ "small-avatar-list"] $ renderLi `mapM_` sortBy orddeleg (flatten delegations)
renderDelegations showScope delegations =
ul_ [class_ "small-avatar-list"] $ do
forM_ ds renderLi
when (null ds) $ p_ [class_ "container-not-found"] "Keine Beauftragung"
where
ds = sortBy orddeleg (flatten delegations)

flatten :: DelegationListsMap -> [(DScopeFull, (User, [User]))]
flatten (DelegationListsMap xs) = concat $ f <$> xs
where f (dscope, DelegateeLists lists) = (dscope,) <$> lists
Expand Down
10 changes: 4 additions & 6 deletions src/Frontend/Fragment/IdeaList.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,15 @@ instance ToHtml ListItemIdea where

instance ToHtml ListItemIdeas where
toHtmlRaw = toHtml
toHtml p@(ListItemIdeas _ctx whatPage ideasQuery []) = semanticDiv p $ do
toHtml p@(ListItemIdeas ctx whatPage ideasQuery ideasAndNumVoters) = semanticDiv p $ do
ideaListHeader whatPage ideasQuery
div_ [class_ "container-not-found"] . toHtml $ "Keine Ideen" <> mCatInfo <> "."
for_ ideasAndNumVoters $ toHtml . ListItemIdea ctx whatPage
when (null ideasAndNumVoters) $
div_ [class_ "container-not-found"] . toHtml $ "Keine Ideen" <> mCatInfo <> "."
where
mCatInfo =
ideasQuery ^. ideasQueryF . _IdeasWithCat . uilabeledST . to (" in der Kategorie " <>)

toHtml p@(ListItemIdeas ctx whatPage ideasQuery ideasAndNumVoters) = semanticDiv p $ do
ideaListHeader whatPage ideasQuery
for_ ideasAndNumVoters $ toHtml . ListItemIdea ctx whatPage


ideaListHeader :: Monad m => WhatListPage -> IdeasQuery -> HtmlT m ()
ideaListHeader whatListPage ideasQuery = do
Expand Down
3 changes: 2 additions & 1 deletion src/Frontend/Page/Overview.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ instance ToHtml PageOverviewOfSpaces where
toHtml p@(PageOverviewOfSpaces spaces) = semanticDiv' [class_ "container-main grid-view"] p $ f spaces
where
f :: forall m. (Monad m) => [IdeaSpace] -> HtmlT m ()
f [] = p_ "Keine Ideenräume"
f [] = p_ [class_ "container-not-found"] "Keine Ideenräume"
f rs@(_:_) = forM_ rs g

g :: forall m. (Monad m) => IdeaSpace -> HtmlT m ()
Expand Down Expand Up @@ -123,6 +123,7 @@ instance ToHtml PageOverviewOfTopics where
when (CanCreateTopic `elem` capabilities ctx) $
button_ [onclick_ (U.createTopic space), class_ "btn-cta m-large"] "+ Neues Thema"

when (null topics) $ p_ [class_ "container-not-found"] "Keine Thema."
forM_ topics $ \topic -> do
div_ [class_ "col-1-3 theme-grid-col"] $ do
div_ [class_ ("theme-grid-item phase-" <> cs (show (topic ^. topicPhase)))] $ do
Expand Down
5 changes: 4 additions & 1 deletion src/Frontend/Page/User.hs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ delegationButtons delegatee delegate delegations = do
`elem`
delegations
but = postButton_ [class_ "btn-cta heroic-cta", jsReloadOnClick]
forM_ (commonSchoolClasses delegatee delegate) $ \clss -> do
classes = commonSchoolClasses delegatee delegate
when (null classes) $
p_ [class_ "container-not-found"] "No class in common" -- TODO english
forM_ classes $ \clss -> do
if isActiveDelegation (DScopeIdeaSpace (ClassSpace clss))
then do
but (U.withdrawDelegationOnClassSpace delegate clss)
Expand Down

0 comments on commit 5d27900

Please sign in to comment.