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 :: JSFunction a => a
deleteTrait = deleteTrait =
makeJSFunction "deleteTrait" ["itemId", "traitId", "traitNode"] makeJSFunction "deleteTrait" ["itemId", "traitId", "traitNode", "traitText"]
[text| [text|
if (confirm("Confirm deletion: “"+traitText+"")) {
$.post("/delete/item/"+itemId+"/trait/"+traitId); $.post("/delete/item/"+itemId+"/trait/"+traitId);
$(traitNode).remove(); $(traitNode).remove();
}
|] |]
-- When adding a function, don't forget to add it to 'allJSFunctions'! -- 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"] $ imgButton "/arrow-thick-bottom.svg" [width_ "12px"] $
JS.moveTraitDown (itemId, trait^.uid, this) JS.moveTraitDown (itemId, trait^.uid, this)
-- TODO: these 3 icons in a row don't look nice -- TODO: these 3 icons in a row don't look nice
-- TODO: it's too easy to delete something accidentally there should be -- TODO: there should be some way to undelete things (e.g. a list of
-- some way to revert everything -- deleted traits under each item)
imgButton "/x.svg" [width_ "12px"] $ imgButton "/x.svg" [width_ "12px"] $
JS.deleteTrait (itemId, trait^.uid, this) JS.deleteTrait (itemId, trait^.uid, this, trait^.content)
textButton "edit" $ textButton "edit" $
JS.setTraitMode (this, itemId, trait^.uid, InEdit) JS.setTraitMode (this, itemId, trait^.uid, InEdit)
renderTrait InEdit itemId trait = li_ $ do renderTrait InEdit itemId trait = li_ $ do