diff --git a/rpg-docs/client/globalHelpers/GlobalUI.js b/rpg-docs/client/globalHelpers/GlobalUI.js
index 387a2cf5..e8f2add9 100644
--- a/rpg-docs/client/globalHelpers/GlobalUI.js
+++ b/rpg-docs/client/globalHelpers/GlobalUI.js
@@ -3,12 +3,25 @@ this.GlobalUI = (function() {
GlobalUI.dialog = {};
- GlobalUI.toast = function(text, className) {
+ GlobalUI.toast = function(opts) {
var toast;
toast = $("[global-toast]")[0];
- toast.text = text;
+ toast.text = opts.text;
+ Session.set("global.ui.toastTemplate", opts.template);
+ Session.set("global.ui.toastData", opts.data);
return toast.show();
};
+
+ GlobalUI.deletedToast = function(id, collection, itemName){
+ GlobalUI.toast({
+ text: itemName? itemName + " deleted" : "Deleted item from" + collection,
+ template: "undoToast",
+ data: {
+ id: id,
+ collection: collection
+ }
+ })
+ }
GlobalUI.setDialog = function(opts){
this.dialog = $("[global-dialog]")[0];
@@ -110,6 +123,12 @@ Template.layout.helpers({
},
globalDetailData: function(){
return Session.get("global.ui.detailData");
+ },
+ globalToastTemplate: function(){
+ return Session.get("global.ui.toastTemplate");
+ },
+ globalToastData: function(){
+ return Session.get("global.ui.toastData");
}
});
diff --git a/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js
index 3141b228..7d3bd4ac 100644
--- a/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js
+++ b/rpg-docs/client/views/character/attacks/attackEdit/attackEdit.js
@@ -3,7 +3,8 @@ var damageTypes = ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire"
Template.attackEdit.events({
"tap #deleteAttack": function(event, instance){
- Attacks.remove(this._id);
+ Attacks.softRemove(this._id);
+ GlobalUI.deletedToast(this._id, "Attacks", "Attack");
},
"change #attackBonusInput": function(event){
var value = event.currentTarget.value;
diff --git a/rpg-docs/client/views/layout/imports.html b/rpg-docs/client/views/layout/imports.html
index 2f2c53ff..273f22d5 100644
--- a/rpg-docs/client/views/layout/imports.html
+++ b/rpg-docs/client/views/layout/imports.html
@@ -33,6 +33,7 @@
+
diff --git a/rpg-docs/client/views/layout/layout.html b/rpg-docs/client/views/layout/layout.html
index 465cbaa2..5c154ab2 100644
--- a/rpg-docs/client/views/layout/layout.html
+++ b/rpg-docs/client/views/layout/layout.html
@@ -78,7 +78,9 @@
{{/if}}
-
-
-
+
+ {{#if session globalToastTemplate}}
+ {{> UI.dynamic template=globalToastTemplate data=globalToastData}}
+ {{/if}}
+
\ No newline at end of file
diff --git a/rpg-docs/client/views/paperTemplates/undoToast/undoToast.html b/rpg-docs/client/views/paperTemplates/undoToast/undoToast.html
new file mode 100644
index 00000000..f4f10501
--- /dev/null
+++ b/rpg-docs/client/views/paperTemplates/undoToast/undoToast.html
@@ -0,0 +1,3 @@
+
+ Undo
+
\ No newline at end of file
diff --git a/rpg-docs/client/views/paperTemplates/undoToast/undoToast.js b/rpg-docs/client/views/paperTemplates/undoToast/undoToast.js
new file mode 100644
index 00000000..4a891177
--- /dev/null
+++ b/rpg-docs/client/views/paperTemplates/undoToast/undoToast.js
@@ -0,0 +1,7 @@
+Template.undoToast.events({
+ 'tap #undoButton': function(event, instance){
+ var collection = window[this.collection];
+ if(!collection) return;
+ collection.restore(this.id);
+ }
+});