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,
|
||||
submitTrait,
|
||||
-- Other things
|
||||
deleteCategory,
|
||||
deleteCategoryAndRedirect,
|
||||
moveTraitUp, moveTraitDown, deleteTrait,
|
||||
moveItemUp, moveItemDown, deleteItem,
|
||||
-- Admin things
|
||||
@ -551,14 +551,14 @@ submitItemInfo =
|
||||
});
|
||||
|]
|
||||
|
||||
deleteCategory :: JSFunction a => a
|
||||
deleteCategory =
|
||||
makeJSFunction "deleteCategory" ["catId", "catNode"]
|
||||
deleteCategoryAndRedirect :: JSFunction a => a
|
||||
deleteCategoryAndRedirect =
|
||||
makeJSFunction "deleteCategoryAndRedirect" ["catId"]
|
||||
[text|
|
||||
if (confirm("Confirm deletion?")) {
|
||||
$.post("/haskell/delete/category/"+catId)
|
||||
.done(function () {
|
||||
fadeOutAndRemove(catNode);
|
||||
window.location.href = "/haskell";
|
||||
});
|
||||
}
|
||||
|]
|
||||
|
@ -562,10 +562,8 @@ renderCategoryTitle category = do
|
||||
textButton "edit" $
|
||||
JS.switchSection (this, "editing" :: Text)
|
||||
emptySpan "1em"
|
||||
-- TODO: when on the category page, deleting the category should
|
||||
-- redirect to the main page
|
||||
textButton "delete" $
|
||||
JS.deleteCategory (category^.uid, categoryNode category)
|
||||
JS.deleteCategoryAndRedirect [category^.uid]
|
||||
|
||||
sectionSpan "editing" [] $ do
|
||||
textInput [
|
||||
@ -1118,9 +1116,6 @@ itemNode = JS.selectId . itemNodeId
|
||||
categoryNodeId :: Category -> Text
|
||||
categoryNodeId category = "category-" <> uidToText (category^.uid)
|
||||
|
||||
categoryNode :: Category -> JQuerySelector
|
||||
categoryNode = JS.selectId . categoryNodeId
|
||||
|
||||
itemLink :: Category -> Item -> Text
|
||||
itemLink category item =
|
||||
format "/haskell/{}#{}" (categorySlug category, itemNodeId item)
|
||||
|
Loading…
Reference in New Issue
Block a user