Added Basic character list view

This commit is contained in:
Thaum
2015-02-27 10:50:28 +00:00
parent 040d5a514b
commit b40094017f
10 changed files with 56 additions and 47 deletions

View File

@@ -187,9 +187,9 @@ Schemas.Character = new SimpleSchema({
initiativeRoll: { type: Number, min: 0, max: 1, decimal: true, defaultValue: 0}, initiativeRoll: { type: Number, min: 0, max: 1, decimal: true, defaultValue: 0},
//permissions //permissions
owner: { type: String, regEx: SimpleSchema.RegEx.Id }, owner: { type: String, regEx: SimpleSchema.RegEx.Id, optional: true },
readers: { type: [String], regEx: SimpleSchema.RegEx.Id }, readers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
writers: { type: [String], regEx: SimpleSchema.RegEx.Id }, writers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"}, color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"},
//TODO add per-character settings //TODO add per-character settings
"settings.experiencesInc": {type: Number, defaultValue: 20}, "settings.experiencesInc": {type: Number, defaultValue: 20},
@@ -219,6 +219,7 @@ Characters.attachSchema(Schemas.Character);
}, },
{type: "inate", name: "Resistance doesn't stack", operation: "min", value: 0.5}, {type: "inate", name: "Resistance doesn't stack", operation: "min", value: 0.5},
{type: "inate", name: "Vulnerability doesn't stack", operation: "max", value: 2} {type: "inate", name: "Vulnerability doesn't stack", operation: "max", value: 2}
{stat: "armor", name: "Natural Armor", value: 10, operation: "base", type: "inate"}}
*/ */
var attributeBase = function(charId, statName){ var attributeBase = function(charId, statName){

View File

@@ -1,21 +0,0 @@
Session.set("Mongol", {
'collections': [
"Characters",
"Actions",
"Attacks",
"Classes",
"Containers",
"Effects",
"Experiences",
"Features",
"Items",
"Levels",
"Notes",
"Spells",
"SpellLists"
],
'display': false,
'opacity_normal': ".7",
'opacity_expand': ".9",
'disable_warning': 'false',
});

View File

@@ -1,6 +1,6 @@
Template.effectsEditList.helpers({ Template.effectsEditList.helpers({
effects: function(){ effects: function(){
var cursor = Effects.find({sourceId: this.sourceId}); var cursor = Effects.find({sourceId: this.sourceId, type: this.type});
return cursor; return cursor;
} }
}); });

View File

@@ -22,9 +22,9 @@
</template> </template>
<template name="containerCardHelper"> <template name="containerCardHelper">
<paper-shadow class="card container" hero-id="main" {{detailHero}}> <paper-shadow class="card container {{class}}" hero-id="main" {{detailHero field}}>
<div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero}}> <div class="containerTop {{colorClass}}" hero-id="toolbar" layout horizontal center {{detailHero field}}>
<div class="containerName subhead" hero-id="title" flex {{detailHero}}>{{title}}</div> <div class="containerName subhead" hero-id="title" flex {{detailHero field}}>{{title}}</div>
</div> </div>
<div flex class="containerMain">{{> UI.contentBlock}}</div> <div flex class="containerMain">{{> UI.contentBlock}}</div>
</paper-shadow> </paper-shadow>

View File

