diff --git a/src/JS.hs b/src/JS.hs index a1ce2bb..d3576f3 100644 --- a/src/JS.hs +++ b/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"; }); } |] diff --git a/src/View.hs b/src/View.hs index 64f3637..6e9d607 100644 --- a/src/View.hs +++ b/src/View.hs @@ -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)