mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 12:15:06 +03:00
Move category status banner into category-info
This commit is contained in:
parent
4511fe68dc
commit
19f9d271b5
@ -8,8 +8,8 @@ module Guide.Views.Category
|
||||
renderCategory,
|
||||
|
||||
-- * Helpers
|
||||
renderCategoryStatus,
|
||||
renderCategoryInfo,
|
||||
renderCategoryStatus,
|
||||
renderCategoryNotes,
|
||||
)
|
||||
where
|
||||
@ -40,7 +40,6 @@ renderCategory :: MonadIO m => Category -> HtmlT m ()
|
||||
renderCategory category = cached (CacheCategory (category^.uid)) $ do
|
||||
div_ [class_ "category", id_ (categoryNodeId category)] $ do
|
||||
renderCategoryInfo category
|
||||
renderCategoryStatus category
|
||||
renderCategoryNotes category
|
||||
itemsNode <- div_ [class_ "items"] $ do
|
||||
mapM_ (renderItem category) (category^.items)
|
||||
@ -56,31 +55,16 @@ renderCategory category = cached (CacheCategory (category^.uid)) $ do
|
||||
-- Helpers
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
-- | Render the category status banner that is shown on the page of each
|
||||
-- unfinished category.
|
||||
renderCategoryStatus :: MonadIO m => Category -> HtmlT m ()
|
||||
renderCategoryStatus category = do
|
||||
case category^.status of
|
||||
CategoryFinished -> return ()
|
||||
CategoryWIP -> catBanner $ do
|
||||
"This category is a work in progress"
|
||||
CategoryStub -> catBanner $ do
|
||||
"This category is a stub, contributions are welcome!"
|
||||
where
|
||||
catBanner :: MonadIO m => HtmlT m () -> HtmlT m ()
|
||||
catBanner divContent = do
|
||||
div_ [class_ "category-status-banner"] $
|
||||
strong_ divContent
|
||||
|
||||
-- | Render info about the category (the header with category name + the edit
|
||||
-- form).
|
||||
-- form + possibly status banner).
|
||||
renderCategoryInfo :: MonadIO m => Category -> HtmlT m ()
|
||||
renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
||||
let thisId = "category-info-" <> uidToText (category^.uid)
|
||||
this = JS.selectId thisId
|
||||
div_ [id_ thisId, class_ "category-info"] $ do
|
||||
|
||||
section "normal" [shown, noScriptShown] $ h2_ $ do
|
||||
section "normal" [shown, noScriptShown] $ do
|
||||
h2_ $ do
|
||||
-- TODO: this link shouldn't be absolute [absolute-links]
|
||||
span_ [class_ "controls"] $
|
||||
a_ [class_ "category-feed",
|
||||
@ -98,6 +82,7 @@ renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
||||
emptySpan "1em"
|
||||
textButton "delete" $
|
||||
JS.deleteCategoryAndRedirect [category^.uid]
|
||||
renderCategoryStatus category
|
||||
|
||||
section "editing" [] $ do
|
||||
let formSubmitHandler formNode =
|
||||
@ -149,6 +134,22 @@ renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
||||
button "Cancel" [class_ "cancel"] $
|
||||
JS.switchSection (this, "normal" :: Text)
|
||||
|
||||
-- | Render the category status banner that is shown on the page of each
|
||||
-- unfinished category.
|
||||
renderCategoryStatus :: MonadIO m => Category -> HtmlT m ()
|
||||
renderCategoryStatus category = do
|
||||
case category^.status of
|
||||
CategoryFinished -> return ()
|
||||
CategoryWIP -> catBanner $ do
|
||||
"This category is a work in progress"
|
||||
CategoryStub -> catBanner $ do
|
||||
"This category is a stub, contributions are welcome!"
|
||||
where
|
||||
catBanner :: MonadIO m => HtmlT m () -> HtmlT m ()
|
||||
catBanner divContent = do
|
||||
div_ [class_ "category-status-banner"] $
|
||||
strong_ divContent
|
||||
|
||||
-- | Render category notes (or “description”).
|
||||
renderCategoryNotes :: MonadIO m => Category -> HtmlT m ()
|
||||
renderCategoryNotes category = cached (CacheCategoryNotes (category^.uid)) $ do
|
||||
|
Loading…
Reference in New Issue
Block a user