1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-24 13:26:08 +03:00

Make new items editable by default

This commit is contained in:
Artyom 2016-02-25 17:39:41 +03:00
parent 501efae542
commit 253150c213

View File

@ -157,10 +157,6 @@ renderMethods = Spock.subcomponent "render" $ do
category <- withGlobal $ use (categoryById catId) category <- withGlobal $ use (categoryById catId)
renderMode <- param' "mode" renderMode <- param' "mode"
lucid $ renderCategoryNotes renderMode category lucid $ renderCategoryNotes renderMode category
-- Item
Spock.get itemVar $ \itemId -> do
item <- withGlobal $ use (itemById itemId)
lucid $ renderItem item
-- Item info -- Item info
Spock.get (itemVar <//> "info") $ \itemId -> do Spock.get (itemVar <//> "info") $ \itemId -> do
item <- withGlobal $ use (itemById itemId) item <- withGlobal $ use (itemById itemId)
@ -246,7 +242,7 @@ addMethods = Spock.subcomponent "add" $ do
-- TODO: maybe do something if the category doesn't exist (e.g. has been -- TODO: maybe do something if the category doesn't exist (e.g. has been
-- already deleted) -- already deleted)
withGlobal $ categoryById catId . items %= (++ [newItem]) withGlobal $ categoryById catId . items %= (++ [newItem])
lucid $ renderItem newItem lucid $ renderItem Editable newItem
-- Pro (argument in favor of a library) -- Pro (argument in favor of a library)
Spock.post (itemVar <//> "pro") $ \itemId -> do Spock.post (itemVar <//> "pro") $ \itemId -> do
content' <- param' "content" content' <- param' "content"
@ -395,7 +391,7 @@ renderCategory category =
renderCategoryTitle Editable category renderCategoryTitle Editable category
renderCategoryNotes Editable category renderCategoryNotes Editable category
itemsNode <- div_ [class_ "items"] $ do itemsNode <- div_ [class_ "items"] $ do
mapM_ renderItem (category^.items) mapM_ (renderItem Normal) (category^.items)
thisNode thisNode
textInput [placeholder_ "add an item"] $ textInput [placeholder_ "add an item"] $
JS.addLibrary (itemsNode, category^.uid, inputValue) <> clearInput JS.addLibrary (itemsNode, category^.uid, inputValue) <> clearInput
@ -403,11 +399,16 @@ renderCategory category =
-- TODO: add arrows for moving items left-and-right in the category (or sort -- TODO: add arrows for moving items left-and-right in the category (or sort
-- them by popularity?) -- them by popularity?)
renderItem :: Item -> HtmlT IO () renderItem :: Editable -> Item -> HtmlT IO ()
renderItem item = renderItem editable item =
div_ [class_ "item"] $ do div_ [class_ "item"] $ do
renderItemInfo Editable item case editable of
renderItemTraits Normal item Normal -> do
renderItemInfo Editable item
renderItemTraits Normal item
Editable -> do
renderItemInfo Editable item
renderItemTraits Editable item
-- TODO: warn when a library isn't on Hackage but is supposed to be -- TODO: warn when a library isn't on Hackage but is supposed to be
-- TODO: give a link to oldest available docs when the new docs aren't there -- TODO: give a link to oldest available docs when the new docs aren't there