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},
//permissions
owner: { type: String, regEx: SimpleSchema.RegEx.Id },
readers: { type: [String], regEx: SimpleSchema.RegEx.Id },
writers: { type: [String], regEx: SimpleSchema.RegEx.Id },
owner: { type: String, regEx: SimpleSchema.RegEx.Id, optional: true },
readers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
writers: { type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [] },
color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"},
//TODO add per-character settings
"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: "Vulnerability doesn't stack", operation: "max", value: 2}
{stat: "armor", name: "Natural Armor", value: 10, operation: "base", type: "inate"}}
*/
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({
effects: function(){
var cursor = Effects.find({sourceId: this.sourceId});
var cursor = Effects.find({sourceId: this.sourceId, type: this.type});
return cursor;
}
});

View File

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

View File

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

View File

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

View File

@@ -1,9 +1,20 @@
<template name="home">
{{>loginButtons}}
<div>
{{# each characters}}
<li><a href="{{ pathFor 'characterSheet' }} ">{{_id}}</a> <button id="deleteChar">delete</button></li>
{{/each}}
<div class="scroll-y" fit>
<div flex horizontal wrap class="padded">
{{# each characters}}
{{#with characterDetails}}
{{#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>
<input id="addCharacter" type="button" value="Add Character">
</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({
"click #addCharacter": function (event, template) {
Characters.insert({});
"tap .characterCard": function(event, instance){
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);
Characters.remove(this._id);
}

View File

@@ -2,10 +2,9 @@
<core-drawer-panel>
<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-item icon="settings" label="item1"></core-item>
<core-item icon="settings" label="item2"></core-item>
<paper-item id="charactersMenuButton">Characters</paper-item>
</core-menu>
</core-header-panel>
<core-animated-pages main

View File

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