@@ -11,7 +11,7 @@ var colorMap = {
Template.persona.helpers({ Template.persona.helpers({
characterDetails: function(){ characterDetails: function(){
var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}}) var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}})
char._id += "details"; char.field = "details";
char.title = char.name; char.title = char.name;
char.color = "d"; char.color = "d";
return char; return char;
@@ -21,25 +21,25 @@ Template.persona.helpers({
fieldSelector.fields[field] = 1; fieldSelector.fields[field] = 1;
var char = Characters.findOne(this._id, fieldSelector); var char = Characters.findOne(this._id, fieldSelector);
var color = colorMap[field]; var color = colorMap[field];
return {_id: char._id + field, title: title, field: field, color: color, body: char[field]}; return {_id: char._id, title: title, field: field, color: color, body: char[field]};
} }
}); });
Template.persona.events({ Template.persona.events({
"tap .containerTop": function(event){ "tap .containerTop": function(event){
if(this.field){ if(this.field !== "details"){
var charId = Template.parentData()._id; var charId = Template.parentData()._id;
GlobalUI.setDetail({ GlobalUI.setDetail({
template: "textDialog", template: "textDialog",
data: {charId: charId, field: this.field, title: this.title, color: this.color}, data: {charId: charId, field: this.field, title: this.title, color: this.color},
heroId: this._id heroId: this._id + this.field
}); });
} else{ } else{
this.charId = Template.parentData()._id; this.charId = Template.parentData()._id;
GlobalUI.setDetail({ GlobalUI.setDetail({
template: "personaDetailsDialog", template: "personaDetailsDialog",
data: this, data: this,
heroId: this._id heroId: this._id + "details"
}); });
} }
} }

View File

@@ -46,10 +46,9 @@ Template.spells.helpers({
} }
if(this.components.material){ if(this.components.material){
components += components? ", M" : "M"; components += components? ", M" : "M";
components += " ("+this.components.material+")";
} }
if(this.components.concentration){ if(this.components.concentration){
components += " - Requires concentration" components += components? ", C" : "C";
} }
return components; return components;
}, },

View File

@@ -1,9 +1,20 @@
<template name="home"> <template name="home">
{{>loginButtons}} <div class="scroll-y" fit>
<div> <div flex horizontal wrap class="padded">
{{# each characters}} {{# each characters}}
<li><a href="{{ pathFor 'characterSheet' }} ">{{_id}}</a> <button id="deleteChar">delete</button></li> {{#with characterDetails}}
{{/each}} {{#containerCardHelper this}}{{alignment}} {{gender}} {{race}}{{/containerCardHelper}}
{{/with}}
{{/each}}
<div class="fab-buffer"></div>
</div>
<paper-fab id="addCharacter"
class="floatyButton"
icon="add"
title="Add"
role="button"
tabindex="0"
aria-label="Add"
hero-id="main"></paper-fab>
</div> </div>
<input id="addCharacter" type="button" value="Add Character">
</template> </template>

View File

@@ -1,8 +1,23 @@
Template.home.helpers({
characterDetails: function(){
var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}})
char.title = char.name;
char.field = "base"
char.color = "d";
char.class = "characterCard"
return char;
}
});
Template.home.events({ Template.home.events({
"click #addCharacter": function (event, template) { "tap .characterCard": function(event, instance){
Characters.insert({}); console.log(this);
Router.go("characterSheet", {_id: this._id});
}, },
"click #deleteChar": function(event, template){ "tap #addCharacter": function (event, template) {
Characters.insert({owner: Meteor.userId()});
},
"tap #deleteChar": function(event, template){
console.log("deleting", this); console.log("deleting", this);
Characters.remove(this._id); Characters.remove(this._id);
} }

View File

@@ -2,10 +2,9 @@
<core-drawer-panel> <core-drawer-panel>
<core-header-panel drawer navigation flex mode="seamed" class="white"> <core-header-panel drawer navigation flex mode="seamed" class="white">
<core-toolbar class="grey white-text">Application</core-toolbar> <core-toolbar class="grey white-text">Cloud Character Sheet</core-toolbar>
<core-menu theme="core-light-theme"> <core-menu theme="core-light-theme">
<core-item icon="settings" label="item1"></core-item> <paper-item id="charactersMenuButton">Characters</paper-item>
<core-item icon="settings" label="item2"></core-item>
</core-menu> </core-menu>
</core-header-panel> </core-header-panel>
<core-animated-pages main <core-animated-pages main

View File

@@ -0,0 +1,5 @@
Template.layout.events({
"tap #charactersMenuButton": function(event, instance){
Router.go("/");
}
});