Added XP, changed spellslot display

This commit is contained in:
Thaum
2015-02-20 10:09:53 +00:00
parent 93578709cd
commit bd86c1608e
18 changed files with 355 additions and 45 deletions

View File

@@ -0,0 +1,3 @@
.noteDialog .colorDropdown {
top: 0;
}

View File

@@ -0,0 +1,32 @@
<template name="experienceDialog">
{{#with experience}}
<core-header-panel fit class="experienceDialog">
<core-toolbar hero-id="toolbar" class={{colorClass}} hero>
<paper-icon-button id="backButton" role="button" tabindex="0" icon="arrow-back" aria-label="close"></paper-icon-button>
<div flex hero-id="title" hero>{{name}}</div>
<paper-icon-button id="deleteExperience"
role="button"
tabindex="0"
icon="delete"
aria-label="Delete Feature"
noink></paper-icon-button>
</core-toolbar>
<div class="detailContent">
<div horizontal layout>
<!--Name-->
<paper-input id="experienceNameInput" label="Name" floatinglabel value={{name}} flex></paper-input>
<!--Value-->
<paper-input-decorator label="Value" floatinglabel>
<input id="valueInput" type="number" value={{value}}>
</paper-input-decorator>
</div>
<!--Description-->
<paper-input-decorator label="Description" floatinglabel layout vertical>
<paper-autogrow-textarea>
<textarea id="experienceDescriptionInput" placeholder value={{description}}></textarea>
</paper-autogrow-textarea>
</paper-input-decorator>
</div>
</core-header-panel>
{{/with}}
</template>

View File

@@ -0,0 +1,49 @@
Template.experienceDialog.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.experienceDialog.events({
"tap #backButton": function(){
GlobalUI.closeDetail();
},
"tap #deleteExperience": function(){
Experiences.remove(this._id);
GlobalUI.closeDetail();
},
//TODO clean up String -> num here so they don't need casting by Schema.clean
//TODO validate input (integer, non-negative, etc) for these inputs and give validation errors
"change #experienceNameInput, input #experienceNameInput": function(event){
var value = event.currentTarget.value
Experiences.update(this._id, {$set: {name: value}});
},
"change #valueInput": function(event){
var value = event.currentTarget.value
Experiences.update(this._id, {$set: {value: value}});
},
"change #experienceDescriptionInput": function(event){
var value = event.currentTarget.value
Experiences.update(this._id, {$set: {description: value}});
}
});
Template.experienceDialog.helpers({
experience: function(){
Experiences.findOne(this.experienceId);
return Experiences.findOne(this.experienceId);
}
});

View File

@@ -0,0 +1,7 @@
.experiences {
padding: 0 0 16px 0;
}
.experience {
height: 48px;
}

View File

@@ -2,9 +2,30 @@
<div fit>
<div id="journal" class="scroll-y" fit>
<div class="containers">
<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>
<div class="containerMain experiences">
{{#each experiences}}
<div class="itemSlot">
<paper-item class="inventoryItem experience" hero-id="main" {{detailHero}} layout horizontal>
<div flex>{{name}}</div><div class="xpValue">{{value}}</div>
</paper-item>
</div>
{{/each}}
</div>
{{#if moreExperiencesOrCollapse}}
<div class="containerFoot" layout="" horizontal="" center="" end-justified="">
<paper-button id="moreExperiences" disabled={{notMoreExperiences}}>Load More</paper-button>
<paper-button id="lessExperiences" disabled={{cantCollapse}}>Collapse</paper-button>
</div>
{{/if}}
</paper-shadow>
{{#each notes}}
<paper-shadow class="card container" hero-id="main" {{detailHero}}>
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}>
<div class="containerTop {{colorClass}} noteTop" hero-id="toolbar" layout horizontal center {{detailHero}}>
<div flex>
<div class="containerName subhead">{{name}}</div>
</div>

View File

@@ -1,22 +1,47 @@
Template.journal.created = function(){
var self = this;
self.experiencesLimit = new ReactiveVar(self.data.settings && self.data.settings.experiencesInc || 10);
};
Template.journal.helpers({
notes: function(){
return Notes.find({charId: this._id}, {sort: {color: 1, name: 1}});
},
experiences: function(){
return Experiences.find({charId: this._id}, {sort: {dateAdded: -1}, limit: Template.instance().experiencesLimit.get()});
},
notMoreExperiences: function(){
return Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get();
},
cantCollapse: function(){
return Template.instance().experiencesLimit.get() <= (this.settings && this.settings.experiencesInc || 10);
},
moreExperiencesOrCollapse: function(){
return (!(Experiences.find({charId: this._id}).count() < Template.instance().experiencesLimit.get())) ||
Template.instance().experiencesLimit.get() > (this.settings && this.settings.experiencesInc || 10);
}
});
Template.journal.events({
"tap .containerTop": function(event){
"tap .noteTop": function(event){
GlobalUI.setDetail({
template: "noteDialog",
data: {noteId: this._id, charId: this.charId},
heroId: this._id
});
},
"tap .experience": function(event){
GlobalUI.setDetail({
template: "experienceDialog",
data: {experienceId: this._id, charId: this.charId},
heroId: this._id
});
},
"tap #addNote": function(event){
var charId = this.charId;
var charId = this._id;
Notes.insert({
name: "New Note",
charId: this._id
charId: charId
}, function(error, id){
if(!error){
GlobalUI.setDetail({
@@ -28,21 +53,32 @@ Template.journal.events({
});
},
"tap #addXP": function(event){
var charId = this.charId;
var listId = this.listId;
throw new Error("not implemented")/*
Spells.insert({
name: "New Spell",
charId: this._id,
listId: SpellLists.findOne({charId: this._id})._id
var charId = this._id;
Experiences.insert({
charId: charId
}, function(error, id){
if(!error){
GlobalUI.setDetail({
template: "spellDialog",
data: {spellId: id, charId: charId, listId: listId},
heroId: id
template: "experienceDialog",
data: {experienceId: id, charId: charId},
heroId: id
});
}
});*/
})
},
"tap #moreExperiences": function(event){
var inst = Template.instance();
inst.experiencesLimit.set(inst.experiencesLimit.get() + (this.settings && this.settings.experiencesInc || 10));
},
"tap #lessExperiences": function(event){
var inst = Template.instance();
inst.experiencesLimit.set(this.settings && this.settings.experiencesInc || 10);
//scroll to the top of the div
inst.$(".scroll-y").animate({
scrollTop: inst.$(".scroll-y").scrollTop() + inst.$(".experiencesCard").position().top - 8
}, 300);
//HACK giggle the columns :( to workaround chrome bug that stops .containers height from updating
var cs = inst.$(".containers").removeClass("containers");
_.defer(function(){cs.addClass("containers")});
}
});