From 402bc0e5ed2907371b66098d255d0b54ebcc3347 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 10 May 2017 10:37:30 +0200 Subject: [PATCH 1/3] Fixed Readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d8167276..e99c9c06 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ RPG Docs ======== -This is the repo for [DiceCloud](dicecloud.com). The currently deployed version should always be the latest release of the master branch. +This is the repo for [DiceCloud](dicecloud.com). Getting started --------------- -`git clone https://github.com/ThaumRystra/RPG-Docs RPG-Docs` -`cd RPG-Docs` +`git clone https://github.com/ThaumRystra/DiceCloud1 dicecloud` +`cd dicecloud` `cd rpg-docs` `bower install` `meteor` From b591c66dd58951545f576ba17e040351e9cac446 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 10 May 2017 10:37:51 +0200 Subject: [PATCH 2/3] Back button now closes dialogs closes #9 --- .../paperTemplates/dialogStack/dialogStack.js | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) 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"; From e7bcc2224cfe31a3fa80b01bc1ac2bb014f10d00 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Wed, 10 May 2017 16:39:36 +0200 Subject: [PATCH 3/3] Replaced effects in-line editing with edit dialogs Closes #41 --- .../effects/effectEdit/effectEdit.css | 10 ++ .../effects/effectEdit/effectEdit.html | 87 ++++++++------- .../effects/effectEdit/effectEdit.js | 105 +++++++++++++----- .../effects/effectView/effectView.html | 6 +- .../effects/effectView/effectView.js | 15 ++- .../effectsEditList/effectsEditList.css | 3 + .../effectsEditList/effectsEditList.html | 18 ++- .../effectsEditList/effectsEditList.js | 21 +++- .../effectsViewList/effectsViewList.html | 4 +- .../effectsViewList/effectsViewList.js | 7 +- .../paperTemplates/baseDialog/baseDialog.html | 2 +- .../baseEditDialog/baseEditDialog.html | 23 ++++ .../baseEditDialog/baseEditDialog.js | 5 + rpg-docs/lib/constants/statOrder.js | 71 ++++++++++++ 14 files changed, 287 insertions(+), 90 deletions(-) create mode 100644 rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.css create mode 100644 rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.html create mode 100644 rpg-docs/client/views/paperTemplates/baseEditDialog/baseEditDialog.js create mode 100644 rpg-docs/lib/constants/statOrder.js diff --git a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.css b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.css index d9170586..30e73411 100644 --- a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.css +++ b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.css @@ -13,3 +13,13 @@ .effectEdit .deleteEffect { flex-shrink: 0; } + +.effectEdit .effect-table-view { + align-self: center; + color: #757575; + color: rgba(0,0,0,0.54); +} + +.effectEdit .iron-selected { + color: #ad2a1f; +} diff --git a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html index ccfc868a..3ae51b94 100644 --- a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html +++ b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.html @@ -1,45 +1,53 @@ - - diff --git a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js index 4a33c503..d18538fa 100644 --- a/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js +++ b/rpg-docs/client/views/character/effects/effectEdit/effectEdit.js @@ -97,7 +97,19 @@ var skillOperations = [ {name: "Conditional Benefit", operation: "conditional"}, ]; +Template.effectEdit.onRendered(function(){ + _.defer(() => { + const statElement = this.find(".statMenu .iron-selected"); + statElement && statElement.scrollIntoView(); + const opElement = this.find(".operationMenu .iron-selected"); + opElement && opElement.scrollIntoView(); + }); +}); + Template.effectEdit.helpers({ + effect: function(){ + return Effects.findOne(this.id); + }, statGroups: function(){ return statGroupNames; }, @@ -115,46 +127,77 @@ Template.effectEdit.helpers({ return attributeOperations; } }, - effectValueTemplate: function(){ - //resistance/vulnerability template + showMultiplierOperations: function(){ + var stat = statsDict[this.stat]; + return stat && stat.group === "Weakness/Resistance" + }, + showEffectValueInput: function(){ var stat = statsDict[this.stat]; var group = stat && stat.group; - if (group === "Weakness/Resistance") return "multiplierEffectValue"; - + if ( + group === "Weakness/Resistance" + ) return false; var op = this.operation; - if (!op) return null; - //operations that don't need templates - if (op === "advantage" || op === "disadvantage" || op === "fail") return null; - - //default template - return "regularEffectValue"; + if ( + !op || + op === "advantage" || + op === "disadvantage" || + op === "fail" + ) return false; + return true; }, -}); - -Template.regularEffectValue.helpers({ effectValue: function(){ return this.calculation || this.value; - } + }, }); Template.effectEdit.events({ - "click .deleteEffect": function(event){ - Effects.softRemoveNode(this._id); - GlobalUI.deletedToast(this._id, "Effects", "Effect"); + "click #deleteButton": function(event, instance){ + Effects.softRemoveNode(instance.data.id); + GlobalUI.deletedToast(instance.data.id, "Effects", "Effect"); + popDialogStack(); }, - "iron-select .statDropDown": function(event){ + "iron-select .statMenu": function(event){ var detail = event.originalEvent.detail; var statName = detail.item.getAttribute("name"); if (statName == this.stat) return; - Effects.update(this._id, {$set: {stat: statName}}); + var setter = {stat: statName}; + var group = Blaze.getData(detail.item).group; + var effect = Effects.findOne(this._id); + if (group === "Saving Throws" || group === "Skills"){ + // Skills must have a valid skill operation + if (!_.contains( + _.map(skillOperations, ao => ao.operation), + effect.operation + )){ + setter.operation = "add"; + } + } else if (group !== "Weakness/Resistance"){ + // Attributes must have a valid attribute operation + if (!_.contains( + _.map(attributeOperations, ao => ao.operation), + effect.operation + )){ + setter.operation = "base"; + } + } else { + // Weakness/Resistance must have a mul operation and value + if (effect.operation !== "mul"){ + setter.operation = "mul"; + } + if (!_.contains([0, 0.5, 2], effect.value)){ + setter.value = 0.5; + } + } + Effects.update(this._id, {$set: setter}); }, - "iron-select .operationDropDown": function(event){ + "iron-select .operationMenu": function(event){ var detail = event.originalEvent.detail; var opName = detail.item.getAttribute("name"); if (opName == this.operation) return; Effects.update(this._id, {$set: {operation: opName}}); }, - "iron-select .damageMultiplierDropDown": function(event){ + "iron-select .multiplierMenu": function(event){ var detail = event.originalEvent.detail; var value = +detail.item.getAttribute("name"); if (value == this.value) return; @@ -164,15 +207,25 @@ Template.effectEdit.events({ operation: "mul", }}); }, - "change .effectValueInput": function(event){ + "change .effectValueInput, input .effectValueInput": + _.debounce(function(event){ var value = event.currentTarget.value; - var numValue = +value; + var numValue = value === "" ? NaN : +value; if (_.isFinite(numValue)){ if (this.value === numValue) return; - Effects.update(this._id, {$set: {value: numValue, calculation: ""}}); + Effects.update(this._id, { + $set: {value: numValue}, + $unset: {calculation: ""}, + }); } else if (_.isString(value)){ if (this.calculation === value) return; - Effects.update(this._id, {$set: {value: "", calculation: value}}); + Effects.update(this._id, { + $set: {calculation: value}, + $unset: {value: ""}, + }, { + removeEmptyStrings: false, + trimStrings: false, + }); } - }, + }, 400), }); diff --git a/rpg-docs/client/views/character/effects/effectView/effectView.html b/rpg-docs/client/views/character/effects/effectView/effectView.html index f47687f1..9fb1db03 100644 --- a/rpg-docs/client/views/character/effects/effectView/effectView.html +++ b/rpg-docs/client/views/character/effects/effectView/effectView.html @@ -1,6 +1,4 @@ diff --git a/rpg-docs/client/views/character/effects/effectView/effectView.js b/rpg-docs/client/views/character/effects/effectView/effectView.js index bc56e078..cd86df70 100644 --- a/rpg-docs/client/views/character/effects/effectView/effectView.js +++ b/rpg-docs/client/views/character/effects/effectView/effectView.js @@ -1,4 +1,3 @@ -//TODO add dexterity armor var stats = { "strength":{"name":"Strength"}, "dexterity":{"name":"Dexterity"}, @@ -131,8 +130,10 @@ Template.effectView.helpers({ return stats[this.stat] && stats[this.stat].name || "No Stat"; }, operationName: function(){ - if (this.operation === "proficiency" || - this.operation === "conditional") return null; + if ( + this.operation === "proficiency" || + this.operation === "conditional" + ) return null; if (stats[this.stat] && stats[this.stat].group === "Weakness/Resistance") return null; if (this.operation === "add" && evaluateEffect(this.charId, this) < 0) @@ -141,9 +142,11 @@ Template.effectView.helpers({ operations[this.operation].name || "No Operation"; }, statValue: function(){ - if (this.operation === "advantage" || - this.operation === "disadvantage" || - this.operation === "fail"){ + if ( + this.operation === "advantage" || + this.operation === "disadvantage" || + this.operation === "fail" + ){ return null; } if (this.operation === "proficiency"){ diff --git a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.css b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.css new file mode 100644 index 00000000..7c92fe71 --- /dev/null +++ b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.css @@ -0,0 +1,3 @@ +.effectsEditList .effect { + background: white; +} diff --git a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html index cf6a6182..f6216b3d 100644 --- a/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html +++ b/rpg-docs/client/views/character/effects/effectsEditList/effectsEditList.html @@ -1,11 +1,19 @@