1
1
mirror of https://github.com/aelve/guide.git synced 2024-12-18 02:11:33 +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, 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";
}); });
} }
|] |]

View File

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