All delete buttons now soft-delete with toast prompt to undo

This commit is contained in:
Thaum
2015-03-25 07:33:27 +00:00
parent 46b836e707
commit d573b325d5
12 changed files with 34 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ this.GlobalUI = (function() {
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,
@@ -20,15 +20,15 @@ this.GlobalUI = (function() {
id: id,
collection: collection
}
})
}
});
};
GlobalUI.setDialog = function(opts){
this.dialog = $("[global-dialog]")[0];
Session.set("global.ui.dialogHeader", opts.heading);
Session.set("global.ui.dialogData", opts.data);
Session.set("global.ui.dialogTemplate", opts.template);
Session.set("global.ui.dialogFullOnMobile", opts.fullOnMobile != null);
Session.set("global.ui.dialogFullOnMobile", opts.fullOnMobile !== null);
};
GlobalUI.showDialog = function(opts) {
@@ -36,7 +36,7 @@ this.GlobalUI = (function() {
Session.set("global.ui.dialogHeader", opts.heading);
Session.set("global.ui.dialogData", opts.data);
Session.set("global.ui.dialogTemplate", opts.template);
Session.set("global.ui.dialogFullOnMobile", opts.fullOnMobile != null);
Session.set("global.ui.dialogFullOnMobile", opts.fullOnMobile !== null);
return Tracker.afterFlush((function(_this) {
return function() {
return _this.dialog.open();

View File

@@ -144,7 +144,8 @@ Template.regularEffectValue.helpers({
Template.effectEdit.events({
"tap #deleteEffect": function(event){
Effects.remove(this._id);
Effects.softRemove(this._id);
GlobalUI.deletedToast(this._id, "Effects", "Effect");
},
"core-select #statGroupDropDown": function(event){
var detail = event.originalEvent.detail;

View File

@@ -3,8 +3,9 @@ Template.featureDialog.events({
Features.update(instance.data.featureId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
Features.remove(instance.data.featureId);
GlobalUI.closeDetail()
Features.softRemove(instance.data.featureId);
GlobalUI.deletedToast(instance.data.featureId, "Features", "Feature");
GlobalUI.closeDetail();
},
"change #featureNameInput": function(event){
var name = Template.instance().find("#featureNameInput").value;

View File

@@ -9,7 +9,8 @@ Template.containerDialog.events({
Containers.update(instance.data.containerId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
Containers.remove(instance.data.containerId);
Containers.softRemove(instance.data.containerId);
GlobalUI.deletedToast(instance.data.containerId, "Containers", "Container and contents");
GlobalUI.closeDetail()
},
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors

View File

@@ -38,7 +38,8 @@ Template.itemDialog.events({
Items.update(instance.data.itemId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
Items.remove(instance.data.itemId);
Items.softRemove(instance.data.itemId);
GlobalUI.deletedToast(instance.data.itemId, "Items", "Item");
GlobalUI.closeDetail()
},
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors

View File

@@ -1,6 +1,7 @@
Template.classDialog.events({
"tap #deleteButton": function(event, instance){
Classes.remove(instance.data.classId);
Classes.softRemove(instance.data.classId);
GlobalUI.deletedToast(instance.data.classId, "Classes", "Class");
GlobalUI.closeDetail()
},
"change #classNameInput": function(event){

View File

@@ -1,6 +1,7 @@
Template.experienceDialog.events({
"tap #deleteButton": function(event, instance){
Experiences.remove(instance.data.experienceId);
Experiences.softRemove(instance.data.experienceId);
GlobalUI.deletedToast(instance.data.experienceId, "Experiences", "Experience");
GlobalUI.closeDetail()
},
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors

View File

@@ -3,7 +3,8 @@ Template.noteDialog.events({
Notes.update(instance.data.noteId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
Notes.remove(instance.data.noteId);
Notes.softRemove(instance.data.noteId);
GlobalUI.deletedToast(instance.data.noteId, "Notes", "Note");
GlobalUI.closeDetail()
},
"change #noteNameInput, input #noteNameInput": function(event){

View File

@@ -38,7 +38,8 @@ Template.spellDialog.events({
Spells.update(instance.data.spellId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
Spells.remove(instance.data.spellId);
Spells.softRemove(instance.data.spellId);
GlobalUI.deletedToast(instance.data.spellId, "Spells", "Spell");
GlobalUI.closeDetail()
},
"change #spellNameInput, input #spellNameInput": function(event){

View File

@@ -3,7 +3,8 @@ Template.spellListDialog.events({
SpellLists.update(instance.data.spellListId, {$set: {color: event.color}});
},
"tap #deleteButton": function(event, instance){
SpellLists.remove(instance.data.spellListId);
SpellLists.softRemove(instance.data.spellListId);
GlobalUI.deletedToast(instance.data.spellListId, "SpellLists", "Spell list and contents");
GlobalUI.closeDetail()
},
//TODO clean up String -> num here so they don't need casting by Schema.clean

View File

@@ -78,9 +78,13 @@
{{/if}}
</paper-action-dialog>
<paper-toast global-toast>
{{#if session globalToastTemplate}}
<paper-toast global-toast duration="5000">
{{#if globalToastTemplate}}
{{> UI.dynamic template=globalToastTemplate data=globalToastData}}
{{else}}
<div>
No Toast template defined
</div>
{{/if}}
</paper-toast>
</template>

View File

@@ -1,7 +1,10 @@
Template.undoToast.events({
'tap #undoButton': function(event, instance){
var collection = window[this.collection];
if(!collection) return;
if(!collection){
console.warn("Collection with name ", this.collection, " could not be found");
return;
}
collection.restore(this.id);
}
});