diff --git a/rpg-docs/Model/Character/Notes.js b/rpg-docs/Model/Character/Notes.js new file mode 100644 index 00000000..bc435089 --- /dev/null +++ b/rpg-docs/Model/Character/Notes.js @@ -0,0 +1,10 @@ +Notes = new Meteor.Collection("notes"); + +Schemas.Note = new SimpleSchema({ + charId: {type: String, regEx: SimpleSchema.RegEx.Id}, + name: {type: String}, + description: {type: String, optional: true}, + color: {type: String, allowedValues: _.pluck(colorOptions, "key"), defaultValue: "q"} +}); + +Notes.attachSchema(Schemas.Note); diff --git a/rpg-docs/client/views/character/characterSheet.html b/rpg-docs/client/views/character/characterSheet.html index 8b978af8..07f8c939 100644 --- a/rpg-docs/client/views/character/characterSheet.html +++ b/rpg-docs/client/views/character/characterSheet.html @@ -24,7 +24,7 @@ {{> inventory}} {{> spells}} {{> persona}} - Journal Under Construction + {{> journal}} diff --git a/rpg-docs/client/views/character/journal/journal.css b/rpg-docs/client/views/character/journal/journal.css new file mode 100644 index 00000000..e69de29b diff --git a/rpg-docs/client/views/character/journal/journal.html b/rpg-docs/client/views/character/journal/journal.html new file mode 100644 index 00000000..ae5506a5 --- /dev/null +++ b/rpg-docs/client/views/character/journal/journal.html @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/journal.js b/rpg-docs/client/views/character/journal/journal.js new file mode 100644 index 00000000..87e1168b --- /dev/null +++ b/rpg-docs/client/views/character/journal/journal.js @@ -0,0 +1,48 @@ +Template.journal.helpers({ + notes: function(){ + return Notes.find({charId: this._id}, {sort: {color: 1, name: 1}}); + } +}); + +Template.journal.events({ + "tap .containerTop": function(event){ + GlobalUI.setDetail({ + template: "noteDialog", + data: {noteId: this._id, charId: this.charId}, + heroId: this._id + }); + }, + "tap #addNote": function(event){ + var charId = this.charId; + Notes.insert({ + name: "New Note", + charId: this._id + }, function(error, id){ + if(!error){ + GlobalUI.setDetail({ + template: "noteDialog", + data: {noteId: id, charId: charId}, + heroId: id + }); + } + }); + }, + "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 + }, function(error, id){ + if(!error){ + GlobalUI.setDetail({ + template: "spellDialog", + data: {spellId: id, charId: charId, listId: listId}, + heroId: id + }); + } + });*/ + } +}); diff --git a/rpg-docs/client/views/character/journal/noteDialog/noteDialog.css b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.css new file mode 100644 index 00000000..2cc1e765 --- /dev/null +++ b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.css @@ -0,0 +1,3 @@ +.noteDialog .colorDropdown { + top: 0; +} diff --git a/rpg-docs/client/views/character/journal/noteDialog/noteDialog.html b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.html new file mode 100644 index 00000000..cf596e5d --- /dev/null +++ b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/character/journal/noteDialog/noteDialog.js b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.js new file mode 100644 index 00000000..85a0184c --- /dev/null +++ b/rpg-docs/client/views/character/journal/noteDialog/noteDialog.js @@ -0,0 +1,50 @@ +Template.noteDialog.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.noteDialog.events({ + "tap #backButton": function(){ + GlobalUI.closeDetail(); + }, + "tap #deleteNote": function(){ + Notes.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 #noteNameInput, input #noteNameInput": function(event){ + var value = event.currentTarget.value + Notes.update(this._id, {$set: {name: value}}); + }, + "change #noteDescriptionInput": function(event){ + var value = event.currentTarget.value + Notes.update(this._id, {$set: {description: value}}); + }, + "core-select .colorDropdown": function(event){ + var detail = event.originalEvent.detail; + if(!detail.isSelected) return; + var value = detail.item.getAttribute("name"); + Notes.update(this._id, {$set: {color: value}}); + } +}); + +Template.noteDialog.helpers({ + note: function(){ + return Notes.findOne(this.noteId); + } +}); \ No newline at end of file diff --git a/rpg-docs/server/publications/singleCharacter.js b/rpg-docs/server/publications/singleCharacter.js index 8e0c7be3..6a5b4163 100644 --- a/rpg-docs/server/publications/singleCharacter.js +++ b/rpg-docs/server/publications/singleCharacter.js @@ -7,6 +7,7 @@ Meteor.publish("singleCharacter", function(characterId, userId){ Features.find({charId: characterId}), Effects.find({charId: characterId}), Spells.find({charId: characterId}), - SpellLists.find({charId: characterId}) + SpellLists.find({charId: characterId}), + Notes.find({charId: characterId}) ]; }); \ No newline at end of file