1
1
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:
Artyom 2016-04-22 01:26:45 +03:00
parent dc2fc3d8e0
commit e279786b55
2 changed files with 6 additions and 11 deletions

View File

@ -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";
});
}
|]

View File

@ -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)