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