1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-25 22:02:58 +03:00

Merge pull request #197 from aelve/deleted-category

Show deleted category items at admin page
This commit is contained in:
Artyom Kazak 2017-09-01 18:44:18 +03:00 committed by GitHub
commit 2f7ab3b505

View File

@ -318,9 +318,6 @@ renderStats globalState acts = do
Nothing -> "<unknown IP>" Nothing -> "<unknown IP>"
Just ip -> toHtml (show ip) Just ip -> toHtml (show ip)
-- TODO: when showing Edit'DeleteCategory, show the amount of items in that
-- category and titles of items themselves
-- | Group edits by IP and render them. -- | Group edits by IP and render them.
renderEdits renderEdits
:: (MonadIO m) :: (MonadIO m)
@ -404,6 +401,14 @@ renderEdit globalState edit = do
let (category, item) = findItem itemId let (category, item) = findItem itemId
quote $ a_ [href_ (itemLink category item)] $ quote $ a_ [href_ (itemLink category item)] $
toHtml (item ^. name) toHtml (item ^. name)
let printCategoryWithItems catId = do
let category = findCategory catId
quote $ toHtml (category ^. title)
let catItems = category ^. items
toHtml $ " with " ++ show (length catItems) ++ " items:"
ul_ $
for_ catItems $ \item ->
li_ $ toHtml (item ^. name)
case edit of case edit of
-- Add -- Add
@ -488,7 +493,7 @@ renderEdit globalState edit = do
-- Delete -- Delete
Edit'DeleteCategory catId _pos -> p_ $ do Edit'DeleteCategory catId _pos -> p_ $ do
"deleted category " >> printCategory catId "deleted category " >> printCategoryWithItems catId
Edit'DeleteItem itemId _pos -> p_ $ do Edit'DeleteItem itemId _pos -> p_ $ do
let (category, item) = findItem itemId let (category, item) = findItem itemId
"deleted item " >> quote (toHtml (item^.name)) "deleted item " >> quote (toHtml (item^.name))