1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-27 10:10:50 +03:00

Add deletion confirmation

This commit is contained in:
Artyom 2016-02-24 21:08:45 +03:00
parent 85a09e4a22
commit 75067a7748
2 changed files with 8 additions and 6 deletions

View File

@ -278,10 +278,12 @@ moveTraitDown =
deleteTrait :: JSFunction a => a
deleteTrait =
makeJSFunction "deleteTrait" ["itemId", "traitId", "traitNode"]
makeJSFunction "deleteTrait" ["itemId", "traitId", "traitNode", "traitText"]
[text|
if (confirm("Confirm deletion: “"+traitText+"")) {
$.post("/delete/item/"+itemId+"/trait/"+traitId);
$(traitNode).remove();
}
|]
-- When adding a function, don't forget to add it to 'allJSFunctions'!

View File

@ -469,10 +469,10 @@ renderTrait Editable itemId trait = li_ $ do
imgButton "/arrow-thick-bottom.svg" [width_ "12px"] $
JS.moveTraitDown (itemId, trait^.uid, this)
-- TODO: these 3 icons in a row don't look nice
-- TODO: it's too easy to delete something accidentally there should be
-- some way to revert everything
-- TODO: there should be some way to undelete things (e.g. a list of
-- deleted traits under each item)
imgButton "/x.svg" [width_ "12px"] $
JS.deleteTrait (itemId, trait^.uid, this)
JS.deleteTrait (itemId, trait^.uid, this, trait^.content)
textButton "edit" $
JS.setTraitMode (this, itemId, trait^.uid, InEdit)
renderTrait InEdit itemId trait = li_ $ do