mirror of
https://github.com/aelve/guide.git
synced 2024-12-24 21:35:06 +03:00
Rename descriptions to notes
This commit is contained in:
parent
1e2f13df01
commit
29c84cfc0b
59
src/Main.hs
59
src/Main.hs
@ -94,7 +94,7 @@ traitById uid' = singular $
|
|||||||
data Category = Category {
|
data Category = Category {
|
||||||
_categoryUid :: Uid,
|
_categoryUid :: Uid,
|
||||||
_categoryTitle :: Text,
|
_categoryTitle :: Text,
|
||||||
_categoryDescription :: Text,
|
_categoryNotes :: Text,
|
||||||
_categoryItems :: [Item] }
|
_categoryItems :: [Item] }
|
||||||
|
|
||||||
makeFields ''Category
|
makeFields ''Category
|
||||||
@ -137,7 +137,7 @@ sampleState = do
|
|||||||
let lensesCategory = Category {
|
let lensesCategory = Category {
|
||||||
_categoryUid = 1,
|
_categoryUid = 1,
|
||||||
_categoryTitle = "lenses",
|
_categoryTitle = "lenses",
|
||||||
_categoryDescription = "Lenses are first-class composable accessors.",
|
_categoryNotes = "Lenses are first-class composable accessors.",
|
||||||
_categoryItems = [lensItem, microlensItem] }
|
_categoryItems = [lensItem, microlensItem] }
|
||||||
|
|
||||||
GlobalState {_categories = [lensesCategory]}
|
GlobalState {_categories = [lensesCategory]}
|
||||||
@ -164,11 +164,11 @@ renderMethods = Spock.subcomponent "render" $ do
|
|||||||
category <- withGlobal $ use (categoryById catId)
|
category <- withGlobal $ use (categoryById catId)
|
||||||
renderMode <- param' "mode"
|
renderMode <- param' "mode"
|
||||||
lucid $ renderCategoryTitle renderMode category
|
lucid $ renderCategoryTitle renderMode category
|
||||||
-- Description of a category
|
-- Notes for a category
|
||||||
Spock.get (categoryVar <//> "description") $ \catId -> do
|
Spock.get (categoryVar <//> "notes") $ \catId -> do
|
||||||
category <- withGlobal $ use (categoryById catId)
|
category <- withGlobal $ use (categoryById catId)
|
||||||
renderMode <- param' "mode"
|
renderMode <- param' "mode"
|
||||||
lucid $ renderCategoryDescription renderMode category
|
lucid $ renderCategoryNotes renderMode category
|
||||||
-- Item
|
-- Item
|
||||||
Spock.get itemVar $ \itemId -> do
|
Spock.get itemVar $ \itemId -> do
|
||||||
item <- withGlobal $ use (itemById itemId)
|
item <- withGlobal $ use (itemById itemId)
|
||||||
@ -198,13 +198,13 @@ setMethods = Spock.subcomponent "set" $ do
|
|||||||
categoryById catId . title .= content'
|
categoryById catId . title .= content'
|
||||||
use (categoryById catId)
|
use (categoryById catId)
|
||||||
lucid $ renderCategoryTitle Editable changedCategory
|
lucid $ renderCategoryTitle Editable changedCategory
|
||||||
-- Description of a category
|
-- Notes for a category
|
||||||
Spock.post (categoryVar <//> "description") $ \catId -> do
|
Spock.post (categoryVar <//> "notes") $ \catId -> do
|
||||||
content' <- param' "content"
|
content' <- param' "content"
|
||||||
changedCategory <- withGlobal $ do
|
changedCategory <- withGlobal $ do
|
||||||
categoryById catId . description .= content'
|
categoryById catId . notes .= content'
|
||||||
use (categoryById catId)
|
use (categoryById catId)
|
||||||
lucid $ renderCategoryDescription Editable changedCategory
|
lucid $ renderCategoryNotes Editable changedCategory
|
||||||
-- Item info
|
-- Item info
|
||||||
Spock.post (itemVar <//> "info") $ \itemId -> do
|
Spock.post (itemVar <//> "info") $ \itemId -> do
|
||||||
name' <- T.strip <$> param' "name"
|
name' <- T.strip <$> param' "name"
|
||||||
@ -240,7 +240,7 @@ addMethods = Spock.subcomponent "add" $ do
|
|||||||
let newCategory = Category {
|
let newCategory = Category {
|
||||||
_categoryUid = uid',
|
_categoryUid = uid',
|
||||||
_categoryTitle = content',
|
_categoryTitle = content',
|
||||||
_categoryDescription = "<write a description here>",
|
_categoryNotes = "(write some notes here, describe the category, etc)",
|
||||||
_categoryItems = [] }
|
_categoryItems = [] }
|
||||||
withGlobal $ categories %= (++ [newCategory])
|
withGlobal $ categories %= (++ [newCategory])
|
||||||
lucid $ renderCategory newCategory
|
lucid $ renderCategory newCategory
|
||||||
@ -358,27 +358,26 @@ renderCategoryTitle editable category =
|
|||||||
textButton "cancel" $
|
textButton "cancel" $
|
||||||
js_setCategoryTitleMode (titleNode, category^.uid, Editable)
|
js_setCategoryTitleMode (titleNode, category^.uid, Editable)
|
||||||
|
|
||||||
renderCategoryDescription :: Editable -> Category -> HtmlT IO ()
|
renderCategoryNotes :: Editable -> Category -> HtmlT IO ()
|
||||||
renderCategoryDescription editable category =
|
renderCategoryNotes editable category =
|
||||||
div_ $ do
|
div_ $ do
|
||||||
descrNode <- thisNode
|
this <- thisNode
|
||||||
case editable of
|
case editable of
|
||||||
Editable -> do
|
Editable -> do
|
||||||
renderMarkdownLong (category^.description)
|
renderMarkdownLong (category^.notes)
|
||||||
textButton "edit" $
|
textButton "edit" $
|
||||||
js_setCategoryDescriptionMode (descrNode, category^.uid, InEdit)
|
js_setCategoryNotesMode (this, category^.uid, InEdit)
|
||||||
InEdit -> do
|
InEdit -> do
|
||||||
let handler s = js_submitCategoryDescription
|
let handler s = js_submitCategoryNotes (this, category^.uid, s)
|
||||||
(descrNode, category^.uid, s)
|
input_ [type_ "text", value_ (category^.notes), onInputSubmit handler]
|
||||||
input_ [type_ "text", value_ (category^.description), onInputSubmit handler]
|
|
||||||
textButton "cancel" $
|
textButton "cancel" $
|
||||||
js_setCategoryDescriptionMode (descrNode, category^.uid, Editable)
|
js_setCategoryNotesMode (this, category^.uid, Editable)
|
||||||
|
|
||||||
renderCategory :: Category -> HtmlT IO ()
|
renderCategory :: Category -> HtmlT IO ()
|
||||||
renderCategory category =
|
renderCategory category =
|
||||||
div_ $ do
|
div_ $ do
|
||||||
renderCategoryTitle Editable category
|
renderCategoryTitle Editable category
|
||||||
renderCategoryDescription Editable category
|
renderCategoryNotes Editable category
|
||||||
itemsNode <- div_ [class_ "items"] $ do
|
itemsNode <- div_ [class_ "items"] $ do
|
||||||
mapM_ renderItem (category^.items)
|
mapM_ renderItem (category^.items)
|
||||||
thisNode
|
thisNode
|
||||||
@ -548,11 +547,11 @@ allJSFunctions = JS . T.unlines . map fromJS $ [
|
|||||||
js_addLibrary, js_addCategory,
|
js_addLibrary, js_addCategory,
|
||||||
js_addPro, js_addCon,
|
js_addPro, js_addCon,
|
||||||
-- Render-as-editable methods
|
-- Render-as-editable methods
|
||||||
js_setCategoryTitleMode, js_setCategoryDescriptionMode,
|
js_setCategoryTitleMode, js_setCategoryNotesMode,
|
||||||
js_setItemInfoMode, js_setItemTraitsMode,
|
js_setItemInfoMode, js_setItemTraitsMode,
|
||||||
js_setTraitMode,
|
js_setTraitMode,
|
||||||
-- Set methods
|
-- Set methods
|
||||||
js_submitCategoryTitle, js_submitCategoryDescription,
|
js_submitCategoryTitle, js_submitCategoryNotes,
|
||||||
js_submitTrait,
|
js_submitTrait,
|
||||||
js_submitItemInfo,
|
js_submitItemInfo,
|
||||||
-- Other things
|
-- Other things
|
||||||
@ -637,19 +636,19 @@ js_submitCategoryTitle =
|
|||||||
.done(replaceWithData(node));
|
.done(replaceWithData(node));
|
||||||
|]
|
|]
|
||||||
|
|
||||||
js_setCategoryDescriptionMode :: JSFunction a => a
|
js_setCategoryNotesMode :: JSFunction a => a
|
||||||
js_setCategoryDescriptionMode =
|
js_setCategoryNotesMode =
|
||||||
makeJSFunction "setCategoryDescriptionMode" ["node", "catId", "mode"]
|
makeJSFunction "setCategoryNotesMode" ["node", "catId", "mode"]
|
||||||
[text|
|
[text|
|
||||||
$.get("/render/category/"+catId+"/description", {mode: mode})
|
$.get("/render/category/"+catId+"/notes", {mode: mode})
|
||||||
.done(replaceWithData(node));
|
.done(replaceWithData(node));
|
||||||
|]
|
|]
|
||||||
|
|
||||||
js_submitCategoryDescription :: JSFunction a => a
|
js_submitCategoryNotes :: JSFunction a => a
|
||||||
js_submitCategoryDescription =
|
js_submitCategoryNotes =
|
||||||
makeJSFunction "submitCategoryDescription" ["node", "catId", "s"]
|
makeJSFunction "submitCategoryNotes" ["node", "catId", "s"]
|
||||||
[text|
|
[text|
|
||||||
$.post("/set/category/"+catId+"/description", {content: s})
|
$.post("/set/category/"+catId+"/notes", {content: s})
|
||||||
.done(replaceWithData(node));
|
.done(replaceWithData(node));
|
||||||
|]
|
|]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user