Improved new user experience and fixed errors on character delete

This commit is contained in:
Stefan Zermatten
2017-09-28 13:03:54 +02:00
parent c4e77c7eae
commit 4c31ab601c
11 changed files with 25 additions and 15 deletions

View File

@@ -299,6 +299,7 @@ Characters.calculate = {
var fieldSelector = {};
fieldSelector[fieldName] = 1;
var char = Characters.findOne(charId, {fields: fieldSelector});
if (!char) return;
var field = char[fieldName];
if (field === undefined){
throw new Meteor.Error(
@@ -332,6 +333,7 @@ Characters.calculate = {
},
attributeValue: memoize(function(charId, attributeName){
var attribute = Characters.calculate.getField(charId, attributeName);
if (!attribute) return;
//base value
var value = Characters.calculate.attributeBase(charId, attributeName);
//plus adjustment
@@ -343,6 +345,7 @@ Characters.calculate = {
}),
skillMod: memoize(preventLoop(function(charId, skillName){
var skill = Characters.calculate.getField(charId, skillName);
if (!skill) return;
//get the final value of the ability score
var ability = Characters.calculate.attributeValue(charId, skill.ability);
@@ -394,7 +397,6 @@ Characters.calculate = {
return prof && prof.value || 0;
}),
passiveSkill: memoize(function(charId, skillName){
var skill = Characters.calculate.getField(charId, skillName);
var mod = +Characters.calculate.skillMod(charId, skillName);
var value = 10 + mod;
Effects.find(

View File

@@ -3,7 +3,8 @@ Template.registerHelper("canEditCharacter", function(charId) {
});
canEditCharacter = function(charId) {
var char = Characters.findOne(charId)
var char = Characters.findOne(charId);
if (!char) return false;
var userId = Meteor.userId();
return char.owner === userId ||
_.contains(char.writers, userId);

View File

@@ -10,7 +10,7 @@ Template.deleteCharacterConfirmation.helpers({
if (Template.instance().canDelete.get()) {
return "background: #d23f31; color: white;";
}
}
},
});
Template.deleteCharacterConfirmation.events({
@@ -20,9 +20,7 @@ Template.deleteCharacterConfirmation.events({
},
"click #deleteButton": function(event, instance) {
if (instance.find("#nameInput").value === this.name) {
popDialogStack();
Router.go("/characterList");
Characters.remove(this._id);
popDialogStack(true);
}
},
"click .cancelButton": function(event, instance){

View File

@@ -1,7 +1,7 @@
<template name="characterSheet">
<div class="fit layout vertical character-sheet">
<app-header fixed effects="waterfall">
<app-toolbar class="medium-tall {{colorClass}}">
<app-toolbar class="medium-tall {{colorClass}}" style="z-index: 2;">
<div top-item class="layout horizontal center">
<paper-icon-button icon="menu" drawer-toggle></paper-icon-button>
<div class="flex character-name">

View File

@@ -199,6 +199,12 @@ Template.characterSheet.events({
data: this,
template: "deleteCharacterConfirmation",
element: event.currentTarget.parentElement.parentElement,
callback: (result) => {
if (result === true){
Router.go("/characterList");
Tracker.afterFlush(() => Characters.remove(this._id));
}
},
});
},
"click #shareCharacter": function(event, instance){

View File

@@ -1,5 +1,5 @@
.newUserStepper {
height: 210px !important;
height: 180px !important;
}
.newUserStepper paper-step .invalid-step-message {

View File

@@ -1,6 +1,6 @@
<template name="statCard">
<div>
<paper-material class="stat-card layout horizontal">
<paper-material class="stat-card layout horizontal {{#if bounce}}bounce{{/if}}">
<div class="numbers paper-font-display1">
{{#if isSkill}}
{{prefix}}{{skillMod}}

View File

@@ -15,7 +15,7 @@
<!--Armor-->
{{> statCard stat="armor" name="Armor Class" color="teal"}}
<!--Speed-->
{{> statCard stat="speed" name="Speed" color="teal"}}
{{> statCard stat="speed" name="Speed" color="teal" bounce=shouldSpeedBounce}}
<!--Initiative-->
{{> statCard stat="initiative" name="Initiative" color="indigo" isSkill="true"}}
<!--Proficiency Bonus-->

View File

@@ -8,6 +8,10 @@ Template.stats.helpers({
};
return Buffs.find(selector);
},
// New user experience
shouldSpeedBounce: function(){
return Session.get("newUserExperienceStep") === 2;
},
})
Template.stats.events({
@@ -84,8 +88,7 @@ Template.stats.events({
callback: (result) => {
if (!result) {
return;
}
else Meteor.call("giveCondition", this._id, result)
} else Meteor.call("giveCondition", this._id, result)
},
//returnElement: () => $(`[data-id='${itemId}']`).get(0),
})

View File

@@ -34,7 +34,7 @@ Missing Doc
}
#slideshowViewport {
position: absolute;
bottom: 42px;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;

View File

@@ -180,14 +180,14 @@ Custom property | Description | Default
<!-- Slideshow and buttons area for horizontal layout -->
<template is="dom-if" if="[[!vertical]]">
<div class="flex"></div>
<!--
<div id="buttonsWrapper">
<paper-button hidden$="[[!hasBackButton]]" disabled=[[!_hasBackStep]] on-tap="back">[[backText]]</paper-button>
<span class="flex"></span>
<paper-button hidden$="[[!hasSkipButton]]" disabled="[[!_canSkip]]" on-tap="progress">[[skipText]]</paper-button>
<!--
<paper-button id="continueButton" on-tap="continue">{{_choosePrimaryButtonText(_attrForSelectedStepPrimaryButtonText, finishText, continueText, updateText)}}</paper-button>
-->
</div>
-->
</template>
</template>