From d6a2fff851560312766d88e38fec86bf41e8c4b1 Mon Sep 17 00:00:00 2001 From: Thaum Date: Fri, 6 Feb 2015 08:56:08 +0000 Subject: [PATCH] Implemented Persona tab --- rpg-docs/Model/Character/Characters.js | 1 - .../personaDetailsDialog.html | 24 +++++++++++ .../personaDetailsDialog.js | 41 +++++++++++++++++++ .../views/character/persona/persona.css | 5 +++ .../views/character/persona/persona.html | 30 ++++++++++++++ .../client/views/character/persona/persona.js | 35 ++++++++++++++++ .../persona/textDialog/textDialog.html | 22 ++++++++++ .../persona/textDialog/textDialog.js | 36 ++++++++++++++++ 8 files changed, 193 insertions(+), 1 deletion(-) create mode 100644 rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html create mode 100644 rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js create mode 100644 rpg-docs/client/views/character/persona/persona.css create mode 100644 rpg-docs/client/views/character/persona/persona.html create mode 100644 rpg-docs/client/views/character/persona/persona.js create mode 100644 rpg-docs/client/views/character/persona/textDialog/textDialog.html create mode 100644 rpg-docs/client/views/character/persona/textDialog/textDialog.js diff --git a/rpg-docs/Model/Character/Characters.js b/rpg-docs/Model/Character/Characters.js index 18f30494..78103125 100644 --- a/rpg-docs/Model/Character/Characters.js +++ b/rpg-docs/Model/Character/Characters.js @@ -13,7 +13,6 @@ Schemas.Character = new SimpleSchema({ bonds: { type: String, defaultValue: "", trim: false}, flaws: { type: String, defaultValue: "", trim: false}, backstory: { type: String, defaultValue: "", trim: false}, - notes: { type: String, defaultValue: "", trim: false}, //attributes //ability scores diff --git a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html new file mode 100644 index 00000000..38f0595d --- /dev/null +++ b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.html @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js new file mode 100644 index 00000000..9913f4d6 --- /dev/null +++ b/rpg-docs/client/views/character/persona/peronaDetailsDialog/personaDetailsDialog.js @@ -0,0 +1,41 @@ +Template.personaDetailsDialog.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.personaDetailsDialog.helpers({ + +}); + +Template.personaDetailsDialog.events({ + "change #nameInput": function(event){ + var input = event.currentTarget.value; + Characters.update( this.charId, {$set: {name: input}} ); + }, + "change #alignmentInput": function(event){ + var input = event.currentTarget.value; + Characters.update( this.charId, {$set: {alignment: input}} ); + }, + "change #genderInput": function(event){ + var input = event.currentTarget.value; + Characters.update( this.charId, {$set: {gender: input}} ); + }, + "change #raceInput": function(event){ + var input = event.currentTarget.value; + Characters.update( this.charId, {$set: {race: input}} ); + } +}); diff --git a/rpg-docs/client/views/character/persona/persona.css b/rpg-docs/client/views/character/persona/persona.css new file mode 100644 index 00000000..a4d0028f --- /dev/null +++ b/rpg-docs/client/views/character/persona/persona.css @@ -0,0 +1,5 @@ +#persona .containerMain{ + margin: 0; + padding: 16px 0 0 0; + white-space: pre-line; +} \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.html b/rpg-docs/client/views/character/persona/persona.html new file mode 100644 index 00000000..873bbfd9 --- /dev/null +++ b/rpg-docs/client/views/character/persona/persona.html @@ -0,0 +1,30 @@ + + + + + \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/persona.js b/rpg-docs/client/views/character/persona/persona.js new file mode 100644 index 00000000..083984a6 --- /dev/null +++ b/rpg-docs/client/views/character/persona/persona.js @@ -0,0 +1,35 @@ +Template.persona.helpers({ + characterDetails: function(){ + var char = Characters.findOne(this._id, {fields: {name: 1, gender: 1, alignment: 1, race:1}}) + char._id += "details"; + char.title = char.name; + return char; + }, + characterField: function(field, title){ + var fieldSelector = {fields: {}}; + fieldSelector.fields[field] = 1; + var char = Characters.findOne(this._id, fieldSelector); + console.log("body is ", char[field]) + return {_id: char._id + field, title: title, field: field, body: char[field]}; + } +}); + +Template.persona.events({ + "tap .containerTop": function(event){ + if(this.field){ + var charId = Template.parentData()._id; + GlobalUI.setDetail({ + template: "textDialog", + data: {charId: charId, field: this.field, title: this.title}, + heroId: this._id + }); + } else{ + this.charId = Template.parentData()._id; + GlobalUI.setDetail({ + template: "personaDetailsDialog", + data: this, + heroId: this._id + }); + } + } +}); \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/textDialog/textDialog.html b/rpg-docs/client/views/character/persona/textDialog/textDialog.html new file mode 100644 index 00000000..b9ef7e03 --- /dev/null +++ b/rpg-docs/client/views/character/persona/textDialog/textDialog.html @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/persona/textDialog/textDialog.js b/rpg-docs/client/views/character/persona/textDialog/textDialog.js new file mode 100644 index 00000000..c2cf10ae --- /dev/null +++ b/rpg-docs/client/views/character/persona/textDialog/textDialog.js @@ -0,0 +1,36 @@ +Template.textDialog.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.textDialog.helpers({ + value: function(){ + var fieldSelector = {fields: {}}; + fieldSelector.fields[this.field] = 1; + var char = Characters.findOne(this.charId, fieldSelector); + return char[this.field]; + } +}); + +Template.textDialog.events({ + "change #textInput": function(event){ + var input = event.currentTarget.value; + var setter = {$set: {}}; + setter.$set[this.field] = input; + Characters.update(this.charId, setter); + } +}); \ No newline at end of file