{{#unless editing}}
{{> UI.contentBlock}}
{{else}}
diff --git a/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.html b/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.html
new file mode 100644
index 00000000..b90019f5
--- /dev/null
+++ b/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.html
@@ -0,0 +1,23 @@
+
+
+
+
+
+ {{title}}
+ {{#unless hideDelete}}
+
+
+ {{/unless}}
+ {{#unless hideColor}}
+ {{> colorDropdown}}
+ {{/unless}}
+
+
+ {{> UI.contentBlock}}
+
+
+
diff --git a/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.js b/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.js
new file mode 100644
index 00000000..b50f622f
--- /dev/null
+++ b/rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.js
@@ -0,0 +1,5 @@
+Template.baseEditDialog.events({
+ "tap #backButton": function(){
+ popDialogStack();
+ },
+});
diff --git a/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.js b/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.js
index 4b45aa4a..93177238 100644
--- a/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.js
+++ b/rpg-docs/client/views/paperTemplates/dialogStack/dialogStack.js
@@ -13,14 +13,76 @@ pushDialogStack = function({template, data, element, returnElement, callback}){
returnElement,
callback,
});
+
+ updateHistory();
};
popDialogStack = function(result){
+ if (history && history.state && history.state.openDialogs){
+ history.back();
+ } else {
+ popDialogStackAction();
+ }
+}
+
+window.onpopstate = function(event){
+ let state = event.state;
+ let numDialogs = dialogs._array.length;
+ if (_.isFinite(state.openDialogs) && numDialogs > state.openDialogs){
+ popDialogStackAction();
+ }
+}
+
+popDialogStackAction = function(result){
const dialog = dialogs.pop();
+ updateHistory();
if (!dialog) return;
dialog.callback && dialog.callback(result);
};
+let updateHistory = function(){
+ // history should looks like: [{openDialogs: 0}, {openDialogs: n}] where
+ // n is the number of open dialogs
+
+ // If we can't access the history object, give up
+ if (!history) return;
+ // Make sure that there is a state tracking open dialogs
+ // replace the state without bashing it in the process
+ if (!history.state || !_.isFinite(history.state.openDialogs)){
+ let newState = _.clone(history.state) || {};
+ newState.openDialogs = 0;
+ history.replaceState(newState, "");
+ }
+
+ const numDialogs = dialogs._array.length;
+ const stateDialogs = history.state.openDialogs;
+
+ // If the number of dialogs and state dialogs are equal, we don't need to do
+ // anything
+ if (numDialogs === stateDialogs) return;
+
+ if (stateDialogs > 0){
+ // On a dialog count
+ if (numDialogs === 0){
+ // but shouldn't be
+ history.back();
+ } else {
+ // but should replace with correct count
+ let newState = _.clone(history.state) || {};
+ newState.openDialogs = dialogs._array.length;
+ history.replaceState(newState, "");
+ }
+ } else if (numDialogs > 0 && stateDialogs === 0){
+ // On the zero state, push a dialog count
+ history.pushState({openDialogs: numDialogs}, "");
+ } else {
+ console.warn(
+ "History could not be updated correctly, unexpected case",
+ {stateDialogs, numDialogs},
+ )
+ }
+};
+
Template.dialogStack.helpers({
dialogStackClass(){
if (!dialogs.get().length) return "hide";
diff --git a/rpg-docs/lib/constants/statOrder.js b/rpg-docs/lib/constants/statOrder.js
new file mode 100644
index 00000000..df566814
--- /dev/null
+++ b/rpg-docs/lib/constants/statOrder.js
@@ -0,0 +1,71 @@
+statOrder = {
+ "strength": 1,
+ "dexterity": 2,
+ "constitution": 3,
+ "intelligence": 4,
+ "wisdom": 5,
+ "charisma": 6,
+ "strengthSave": 7,
+ "dexteritySave": 8,
+ "constitutionSave": 9,
+ "intelligenceSave": 10,
+ "wisdomSave": 11,
+ "charismaSave": 12,
+ "acrobatics": 13,
+ "animalHandling": 14,
+ "arcana": 15,
+ "athletics": 16,
+ "deception": 17,
+ "history": 18,
+ "insight": 19,
+ "intimidation": 20,
+ "investigation": 21,
+ "medicine": 22,
+ "nature": 23,
+ "perception": 24,
+ "performance": 25,
+ "persuasion": 26,
+ "religion": 27,
+ "sleightOfHand": 28,
+ "stealth": 29,
+ "survival": 30,
+ "initiative": 31,
+ "hitPoints": 32,
+ "armor": 33,
+ "dexterityArmor": 34,
+ "speed": 35,
+ "proficiencyBonus": 36,
+ "ki": 37,
+ "sorceryPoints": 38,
+ "rages": 39,
+ "rageDamage": 40,
+ "expertiseDice": 41,
+ "superiorityDice": 42,
+ "carryMultiplier": 43,
+ "level1SpellSlots": 44,
+ "level2SpellSlots": 45,
+ "level3SpellSlots": 46,
+ "level4SpellSlots": 47,
+ "level5SpellSlots": 48,
+ "level6SpellSlots": 49,
+ "level7SpellSlots": 50,
+ "level8SpellSlots": 51,
+ "level9SpellSlots": 52,
+ "d6HitDice": 53,
+ "d8HitDice": 54,
+ "d10HitDice": 55,
+ "d12HitDice": 56,
+ "acidMultiplier": 57,
+ "bludgeoningMultiplier": 58,
+ "coldMultiplier": 59,
+ "fireMultiplier": 60,
+ "forceMultiplier": 61,
+ "lightningMultiplier": 62,
+ "necroticMultiplier": 63,
+ "piercingMultiplier": 64,
+ "poisonMultiplier": 65,
+ "psychicMultiplier": 66,
+ "radiantMultiplier": 67,
+ "slashingMultiplier": 68,
+ "thunderMultiplier": 69,
+};