Compare commits

...

6 Commits

6 changed files with 18 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ Template.itemLibraryDialog.onCreated(function(){
if (_.contains(categoryKeys, key)){
handle = librarySubs.subscribe("standardLibraryItems", key);
} else {
handle = librarySubs.subscribe("libraryItems", key);
handle = librarySubs.subscribe("fullLibraryItems", key);
}
this.autorun(() => {
this.readyDict.set(key, handle.ready());

View File

@@ -9,7 +9,7 @@ Template.libraries.helpers({
{readers: userId},
{writers: userId},
{owner: userId},
{_id: {$in: subs}}
{_id: {$in: subs || []}}
],
}, {
sort: {name: 1},

View File

@@ -0,0 +1,3 @@
.library-item-dialog paper-input {
min-width: 160px;
}

View File

@@ -1,5 +1,5 @@
<template name="libraryItemDialog">
<div class="fit base-dialog layout vertical">
<div class="fit base-dialog layout vertical library-item-dialog">
<app-toolbar>
<paper-icon-button id="backButton"
icon="arrow-back">
@@ -24,8 +24,8 @@
</paper-checkbox>
</div>
<div class="layout horizontal center wrap">
<paper-input id="libraryItemValueInput" class="flex" label="Value" type="number" value={{item.value}} disabled="{{cantEdit}}"></paper-input>
<paper-input id="libraryItemWeightInput" class="flex" label="Weight" type="number" value={{item.weight}} disabled="{{cantEdit}}"></paper-input>
<paper-input id="libraryItemValueInput" class="flex" label="Value" type="number" value={{item.value}} disabled="{{cantEdit}}"></paper-input>
<paper-checkbox id="attunementCheckbox" class="flex" checked={{item.requiresAttunement}} disabled="{{cantEdit}}">
Requires Attunement
</paper-checkbox>
@@ -34,7 +34,7 @@
<div style="margin-top: 8px;">
<div class="paper-font-subhead">Effects</div>
{{#each indexedEffects}}
<div class="effect layout horizontal center wrap">
<div class="effect layout horizontal center wrap" style="margin-bottom: 32px;">
<paper-dropdown-menu label="Operation" class="operationMenu" disabled="{{cantEdit}}">
<paper-listbox class="dropdown-content" selected={{operationIndex operation}}>
<paper-item label="Base Value" name="base"> Base Value </paper-item>
@@ -59,7 +59,7 @@
<div style="margin-top: 8px;">
<div class="paper-font-subhead">Attacks</div>
{{#each indexedAttacks}}
<div class="effect layout horizontal center wrap">
<div class="effect layout horizontal center wrap" style="margin-bottom: 32px">
<paper-input class="LibraryItemAttackBonusInput flex" label="Attack Bonus" value={{attackBonus}} disabled="{{cantEdit}}"></paper-input>
<paper-input class="LibraryItemAttackDamageInput flex" label="Damage" value={{damage}} disabled="{{cantEdit}}"></paper-input>
<paper-input class="LibraryItemAttackDetailsInput flex" label="Details" value={{details}} disabled="{{cantEdit}}"></paper-input>

View File

@@ -66,7 +66,9 @@ Template.libraryItemDialog.helpers({
return Template.instance().subscriptionsReady();
},
cantEdit(){
let item = LibraryItems.findOne(this.itemId);
// Get itemId from the top level template data regardless of current context
let itemId = Blaze.getData(Template.instance().view).itemId;
let item = LibraryItems.findOne(itemId);
if (!item) return;
let library = Libraries.findOne(item.library);
if (!library) return;

View File

@@ -63,6 +63,12 @@ Meteor.publish("libraryItems", function(libraryId){
});
});
Meteor.publish("fullLibraryItems", function(libraryId){
return LibraryItems.find({
library: libraryId
});
});
Meteor.publish("libraryItem", function(itemId){
let cursor = LibraryItems.find(itemId);
let item = cursor.fetch()[0];