Implemented remaining core features

This commit is contained in:
Thaum
2015-02-25 12:48:45 +00:00
parent 52b8c8b8d6
commit 56f8e95d81
38 changed files with 748 additions and 100 deletions

View File

@@ -5,7 +5,7 @@
<paper-shadow class="card container experiencesCard" hero-id="main" {{detailHero}}>
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}>
<div class="containerName subhead" flex>Experience</div>
<div class="subhead">{{experience}}XP</div>
<div class="subhead">{{experience}} XP</div>
</div>
<div class="containerMain experiences">
{{#each experiences}}
@@ -23,6 +23,35 @@
</div>
{{/if}}
</paper-shadow>
<paper-shadow class="card container" hero-id="main" {{detailHero}}>
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}>
<div flex>
<div class="containerName subhead">Levels</div>
</div>
</div>
<div class="containerMain experiences">
<div class="list-subhead" layout horizontal center>
Race
</div>
<div class="itemSlot">
<paper-item class="inventoryItem race" hero-id="main" {{detailHero "race"}} layout horizontal>
{{race}}
</paper-item>
</div>
{{#each classes}}
<div class="list-subhead" layout horizontal center>
{{name}}
</div>
{{#each levels ../_id}}
<div class="itemSlot">
<paper-item class="inventoryItem level" hero-id="main" {{detailHero}} layout horizontal>
Level {{value}}
</paper-item>
</div>
{{/each}}
{{/each}}
</div>
</paper-shadow>
{{#each notes}}
<paper-shadow class="card container" hero-id="main" {{detailHero}}>
<div class="containerTop {{colorClass}} noteTop" hero-id="toolbar" layout horizontal center {{detailHero}}>
@@ -30,9 +59,7 @@
<div class="containerName subhead">{{name}}</div>
</div>
</div>
<div class="containerMain">
{{description}}
</div>
<div class="containerMain preline">{{description}}</div>
</paper-shadow>
{{/each}}
</div>

View File

@@ -19,6 +19,16 @@ Template.journal.helpers({
moreExperiencesOrCollapse: function(){
return (!(Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get())) ||
Template.instance().experiencesLimit.get() > (this.settings && this.settings.experiencesInc || 10);
},
classes: function(){
return Classes.find({charId: this._id}, {sort: {createdAt: 1}});
},
levels: function(charId){
return Levels.find({charId: charId, classId: this._id}, {sort: {value: 1}});
},
race: function(){
var char = Characters.findOne(this._id, {fields: {race: 1}});
return char && char.race;
}
});
@@ -37,6 +47,20 @@ Template.journal.events({
heroId: this._id
});
},
"tap .level": function(event){
GlobalUI.setDetail({
template: "levelDialog",
data: {levelId: this._id, charId: this.charId},
heroId: this._id
});
},
"tap .race": function(event){
GlobalUI.setDetail({
template: "raceDialog",
data: {charId: this._id},
heroId: this._id + "race"
});
},
"tap #addNote": function(event){
var charId = this._id;
Notes.insert({

View File

@@ -0,0 +1,32 @@
<template name="levelDialog">
{{#with level}}
<core-header-panel fit>
<core-toolbar class="grey white-text" hero-id="toolbar" hero>
<paper-icon-button id="backButton" role="button" tabindex="0" icon="arrow-back" aria-label="close"></paper-icon-button>
<div flex>{{name}}</div>
<paper-icon-button id="deleteLevel"
role="button"
tabindex="0"
icon="delete"
aria-label="Delete Level"
noink></paper-icon-button>
</core-toolbar>
<div class="detailContent">
<!--Level-->
<paper-input id="levelValueInput" label="Level" floatinglabel value={{value}}></paper-input>
{{#if effects}}
<hr style="margin: 16px 0 16px 0;">
<div id="effects">
<h2>Effects</h2>
{{#each effects}}
{{>effectEdit}}
{{/each}}
</div>
{{/if}}
<div layout horizontal end-justified>
<paper-button id="addEffectButton" raised>Add Effect</paper-button>
</div>
</div>
</core-header-panel>
{{/with}}
</template>

View File

@@ -0,0 +1,49 @@
Template.levelDialog.rendered = function(){
var self = this;
//update all autogrows after they've been filled
var pata = this.$("paper-autogrow-textarea");
pata.each(function(index, el){
el.update($(el).children().get(0));
})
//update all input fields as well
var input = this.$("paper-input");
input.each(function(index, el){
el.valueChanged();
})
//after the dialog is built, open it
if (!this.alreadyRendered){
Session.set("global.ui.detailShow", true);
this.alreadyRendered = true;
}
}
Template.levelDialog.events({
"tap #backButton": function(){
GlobalUI.closeDetail()
},
"tap #deleteLevel": function(){
Levels.remove(this._id);
GlobalUI.closeDetail()
},
"tap #addEffectButton": function(){
Effects.insert({
charId: this.charId,
sourceId: this._id,
operation: "add",
type: "level"
});
},
"change #levelValueInput": function(event){
var value = event.currentTarget.value;
Levels.update(this._id, {$set: {value: value}});
}
});
Template.levelDialog.helpers({
level: function(){
return Levels.findOne(this.levelId);
},
effects: function(){
return Effects.find({sourceId: this._id, type: "level"});
}
});

View File

@@ -0,0 +1,23 @@
<template name="raceDialog">
<core-header-panel fit>
<core-toolbar class="grey white-text" hero-id="toolbar" hero>
<paper-icon-button id="backButton" role="button" tabindex="0" icon="arrow-back" aria-label="close"></paper-icon-button>
<div flex>{{race}}</div>
</core-toolbar>
<div class="detailContent">
<paper-input id="raceInput" label="Race" floatinglabel value={{race}}></paper-input>
{{#if effects}}
<hr style="margin: 16px 0 16px 0;">
<div id="effects">
<h2>Effects</h2>
{{#each effects}}
{{>effectEdit}}
{{/each}}
</div>
{{/if}}
<div layout horizontal end-justified>
<paper-button id="addEffectButton" raised>Add Effect</paper-button>
</div>
</div>
</core-header-panel>
</template>

View File

@@ -0,0 +1,45 @@
Template.raceDialog.rendered = function(){
var self = this;
//update all autogrows after they've been filled
var pata = this.$("paper-autogrow-textarea");
pata.each(function(index, el){
el.update($(el).children().get(0));
})
//update all input fields as well
var input = this.$("paper-input");
input.each(function(index, el){
el.valueChanged();
})
//after the dialog is built, open it
if (!this.alreadyRendered){
Session.set("global.ui.detailShow", true);
this.alreadyRendered = true;
}
}
Template.raceDialog.events({
"tap #backButton": function(){
GlobalUI.closeDetail()
},
"tap #addEffectButton": function(){
Effects.insert({
charId: this.charId,
operation: "add",
type: "racial"
});
},
"change #raceInput": function(event){
var value = event.currentTarget.value;
Characters.update(this.charId, {$set: {race: value}});
}
});
Template.raceDialog.helpers({
effects: function(){
return Effects.find({charId: this.charId, type: "racial"});
},
race: function(){
var char = Characters.findOne(this.charId, {fields: {race: 1}});
return char && char.race;
}
});