Now only show edit and add buttons to writers, not readers
This commit is contained in:
@@ -61,7 +61,6 @@ Effects.attachSchema(Schemas.Effect);
|
||||
if (Meteor.isServer) Characters.after.insert(function(userId, char) {
|
||||
Effects.insert({
|
||||
charId: char._id,
|
||||
type: "inate",
|
||||
name: "Constitution modifier for each level",
|
||||
stat: "hitPoints",
|
||||
operation: "add",
|
||||
@@ -69,11 +68,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
|
||||
parent: {
|
||||
id: char._id,
|
||||
collection: "Characters",
|
||||
group: "Inate",
|
||||
},
|
||||
});
|
||||
Effects.insert({
|
||||
charId: char._id,
|
||||
type: "inate",
|
||||
name: "Proficiency bonus by level",
|
||||
stat: "proficiencyBonus",
|
||||
operation: "add",
|
||||
@@ -81,11 +80,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
|
||||
parent: {
|
||||
id: char._id,
|
||||
collection: "Characters",
|
||||
group: "Inate",
|
||||
},
|
||||
});
|
||||
Effects.insert({
|
||||
charId: char._id,
|
||||
type: "inate",
|
||||
name: "Dexterity Armor Bonus",
|
||||
stat: "armor",
|
||||
operation: "add",
|
||||
@@ -93,11 +92,11 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
|
||||
parent: {
|
||||
id: char._id,
|
||||
collection: "Characters",
|
||||
group: "Inate",
|
||||
},
|
||||
});
|
||||
Effects.insert({
|
||||
charId: char._id,
|
||||
type: "inate",
|
||||
name: "Natural Armor",
|
||||
stat: "armor",
|
||||
operation: "base",
|
||||
@@ -105,6 +104,7 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
|
||||
parent: {
|
||||
id: char._id,
|
||||
collection: "Characters",
|
||||
group: "Inate",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -53,7 +53,7 @@ Router.map(function() {
|
||||
data: function() {
|
||||
var data = Characters.findOne(
|
||||
{_id: this.params._id},
|
||||
{fields: {_id: 1, name: 1, color: 1}}
|
||||
{fields: {_id: 1, name: 1, color: 1, writers: 1, readers: 1}}
|
||||
);
|
||||
return data;
|
||||
},
|
||||
|
||||
6
rpg-docs/client/globalHelpers/canEditCharacter.js
Normal file
6
rpg-docs/client/globalHelpers/canEditCharacter.js
Normal file
@@ -0,0 +1,6 @@
|
||||
Template.registerHelper("canEditCharacter", function(charId) {
|
||||
var char = Characters.findOne(charId)
|
||||
var userId = Meteor.userId();
|
||||
return char.owner === userId ||
|
||||
_.contains(char.writers, userId);
|
||||
});
|
||||
@@ -5,18 +5,24 @@
|
||||
<div flex>
|
||||
{{name}}
|
||||
</div>
|
||||
<div>
|
||||
{{> colorDropdown}}
|
||||
</div>
|
||||
<paper-menu-button>
|
||||
<paper-icon-button icon="more-vert" noink></paper-icon-button>
|
||||
<paper-dropdown class="dropdown" halign="right">
|
||||
<core-menu class="menu" style="color: black; color: rgba(0,0,0,0.87);">
|
||||
<paper-item id="deleteCharacter"><core-icon icon="delete"></core-icon>Delete</paper-item>
|
||||
<paper-item id="shareCharacter"><core-icon icon="social:share"></core-icon>Share</paper-item>
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-menu-button>
|
||||
{{#if canEditCharacter _id}}
|
||||
<div>
|
||||
{{> colorDropdown}}
|
||||
</div>
|
||||
<paper-menu-button>
|
||||
<paper-icon-button icon="more-vert" noink></paper-icon-button>
|
||||
<paper-dropdown class="dropdown" halign="right">
|
||||
<core-menu class="menu" style="color: black; color: rgba(0,0,0,0.87);">
|
||||
<paper-item id="deleteCharacter">
|
||||
<core-icon icon="delete"></core-icon>Delete
|
||||
</paper-item>
|
||||
<paper-item id="shareCharacter">
|
||||
<core-icon icon="social:share"></core-icon>Share
|
||||
</paper-item>
|
||||
</core-menu>
|
||||
</paper-dropdown>
|
||||
</paper-menu-button>
|
||||
{{/if}}
|
||||
<div class="bottom fit" horizontal layout>
|
||||
<paper-tabs flex horizontal center layout id="characterSheetTabs" selected={{selectedTab}} class="{{colorClass}}">
|
||||
<paper-tab name="stats">Stats</paper-tab>
|
||||
|
||||
@@ -13,7 +13,7 @@ var getTab = function(charId){
|
||||
Template.characterSheet.helpers({
|
||||
selectedTab: function(){
|
||||
return getTab(this._id);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Template.characterSheet.events({
|
||||
|
||||
@@ -104,14 +104,16 @@
|
||||
</div>
|
||||
<div class="fab-buffer"></div>
|
||||
</div>
|
||||
<paper-fab id="addFeature"
|
||||
class="floatyButton"
|
||||
icon="add"
|
||||
title="Add"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Add"
|
||||
hero-id="main"></paper-fab>
|
||||
{{#if canEditCharacter _id}}
|
||||
<paper-fab id="addFeature"
|
||||
class="floatyButton"
|
||||
icon="add"
|
||||
title="Add"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
aria-label="Add"
|
||||
hero-id="main"></paper-fab>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -77,10 +77,12 @@
|
||||
</div>
|
||||
<div class="fab-buffer"></div>
|
||||
</div>
|
||||
<paper-fab-menu id="inventoryAddMenu" icon="add" closeIcon="close" duration="0.3">
|
||||
<paper-fab-menu-item id="addItem" icon="note-add" color="#d23f31" tooltip="Item"></paper-fab-menu-item>
|
||||
<paper-fab-menu-item id="addContainer" icon="work" color="#d23f31" tooltip="Container"></paper-fab-menu-item>
|
||||
</paper-fab-menu>
|
||||
{{#if canEditCharacter _id}}
|
||||
<paper-fab-menu id="inventoryAddMenu" icon="add" closeIcon="close" duration="0.3">
|
||||
<paper-fab-menu-item id="addItem" icon="note-add" color="#d23f31" tooltip="Item"></paper-fab-menu-item>
|
||||
<paper-fab-menu-item id="addContainer" icon="work" color="#d23f31" tooltip="Container"></paper-fab-menu-item>
|
||||
</paper-fab-menu>
|
||||
{{/if}}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
<div class="fab-buffer"></div>
|
||||
</div>
|
||||
</div>
|
||||
{{#if canEditCharacter _id}}
|
||||
<paper-fab id="addNote"
|
||||
class="floatyButton"
|
||||
icon="add"
|
||||
@@ -75,4 +76,5 @@
|
||||
role="button"
|
||||
tabindex="0"
|
||||
hero-id="main"></paper-fab>
|
||||
{{/if}}
|
||||
</template>
|
||||
@@ -91,8 +91,10 @@
|
||||
<div class="fab-buffer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<paper-fab-menu id="inventoryAddMenu" icon="add" closeIcon="close" duration="0.3">
|
||||
<paper-fab-menu-item id="addSpell" icon="note-add" color="#d23f31" tooltip="Spell"></paper-fab-menu-item>
|
||||
<paper-fab-menu-item id="addSpellList" icon="work" color="#d23f31" tooltip="Spell List"></paper-fab-menu-item>
|
||||
</paper-fab-menu>
|
||||
{{#if canEditCharacter _id}}
|
||||
<paper-fab-menu id="inventoryAddMenu" icon="add" closeIcon="close" duration="0.3">
|
||||
<paper-fab-menu-item id="addSpell" icon="note-add" color="#d23f31" tooltip="Spell"></paper-fab-menu-item>
|
||||
<paper-fab-menu-item id="addSpellList" icon="work" color="#d23f31" tooltip="Spell List"></paper-fab-menu-item>
|
||||
</paper-fab-menu>
|
||||
{{/if}}
|
||||
</template>
|
||||
@@ -20,12 +20,12 @@
|
||||
aria-label="Delete Feature"
|
||||
noink></paper-icon-button>
|
||||
{{else}}
|
||||
{{#unless hideEdit}}
|
||||
{{#if showEdit}}
|
||||
<paper-icon-button id="editButton"
|
||||
icon="create"
|
||||
aria-label="Delete Feature"
|
||||
noink></paper-icon-button>
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</core-toolbar>
|
||||
<div class="detailContent">
|
||||
|
||||
@@ -11,6 +11,18 @@ Template.baseDialog.helpers({
|
||||
editing: function(){
|
||||
return Template.instance().editing.get();
|
||||
},
|
||||
showEdit: function() {
|
||||
if (this.hideEdit) return false;
|
||||
var charId = Template.parentData().charId;
|
||||
if (charId){
|
||||
var char = Characters.findOne(charId);
|
||||
var userId = Meteor.userId();
|
||||
if (char && userId)
|
||||
return char.owner === userId ||
|
||||
_.contains(char.writers, userId);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
Template.baseDialog.events({
|
||||
|
||||
Reference in New Issue
Block a user