From 28aed14cdaf4d2939d59f158287f20de5216e90a Mon Sep 17 00:00:00 2001 From: Thaum Date: Mon, 16 Feb 2015 10:28:44 +0000 Subject: [PATCH] Made unprepared spells hidable --- rpg-docs/Model/Character/Spells.js | 2 +- .../views/character/effectEdit/effectEdit.css | 5 ++- .../client/views/character/spells/spells.css | 8 ++++ .../client/views/character/spells/spells.html | 41 +++++++++++-------- .../client/views/character/spells/spells.js | 27 ++++++++++-- 5 files changed, 60 insertions(+), 23 deletions(-) diff --git a/rpg-docs/Model/Character/Spells.js b/rpg-docs/Model/Character/Spells.js index a5be9d03..50368a03 100644 --- a/rpg-docs/Model/Character/Spells.js +++ b/rpg-docs/Model/Character/Spells.js @@ -6,7 +6,7 @@ Schemas.Spell = new SimpleSchema({ prepared: {type: String, defaultValue: "unprepared", allowedValues: ["prepared","unprepared","always"]}, name: {type: String}, description: {type: String, optional: true}, - castingTime: {type: String, defaultValue: "action"}, + castingTime: {type: String, optional: true, defaultValue: "action"}, range: {type: String, optional: true}, duration: {type: String, optional: true}, "components.verbal": {type: Boolean, defaultValue: false}, diff --git a/rpg-docs/client/views/character/effectEdit/effectEdit.css b/rpg-docs/client/views/character/effectEdit/effectEdit.css index 4d67f399..4f501c01 100644 --- a/rpg-docs/client/views/character/effectEdit/effectEdit.css +++ b/rpg-docs/client/views/character/effectEdit/effectEdit.css @@ -18,8 +18,9 @@ body /deep/ #proficiencyDropDown { width: 120px; } -html /deep/ paper-input { - margin-bottom: 1px; +html /deep/ .effectEdit paper-input { + position: relative; + bottom: 5px; } html /deep/ .effectEdit { diff --git a/rpg-docs/client/views/character/spells/spells.css b/rpg-docs/client/views/character/spells/spells.css index 674937de..023c8f38 100644 --- a/rpg-docs/client/views/character/spells/spells.css +++ b/rpg-docs/client/views/character/spells/spells.css @@ -6,3 +6,11 @@ width: 32px; height: 32px; } + +#spells .inventoryItem paper-checkbox{ + pointer-events: initial; +} + +#spells paper-checkbox /deep/ #ink { + color: #009688; +} diff --git a/rpg-docs/client/views/character/spells/spells.html b/rpg-docs/client/views/character/spells/spells.html index bf36fb50..566b0a81 100644 --- a/rpg-docs/client/views/character/spells/spells.html +++ b/rpg-docs/client/views/character/spells/spells.html @@ -17,30 +17,37 @@ {{/if}} - {{#if maxPrepared}}
{{numPrepared}} / {{maxPrepared}}
{{/if}} + {{#if settings.showUnprepared}} + {{#if maxPrepared}}
{{numPrepared}} / {{maxPrepared}}
{{/if}} + + {{else}} + + {{/if}}
{{#each levels}} - {{#if spellCount ../_id ../../_id}} + {{#if spellCount .. ../../_id}}
{{name}}
{{/if}} {{#each spells ../_id ../../_id}} -
- - -
-
{{name}}
-
- {{school}} {{castingTime}}{{#if ritual}} (ritual){{/if}} - {{spellComponents}} + {{#if showSpell ../../settings.showUnprepared}} +
+ + +
+
{{name}}
+
+ {{school}} {{castingTime}}{{#if ritual}} (ritual){{/if}} - {{spellComponents}} +
-
- {{#if ../../settings.showUnprepared}} - - {{else}} - - {{/if}} - -
+ {{#if ../../settings.showUnprepared}} + + {{else}} + + {{/if}} + +
+ {{/if}} {{/each}} {{/each}}
diff --git a/rpg-docs/client/views/character/spells/spells.js b/rpg-docs/client/views/character/spells/spells.js index 779ee63d..9c96568e 100644 --- a/rpg-docs/client/views/character/spells/spells.js +++ b/rpg-docs/client/views/character/spells/spells.js @@ -15,8 +15,14 @@ Template.spells.helpers({ spellLists: function(){ return SpellLists.find({charId: this._id}); }, - spellCount: function(listId, charId){ - return Spells.find( {charId: charId, listId: listId, level: this.level}, {fields: {_id: 1, level: 1}} ).count() > 0; + spellCount: function(list, charId){ + if(list.settings.showUnprepared){ + return Spells.find( {charId: charId, listId: list._id, level: this.level}, + {fields: {_id: 1, level: 1}} ).count() > 0; + } else{ + return Spells.find( {charId: charId, listId: list._id, level: this.level, prepared: {$in: ["prepared", "always"]} }, + {fields: {_id: 1, level: 1}} ).count() > 0; + } }, spells: function(listId, charId){ return Spells.find( {charId: charId, listId: listId, level: this.level} ); @@ -50,6 +56,13 @@ Template.spells.helpers({ isPrepared: function(){ return this.prepared === "prepared" || this.prepared === "always"; }, + showSpell: function(listShowPrepped){ + if(listShowPrepped) { + return true; + } else { + return this.prepared === "prepared" || this.prepared === "always"; + } + }, cantUnprepare: function(){ return this.prepared === "always"; } @@ -113,5 +126,13 @@ Template.spells.events({ Spells.update(this._id, {$set: {prepared: "prepared"}}); else if(this.prepared === "prepared" && !value) Spells.update(this._id, {$set: {prepared: "unprepared"}}); - } + }, + "tap .prepSpells": function(event){ + SpellLists.update(this._id, {$set: {"settings.showUnprepared": true}}); + event.stopPropagation(); + }, + "tap .finishPrep": function(event){ + SpellLists.update(this._id, {$set: {"settings.showUnprepared": false}}); + event.stopPropagation(); + }, });