diff --git a/.jshintrc b/.jshintrc index d80e383a5..7e1af9b70 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,3 +1,4 @@ { - "undef": false -} \ No newline at end of file + "undef": false, + "esversion": 6 +} diff --git a/dataSources/srd/tools.json b/dataSources/srd/tools.json new file mode 100644 index 000000000..64be9a3f7 --- /dev/null +++ b/dataSources/srd/tools.json @@ -0,0 +1,247 @@ +[ + { + "name": "Alchemist’s supplies", + "plural": "Alchemist’s supplies", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 50, + "weight": 8 + }, + { + "name": "Brewer’s supplies", + "plural": "Brewer’s supplies", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 20, + "weight": 9 + }, + { + "name": "Calligrapher’s supplies", + "plural": "Calligrapher’s supplies", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 10, + "weight": 5 + }, + { + "name": "Carpenter’s tools", + "plural": "Carpenter’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 8, + "weight": 6 + }, + { + "name": "Cartographer’s tools", + "plural": "Cartographer’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 15, + "weight": 6 + }, + { + "name": "Cobbler’s tools", + "plural": "Cobbler’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 5, + "weight": 5 + }, + { + "name": "Cook’s utensils", + "plural": "Cook’s utensils", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 1, + "weight": 8 + }, + { + "name": "Glassblower’s tools", + "plural": "Glassblower’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 30, + "weight": 5 + }, + { + "name": "Jeweler’s tools", + "plural": "Jeweler’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 25, + "weight": 2 + }, + { + "name": "Leatherworker’s tools", + "plural": "Leatherworker’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 5, + "weight": 5 + }, + { + "name": "Mason’s tools", + "plural": "Mason’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 10, + "weight": 8 + }, + { + "name": "Painter’s supplies", + "plural": "Painter’s supplies", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 10, + "weight": 5 + }, + { + "name": "Potter’s tools", + "plural": "Potter’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 10, + "weight": 3 + }, + { + "name": "Smith’s tools", + "plural": "Smith’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 20, + "weight": 8 + }, + { + "name": "Tinker’s tools", + "plural": "Tinker’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 50, + "weight": 10 + }, + { + "name": "Weaver’s tools", + "plural": "Weaver’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 1, + "weight": 5 + }, + { + "name": "Woodcarver’s tools", + "plural": "Woodcarver’s tools", + "description": "These special tools include the items needed to pursue a craft or trade. The table shows examples of the most common types of tools, each providing items related to a single craft. Proficiency with a set of artisan’s tools lets you add your proficiency bonus to any ability checks you make using the tools in your craft. Each type of artisan’s tools requires a separate proficiency.", + "value": 1, + "weight": 5 + }, + { + "name": "Dice set", + "plural": "Dice sets", + "description": "This item encompasses a wide range of game pieces, including dice and decks of cards (for games such as Three-Dragon Ante). A few common examples appear on the Tools table, but other kinds of gaming sets exist. If you are proficient with a gaming set, you can add your proficiency bonus to ability checks you make to play a game with that set. Each type of gaming set requires a separate proficiency.", + "value": 0.1, + "weight": 0 + }, + { + "name": "Playing card set", + "plural": "Playing card sets", + "description": "This item encompasses a wide range of game pieces, including dice and decks of cards (for games such as Three-Dragon Ante). A few common examples appear on the Tools table, but other kinds of gaming sets exist. If you are proficient with a gaming set, you can add your proficiency bonus to ability checks you make to play a game with that set. Each type of gaming set requires a separate proficiency.", + "value": 0.5, + "weight": 0 + }, + { + "name": "Bagpipes", + "plural": "Bagpipes", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 30, + "weight": 6 + }, + { + "name": "Drum", + "plural": "Drums", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 6, + "weight": 3 + }, + { + "name": "Dulcimer", + "plural": "Dulcimers", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 25, + "weight": 10 + }, + { + "name": "Flute", + "plural": "Flutes", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 2, + "weight": 1 + }, + { + "name": "Lute", + "plural": "Lutes", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 35, + "weight": 2 + }, + { + "name": "Lyre", + "plural": "Lyres", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 30, + "weight": 2 + }, + { + "name": "Horn", + "plural": "Horns", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 3, + "weight": 2 + }, + { + "name": "Pan flute", + "plural": "Pan flutes", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 12, + "weight": 2 + }, + { + "name": "Shawm", + "plural": "Shawms", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 2, + "weight": 1 + }, + { + "name": "Viol", + "plural": "Viols", + "description": "If you have proficiency with a given musical instrument, you can add your proficiency bonus to any ability checks you make to play music with the instrument. A bard can use a musical instrument as a spellcasting focus.", + "value": 30, + "weight": 1 + }, + { + "name": "Disguise Kit", + "plural": "Disguise Kits", + "description": "This pouch of cosmetics, hair dye, and small props lets you create disguises that change your physical appearance. Proficiency with this kit lets you add your proficiency bonus to any ability checks you make to create a visual disguise.", + "value": 25, + "weight": 3 + }, + { + "name": "Forgery Kit", + "plural": "Forgery Kits", + "description": "This small box contains a variety of papers and parchments, pens and inks, seals and sealing wax, gold and silver leaf, and other supplies necessary to create convincing forgeries of physical documents. Proficiency with this kit lets you add your proficiency bonus to any ability checks you make to create a physical forgery of a document.", + "value": 15, + "weight": 5 + }, + { + "name": "Herbalism Kit", + "plural": "Herbalism Kits", + "description": "This kit contains a variety of instruments such as clippers, mortar and pestle, and pouches and vials used by herbalists to create remedies and potions. Proficiency with this kit lets you add your proficiency bonus to any ability checks you make to identify or apply herbs. Also, proficiency with this kit is required to create antitoxin and potions of healing.", + "value": 5, + "weight": 3 + }, + { + "name": "Navigator’s tools", + "plural": "Navigator’s tools", + "description": "This set of instruments is used for navigation at sea. Proficiency with navigator’s tools lets you chart a ship’s course and follow navigation charts. In addition, these tools allow you to add your proficiency bonus to any ability check you make to avoid getting lost at sea.", + "value": 25, + "weight": 2 + }, + { + "name": "Thieves’ tools", + "plural": "Thieves’ tools", + "description": "This set of tools includes a small file, a set of lock picks, a small mirror mounted on a metal handle, a set of narrow-bladed scissors, and a pair of pliers. Proficiency with these tools lets you add your proficiency bonus to any ability checks you make to disarm traps or open locks.", + "value": 25, + "weight": 1 + }, + { + "name": "Poisoner's Kit", + "plural": "Poisoner's Kits", + "description": "A poisoner’s kit includes the vials, chemicals, and other equipment necessary for the creation of poisons. Proficiency with this kit lets you add your proficiency bonus to any ability checks you make to craft or use poisons.", + "value": 50, + "weight": 2 + } +] diff --git a/rpg-docs/.meteor/packages b/rpg-docs/.meteor/packages index c1e8a81cc..3f142441a 100644 --- a/rpg-docs/.meteor/packages +++ b/rpg-docs/.meteor/packages @@ -46,3 +46,4 @@ templates:array ecmascript@0.6.1 es5-shim@4.6.15 differential:vulcanize +reactive-dict diff --git a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.css b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.css index d96d66b90..5c8d14a9c 100644 --- a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.css +++ b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.css @@ -2,6 +2,22 @@ background-color: #e4e4e4; } -.item-library-dialog .paper-font-subhead { - color: rgba(0,0,0,0.54); +.item-library-dialog .category-header { + font-size: 16px; +} + +.item-library-dialog .category-header iron-icon { + transition: transform 0.3s ease; +} + +.item-library-dialog .category-header iron-icon.open { + transform: rotate(90deg); +} + +.item-library-dialog table { + border-collapse: collapse; +} + +.item-library-dialog .library-item td { + position: relative; } diff --git a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.html b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.html index 3681e88b3..3a8110c96 100644 --- a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.html +++ b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.html @@ -10,32 +10,46 @@
- {{#if ready}} -
- {{#if searchTerm}} - {{#if searchItems.count}} - {{#each item in searchItems}} - {{>libraryItem item=item selected=(isSelected item)}} - {{/each}} - {{else}} +
+ {{#if searchTerm}} + {{#if searchItems.count}} + + + {{#each item in searchItems}} + {{>libraryItem item=item selected=(isSelected item)}} + {{/each}} + +
+ {{else}}{{#if searchReady}} No items match "{{searchTerm}}" - {{/if}} - {{else}} - {{#each category in categories}} -
- {{category.name}} -
- {{#each item in (itemsInCategory category.key)}} - {{>libraryItem item=item selected=(isSelected item)}} - {{/each}} - {{/each}} - {{/if}} -
- {{else}} -
- -
- {{/if}} + {{/if}}{{/if}} + {{#unless searchReady}} +
+ +
+ {{/unless}} + {{else}} + {{#each categories}} +
+ + + {{name}} +
+ + + + {{#each item in (itemsInCategory key)}} + {{>libraryItem item=item selected=(isSelected item)}} + {{/each}} + +
+ {{#unless ready key}} + + {{/unless}} +
+ {{/each}} + {{/if}} +
Cancel @@ -45,10 +59,18 @@ diff --git a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.js b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.js index c68e8b080..c3fecdd60 100644 --- a/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.js +++ b/rpg-docs/client/views/character/inventory/itemLibraryDialog/itemLibraryDialog.js @@ -1,41 +1,74 @@ const librarySubs = new SubsManager(); +const categories = [ + {name: "Weapons", key: "weapons"}, + {name: "Armor", key: "armor"}, + {name: "Adventuring Gear", key: "adventuringGear"}, + {name: "Tools", key: "tools"}, +]; + Template.itemLibraryDialog.onCreated(function(){ this.selectedItem = new ReactiveVar(); this.searchTerm = new ReactiveVar(); - this.ready = new ReactiveVar(); + this.categoriesOpen = new ReactiveVar([]); + this.readyDict = new ReactiveDict(); + this.searchReady = new ReactiveVar(); + librarySubs.subscribe("standardLibraries"); + this.autorun(() => { + // Subscribe to all open categories + _.each(this.categoriesOpen.get(), (key) => { + var handle = librarySubs.subscribe("standardLibraryItems", key); + this.autorun(() => { + this.readyDict.set(key, handle.ready()); + }); + }); + }); this.autorun(() => { - var handle = librarySubs.subscribe("standardLibraries"); - this.ready.set(handle.ready()); + // If we are searching, subscibe to all categories + if (this.searchTerm.get()){ + let handles = _.map(categories, category => + librarySubs.subscribe("standardLibraryItems", category.key) + ); + // Ready when all handles are ready + this.autorun(() => { + this.searchReady.set(_.every(handles, h => h.ready())); + }); + } }); }); Template.itemLibraryDialog.helpers({ - ready(){ - return Template.instance().ready.get(); + ready(key){ + return Template.instance().readyDict.get(key); }, categories(){ - return [ - {name: "Weapons", key: "weapons"}, - {name: "Armor", key: "armor"}, - {name: "Adventuring Gear", key: "adventuringGear"}, - ]; + return categories; }, itemsInCategory(categoryKey){ return LibraryItems.find({ library: "SRDLibraryGA3XWsd", "settings.category": categoryKey, + }, { + sort: {name: 1}, }); }, isSelected(item){ const selected = Template.instance().selectedItem.get(); return selected && selected._id === item._id; }, + isOpen(key){ + const cats = Template.instance().categoriesOpen.get(); + return _.contains(cats, key); + }, searchTerm(){ return Template.instance().searchTerm.get(); }, + searchReady(){ + return Template.instance().searchReady.get(); + }, searchItems(){ const searchTerm = Template.instance().searchTerm.get(); + if (!searchTerm) return; return LibraryItems.find({ library: "SRDLibraryGA3XWsd", name: { @@ -58,6 +91,17 @@ Template.itemLibraryDialog.events({ "click #backButton": function(event, template){ popDialogStack(); }, + "click .category-header": function(event, template){ + let cats = template.categoriesOpen.get(); + const key = this.key; + // Toggle whether this key is in the array or not + if (_.contains(cats, key)){ + cats = _.without(cats, key); + } else { + cats.push(key); + } + template.categoriesOpen.set(cats); + }, "input .search-input, change .search-input": function(event, template){ const value = event.currentTarget.value; template.searchTerm.set(value); diff --git a/rpg-docs/client/views/layout/layout.css b/rpg-docs/client/views/layout/layout.css index 8e0957092..2ecbb5ad6 100644 --- a/rpg-docs/client/views/layout/layout.css +++ b/rpg-docs/client/views/layout/layout.css @@ -7,10 +7,6 @@ display: initial !important; } -#navPanel { - padding: 16px; -} - #navPanel paper-icon-item { background: white; cursor: pointer; diff --git a/rpg-docs/config.vulcanize b/rpg-docs/config.vulcanize index 88a89f373..0e27de89f 100644 --- a/rpg-docs/config.vulcanize +++ b/rpg-docs/config.vulcanize @@ -8,6 +8,7 @@ "/components/app-layout/app-scroll-effects/effects/parallax-background.html", "/components/app-layout/app-scroll-effects/effects/resize-title.html", + "/components/iron-collapse/iron-collapse.html", "/components/iron-icon/iron-icon.html", "/components/iron-icons/av-icons.html", "/components/iron-icons/editor-icons.html", diff --git a/rpg-docs/server/publications/library.js b/rpg-docs/server/publications/library.js index b82fcfed0..e113a531b 100644 --- a/rpg-docs/server/publications/library.js +++ b/rpg-docs/server/publications/library.js @@ -1,9 +1,16 @@ +const standardLibraryIds = [ + "SRDLibraryGA3XWsd", +]; + Meteor.publish("standardLibraries", function(){ - const standardLibraryIds = [ - "SRDLibraryGA3XWsd", - ]; - return [ - LibraryItems.find({library: {$in: standardLibraryIds}}), - Libraries.find({_id: {$in: standardLibraryIds}}), - ]; + return Libraries.find({_id: {$in: standardLibraryIds}}); +}); + +Meteor.publish("standardLibraryItems", function(categoryKey){ + return LibraryItems.find({ + library: {$in: standardLibraryIds}, + "settings.category": categoryKey, + }, { + sort: {name: 1}, + }); });