mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 12:15:06 +03:00
Put new categories at the beginning of the list
This commit is contained in:
parent
253150c213
commit
4211e3c4fc
11
src/JS.hs
11
src/JS.hs
@ -32,7 +32,7 @@ newtype JS = JS {fromJS :: Text}
|
||||
allJSFunctions :: JS
|
||||
allJSFunctions = JS . T.unlines . map fromJS $ [
|
||||
-- Utilities
|
||||
replaceWithData, appendData,
|
||||
replaceWithData, prependData, appendData,
|
||||
moveNodeUp, moveNodeDown,
|
||||
-- Search
|
||||
search,
|
||||
@ -116,6 +116,13 @@ replaceWithData =
|
||||
return function(data) {$(node).replaceWith(data);};
|
||||
|]
|
||||
|
||||
prependData :: JSFunction a => a
|
||||
prependData =
|
||||
makeJSFunction "prependData" ["node"]
|
||||
[text|
|
||||
return function(data) {$(node).prepend(data);};
|
||||
|]
|
||||
|
||||
appendData :: JSFunction a => a
|
||||
appendData =
|
||||
makeJSFunction "appendData" ["node"]
|
||||
@ -165,7 +172,7 @@ addCategory =
|
||||
makeJSFunction "addCategory" ["node", "s"]
|
||||
[text|
|
||||
$.post("/add/category", {content: s})
|
||||
.done(appendData(node));
|
||||
.done(prependData(node));
|
||||
|]
|
||||
|
||||
-- | Add a new library to some category.
|
||||
|
@ -226,7 +226,7 @@ addMethods = Spock.subcomponent "add" $ do
|
||||
_categoryTitle = content',
|
||||
_categoryNotes = "(write some notes here, describe the category, etc)",
|
||||
_categoryItems = [] }
|
||||
withGlobal $ categories %= (++ [newCategory])
|
||||
withGlobal $ categories %= (newCategory :)
|
||||
lucid $ renderCategory newCategory
|
||||
-- New library in a category
|
||||
Spock.post (categoryVar <//> "library") $ \catId -> do
|
||||
|
Loading…
Reference in New Issue
Block a user