Started implementing soft delete attacks, added delete toast
This commit is contained in:
@@ -3,12 +3,25 @@ this.GlobalUI = (function() {
|
|||||||
|
|
||||||
GlobalUI.dialog = {};
|
GlobalUI.dialog = {};
|
||||||
|
|
||||||
GlobalUI.toast = function(text, className) {
|
GlobalUI.toast = function(opts) {
|
||||||
var toast;
|
var toast;
|
||||||
toast = $("[global-toast]")[0];
|
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();
|
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){
|
GlobalUI.setDialog = function(opts){
|
||||||
this.dialog = $("[global-dialog]")[0];
|
this.dialog = $("[global-dialog]")[0];
|
||||||
@@ -110,6 +123,12 @@ Template.layout.helpers({
|
|||||||
},
|
},
|
||||||
globalDetailData: function(){
|
globalDetailData: function(){
|
||||||
return Session.get("global.ui.detailData");
|
return Session.get("global.ui.detailData");
|
||||||
|
},
|
||||||
|
globalToastTemplate: function(){
|
||||||
|
return Session.get("global.ui.toastTemplate");
|
||||||
|
},
|
||||||
|
globalToastData: function(){
|
||||||
|
return Session.get("global.ui.toastData");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ var damageTypes = ["bludgeoning", "piercing", "slashing", "acid", "cold", "fire"
|
|||||||
|
|
||||||
Template.attackEdit.events({
|
Template.attackEdit.events({
|
||||||
"tap #deleteAttack": function(event, instance){
|
"tap #deleteAttack": function(event, instance){
|
||||||
Attacks.remove(this._id);
|
Attacks.softRemove(this._id);
|
||||||
|
GlobalUI.deletedToast(this._id, "Attacks", "Attack");
|
||||||
},
|
},
|
||||||
"change #attackBonusInput": function(event){
|
"change #attackBonusInput": function(event){
|
||||||
var value = event.currentTarget.value;
|
var value = event.currentTarget.value;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
<link rel="import" href="/components/paper-slider-diff/paper-slider.html">
|
<link rel="import" href="/components/paper-slider-diff/paper-slider.html">
|
||||||
<link rel="import" href="/components/paper-spinner/paper-spinner.html">
|
<link rel="import" href="/components/paper-spinner/paper-spinner.html">
|
||||||
<link rel="import" href="/components/paper-tabs/paper-tabs.html">
|
<link rel="import" href="/components/paper-tabs/paper-tabs.html">
|
||||||
|
<link rel="import" href="/components/paper-toast/paper-toast.html">
|
||||||
<link rel="import" href="/components/paper-toggle-button/paper-toggle-button.html">
|
<link rel="import" href="/components/paper-toggle-button/paper-toggle-button.html">
|
||||||
|
|
||||||
<!--custom components-->
|
<!--custom components-->
|
||||||
|
|||||||
@@ -78,7 +78,9 @@
|
|||||||
{{/if}}
|
{{/if}}
|
||||||
</paper-action-dialog>
|
</paper-action-dialog>
|
||||||
|
|
||||||
<paper-toast global-toast></paper-toast>
|
<paper-toast global-toast>
|
||||||
<core-overlay></core-overlay>
|
{{#if session globalToastTemplate}}
|
||||||
<core-overlay-layer></core-overlay-layer>
|
{{> UI.dynamic template=globalToastTemplate data=globalToastData}}
|
||||||
|
{{/if}}
|
||||||
|
</paper-toast>
|
||||||
</template>
|
</template>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<template name="undoToast">
|
||||||
|
<div id="undoButton" style="color: #eeff41;">Undo</div>
|
||||||
|
</template>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Template.undoToast.events({
|
||||||
|
'tap #undoButton': function(event, instance){
|
||||||
|
var collection = window[this.collection];
|
||||||
|
if(!collection) return;
|
||||||
|
collection.restore(this.id);
|
||||||
|
}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user