mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 21:13:07 +03:00
When deleting categories, redirect to main page
This commit is contained in:
parent
dc2fc3d8e0
commit
e279786b55
10
src/JS.hs
10
src/JS.hs
@ -60,7 +60,7 @@ allJSFunctions = JS . T.unlines . map fromJS $ [
|
|||||||
submitItemInfo, submitItemNotes, submitItemEcosystem,
|
submitItemInfo, submitItemNotes, submitItemEcosystem,
|
||||||
submitTrait,
|
submitTrait,
|
||||||
-- Other things
|
-- Other things
|
||||||
deleteCategory,
|
deleteCategoryAndRedirect,
|
||||||
moveTraitUp, moveTraitDown, deleteTrait,
|
moveTraitUp, moveTraitDown, deleteTrait,
|
||||||
moveItemUp, moveItemDown, deleteItem,
|
moveItemUp, moveItemDown, deleteItem,
|
||||||
-- Admin things
|
-- Admin things
|
||||||
@ -551,14 +551,14 @@ submitItemInfo =
|
|||||||
});
|
});
|
||||||
|]
|
|]
|
||||||
|
|
||||||
deleteCategory :: JSFunction a => a
|
deleteCategoryAndRedirect :: JSFunction a => a
|
||||||
deleteCategory =
|
deleteCategoryAndRedirect =
|
||||||
makeJSFunction "deleteCategory" ["catId", "catNode"]
|
makeJSFunction "deleteCategoryAndRedirect" ["catId"]
|
||||||
[text|
|
[text|
|
||||||
if (confirm("Confirm deletion?")) {
|
if (confirm("Confirm deletion?")) {
|
||||||
$.post("/haskell/delete/category/"+catId)
|
$.post("/haskell/delete/category/"+catId)
|
||||||
.done(function () {
|
.done(function () {
|
||||||
fadeOutAndRemove(catNode);
|
window.location.href = "/haskell";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|]
|
|]
|
||||||
|
@ -562,10 +562,8 @@ renderCategoryTitle category = do
|
|||||||
textButton "edit" $
|
textButton "edit" $
|
||||||
JS.switchSection (this, "editing" :: Text)
|
JS.switchSection (this, "editing" :: Text)
|
||||||
emptySpan "1em"
|
emptySpan "1em"
|
||||||
-- TODO: when on the category page, deleting the category should
|
|
||||||
-- redirect to the main page
|
|
||||||
textButton "delete" $
|
textButton "delete" $
|
||||||
JS.deleteCategory (category^.uid, categoryNode category)
|
JS.deleteCategoryAndRedirect [category^.uid]
|
||||||
|
|
||||||
sectionSpan "editing" [] $ do
|
sectionSpan "editing" [] $ do
|
||||||
textInput [
|
textInput [
|
||||||
@ -1118,9 +1116,6 @@ itemNode = JS.selectId . itemNodeId
|
|||||||
categoryNodeId :: Category -> Text
|
categoryNodeId :: Category -> Text
|
||||||
categoryNodeId category = "category-" <> uidToText (category^.uid)
|
categoryNodeId category = "category-" <> uidToText (category^.uid)
|
||||||
|
|
||||||
categoryNode :: Category -> JQuerySelector
|
|
||||||
categoryNode = JS.selectId . categoryNodeId
|
|
||||||
|
|
||||||
itemLink :: Category -> Item -> Text
|
itemLink :: Category -> Item -> Text
|
||||||
itemLink category item =
|
itemLink category item =
|
||||||
format "/haskell/{}#{}" (categorySlug category, itemNodeId item)
|
format "/haskell/{}#{}" (categorySlug category, itemNodeId item)
|
||||||
|
Loading…
Reference in New Issue
Block a user