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,
|
renderCategory,
|
||||||
|
|
||||||
-- * Helpers
|
-- * Helpers
|
||||||
renderCategoryStatus,
|
|
||||||
renderCategoryInfo,
|
renderCategoryInfo,
|
||||||
|
renderCategoryStatus,
|
||||||
renderCategoryNotes,
|
renderCategoryNotes,
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@ -40,7 +40,6 @@ renderCategory :: MonadIO m => Category -> HtmlT m ()
|
|||||||
renderCategory category = cached (CacheCategory (category^.uid)) $ do
|
renderCategory category = cached (CacheCategory (category^.uid)) $ do
|
||||||
div_ [class_ "category", id_ (categoryNodeId category)] $ do
|
div_ [class_ "category", id_ (categoryNodeId category)] $ do
|
||||||
renderCategoryInfo category
|
renderCategoryInfo category
|
||||||
renderCategoryStatus category
|
|
||||||
renderCategoryNotes category
|
renderCategoryNotes category
|
||||||
itemsNode <- div_ [class_ "items"] $ do
|
itemsNode <- div_ [class_ "items"] $ do
|
||||||
mapM_ (renderItem category) (category^.items)
|
mapM_ (renderItem category) (category^.items)
|
||||||
@ -56,48 +55,34 @@ renderCategory category = cached (CacheCategory (category^.uid)) $ do
|
|||||||
-- Helpers
|
-- 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
|
-- | Render info about the category (the header with category name + the edit
|
||||||
-- form).
|
-- form + possibly status banner).
|
||||||
renderCategoryInfo :: MonadIO m => Category -> HtmlT m ()
|
renderCategoryInfo :: MonadIO m => Category -> HtmlT m ()
|
||||||
renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
||||||
let thisId = "category-info-" <> uidToText (category^.uid)
|
let thisId = "category-info-" <> uidToText (category^.uid)
|
||||||
this = JS.selectId thisId
|
this = JS.selectId thisId
|
||||||
div_ [id_ thisId, class_ "category-info"] $ do
|
div_ [id_ thisId, class_ "category-info"] $ do
|
||||||
|
|
||||||
section "normal" [shown, noScriptShown] $ h2_ $ do
|
section "normal" [shown, noScriptShown] $ do
|
||||||
-- TODO: this link shouldn't be absolute [absolute-links]
|
h2_ $ do
|
||||||
span_ [class_ "controls"] $
|
-- TODO: this link shouldn't be absolute [absolute-links]
|
||||||
a_ [class_ "category-feed",
|
span_ [class_ "controls"] $
|
||||||
href_ ("/haskell/feed/category/" <> uidToText (category^.uid))] $
|
a_ [class_ "category-feed",
|
||||||
img_ [src_ "/rss-alt.svg",
|
href_ ("/haskell/feed/category/" <> uidToText (category^.uid))] $
|
||||||
alt_ "category feed", title_ "category feed"]
|
img_ [src_ "/rss-alt.svg",
|
||||||
a_ [href_ (categoryLink category), class_ "category-title"] $
|
alt_ "category feed", title_ "category feed"]
|
||||||
toHtml (category^.title)
|
a_ [href_ (categoryLink category), class_ "category-title"] $
|
||||||
emptySpan "1em"
|
toHtml (category^.title)
|
||||||
span_ [class_ "group"] $
|
emptySpan "1em"
|
||||||
toHtml (category^.group_)
|
span_ [class_ "group"] $
|
||||||
emptySpan "1em"
|
toHtml (category^.group_)
|
||||||
textButton "edit" $
|
emptySpan "1em"
|
||||||
JS.switchSection (this, "editing" :: Text)
|
textButton "edit" $
|
||||||
emptySpan "1em"
|
JS.switchSection (this, "editing" :: Text)
|
||||||
textButton "delete" $
|
emptySpan "1em"
|
||||||
JS.deleteCategoryAndRedirect [category^.uid]
|
textButton "delete" $
|
||||||
|
JS.deleteCategoryAndRedirect [category^.uid]
|
||||||
|
renderCategoryStatus category
|
||||||
|
|
||||||
section "editing" [] $ do
|
section "editing" [] $ do
|
||||||
let formSubmitHandler formNode =
|
let formSubmitHandler formNode =
|
||||||
@ -149,6 +134,22 @@ renderCategoryInfo category = cached (CacheCategoryInfo (category^.uid)) $ do
|
|||||||
button "Cancel" [class_ "cancel"] $
|
button "Cancel" [class_ "cancel"] $
|
||||||
JS.switchSection (this, "normal" :: Text)
|
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”).
|
-- | Render category notes (or “description”).
|
||||||
renderCategoryNotes :: MonadIO m => Category -> HtmlT m ()
|
renderCategoryNotes :: MonadIO m => Category -> HtmlT m ()
|
||||||
renderCategoryNotes category = cached (CacheCategoryNotes (category^.uid)) $ do
|
renderCategoryNotes category = cached (CacheCategoryNotes (category^.uid)) $ do
|
||||||
|
Loading…
Reference in New Issue
Block a user